mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-12-01 10:34:23 +01:00
[instancer] Recalc avgcharwidth after instancing
This commit is contained in:
1 parent
d053426bb4
commit
d550e16acc
45 files changed
+24
-1
No files matched your search
@@ -209,6 +209,23 @@ struct OS2
|
||||
return ret;
|
||||
}
|
||||
|
||||
static unsigned calc_avg_char_width (const hb_hashmap_t<hb_codepoint_t, hb_pair_t<unsigned, int>>& hmtx_map)
|
||||
{
|
||||
unsigned num = 0;
|
||||
unsigned total_width = 0;
|
||||
for (const auto& _ : hmtx_map.values_ref ())
|
||||
{
|
||||
unsigned width = _.first;
|
||||
if (width)
|
||||
{
|
||||
total_width += width;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
return num ? (unsigned) roundf (total_width / num) : 0;
|
||||
}
|
||||
|
||||
bool subset (hb_subset_context_t *c) const
|
||||
{
|
||||
TRACE_SUBSET (this);
|
||||
@@ -244,6 +261,11 @@ struct OS2
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_X_HEIGHT, sxHeight);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_CAP_HEIGHT, sCapHeight);
|
||||
}
|
||||
|
||||
unsigned avg_char_width = calc_avg_char_width (c->plan->hmtx_map);
|
||||
if (!c->serializer->check_assign (os2_prime->xAvgCharWidth, avg_char_width,
|
||||
HB_SERIALIZE_ERROR_INT_OVERFLOW))
|
||||
return_trace (false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -460,6 +460,7 @@ _dependencies_satisfied (hb_subset_plan_t *plan, hb_tag_t tag,
|
||||
case HB_OT_TAG_hmtx:
|
||||
case HB_OT_TAG_vmtx:
|
||||
case HB_OT_TAG_maxp:
|
||||
case HB_OT_TAG_OS2:
|
||||
return !plan->normalized_coords || !pending_subset_tags.has (HB_OT_TAG_glyf);
|
||||
case HB_OT_TAG_GPOS:
|
||||
return plan->all_axes_pinned || !pending_subset_tags.has (HB_OT_TAG_GDEF);
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -44,7 +44,7 @@ def generate_expected_output(input_file, unicodes, profile_flags, instance_flags
|
||||
fonttools_path = os.path.join(tempfile.mkdtemp (), font_name)
|
||||
args = ["fonttools", "subset", input_path]
|
||||
if instance_flags:
|
||||
args.extend(["--recalc-bounds"])
|
||||
args.extend(["--recalc-bounds", "--recalc-average-width"])
|
||||
args.extend(["--drop-tables+=DSIG",
|
||||
"--drop-tables-=sbix",
|
||||
"--no-harfbuzz-repacker", # disable harfbuzz repacker so we aren't comparing to ourself.
|
||||
|
||||
Reference in new issue
Block a user