Commit 76f421b0 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Use correct glyph origins during rendering.

parent 87bc6aac
...@@ -347,6 +347,8 @@ extern HRESULT create_inmemory_fileloader(IDWriteInMemoryFontFileLoader **loader ...@@ -347,6 +347,8 @@ extern HRESULT create_inmemory_fileloader(IDWriteInMemoryFontFileLoader **loader
extern HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index, extern HRESULT create_font_resource(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
IDWriteFontResource **resource) DECLSPEC_HIDDEN; IDWriteFontResource **resource) DECLSPEC_HIDDEN;
extern HRESULT create_fontset_builder(IDWriteFactory7 *factory, IDWriteFontSetBuilder2 **ret) DECLSPEC_HIDDEN; extern HRESULT create_fontset_builder(IDWriteFactory7 *factory, IDWriteFontSetBuilder2 **ret) DECLSPEC_HIDDEN;
extern HRESULT compute_glyph_origins(DWRITE_GLYPH_RUN const *run, DWRITE_MEASURING_MODE measuring_mode,
D2D1_POINT_2F baseline_origin, DWRITE_MATRIX const *transform, D2D1_POINT_2F *origins) DECLSPEC_HIDDEN;
struct dwrite_fontface; struct dwrite_fontface;
......
...@@ -5918,10 +5918,7 @@ float fontface_get_scaled_design_advance(struct dwrite_fontface *fontface, DWRIT ...@@ -5918,10 +5918,7 @@ float fontface_get_scaled_design_advance(struct dwrite_fontface *fontface, DWRIT
HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWriteGlyphRunAnalysis **ret) HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWriteGlyphRunAnalysis **ret)
{ {
struct dwrite_glyphrunanalysis *analysis; struct dwrite_glyphrunanalysis *analysis;
struct dwrite_fontface *fontface; unsigned int i;
D2D_POINT_2F origin;
FLOAT rtl_factor;
UINT32 i;
*ret = NULL; *ret = NULL;
...@@ -5977,57 +5974,13 @@ HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWrit ...@@ -5977,57 +5974,13 @@ HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWrit
} }
analysis->run.glyphIndices = analysis->glyphs; analysis->run.glyphIndices = analysis->glyphs;
rtl_factor = desc->run->bidiLevel & 1 ? -1.0f : 1.0f;
memcpy(analysis->glyphs, desc->run->glyphIndices, desc->run->glyphCount*sizeof(*desc->run->glyphIndices)); memcpy(analysis->glyphs, desc->run->glyphIndices, desc->run->glyphCount*sizeof(*desc->run->glyphIndices));
fontface = unsafe_impl_from_IDWriteFontFace(desc->run->fontFace); compute_glyph_origins(desc->run, desc->measuring_mode, desc->origin, desc->transform, analysis->origins);
origin.x = desc->origin.x;
origin.y = desc->origin.y;
for (i = 0; i < desc->run->glyphCount; ++i)
{
float advance;
/* Use nominal advances if not provided by caller. */
if (desc->run->glyphAdvances)
advance = rtl_factor * desc->run->glyphAdvances[i];
else
advance = rtl_factor * fontface_get_scaled_design_advance(fontface, desc->measuring_mode,
desc->run->fontEmSize, 1.0f, desc->transform, desc->run->glyphIndices[i], desc->run->isSideways);
analysis->origins[i] = origin;
if (desc->run->bidiLevel & 1)
{
if (desc->run->isSideways)
analysis->origins[i].y += advance;
else
analysis->origins[i].x += advance;
}
/* Offsets are optional, appled to pre-transformed origin. */
if (desc->run->glyphOffsets) {
FLOAT advanceoffset = rtl_factor * desc->run->glyphOffsets[i].advanceOffset;
FLOAT ascenderoffset = -desc->run->glyphOffsets[i].ascenderOffset;
if (desc->run->isSideways) {
analysis->origins[i].x += ascenderoffset;
analysis->origins[i].y += advanceoffset;
}
else {
analysis->origins[i].x += advanceoffset;
analysis->origins[i].y += ascenderoffset;
}
}
if (analysis->flags & RUNANALYSIS_USE_TRANSFORM) if (analysis->flags & RUNANALYSIS_USE_TRANSFORM)
transform_point(analysis->origins + i, &analysis->m); {
for (i = 0; i < desc->run->glyphCount; ++i)
if (desc->run->isSideways) transform_point(&analysis->origins[i], &analysis->m);
origin.y += advance;
else
origin.x += advance;
} }
*ret = &analysis->IDWriteGlyphRunAnalysis_iface; *ret = &analysis->IDWriteGlyphRunAnalysis_iface;
......
...@@ -488,8 +488,8 @@ HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize, ...@@ -488,8 +488,8 @@ HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize,
scaler.y_res = 0; scaler.y_res = 0;
EnterCriticalSection(&freetype_cs); EnterCriticalSection(&freetype_cs);
if (pFTC_Manager_LookupSize(cache_manager, &scaler, &size) == 0) { if (pFTC_Manager_LookupSize(cache_manager, &scaler, &size) == 0)
float rtl_factor = is_rtl ? -1.0f : 1.0f; {
D2D1_POINT_2F origin; D2D1_POINT_2F origin;
unsigned int i; unsigned int i;
...@@ -501,7 +501,6 @@ HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize, ...@@ -501,7 +501,6 @@ HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize,
FLOAT ft_advance = size->face->glyph->metrics.horiAdvance >> 6; FLOAT ft_advance = size->face->glyph->metrics.horiAdvance >> 6;
FT_Outline *outline = &size->face->glyph->outline; FT_Outline *outline = &size->face->glyph->outline;
D2D1_POINT_2F glyph_origin; D2D1_POINT_2F glyph_origin;
float advance;
FT_Matrix m; FT_Matrix m;
if (simulations & DWRITE_FONT_SIMULATIONS_BOLD) if (simulations & DWRITE_FONT_SIMULATIONS_BOLD)
...@@ -514,25 +513,32 @@ HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize, ...@@ -514,25 +513,32 @@ HRESULT freetype_get_glyphrun_outline(IDWriteFontFace5 *fontface, float emSize,
pFT_Outline_Transform(outline, &m); pFT_Outline_Transform(outline, &m);
if (advances)
advance = rtl_factor * advances[i];
else
advance = rtl_factor * ft_advance;
glyph_origin = origin; glyph_origin = origin;
if (is_rtl) if (is_rtl)
glyph_origin.x += advance; {
glyph_origin.x -= ft_advance;
/* glyph offsets act as current glyph adjustment */
if (offsets) if (offsets)
{ {
glyph_origin.x += rtl_factor * offsets[i].advanceOffset; glyph_origin.x -= offsets[i].advanceOffset;
glyph_origin.y -= offsets[i].ascenderOffset; glyph_origin.y -= offsets[i].ascenderOffset;
} }
decompose_outline(outline, glyph_origin, sink); 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;
}
origin.x += advance; decompose_outline(outline, glyph_origin, sink);
} }
} }
} }
......
...@@ -1550,7 +1550,7 @@ static HRESULT WINAPI dwritefactory4_TranslateColorGlyphRun(IDWriteFactory7 *ifa ...@@ -1550,7 +1550,7 @@ static HRESULT WINAPI dwritefactory4_TranslateColorGlyphRun(IDWriteFactory7 *ifa
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT compute_glyph_origins(DWRITE_GLYPH_RUN const *run, DWRITE_MEASURING_MODE measuring_mode, HRESULT compute_glyph_origins(DWRITE_GLYPH_RUN const *run, DWRITE_MEASURING_MODE measuring_mode,
D2D1_POINT_2F baseline_origin, DWRITE_MATRIX const *transform, D2D1_POINT_2F *origins) D2D1_POINT_2F baseline_origin, DWRITE_MATRIX const *transform, D2D1_POINT_2F *origins)
{ {
struct dwrite_fontface *font_obj; struct dwrite_fontface *font_obj;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment