Skip to content
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

[glyf] Respect WE_HAVE_INSTRUCTIONS on any component of a composite. #288

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/glyf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ bool OpenTypeGLYF::ParseCompositeGlyph(
ComponentPointCount* component_point_count) {
uint16_t flags = 0;
uint16_t gid = 0;
bool we_have_instructions = false;
do {
if (!glyph.ReadU16(&flags) || !glyph.ReadU16(&gid)) {
return Error("Can't read composite glyph flags or glyphIndex");
Expand All @@ -271,6 +272,12 @@ bool OpenTypeGLYF::ParseCompositeGlyph(
return Error("Invalid glyph id used in composite glyph: %d", gid);
}

// According to https://learn.microsoft.com/en-gb/typography/opentype/spec/glyf#composite-glyph-description,
// if the WE_HAVE_INSTRUCTIONS bit is set on ANY component,
// there are instructions (following the last component) for
// the composite as a whole.
we_have_instructions = we_have_instructions || (flags & WE_HAVE_INSTRUCTIONS);

if (flags & ARG_1_AND_2_ARE_WORDS) {
int16_t argument1;
int16_t argument2;
Expand Down Expand Up @@ -314,7 +321,7 @@ bool OpenTypeGLYF::ParseCompositeGlyph(
component_point_count->gid_stack.push_back({gid, 1});
} while (flags & MORE_COMPONENTS);

if (flags & WE_HAVE_INSTRUCTIONS) {
if (we_have_instructions) {
uint16_t bytecode_length;
if (!glyph.ReadU16(&bytecode_length)) {
return Error("Can't read instructions size");
Expand Down