Merge pull request #3068 from harfbuzz/hoi
[variations] Support multiple axes with same tag, aka HOI
This commit is contained in:
commit
aeec278453
|
@ -2052,7 +2052,9 @@ hb_font_set_variations (hb_font_t *font,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int coords_length = hb_ot_var_get_axis_count (font->face);
|
const OT::fvar &fvar = *font->face->table.fvar;
|
||||||
|
auto axes = fvar.get_axes ();
|
||||||
|
const unsigned coords_length = axes.length;
|
||||||
|
|
||||||
int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr;
|
int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr;
|
||||||
float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr;
|
float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr;
|
||||||
|
@ -2064,14 +2066,13 @@ hb_font_set_variations (hb_font_t *font,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const OT::fvar &fvar = *font->face->table.fvar;
|
|
||||||
for (unsigned int i = 0; i < variations_length; i++)
|
for (unsigned int i = 0; i < variations_length; i++)
|
||||||
{
|
{
|
||||||
unsigned axis_index;
|
const auto tag = variations[i].tag;
|
||||||
if (fvar.find_axis_index (variations[i].tag, &axis_index) &&
|
const auto v = variations[i].value;
|
||||||
axis_index < coords_length)
|
for (unsigned axis_index = 0; axis_index < coords_length; axis_index++)
|
||||||
|
if (axes[axis_index].axisTag == tag)
|
||||||
{
|
{
|
||||||
float v = variations[i].value;
|
|
||||||
design_coords[axis_index] = v;
|
design_coords[axis_index] = v;
|
||||||
normalized[axis_index] = fvar.normalize_axis_value (axis_index, v);
|
normalized[axis_index] = fvar.normalize_axis_value (axis_index, v);
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,38 +213,15 @@ struct fvar
|
||||||
if (!axis_index) axis_index = &i;
|
if (!axis_index) axis_index = &i;
|
||||||
*axis_index = HB_OT_VAR_NO_AXIS_INDEX;
|
*axis_index = HB_OT_VAR_NO_AXIS_INDEX;
|
||||||
auto axes = get_axes ();
|
auto axes = get_axes ();
|
||||||
return find_axis_index (tag, axis_index) && (axes[*axis_index].get_axis_deprecated (info), true);
|
return axes.lfind (tag, axis_index) && (axes[*axis_index].get_axis_deprecated (info), true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool
|
|
||||||
find_axis_index (hb_tag_t tag,
|
|
||||||
unsigned *axis_index_start,
|
|
||||||
unsigned *axis_index_end = nullptr) const
|
|
||||||
{
|
|
||||||
auto axes = get_axes ();
|
|
||||||
|
|
||||||
/* TODO bfind() for larger array? Should then look back to find first entry for tag. */
|
|
||||||
if (!axes.lfind (tag, axis_index_start))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (axis_index_end)
|
|
||||||
{
|
|
||||||
unsigned end = *axis_index_start + 1;
|
|
||||||
unsigned count = axes.length;
|
|
||||||
while (end < count && axes[end].axisTag == tag)
|
|
||||||
end++;
|
|
||||||
*axis_index_end = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool
|
bool
|
||||||
find_axis_info (hb_tag_t tag, hb_ot_var_axis_info_t *info) const
|
find_axis_info (hb_tag_t tag, hb_ot_var_axis_info_t *info) const
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
auto axes = get_axes ();
|
auto axes = get_axes ();
|
||||||
return find_axis_index (tag, &i) && (axes[i].get_axis_info (i, info), true);
|
return axes.lfind (tag, &i) && (axes[i].get_axis_info (i, info), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int normalize_axis_value (unsigned int axis_index, float v) const
|
int normalize_axis_value (unsigned int axis_index, float v) const
|
||||||
|
@ -313,7 +290,7 @@ struct fvar
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
hb_array_t<const AxisRecord> get_axes () const
|
hb_array_t<const AxisRecord> get_axes () const
|
||||||
{ return hb_array (&(this+firstAxis), axisCount); }
|
{ return hb_array (&(this+firstAxis), axisCount); }
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,8 @@ TESTS = \
|
||||||
tests/use-marchen.tests \
|
tests/use-marchen.tests \
|
||||||
tests/use-syllable.tests \
|
tests/use-syllable.tests \
|
||||||
tests/use.tests \
|
tests/use.tests \
|
||||||
tests/variations-rounding.tests \
|
tests/variations.tests \
|
||||||
tests/variations-rvrn.tests \
|
tests/variations-rvrn.tests \
|
||||||
tests/variations-space.tests \
|
|
||||||
tests/vertical.tests \
|
tests/vertical.tests \
|
||||||
tests/zero-width-marks.tests \
|
tests/zero-width-marks.tests \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
Binary file not shown.
|
@ -58,9 +58,8 @@ in_house_tests = [
|
||||||
'use-marchen.tests',
|
'use-marchen.tests',
|
||||||
'use-syllable.tests',
|
'use-syllable.tests',
|
||||||
'use.tests',
|
'use.tests',
|
||||||
'variations-rounding.tests',
|
'variations.tests',
|
||||||
'variations-rvrn.tests',
|
'variations-rvrn.tests',
|
||||||
'variations-space.tests',
|
|
||||||
'vertical.tests',
|
'vertical.tests',
|
||||||
'zero-width-marks.tests',
|
'zero-width-marks.tests',
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
../fonts/HBTest-VF.ttf:--variations=TEST=491:U+0041:[A=0+496]
|
|
||||||
../fonts/HBTest-VF.ttf:--variations=TEST=509:U+0041:[A=0+505]
|
|
|
@ -1,2 +0,0 @@
|
||||||
../fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf:--variations=wdth=60:U+0020:[space=0+266]
|
|
||||||
../fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf:--variations=wdth=402:U+0020:[space=0+639]
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
../fonts/HBTest-VF.ttf:--variations=TEST=491:U+0041:[A=0+496]
|
||||||
|
../fonts/HBTest-VF.ttf:--variations=TEST=509:U+0041:[A=0+505]
|
||||||
|
../fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf:--variations=wdth=60:U+0020:[space=0+266]
|
||||||
|
../fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf:--variations=wdth=402:U+0020:[space=0+639]
|
||||||
|
../fonts/e8691822f6a705e3e9fb48a0405c645b1a036590.ttf:--variations=0001=500:U+002E,U+0065:[period=0+681|e=1+650]
|
Loading…
Reference in New Issue