-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Warn when asked to measure a character not shaped in a font #2193
base: master
Are you sure you want to change the base?
Conversation
shapers/base.lua
Outdated
) | ||
) | ||
end | ||
return { height = item.height, width = item.width, depth = item.depth, name = item.name } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need returning the name? Could be the GID, or just a boolean "undefined = true", so the caller wouldn't have to perform a ".notdef" explicit check. The name might not be meaningful or portable any for most extended characters (ligatures, etc.), would it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N.B. I am not fond of warnings is such utilities. The caller could try to measure char X, and fallback to char Y if X is not defined, without low-level warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think we need to return the name. That way downstream users of the API can make their own call about whether to use the results or not. Actually I just took it a step farther and passed the entire table of info we got back from the shaper. That includes all the keys currently used and also some information about offsets that could be useful for some measurement scenarios. Also it includes the GID and name in case the consumer wants to check them.
My rational for including the warning was that we have better access to the font name and such here in the function than the user does easily when using the function so it was easier to create a meaningful warning. I'm not set on it though, so lets try a different shape ... returning a boolean status flag might be pretty useful too. How does that look?
e550067
to
52f0c9d
Compare
52f0c9d
to
e0b5cd8
Compare
The fact that this failed a test may have just revealed a big lurking bug, but I don't have time to pull it apart right now and I urgently need a tagged release so I can send a book to press with a known version. I'm going to bump this and release dot-8, but I'm open to a quick follow up patch release if we figure this or anything else out. Right now macOS being 2 versions behind because I broke Darwin builds is a big deal and that needs to get fixed ASAP. |
return { height = items[1].height, width = items[1].width, depth = items[1].depth } | ||
if items and items[1] then | ||
local item = items[1] | ||
return item, item.gid ~= 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code (even before this PR) seems to assume that a character will be mapped to only a single glyph, but this is not true in general.
Closes #1706