diff --git a/src/hb-directwrite-shape.cc b/src/hb-directwrite-shape.cc index c312ed492..e686cf2b8 100644 --- a/src/hb-directwrite-shape.cc +++ b/src/hb-directwrite-shape.cc @@ -442,6 +442,44 @@ _hb_directwrite_shape (hb_shape_plan_t *shape_plan, mbstowcs ((wchar_t*) localeName, hb_language_to_string (buffer->props.language), 20); + /* + * Set up variations. + */ + IDWriteFontFace5 *fontFaceVariations = nullptr; + if (font->num_coords) + { + IDWriteFontFace5 *fontFace5; + if (SUCCEEDED (fontFace->QueryInterface (__uuidof (IDWriteFontFace5), (void **) &fontFace5))) + { + IDWriteFontResource *fontResource; + if (SUCCEEDED (fontFace5->GetFontResource (&fontResource))) + { + hb_vector_t axis_values; + if (likely (axis_values.resize_exact (font->num_coords))) + { + for (unsigned int i = 0; i < font->num_coords; i++) + { + hb_ot_var_axis_info_t info; + unsigned int c = 1; + hb_ot_var_get_axis_infos (font->face, i, &c, &info); + axis_values[i].axisTag = (DWRITE_FONT_AXIS_TAG) hb_uint32_swap (info.tag); + axis_values[i].value = i < font->num_coords ? + hb_clamp (font->design_coords[i], info.min_value, info.max_value) : + info.default_value; + } + + if (SUCCEEDED (fontResource->CreateFontFace (DWRITE_FONT_SIMULATIONS::DWRITE_FONT_SIMULATIONS_NONE, + axis_values.arrayZ, axis_values.length, &fontFaceVariations))) + { + fontFace = fontFaceVariations; + } + } + fontResource->Release (); + } + fontFace5->Release (); + } + } + /* * Set up features. */ @@ -614,6 +652,9 @@ retry_getglyphs: delete [] glyphAdvances; delete [] glyphOffsets; + if (fontFaceVariations) + fontFaceVariations->Release (); + /* Wow, done! */ return true; } diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index 3d2e42990..1dc3a5844 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -367,7 +367,7 @@ hb_directwrite_font_create (IDWriteFont *dw_font) { for (uint32_t i = 0; i < count; ++i) { - hb_tag_t tag = values[i].axisTag; + hb_tag_t tag = hb_uint32_swap (values[i].axisTag); float value = values[i].value; vars[i] = {tag, value}; } diff --git a/test/shape/data/in-house/tests/directwrite.tests b/test/shape/data/in-house/tests/directwrite.tests index 48b5bbb33..cb75bc4c9 100644 --- a/test/shape/data/in-house/tests/directwrite.tests +++ b/test/shape/data/in-house/tests/directwrite.tests @@ -1,5 +1,11 @@ +@font-funcs-=directwrite ../fonts/872d2955d326bd6676a06f66b8238ebbaabc212f.ttf;--shaper=directwrite;U+0628,U+0628,U+0628;[uni0628.fina=2+883|uni0628.medi_High=1+244|uni0628.init_High=0+233] ../fonts/7bbd3175734d5d291e1c15271ec0cbb97b626ebf.ttf;--shaper=directwrite;U+0066,U+0066,U+0069;[f_f_i=0+795] ../fonts/7bbd3175734d5d291e1c15271ec0cbb97b626ebf.ttf;--shaper=directwrite --features=-liga;U+0066,U+0066,U+0069;[f=0+300|f=1+300|i=2+263] ../fonts/7bbd3175734d5d291e1c15271ec0cbb97b626ebf.ttf;--shaper=directwrite;U+0648,U+0628,U+0627;[alef-ar.fina=2+229|beh-ar.init=1+190|waw-ar=0+483] -../fonts/7bbd3175734d5d291e1c15271ec0cbb97b626ebf.ttf;--shaper=directwrite --features=ss01;U+0648,U+0628,U+0627;[alef-ar.fina=2+229|beh-ar.init.LD=1+190|waw-ar=0+400] \ No newline at end of file +../fonts/7bbd3175734d5d291e1c15271ec0cbb97b626ebf.ttf;--shaper=directwrite --features=ss01;U+0648,U+0628,U+0627;[alef-ar.fina=2+229|beh-ar.init.LD=1+190|waw-ar=0+400] +#../fonts/HBTest-VF.ttf;--shaper=directwrite --variations=TEST=491;U+0041;[A=0+496] +#../fonts/HBTest-VF.ttf;--shaper=directwrite --variations=TEST=509;U+0041;[A=0+505] +../fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf;--shaper=directwrite --variations=wdth=60;U+0020;[space=0+266] +../fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf;--shaper=directwrite --variations=wdth=402;U+0020;[space=0+639] +../fonts/e8691822f6a705e3e9fb48a0405c645b1a036590.ttf;--shaper=directwrite --variations=0001=500;U+002E,U+0065;[period=0+681|e=1+650]