Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font size messed up #38

Open
gaetgu opened this issue Dec 12, 2022 · 13 comments
Open

Font size messed up #38

gaetgu opened this issue Dec 12, 2022 · 13 comments

Comments

@gaetgu
Copy link

gaetgu commented Dec 12, 2022

I am trying to get svg-tags set up with org mode (using org-modern and doom emacs). However, I am having some issues. Here is what the tags look like:

image

I have looked through some of the other issues (mostly #12 and #10) and I have tried using the fork from PR #14, with no success. I am wondering if there is anything obvious that I am missing?

@rougier
Copy link
Owner

rougier commented Dec 20, 2022

No, it's a recurrent problem that I've hard time fixing. Do you use any kind of magnification on your os?

@ronisbr
Copy link

ronisbr commented Feb 27, 2023

I have the exactly the same problem in macOS with default configurations of monitor.

@rougier
Copy link
Owner

rougier commented Feb 27, 2023

@ronisbr Do you have a second monitor ? What is your version of Emacs ?

@ronisbr
Copy link

ronisbr commented Feb 27, 2023

@rougier Yes, I do! I am using Emacs 29. I will try removing the second monitor.

@ronisbr
Copy link

ronisbr commented Feb 27, 2023

Captura de Tela 2023-02-27 às 15 34 36

No, removing the second monitor did not change anything.

@rougier
Copy link
Owner

rougier commented Mar 17, 2023

@ronisbr Could you tr the various fixes pointed by @gaetgu (#12 and #10) and the fork?

@ronisbr
Copy link

ronisbr commented Mar 21, 2023

Hi @rougier !

I found the problem here! Everything started to work if I change this line:

         (font-info       (font-info (format "%s-%d" font-family font-size)))

to

         (font-info       (font-info "JetBrainsMono Nerd Font Mono"))

The problem is that the name of my font does not appear to follow the expected format! By default, font-size is set to 10 whereas my font size is 13. If I change font-size to 13, everything works perfectly.

EDIT:

I found the problem! The library is picking the default font probably at a stage where my current font is not defined. The following screenshot shows the default values:

Captura de Tela 2023-03-21 às 12 47 56

I user JetBrainsMono with size 13.

The final fix for me is just to set the configuration as follows (Doom emacs):

(use-package! svg-tag-mode
  :config
  (plist-put svg-lib-style-default :font-family "JetBrainsMono Nerd Font")
  (plist-put svg-lib-style-default :font-size 13))

@ronisbr
Copy link

ronisbr commented Mar 21, 2023

After the modification:

Captura de Tela 2023-03-21 às 12 34 43

@rougier
Copy link
Owner

rougier commented Apr 3, 2023

Fantastic! Thanks for the very helpful debug! This size problem has plagued the library from the start without any obvious solution. Now the question is why do I not pick the right size when required? Do you know when your default font size is actually set?

@ronisbr
Copy link

ronisbr commented Apr 3, 2023

Hi @rougier !

I have no idea. Since I use Doom Emacs, it has its own method to customize the default fonts. This is the code where I set the font in Doom: https://github.com/ronisbr/doom.d/blob/25c12efa4dc90ca2b6b2824047c33fc4f2b596d4/settings/setup-theme.el#L3 It is a variable that is used to set Emacs fonts at some stage.

If we manage to find a hook that runs after that, we might just add comments to the README here instructing the users to add a specific function to that hook setting the fonts in svg-tag-mode.

@rougier
Copy link
Owner

rougier commented Apr 3, 2023

I see. Then maybe a warning/howto in the README would be our best option since I don't think it's possible to have a hook on default font change.

@tam5
Copy link

tam5 commented Apr 3, 2023

Re: above regarding hooks and such, for temp fix I'm doing the following:

(use-package! svg-lib
  :init (add-hook 'after-setting-font-hook (lambda () (setq svg-lib-style-default (svg-lib-style-compute-default)))))

Which seems to alleviate the issue for me.

Will try to add more debug info i've found soon

(presumably same thing if using svg-tag-mode directly just replace as necessary)

@rougier
Copy link
Owner

rougier commented Apr 4, 2023

Oh, the after-setting-font-hook is really useful. Maybe we could include your fix in the lib.
Could you make a PR (for this and svg-lib as well since it may suffer from the same problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants