Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Implement text shaping with libraqm#30000
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
f8dea40
tod1780a2
CompareThis was useful in pointing out some cross-platform incompatibilities. I may check cibuildwheel as well later to ensure bundling is working correctly. The failing test is a relatively recent one; I will have to check if that is from here or the FreeType change. |
Namely, `text.hinting` is now `default` instead of `force_autohint` (or`none` for classic tests) and `text.hinting_factor` is now 1, not 8.
If we've updated an image in the past couple commits, then we can removethe backwards-compatibility styling so that they're generated asintended.
The `FontInfo.num` value returned by `TruetypeFonts._get_info` is acharacter code, but `FT2Font.get_kerning` takes *glyph indices*, meaningthat kerning was likely off in most cases.
Also add some missing license entries in more places.
Do you envision that raqm will become the sole text layout method, or do you plan to keep the old manual layouting around (perhaps togglable)? I just noticed that the old layouting method appears to be missing handling of lsb_delta and rsb_delta (see note athttps://freetype.org/freetype2/docs/reference/ft2-glyph_retrieval.html#ft_glyphslotrec ("If you use strong auto-hinting, you must apply these delta values! Otherwise you will experience far too large inter-glyph spacing at small rendering sizes in most cases.")) but raqm would likely (hopefully?) take care of that for us. If the manual layouting is going to stay then I'll open a separate issue to implement this (perhaps also to be folded into the FreeType update mega-PR); if not, perhaps we can just forget about it. |
I intend for it to replace everything, I think. I have some in-progress work to apply it to PDF/PS/SVG as well. I did notice the |
anntzer commentedMay 21, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Also, does _text_helpers.layout() also need to be rewritten to use raqm as well? (likely it would need to also include y information now) A nice endpoint would be if the new _text_helpers.LayoutItem, by supporting both x and y, was general enough that draw_text and draw_mathtext (and even draw_tex) could ultimately just all pass a list of LayoutItems (+ rects, in the mathtext/tex case) down to a single glyph rendering method. |
The former may be used even on PS/PDF backend where nothing is rendered.
QuLogic commentedMay 24, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
OK, I've figured out why I was running into issues before and pushed the vector implementation up now. The issues aren't fixed, but at least in a position to be discussed. Specifically,
which works out to:
But the libraqm 26.6 advances are (equivalent to the linear advances divided by 1024 and rounded to integers):
which works out to:
or the small difference of:
Unfortunately, this touches almost every single SVG in a way that they all fail, but invisibly. I'm not sure if we should attempt to work around this (by scaling DPI by 1024, or adding a 1024 scaling |
[I guess what's really stored in the font file are advances in font design units and then FreeType scales them by (font design units->real space) and then by 2^16 whereas raqm (really, harfbuzz) uses 2^6 for that last scaling, so probably neither of them is really right or wrong?] If the breakages are only in svg files then I guess this isn't really a problem because it's just a few numbers (the glyph x-positions) that will change and so the diff will not actually be so big? (If you check by git diff rather than the github UI or similar it would just be a few small changes?) |
PR summary
This is based on#29816 but doesn't yet include#29794 and#29695. I'm mostly opening it to see how CI will cope.
PR checklist