Skip to content

Commit

Permalink
Improperly ordered filter range is a non-fatal error, just issue a wa…
Browse files Browse the repository at this point in the history
…rning.

Condition table format 1 is described at
https://learn.microsoft.com/en-gb/typography/opentype/spec/chapter2#condition-table-format-1-font-variation-axis-range

In mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=1916037, we saw
fonts being rejected due to incorrectly-ordered min/max values in this table,
but this does not need to be a hard error; we can just issue a warning.
  • Loading branch information
jfkthame committed Oct 1, 2024
1 parent cf38b5d commit e20e492
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1145,13 +1145,17 @@ bool ParseConditionTable(const ots::Font *font,
return OTS_FAILURE_MSG("Axis index out of range in condition");
}

// Check min/max values are within range -1.0 .. 1.0 and properly ordered
// Check min/max values are within range -1.0 .. 1.0.
if (filter_range_min_value < -0x4000 || // -1.0 in F2DOT14 format
filter_range_max_value > 0x4000 || // +1.0 in F2DOT14 format
filter_range_min_value > filter_range_max_value) {
filter_range_max_value > 0x4000) // +1.0 in F2DOT14 format
return OTS_FAILURE_MSG("Invalid filter range in condition");
}

// Warn if range is improperly ordered (and therefore useless).
if (filter_range_min_value > filter_range_max_value) {
OTS_WARNING("Misordered filter range in condition table");
}

return true;
}

Expand Down

0 comments on commit e20e492

Please sign in to comment.