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

Patch is working #1

Open
rougier opened this issue Jan 23, 2024 · 7 comments
Open

Patch is working #1

rougier opened this issue Jan 23, 2024 · 7 comments

Comments

@rougier
Copy link

rougier commented Jan 23, 2024

Thank you very much for this patch. Font weights selection has bothered me for a few months and your patch is working nicely. I've included in a fork of emacs-plus (https://github.com/rougier/homebrew-emacs-plus) and I would like to ask permission to make a pull request and if not possible, could you make a PR on emacs-plus?

Also, may I ask you if you submit your patch to emacs ? I opened a thread on emacs-devel concerning my problem and link to your patch.

@yaglo
Copy link
Owner

yaglo commented Jan 23, 2024

Hi @rougier,

I'm happy to hear the patch is useful! Emacs typography on macOS bothered me also.

I actually have submitted the patch to bug-gnu-emacs here: https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-06/msg00585.html

The process of signing the copyright papers took a while, but after signing them, I replied in the thread that it should be good to go. Done it a few times but haven’t received a response and the emails are not listed in the thread in the archive either, not sure if they have been read.

I’ll happily submit a PR to Emacs Plus. In fact, I have a few more patches for typography that I use in my custom build like adjusted line height calculation (more balanced with hl-line and selection), ability to control line height anywhere including the mode line (as opposed to line-spacing which sticks the text at the top), and some little things like a more modern wave underline. I can extract these and submit to Emacs Plus as well.

I also tried to improve the kerning situation because every character in Emacs is aligned to an integer pixel grid (to a two-pixel grid on Retina displays) so the space between characters isn't as it should be, either squeezed or expanded and in non-monospaced fonts it’s all over the place. I did it by increasing the scale so that internally Emacs works with about 8x sizes and then scaling back with Core Graphics for display, but I had 0.125px box artefacts from the cursor and backgrounds in general when it changes. I haven’t had a chance to get back to it and fix this because of other commitments and in the meantime settled for a font and size that fits into the integer grid. I’ll happily pick it up again when time allows and if it’s useful to others.

@rougier
Copy link
Author

rougier commented Jan 24, 2024

Oh great! I re-activated a thread on font here: https://lists.gnu.org/archive/html/emacs-devel/2024-01/msg00774.html, pointing to your patch. Hopefully this will re-activate things. As for emacs-plus, I'll let you submit the PR then.

I'm now curious about your other patches. I've played a lot with Emacs settings to have crisp and aligned rendering for monospaced font but I do not use non-monospaced because I found the rendering not so good. I'll wait for your patch.

By the way, for the modeline, I usually two 1 pixel spaces with a raise display property up and down that give some space to the text.

By the way, do you know a method for finding the true size of a face, independently of system zoom? I need this for the svg-lib package but I did not find a universal method to get the exact size (because of retina, or other system scaling).

@yaglo
Copy link
Owner

yaglo commented Feb 5, 2024

Thank you for chasing up this patch! As I can see, it has been merged to Emacs, so there's no need to add it to the emacs-plus repository.

I will extract the patches and will push them soon.

By the way, for the modeline, I usually two 1 pixel spaces with a raise display property up and down that give some space to the text.

Yes, this is what I initially did, but it doesn't help if you want to also have the border. I initially patched the fonts themselves to use for this, but eventually updated Emacs itself to support vertical padding for fonts.

By the way, do you know a method for finding the true size of a face, independently of system zoom? I need this for the svg-lib package but I did not find a universal method to get the exact size (because of retina, or other system scaling).

Could you please clarify what size do you want to find? In fonts there are a few dimensions, ascender, descender, x-height primarily being the most important ones. Do you want to find the actual letter height like "x" in pixels, or just the line height in pixels?

@rougier
Copy link
Author

rougier commented Feb 5, 2024

I need to find the font size in points such as to produce SVG text with the exact same size (see rougier/svg-tag-mode#12). I tried many things but there are always some case where it breaks. I tried to find the actual dpi from inside emacs depending in user settings, fixing dpi in SVG, etc, but I did not find a universal method.

@yaglo
Copy link
Owner

yaglo commented Feb 5, 2024

I vaguely remember all the details but there were some issues with Emacs handling font sizes in a weird way when the DPI is different when I was working on it. When you load a font, the C function gets the already adjusted font size for the DPI.

For example, if you are setting "My Font 12" and your DPI is twice the default, it calls to open "My Font 24" on Linux with screen scaling. But I may be wrong as it was a year ago. Will dig into that when I extract the other patches.

In macOS the DPI is constant regardless of the screen type, and is 72.27. It's defined in macfont.m.

@yaglo
Copy link
Owner

yaglo commented Feb 5, 2024

I think you can use the scaling code that you have in the PR for Linux (if it works correctly), and use the font size that you get from font-info directly on macOS without any adjustments and it should work.

@rougier
Copy link
Author

rougier commented Feb 6, 2024

Thanks, I'll look into that.

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

2 participants