-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
shaper:measureChar can return the width of a .notdef character #1706
Comments
... Which might be a harfbuzz-specific approach, however (i.e. I am not sure other shapers are expected to return a "gid' or "name" in the shaped items, so it might not be that appropriate to have it in the "base" class)? |
I'm not familiar with this API, but it doesn't feel like a good idea to error here unless other SILE shaping code also errors for missing characters. Also it depends on what this API is supposed to do, if .notdef is what is going to be displayed, then it seems appropriate that measuring gives its dimensions. |
@khaledhosny It doesn't feel good either to return the width of a .notdef for measurement of something that might not make it to ouput (depending on why things are measured, and depending too on whether there are font-fallbacks that apply, but these are not checked here either...) An example use is here #1705 where I'd prefer the explicit warning handling if the font doesn't have the "numeric / figure space" character1 ... The zenkaku "zw" unit also has the same type of problem (i.e. it didn't warn, but measured .notdef too). Footnotes
|
Re: "The zenkaku unit has the same issue"
From the warning text it seems that the intent was to warn if the specified character couldn't be measured (rather than a measure succeeded, but actually on something else). ❓ Your point is sound too, though. scratches head |
Interestingly, the |
Maybe we want another function: |
... Or it could return, besides the width/height, something so that the caller knows what was measured, perhaps? |
That would work too. You could return an object having glyphname and codepoint if available. |
I recently touched that measureChar function (to also return the depth of the measured character, in #2141) - So self-assigning this issue before I forget again about it.... |
I just took a pass at this by: a) throwing a warning if we are asked to measure something that resolves to How does that sit? |
I had some surprise getting a width from calling SILE.shaper:measureChar() with a character not existing in my font. (It existed in another font I previously used.)
Investigating, the measured character is a
.notdef
one in that font, i.e. the function does shape something and silently returns a value, but is it not what one may expect (but, likely, the width of a default square or of a ☠️ or whatever the font returns here).See:
sile/shapers/base.lua
Lines 67 to 69 in 607dcf7
Shouldn't this be:
N.B. The proposed extra check is what the fallback shaper does...
sile/shapers/fallback.lua
Line 104 in 607dcf7
... to actually ensure the shaped token(s) lead to valid glyph(s).
(EDIT: cleaned up the proposed code, I had left some stuff from earlier debugging)
The text was updated successfully, but these errors were encountered: