Commit ff8f129a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Use callback freetype API to implement GetGlyphRunOutline().

parent f92d7726
......@@ -175,22 +175,6 @@ extern WORD opentype_get_gasp_flags(const WORD*,UINT32,INT) DECLSPEC_HIDDEN;
extern HRESULT bidi_computelevels(const WCHAR*,UINT32,UINT8,UINT8*,UINT8*) DECLSPEC_HIDDEN;
extern WCHAR bidi_get_mirrored_char(WCHAR) DECLSPEC_HIDDEN;
enum outline_point_tag {
OUTLINE_POINT_START = 1 << 0,
OUTLINE_POINT_END = 1 << 1,
OUTLINE_POINT_BEZIER = 1 << 2,
OUTLINE_POINT_LINE = 1 << 3
};
struct glyph_outline {
D2D1_POINT_2F *points;
UINT8 *tags;
UINT16 count;
FLOAT advance;
};
extern HRESULT new_glyph_outline(UINT32,struct glyph_outline**) DECLSPEC_HIDDEN;
/* FreeType integration */
struct dwrite_glyphbitmap {
IDWriteFontFace2 *fontface;
......@@ -209,7 +193,8 @@ extern void release_freetype(void) DECLSPEC_HIDDEN;
extern HRESULT freetype_get_design_glyph_metrics(IDWriteFontFace2*,UINT16,UINT16,DWRITE_GLYPH_METRICS*) DECLSPEC_HIDDEN;
extern void freetype_notify_cacheremove(IDWriteFontFace2*) DECLSPEC_HIDDEN;
extern BOOL freetype_is_monospaced(IDWriteFontFace2*) DECLSPEC_HIDDEN;
extern HRESULT freetype_get_glyph_outline(IDWriteFontFace2*,FLOAT,UINT16,USHORT,struct glyph_outline**) DECLSPEC_HIDDEN;
extern HRESULT freetype_get_glyphrun_outline(IDWriteFontFace2*,FLOAT,UINT16 const*,FLOAT const*, DWRITE_GLYPH_OFFSET const*,
UINT32,BOOL,IDWriteGeometrySink*) DECLSPEC_HIDDEN;
extern UINT16 freetype_get_glyphcount(IDWriteFontFace2*) DECLSPEC_HIDDEN;
extern UINT16 freetype_get_glyphindex(IDWriteFontFace2*,UINT32,INT) DECLSPEC_HIDDEN;
extern BOOL freetype_has_kerning_pairs(IDWriteFontFace2*) DECLSPEC_HIDDEN;
......
......@@ -584,84 +584,11 @@ static void WINAPI dwritefontface_ReleaseFontTable(IDWriteFontFace2 *iface, void
IDWriteFontFileStream_ReleaseFileFragment(This->streams[0], table_context);
}
HRESULT new_glyph_outline(UINT32 count, struct glyph_outline **ret)
{
struct glyph_outline *outline;
D2D1_POINT_2F *points;
UINT8 *tags;
*ret = NULL;
outline = heap_alloc(sizeof(*outline));
if (!outline)
return E_OUTOFMEMORY;
points = heap_alloc(count*sizeof(D2D1_POINT_2F));
tags = heap_alloc_zero(count*sizeof(UINT8));
if (!points || !tags) {
heap_free(points);
heap_free(tags);
heap_free(outline);
return E_OUTOFMEMORY;
}
outline->points = points;
outline->tags = tags;
outline->count = count;
outline->advance = 0.0f;
*ret = outline;
return S_OK;
}
static void free_glyph_outline(struct glyph_outline *outline)
{
heap_free(outline->points);
heap_free(outline->tags);
heap_free(outline);
}
static void report_glyph_outline(const struct glyph_outline *outline, IDWriteGeometrySink *sink)
{
UINT16 p;
for (p = 0; p < outline->count; p++) {
if (outline->tags[p] & OUTLINE_POINT_START) {
ID2D1SimplifiedGeometrySink_BeginFigure(sink, outline->points[p], D2D1_FIGURE_BEGIN_FILLED);
continue;
}
if (outline->tags[p] & OUTLINE_POINT_LINE)
ID2D1SimplifiedGeometrySink_AddLines(sink, outline->points+p, 1);
else if (outline->tags[p] & OUTLINE_POINT_BEZIER) {
static const UINT16 segment_length = 3;
ID2D1SimplifiedGeometrySink_AddBeziers(sink, (D2D1_BEZIER_SEGMENT*)&outline->points[p], 1);
p += segment_length - 1;
}
if (outline->tags[p] & OUTLINE_POINT_END)
ID2D1SimplifiedGeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
}
}
static inline void translate_glyph_outline(struct glyph_outline *outline, FLOAT xoffset, FLOAT yoffset)
{
UINT16 p;
for (p = 0; p < outline->count; p++) {
outline->points[p].x += xoffset;
outline->points[p].y += yoffset;
}
}
static HRESULT WINAPI dwritefontface_GetGlyphRunOutline(IDWriteFontFace2 *iface, FLOAT emSize,
UINT16 const *glyphs, FLOAT const* advances, DWRITE_GLYPH_OFFSET const *offsets,
UINT32 count, BOOL is_sideways, BOOL is_rtl, IDWriteGeometrySink *sink)
{
struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface);
FLOAT advance = 0.0f;
HRESULT hr;
UINT32 g;
TRACE("(%p)->(%.2f %p %p %p %u %d %d %p)\n", This, emSize, glyphs, advances, offsets,
count, is_sideways, is_rtl, sink);
......@@ -672,42 +599,7 @@ static HRESULT WINAPI dwritefontface_GetGlyphRunOutline(IDWriteFontFace2 *iface,
if (is_sideways)
FIXME("sideways mode is not supported.\n");
if (count)
ID2D1SimplifiedGeometrySink_SetFillMode(sink, D2D1_FILL_MODE_WINDING);
for (g = 0; g < count; g++) {
FLOAT xoffset = 0.0f, yoffset = 0.0f;
struct glyph_outline *outline;
/* FIXME: cache outlines */
hr = freetype_get_glyph_outline(iface, emSize, glyphs[g], This->simulations, &outline);
if (FAILED(hr))
return hr;
/* glyph offsets act as current glyph adjustment */
if (offsets) {
xoffset += is_rtl ? -offsets[g].advanceOffset : offsets[g].advanceOffset;
yoffset -= offsets[g].ascenderOffset;
}
if (g == 0)
advance = is_rtl ? -outline->advance : 0.0f;
xoffset += advance;
translate_glyph_outline(outline, xoffset, yoffset);
/* update advance to next glyph */
if (advances)
advance += is_rtl ? -advances[g] : advances[g];
else
advance += is_rtl ? -outline->advance : outline->advance;
report_glyph_outline(outline, sink);
free_glyph_outline(outline);
}
return S_OK;
return freetype_get_glyphrun_outline(iface, emSize, glyphs, advances, offsets, count, is_rtl, sink);
}
static DWRITE_RENDERING_MODE fontface_renderingmode_from_measuringmode(DWRITE_MEASURING_MODE measuring,
......
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