Skip to content

Add Face.getNamedInstances() - #247

Open
FlorianDenis wants to merge 1 commit into
harfbuzz:mainfrom
FlorianDenis:named-instances
Open

FlorianDenis wants to merge 1 commit into
harfbuzz:mainfrom
FlorianDenis:named-instances

Conversation

@FlorianDenis

Copy link
Copy Markdown

Binds the hb_ot_var named-instance functions, which are already compiled in but weren't exported:

  • hb_ot_var_get_named_instance_count()
  • hb_ot_var_named_instance_get_subfamily_name_id()
  • hb_ot_var_named_instance_get_postscript_name_id()
  • hb_ot_var_named_instance_get_design_coords()

Face.getNamedInstances() returns, for each named instance of a variable font, its index, its subfamily name ID, its PostScript name ID when the font has one, and its design coordinates keyed by axis tag:

const instance = face.getNamedInstances()[11];
// { instanceIndex: 11, subfamilyNameId: 269, coords: { wght: 300, wdth: 75 } }
face.getName(instance.subfamilyNameId, "en"); // "Condensed Light"
font.setVariations(instance.coords);

Notes:

  • Returns name IDs rather than resolved names, like getAxisInfos() and getColorPalettes(). An absent PostScript name ID (HB_OT_NAME_ID_INVALID) is left out, as getFeatureNameIds() does.
  • Coordinates are keyed by axis tag so they line up with getAxisInfos() and can go straight to Font.setVariations(). If a font repeats an axis tag, the coordinate follows the axis that getAxisInfos() reports for that tag (the last one).

Bind hb_ot_var_get_named_instance_count() and the
hb_ot_var_named_instance_get_*() functions, returning per named instance
its subfamily and PostScript name IDs and its design coordinates keyed
by axis tag, ready to pass to Font.setVariations().

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant