-
Notifications
You must be signed in to change notification settings - Fork 611
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] Load named-instance if face index has top bits set #3348
Comments
I am always a bit puzzled by the status of named instances, and I don't think this would make it much clearer. Does a hb_face_t just contain predefined coordinates for a bunch of named instances that I have to pull out manually and apply to my font if I want that instance, or is the hb_face_t one particular named instance (the one that corresponds to the high bits of the index). And in that case, what is the status of a font that I create from that face ? Can I still set other coordinates on it even though that messes up the correspondence beween the index of the face and the effective coordinates of the font? |
Short answer is /both/. A face contains an entire variation space, which includes a set of named instances. However, when you create a hb_font_t from it, by default, it corresponds to a particular point in the variation space. Currently that always corresponds to the "default-instance" of the variation space. After this proposed change, you can use the high-bits of the index to choose a named-instance. You can still change the font to point somewhere else. |
cc @drott |
Should there be a separate api to get/set the named instance that is 'current' on a hb_face_t? That would save callers from having to fiddle with bits to create a combined index+instance_id to pass to hb_face_set_index(). It would be great if the docs for hb_font_create() talked about this. |
I suppose we can do that.
I added a few words there. Check the commit. Improvements welcome. |
This matches FreeType behavior. Fixes harfbuzz#3348
In fontconfig and freetype I added a special wiring to make named-instances work in older applications transparently. The way it works is this: The high word of face_index is used to pass-through the named-instance index (plus-one). For example, if face-index is 0x00030000 then we load the third named-instance.
HarfBuzz can do the same. In #3347 I already made hb_face_create() only use the lower 16 bit of face_index. When a hb_font_t is created from a hb_face_t, we can look at the face_index of the face and use the higher 16 bits to choose which named-instance to load by default. This will match FreeType behavior.
The text was updated successfully, but these errors were encountered: