This has no functional impact. Internal function is only called with one bit set at a time, but there is no reason to make it more confusing.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 14be1b9fc1b..4e2917854ba 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -4022,7 +4022,7 @@ static HRESULT init_font_data(const struct fontface_desc *desc, struct dwrite_fo return S_OK; }
-static HRESULT init_font_data_from_font(const struct dwrite_font_data *src, DWRITE_FONT_SIMULATIONS sim, +static HRESULT init_font_data_from_font(const struct dwrite_font_data *src, DWRITE_FONT_SIMULATIONS simulations, const WCHAR *facenameW, struct dwrite_font_data **ret) { struct dwrite_font_data *data; @@ -4035,10 +4035,10 @@ static HRESULT init_font_data_from_font(const struct dwrite_font_data *src, DWRI
*data = *src; data->refcount = 1; - data->simulations |= sim; - if (sim == DWRITE_FONT_SIMULATIONS_BOLD) + data->simulations |= simulations; + if (simulations & DWRITE_FONT_SIMULATIONS_BOLD) data->weight = DWRITE_FONT_WEIGHT_BOLD; - else if (sim == DWRITE_FONT_SIMULATIONS_OBLIQUE) + if (simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE) data->style = DWRITE_FONT_STYLE_OBLIQUE; memset(data->info_strings, 0, sizeof(data->info_strings)); data->names = NULL;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/tests/font.c | 66 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-)
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index c14c557c92a..7aa871dcd3c 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -7822,10 +7822,31 @@ static void test_HasCharacter(void) ok(ref == 0, "factory not released, %u\n", ref); }
+static BOOL has_main_axis_values(const DWRITE_FONT_AXIS_VALUE *values, unsigned int count) +{ + BOOL has_wght = FALSE, has_wdth = FALSE, has_ital = FALSE, has_slnt = FALSE; + unsigned int i; + + for (i = 0; i < count; ++i) + { + if (values[i].axisTag == DWRITE_FONT_AXIS_TAG_WEIGHT) + has_wght = TRUE; + else if (values[i].axisTag == DWRITE_FONT_AXIS_TAG_WIDTH) + has_wdth = TRUE; + else if (values[i].axisTag == DWRITE_FONT_AXIS_TAG_ITALIC) + has_ital = TRUE; + else if (values[i].axisTag == DWRITE_FONT_AXIS_TAG_SLANT) + has_slnt = TRUE; + } + + return has_wght && has_wdth && has_ital && has_slnt; +} + static void test_CreateFontFaceReference(void) { IDWriteFontFaceReference *ref, *ref1, *ref3; IDWriteFontFace3 *fontface, *fontface1; + DWRITE_FONT_AXIS_VALUE axis_values[16]; IDWriteFontCollection1 *collection; IDWriteFontFile *file, *file1; IDWriteFactory3 *factory; @@ -7978,7 +7999,15 @@ todo_wine (void **)&ref2))) { UINT32 axis_count = IDWriteFontFaceReference1_GetFontAxisValueCount(ref2); - ok(axis_count > 0, "Unexpected axis value count.\n"); + todo_wine + ok(axis_count >= 4, "Unexpected axis value count.\n"); + + hr = IDWriteFontFaceReference1_GetFontAxisValues(ref2, axis_values, ARRAY_SIZE(axis_values)); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + todo_wine + ok(has_main_axis_values(axis_values, axis_count), "Unexpected axis returned.\n"); + IDWriteFontFaceReference1_Release(ref2); }
@@ -9394,9 +9423,11 @@ static void test_AnalyzeContainerType(void) static void test_fontsetbuilder(void) { IDWriteFontFaceReference *ref, *ref2, *ref3; + IDWriteFontFaceReference1 *ref1; IDWriteFontCollection1 *collection; IDWriteFontSetBuilder1 *builder1; IDWriteFontSetBuilder *builder; + DWRITE_FONT_AXIS_VALUE axis_values[4]; IDWriteFactory3 *factory; UINT32 count, i, refcount; IDWriteFontSet *fontset; @@ -9436,6 +9467,39 @@ static void test_fontsetbuilder(void) count = IDWriteFontSet_GetFontCount(fontset); ok(count == 2, "Unexpected font count %u.\n", count);
+ hr = IDWriteFontSet_GetFontFaceReference(fontset, 0, &ref); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + + hr = IDWriteFontFaceReference_QueryInterface(ref, &IID_IDWriteFontFaceReference1, (void **)&ref1); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + + count = IDWriteFontFaceReference1_GetFontAxisValueCount(ref1); + todo_wine + ok(count == 4, "Unexpected axis count %u.\n", count); + + if (count == 4) + { + hr = IDWriteFontFaceReference1_GetFontAxisValues(ref1, axis_values, ARRAY_SIZE(axis_values)); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + + ok(axis_values[0].axisTag == DWRITE_FONT_AXIS_TAG_WEIGHT, "Unexpected tag[0] %s.\n", + wine_dbgstr_an((char *)&axis_values[0].axisTag, 4)); + ok(axis_values[0].value == 500.0f, "Unexpected value[0] %f.\n", axis_values[0].value); + ok(axis_values[1].axisTag == DWRITE_FONT_AXIS_TAG_WIDTH, "Unexpected tag[1] %s.\n", + wine_dbgstr_an((char *)&axis_values[1].axisTag, 4)); + ok(axis_values[1].value == 100.0f, "Unexpected value[1] %f.\n", axis_values[1].value); + ok(axis_values[2].axisTag == DWRITE_FONT_AXIS_TAG_ITALIC, "Unexpected tag[2] %s.\n", + wine_dbgstr_an((char *)&axis_values[2].axisTag, 4)); + ok(axis_values[2].value == 0.0f, "Unexpected value[2] %f.\n", axis_values[2].value); + ok(axis_values[3].axisTag == DWRITE_FONT_AXIS_TAG_SLANT, "Unexpected tag[3] %s.\n", + wine_dbgstr_an((char *)&axis_values[3].axisTag, 4)); + ok(axis_values[3].value == 0.0f, "Unexpected value[3] %f.\n", axis_values[3].value); + } + + IDWriteFontFaceReference1_Release(ref1); + + IDWriteFontFaceReference_Release(ref); + IDWriteFontSet_Release(fontset);
IDWriteFontFile_Release(file);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 12 ++++++++++-- dlls/dwrite/tests/font.c | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 4e2917854ba..c0fff68ed15 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -7467,9 +7467,17 @@ static HRESULT WINAPI dwritefontset1_GetFontFaceReference(IDWriteFontSet3 *iface
static HRESULT WINAPI dwritefontset1_CreateFontResource(IDWriteFontSet3 *iface, UINT32 index, IDWriteFontResource **resource) { - FIXME("%p, %u, %p.\n", iface, index, resource); + struct dwrite_fontset *set = impl_from_IDWriteFontSet3(iface);
- return E_NOTIMPL; + TRACE("%p, %u, %p.\n", iface, index, resource); + + *resource = NULL; + + if (index >= set->count) + return E_INVALIDARG; + + return IDWriteFactory7_CreateFontResource(set->factory, set->entries[index]->file, + set->entries[index]->face_index, resource); }
static HRESULT WINAPI dwritefontset1_CreateFontFace(IDWriteFontSet3 *iface, UINT32 index, IDWriteFontFace5 **fontface) diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 7aa871dcd3c..27c2a9d0b7d 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -10018,6 +10018,7 @@ static void test_family_font_set(void) unsigned int count, refcount; IDWriteFontSet1 *fontset, *fontset2; IDWriteLocalizedStrings *values; + IDWriteFontResource *resource; WCHAR buffW[64]; BOOL exists; HRESULT hr; @@ -10070,6 +10071,13 @@ static void test_family_font_set(void) IDWriteLocalizedStrings_Release(values); }
+ hr = IDWriteFontSet1_CreateFontResource(fontset, 100, &resource); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IDWriteFontSet1_CreateFontResource(fontset, 0, &resource); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IDWriteFontResource_Release(resource); + IDWriteFontSet1_Release(fontset2); IDWriteFontSet1_Release(fontset);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 4 ++-- dlls/dwrite/gdiinterop.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index c0fff68ed15..e5050476938 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -1265,7 +1265,7 @@ static HRESULT WINAPI dwritefontface2_GetRecommendedRenderingMode(IDWriteFontFac TRACE("%p, %.8e, %.8e, %.8e, %p, %d, %d, %d, %p, %p, %p.\n", iface, emSize, dpiX, dpiY, m, is_sideways, threshold, measuringmode, params, renderingmode, gridfitmode);
- if (m) + if (m && memcmp(m, &identity, sizeof(*m))) FIXME("transform not supported %s\n", debugstr_matrix(m));
if (is_sideways) @@ -1452,7 +1452,7 @@ static HRESULT WINAPI dwritefontface3_GetRecommendedRenderingMode(IDWriteFontFac TRACE("%p, %.8e, %.8e, %.8e, %p, %d, %d, %d, %p, %p, %p.\n", iface, emSize, dpiX, dpiY, m, is_sideways, threshold, measuring_mode, params, rendering_mode, gridfit_mode);
- if (m) + if (m && memcmp(m, &identity, sizeof(*m))) FIXME("transform not supported %s\n", debugstr_matrix(m));
if (is_sideways) diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c index 84d1f615f75..6a5953a67e9 100644 --- a/dlls/dwrite/gdiinterop.c +++ b/dlls/dwrite/gdiinterop.c @@ -369,7 +369,7 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac }
hr = IDWriteFontFace3_GetRecommendedRenderingMode(fontface, run->fontEmSize, target->ppdip * 96.0f, - target->ppdip * 96.0f, NULL /* FIXME */, run->isSideways, DWRITE_OUTLINE_THRESHOLD_ALIASED, measuring_mode, + target->ppdip * 96.0f, &target->m, run->isSideways, DWRITE_OUTLINE_THRESHOLD_ALIASED, measuring_mode, params, &rendermode, &gridfitmode); IDWriteFontFace3_Release(fontface); if (FAILED(hr))
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
In preparation to remove user callbacks from freetype integration code. Also this reuses currently duplicated code for origins.
dlls/dwrite/dwrite_private.h | 5 +-- dlls/dwrite/font.c | 39 ++++++++++++++++-- dlls/dwrite/freetype.c | 79 +++++++++--------------------------- 3 files changed, 57 insertions(+), 66 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 8c09a315f54..fe1a16c8899 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -463,9 +463,8 @@ extern void release_freetype(void) DECLSPEC_HIDDEN; extern HRESULT freetype_get_design_glyph_metrics(struct dwrite_fontface *fontface, UINT16 glyph, DWRITE_GLYPH_METRICS *metrics) DECLSPEC_HIDDEN; extern void freetype_notify_cacheremove(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; -extern HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emsize, UINT16 const *glyphs, - float const *advances, DWRITE_GLYPH_OFFSET const *offsets, unsigned int count, BOOL is_rtl, - IDWriteGeometrySink *sink) DECLSPEC_HIDDEN; +extern HRESULT freetype_get_glyph_outline(IDWriteFontFace5 *fontface, float emSize, UINT16 glyph, + D2D1_POINT_2F origin, IDWriteGeometrySink *sink) DECLSPEC_HIDDEN; extern UINT16 freetype_get_glyphcount(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; extern void freetype_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap_desc) DECLSPEC_HIDDEN; extern BOOL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap*) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index e5050476938..0167878e912 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -827,16 +827,49 @@ static HRESULT WINAPI dwritefontface_GetGlyphRunOutline(IDWriteFontFace5 *iface, UINT16 const *glyphs, FLOAT const* advances, DWRITE_GLYPH_OFFSET const *offsets, UINT32 count, BOOL is_sideways, BOOL is_rtl, IDWriteGeometrySink *sink) { + D2D1_POINT_2F *origins, baseline_origin = { 0 }; + DWRITE_GLYPH_RUN run; + unsigned int i; + HRESULT hr; + TRACE("%p, %.8e, %p, %p, %p, %u, %d, %d, %p.\n", iface, emSize, glyphs, advances, offsets, count, is_sideways, is_rtl, sink);
if (!glyphs || !sink) return E_INVALIDARG;
- if (is_sideways) - FIXME("sideways mode is not supported.\n"); + if (!count) + return S_OK;
- return freetype_get_glyphrun_outline(iface, emSize, glyphs, advances, offsets, count, is_rtl, sink); + run.fontFace = (IDWriteFontFace *)iface; + run.fontEmSize = emSize; + run.glyphCount = count; + run.glyphIndices = glyphs; + run.glyphAdvances = advances; + run.glyphOffsets = offsets; + run.isSideways = is_sideways; + run.bidiLevel = is_rtl ? 1 : 0; + + if (!(origins = heap_alloc(sizeof(*origins) * count))) + return E_OUTOFMEMORY; + + if (FAILED(hr = compute_glyph_origins(&run, DWRITE_MEASURING_MODE_NATURAL, baseline_origin, NULL, origins))) + { + heap_free(origins); + return hr; + } + + ID2D1SimplifiedGeometrySink_SetFillMode(sink, D2D1_FILL_MODE_WINDING); + + for (i = 0; i < count; ++i) + { + if (FAILED(hr = freetype_get_glyph_outline(iface, emSize, glyphs[i], origins[i], sink))) + WARN("Failed to get glyph outline for glyph %u.\n", glyphs[i]); + } + + heap_free(origins); + + return S_OK; }
static DWRITE_RENDERING_MODE fontface_renderingmode_from_measuringmode(DWRITE_MEASURING_MODE measuring, diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c index b770caac479..83b2ae1bc88 100644 --- a/dlls/dwrite/freetype.c +++ b/dlls/dwrite/freetype.c @@ -464,20 +464,14 @@ static void embolden_glyph(FT_Glyph glyph, FLOAT emsize) embolden_glyph_outline(&outline_glyph->outline, emsize); }
-HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize, UINT16 const *glyphs, - float const *advances, DWRITE_GLYPH_OFFSET const *offsets, unsigned int count, BOOL is_rtl, - IDWriteGeometrySink *sink) +HRESULT freetype_get_glyph_outline(IDWriteFontFace5 *fontface, float emSize, UINT16 glyph, + D2D1_POINT_2F origin, IDWriteGeometrySink *sink) { FTC_ScalerRec scaler; USHORT simulations; HRESULT hr = S_OK; FT_Size size;
- if (!count) - return S_OK; - - ID2D1SimplifiedGeometrySink_SetFillMode(sink, D2D1_FILL_MODE_WINDING); - simulations = IDWriteFontFace5_GetSimulations(fontface);
scaler.face_id = fontface; @@ -490,56 +484,22 @@ HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize, EnterCriticalSection(&freetype_cs); if (pFTC_Manager_LookupSize(cache_manager, &scaler, &size) == 0) { - D2D1_POINT_2F origin; - unsigned int i; - - origin.x = origin.y = 0.0f; - for (i = 0; i < count; ++i) + if (pFT_Load_Glyph(size->face, glyph, FT_LOAD_NO_BITMAP) == 0) { - if (pFT_Load_Glyph(size->face, glyphs[i], FT_LOAD_NO_BITMAP) == 0) - { - FLOAT ft_advance = size->face->glyph->metrics.horiAdvance >> 6; - FT_Outline *outline = &size->face->glyph->outline; - D2D1_POINT_2F glyph_origin; - FT_Matrix m; - - if (simulations & DWRITE_FONT_SIMULATIONS_BOLD) - embolden_glyph_outline(outline, emSize); - - m.xx = 1 << 16; - m.xy = simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE ? (1 << 16) / 3 : 0; - m.yx = 0; - m.yy = -(1 << 16); /* flip Y axis */ - - pFT_Outline_Transform(outline, &m); - - glyph_origin = origin; - - if (is_rtl) - { - glyph_origin.x -= ft_advance; - - if (offsets) - { - glyph_origin.x -= offsets[i].advanceOffset; - glyph_origin.y -= offsets[i].ascenderOffset; - } - - origin.x -= advances ? advances[i] : ft_advance; - } - else - { - if (offsets) - { - glyph_origin.x += offsets[i].advanceOffset; - glyph_origin.y -= offsets[i].ascenderOffset; - } - - origin.x += advances ? advances[i] : ft_advance; - } - - decompose_outline(outline, glyph_origin, sink); - } + FT_Outline *outline = &size->face->glyph->outline; + FT_Matrix m; + + if (simulations & DWRITE_FONT_SIMULATIONS_BOLD) + embolden_glyph_outline(outline, emSize); + + m.xx = 1 << 16; + m.xy = simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE ? (1 << 16) / 3 : 0; + m.yx = 0; + m.yy = -(1 << 16); /* flip Y axis */ + + pFT_Outline_Transform(outline, &m); + + decompose_outline(outline, origin, sink); } } else @@ -837,9 +797,8 @@ HRESULT freetype_get_design_glyph_metrics(struct dwrite_fontface *fontface, UINT return E_NOTIMPL; }
-HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize, UINT16 const *glyphs, - float const *advances, DWRITE_GLYPH_OFFSET const *offsets, unsigned int count, BOOL is_rtl, - IDWriteGeometrySink *sink) +HRESULT freetype_get_glyph_outline(IDWriteFontFace5 *fontface, float emSize, UINT16 glyph, + D2D1_POINT_2F origin, IDWriteGeometrySink *sink) { return E_NOTIMPL; }