Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 121 +++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 53 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index aa51c744297..9889add8899 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -151,9 +151,10 @@ struct dwrite_fontlist struct dwrite_fontfamily *family; };
-struct dwrite_font { +struct dwrite_font +{ IDWriteFont3 IDWriteFont3_iface; - LONG ref; + LONG refcount;
DWRITE_FONT_STYLE style; struct dwrite_font_data *data; @@ -1848,9 +1849,7 @@ static HRESULT get_fontface_from_font(struct dwrite_font *font, IDWriteFontFace5
static HRESULT WINAPI dwritefont_QueryInterface(IDWriteFont3 *iface, REFIID riid, void **obj) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IDWriteFont3) || IsEqualIID(riid, &IID_IDWriteFont2) || @@ -1871,57 +1870,67 @@ static HRESULT WINAPI dwritefont_QueryInterface(IDWriteFont3 *iface, REFIID riid
static ULONG WINAPI dwritefont_AddRef(IDWriteFont3 *iface) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); - return ref; + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + ULONG refcount = InterlockedIncrement(&font->refcount); + + TRACE("%p, refcount %d.\n", iface, refcount); + + return refcount; }
static ULONG WINAPI dwritefont_Release(IDWriteFont3 *iface) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + ULONG refcount = InterlockedDecrement(&font->refcount);
- TRACE("(%p)->(%d)\n", This, ref); + TRACE("%p, refcount %d.\n", iface, refcount);
- if (!ref) { - IDWriteFontFamily2_Release(&This->family->IDWriteFontFamily2_iface); - release_font_data(This->data); - heap_free(This); + if (!refcount) + { + IDWriteFontFamily2_Release(&font->family->IDWriteFontFamily2_iface); + release_font_data(font->data); + heap_free(font); }
- return ref; + return refcount; }
static HRESULT WINAPI dwritefont_GetFontFamily(IDWriteFont3 *iface, IDWriteFontFamily **family) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - TRACE("(%p)->(%p)\n", This, family); + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + + TRACE("%p, %p.\n", iface, family);
- *family = (IDWriteFontFamily*)This->family; + *family = (IDWriteFontFamily *)font->family; IDWriteFontFamily_AddRef(*family); return S_OK; }
static DWRITE_FONT_WEIGHT WINAPI dwritefont_GetWeight(IDWriteFont3 *iface) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - TRACE("(%p)\n", This); - return This->data->weight; + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + + TRACE("%p.\n", iface); + + return font->data->weight; }
static DWRITE_FONT_STRETCH WINAPI dwritefont_GetStretch(IDWriteFont3 *iface) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - TRACE("(%p)\n", This); - return This->data->stretch; + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + + TRACE("%p.\n", iface); + + return font->data->stretch; }
static DWRITE_FONT_STYLE WINAPI dwritefont_GetStyle(IDWriteFont3 *iface) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - TRACE("(%p)\n", This); - return This->style; + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + + TRACE("%p.\n", iface); + + return font->style; }
static BOOL WINAPI dwritefont_IsSymbolFont(IDWriteFont3 *iface) @@ -1960,17 +1969,20 @@ static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont3 *iface,
static DWRITE_FONT_SIMULATIONS WINAPI dwritefont_GetSimulations(IDWriteFont3 *iface) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - TRACE("(%p)\n", This); - return This->data->simulations; + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + + TRACE("%p.\n", iface); + + return font->data->simulations; }
static void WINAPI dwritefont_GetMetrics(IDWriteFont3 *iface, DWRITE_FONT_METRICS *metrics) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); + struct dwrite_font *font = impl_from_IDWriteFont3(iface);
- TRACE("(%p)->(%p)\n", This, metrics); - memcpy(metrics, &This->data->metrics, sizeof(*metrics)); + TRACE("%p, %p.\n", iface, metrics); + + memcpy(metrics, &font->data->metrics, sizeof(*metrics)); }
static BOOL dwritefont_has_character(struct dwrite_font *font, UINT32 ch) @@ -2003,16 +2015,20 @@ static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont3 *iface, IDWriteFont
static void WINAPI dwritefont1_GetMetrics(IDWriteFont3 *iface, DWRITE_FONT_METRICS1 *metrics) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - TRACE("(%p)->(%p)\n", This, metrics); - *metrics = This->data->metrics; + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + + TRACE("%p, %p.\n", iface, metrics); + + *metrics = font->data->metrics; }
static void WINAPI dwritefont1_GetPanose(IDWriteFont3 *iface, DWRITE_PANOSE *panose) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - TRACE("(%p)->(%p)\n", This, panose); - *panose = This->data->panose; + struct dwrite_font *font = impl_from_IDWriteFont3(iface); + + TRACE("%p, %p.\n", iface, panose); + + *panose = font->data->panose; }
static HRESULT WINAPI dwritefont1_GetUnicodeRanges(IDWriteFont3 *iface, UINT32 max_count, DWRITE_UNICODE_RANGE *ranges, @@ -2093,8 +2109,8 @@ static BOOL WINAPI dwritefont3_HasCharacter(IDWriteFont3 *iface, UINT32 ch)
static DWRITE_LOCALITY WINAPI dwritefont3_GetLocality(IDWriteFont3 *iface) { - struct dwrite_font *This = impl_from_IDWriteFont3(iface); - FIXME("(%p): stub\n", This); + FIXME("%p: stub.\n", iface); + return DWRITE_LOCALITY_LOCAL; }
@@ -2179,23 +2195,22 @@ HRESULT get_fontsig_from_fontface(IDWriteFontFace *iface, FONTSIGNATURE *fontsig
static HRESULT create_font(struct dwrite_fontfamily *family, UINT32 index, IDWriteFont3 **font) { - struct dwrite_font *This; + struct dwrite_font *object;
*font = NULL;
- This = heap_alloc(sizeof(*This)); - if (!This) + if (!(object = heap_alloc(sizeof(*object)))) return E_OUTOFMEMORY;
- This->IDWriteFont3_iface.lpVtbl = &dwritefontvtbl; - This->ref = 1; - This->family = family; + object->IDWriteFont3_iface.lpVtbl = &dwritefontvtbl; + object->refcount = 1; + object->family = family; IDWriteFontFamily2_AddRef(&family->IDWriteFontFamily2_iface); - This->data = family->data->fonts[index]; - This->style = This->data->style; - addref_font_data(This->data); + object->data = family->data->fonts[index]; + object->style = object->data->style; + addref_font_data(object->data);
- *font = &This->IDWriteFont3_iface; + *font = &object->IDWriteFont3_iface;
return S_OK; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/gdiinterop.c | 116 +++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 53 deletions(-)
diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c index 7e88f7490ca..47924011fd3 100644 --- a/dlls/dwrite/gdiinterop.c +++ b/dlls/dwrite/gdiinterop.c @@ -46,7 +46,7 @@ struct rendertarget
IDWriteFactory7 *factory; DWRITE_TEXT_ANTIALIAS_MODE antialiasmode; - FLOAT ppdip; + float ppdip; DWRITE_MATRIX m; SIZE size; HDC hdc; @@ -149,20 +149,20 @@ static HRESULT WINAPI rendertarget_sink_QueryInterface(ID2D1SimplifiedGeometrySi
static ULONG WINAPI rendertarget_sink_AddRef(ID2D1SimplifiedGeometrySink *iface) { - struct rendertarget *This = impl_from_ID2D1SimplifiedGeometrySink(iface); - return IDWriteBitmapRenderTarget1_AddRef(&This->IDWriteBitmapRenderTarget1_iface); + struct rendertarget *target = impl_from_ID2D1SimplifiedGeometrySink(iface); + return IDWriteBitmapRenderTarget1_AddRef(&target->IDWriteBitmapRenderTarget1_iface); }
static ULONG WINAPI rendertarget_sink_Release(ID2D1SimplifiedGeometrySink *iface) { - struct rendertarget *This = impl_from_ID2D1SimplifiedGeometrySink(iface); - return IDWriteBitmapRenderTarget1_Release(&This->IDWriteBitmapRenderTarget1_iface); + struct rendertarget *target = impl_from_ID2D1SimplifiedGeometrySink(iface); + return IDWriteBitmapRenderTarget1_Release(&target->IDWriteBitmapRenderTarget1_iface); }
static void WINAPI rendertarget_sink_SetFillMode(ID2D1SimplifiedGeometrySink *iface, D2D1_FILL_MODE mode) { - struct rendertarget *This = impl_from_ID2D1SimplifiedGeometrySink(iface); - SetPolyFillMode(This->hdc, mode == D2D1_FILL_MODE_ALTERNATE ? ALTERNATE : WINDING); + struct rendertarget *target = impl_from_ID2D1SimplifiedGeometrySink(iface); + SetPolyFillMode(target->hdc, mode == D2D1_FILL_MODE_ALTERNATE ? ALTERNATE : WINDING); }
static void WINAPI rendertarget_sink_SetSegmentFlags(ID2D1SimplifiedGeometrySink *iface, D2D1_PATH_SEGMENT vertexFlags) @@ -171,26 +171,28 @@ static void WINAPI rendertarget_sink_SetSegmentFlags(ID2D1SimplifiedGeometrySink
static void WINAPI rendertarget_sink_BeginFigure(ID2D1SimplifiedGeometrySink *iface, D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin) { - struct rendertarget *This = impl_from_ID2D1SimplifiedGeometrySink(iface); - MoveToEx(This->hdc, startPoint.x, startPoint.y, NULL); + struct rendertarget *target = impl_from_ID2D1SimplifiedGeometrySink(iface); + MoveToEx(target->hdc, startPoint.x, startPoint.y, NULL); }
static void WINAPI rendertarget_sink_AddLines(ID2D1SimplifiedGeometrySink *iface, const D2D1_POINT_2F *points, UINT32 count) { - struct rendertarget *This = impl_from_ID2D1SimplifiedGeometrySink(iface); + struct rendertarget *target = impl_from_ID2D1SimplifiedGeometrySink(iface);
- while (count--) { - LineTo(This->hdc, points->x, points->y); + while (count--) + { + LineTo(target->hdc, points->x, points->y); points++; } }
static void WINAPI rendertarget_sink_AddBeziers(ID2D1SimplifiedGeometrySink *iface, const D2D1_BEZIER_SEGMENT *beziers, UINT32 count) { - struct rendertarget *This = impl_from_ID2D1SimplifiedGeometrySink(iface); + struct rendertarget *target = impl_from_ID2D1SimplifiedGeometrySink(iface); POINT points[3];
- while (count--) { + while (count--) + { points[0].x = beziers->point1.x; points[0].y = beziers->point1.y; points[1].x = beziers->point2.x; @@ -198,15 +200,15 @@ static void WINAPI rendertarget_sink_AddBeziers(ID2D1SimplifiedGeometrySink *ifa points[2].x = beziers->point3.x; points[2].y = beziers->point3.y;
- PolyBezierTo(This->hdc, points, 3); + PolyBezierTo(target->hdc, points, 3); beziers++; } }
static void WINAPI rendertarget_sink_EndFigure(ID2D1SimplifiedGeometrySink *iface, D2D1_FIGURE_END figureEnd) { - struct rendertarget *This = impl_from_ID2D1SimplifiedGeometrySink(iface); - CloseFigure(This->hdc); + struct rendertarget *target = impl_from_ID2D1SimplifiedGeometrySink(iface); + CloseFigure(target->hdc); }
static HRESULT WINAPI rendertarget_sink_Close(ID2D1SimplifiedGeometrySink *iface) @@ -214,7 +216,8 @@ static HRESULT WINAPI rendertarget_sink_Close(ID2D1SimplifiedGeometrySink *iface return S_OK; }
-static const ID2D1SimplifiedGeometrySinkVtbl rendertargetsinkvtbl = { +static const ID2D1SimplifiedGeometrySinkVtbl rendertargetsinkvtbl = +{ rendertarget_sink_QueryInterface, rendertarget_sink_AddRef, rendertarget_sink_Release, @@ -229,9 +232,7 @@ static const ID2D1SimplifiedGeometrySinkVtbl rendertargetsinkvtbl = {
static HRESULT WINAPI rendertarget_QueryInterface(IDWriteBitmapRenderTarget1 *iface, REFIID riid, void **obj) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IDWriteBitmapRenderTarget1) || IsEqualIID(riid, &IID_IDWriteBitmapRenderTarget) || @@ -490,93 +491,101 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac
static HDC WINAPI rendertarget_GetMemoryDC(IDWriteBitmapRenderTarget1 *iface) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); - TRACE("(%p)\n", This); - return This->hdc; + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface); + + TRACE("%p.\n", iface); + + return target->hdc; }
-static FLOAT WINAPI rendertarget_GetPixelsPerDip(IDWriteBitmapRenderTarget1 *iface) +static float WINAPI rendertarget_GetPixelsPerDip(IDWriteBitmapRenderTarget1 *iface) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); - TRACE("(%p)\n", This); - return This->ppdip; + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface); + + TRACE("%p.\n", iface); + + return target->ppdip; }
-static HRESULT WINAPI rendertarget_SetPixelsPerDip(IDWriteBitmapRenderTarget1 *iface, FLOAT ppdip) +static HRESULT WINAPI rendertarget_SetPixelsPerDip(IDWriteBitmapRenderTarget1 *iface, float ppdip) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface);
- TRACE("(%p)->(%.2f)\n", This, ppdip); + TRACE("%p, %.2f.\n", iface, ppdip);
if (ppdip <= 0.0f) return E_INVALIDARG;
- This->ppdip = ppdip; + target->ppdip = ppdip; return S_OK; }
static HRESULT WINAPI rendertarget_GetCurrentTransform(IDWriteBitmapRenderTarget1 *iface, DWRITE_MATRIX *transform) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface);
- TRACE("(%p)->(%p)\n", This, transform); + TRACE("%p, %p.\n", iface, transform);
- *transform = This->m; + *transform = target->m; return S_OK; }
static HRESULT WINAPI rendertarget_SetCurrentTransform(IDWriteBitmapRenderTarget1 *iface, DWRITE_MATRIX const *transform) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface);
- TRACE("(%p)->(%p)\n", This, transform); + TRACE("%p, %p.\n", iface, transform);
- This->m = transform ? *transform : identity; + target->m = transform ? *transform : identity; return S_OK; }
static HRESULT WINAPI rendertarget_GetSize(IDWriteBitmapRenderTarget1 *iface, SIZE *size) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface);
- TRACE("(%p)->(%p)\n", This, size); - *size = This->size; + TRACE("%p, %p.\n", iface, size); + + *size = target->size; return S_OK; }
static HRESULT WINAPI rendertarget_Resize(IDWriteBitmapRenderTarget1 *iface, UINT32 width, UINT32 height) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface);
- TRACE("(%p)->(%u %u)\n", This, width, height); + TRACE("%p, %u, %u.\n", iface, width, height);
- if (This->size.cx == width && This->size.cy == height) + if (target->size.cx == width && target->size.cy == height) return S_OK;
- return create_target_dibsection(This, width, height); + return create_target_dibsection(target, width, height); }
static DWRITE_TEXT_ANTIALIAS_MODE WINAPI rendertarget_GetTextAntialiasMode(IDWriteBitmapRenderTarget1 *iface) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); - TRACE("(%p)\n", This); - return This->antialiasmode; + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface); + + TRACE("%p.\n", iface); + + return target->antialiasmode; }
static HRESULT WINAPI rendertarget_SetTextAntialiasMode(IDWriteBitmapRenderTarget1 *iface, DWRITE_TEXT_ANTIALIAS_MODE mode) { - struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget1(iface); + struct rendertarget *target = impl_from_IDWriteBitmapRenderTarget1(iface);
- TRACE("(%p)->(%d)\n", This, mode); + TRACE("%p, %d.\n", iface, mode);
if ((DWORD)mode > DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE) return E_INVALIDARG;
- This->antialiasmode = mode; + target->antialiasmode = mode; return S_OK; }
-static const IDWriteBitmapRenderTarget1Vtbl rendertargetvtbl = { +static const IDWriteBitmapRenderTarget1Vtbl rendertargetvtbl = +{ rendertarget_QueryInterface, rendertarget_AddRef, rendertarget_Release, @@ -592,7 +601,8 @@ static const IDWriteBitmapRenderTarget1Vtbl rendertargetvtbl = { rendertarget_SetTextAntialiasMode };
-static HRESULT create_rendertarget(IDWriteFactory7 *factory, HDC hdc, UINT32 width, UINT32 height, IDWriteBitmapRenderTarget **ret) +static HRESULT create_rendertarget(IDWriteFactory7 *factory, HDC hdc, UINT32 width, UINT32 height, + IDWriteBitmapRenderTarget **ret) { struct rendertarget *target; HRESULT hr;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/gdiinterop.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c index 47924011fd3..81cfc3a586b 100644 --- a/dlls/dwrite/gdiinterop.c +++ b/dlls/dwrite/gdiinterop.c @@ -637,9 +637,7 @@ static HRESULT create_rendertarget(IDWriteFactory7 *factory, HDC hdc, UINT32 wid
static HRESULT WINAPI gdiinterop_QueryInterface(IDWriteGdiInterop1 *iface, REFIID riid, void **obj) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IDWriteGdiInterop1) || IsEqualIID(riid, &IID_IDWriteGdiInterop) || @@ -686,9 +684,7 @@ static ULONG WINAPI gdiinterop_Release(IDWriteGdiInterop1 *iface) static HRESULT WINAPI gdiinterop_CreateFontFromLOGFONT(IDWriteGdiInterop1 *iface, LOGFONTW const *logfont, IDWriteFont **font) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - - TRACE("(%p)->(%p %p)\n", This, logfont, font); + TRACE("%p, %p, %p.\n", iface, logfont, font);
return IDWriteGdiInterop1_CreateFontFromLOGFONT(iface, logfont, NULL, font); } @@ -696,12 +692,11 @@ static HRESULT WINAPI gdiinterop_CreateFontFromLOGFONT(IDWriteGdiInterop1 *iface static HRESULT WINAPI gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop1 *iface, IDWriteFont *font, LOGFONTW *logfont, BOOL *is_systemfont) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); IDWriteFontCollection *collection; IDWriteFontFamily *family; HRESULT hr;
- TRACE("(%p)->(%p %p %p)\n", This, font, logfont, is_systemfont); + TRACE("%p, %p, %p, %p.\n", iface, font, logfont, is_systemfont);
*is_systemfont = FALSE;
@@ -732,9 +727,7 @@ static HRESULT WINAPI gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop1 *iface, static HRESULT WINAPI gdiinterop_ConvertFontFaceToLOGFONT(IDWriteGdiInterop1 *iface, IDWriteFontFace *fontface, LOGFONTW *logfont) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - - TRACE("(%p)->(%p %p)\n", This, fontface, logfont); + TRACE("%p, %p, %p.\n", iface, fontface, logfont);
memset(logfont, 0, sizeof(*logfont));
@@ -841,9 +834,11 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface static HRESULT WINAPI gdiinterop_CreateBitmapRenderTarget(IDWriteGdiInterop1 *iface, HDC hdc, UINT32 width, UINT32 height, IDWriteBitmapRenderTarget **target) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - TRACE("(%p)->(%p %u %u %p)\n", This, hdc, width, height, target); - return create_rendertarget(This->factory, hdc, width, height, target); + struct gdiinterop *interop = impl_from_IDWriteGdiInterop1(iface); + + TRACE("%p, %p, %u, %u, %p.\n", iface, hdc, width, height, target); + + return create_rendertarget(interop->factory, hdc, width, height, target); }
static HRESULT WINAPI gdiinterop1_CreateFontFromLOGFONT(IDWriteGdiInterop1 *iface, @@ -897,9 +892,7 @@ done: static HRESULT WINAPI gdiinterop1_GetFontSignature_(IDWriteGdiInterop1 *iface, IDWriteFontFace *fontface, FONTSIGNATURE *fontsig) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - - TRACE("(%p)->(%p %p)\n", This, fontface, fontsig); + TRACE("%p, %p, %p.\n", iface, fontface, fontsig);
return get_fontsig_from_fontface(fontface, fontsig); } @@ -919,9 +912,7 @@ static HRESULT WINAPI gdiinterop1_GetFontSignature(IDWriteGdiInterop1 *iface, ID static HRESULT WINAPI gdiinterop1_GetMatchingFontsByLOGFONT(IDWriteGdiInterop1 *iface, LOGFONTW const *logfont, IDWriteFontSet *fontset, IDWriteFontSet **subset) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - - FIXME("(%p)->(%p %p %p): stub\n", This, logfont, fontset, subset); + FIXME("%p, %p, %p, %p: stub.\n", iface, logfont, fontset, subset);
return E_NOTIMPL; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/dwrite_private.h | 2 +- dlls/dwrite/font.c | 2 +- dlls/dwrite/opentype.c | 175 ++++++++++++++--------------------- dlls/dwrite/tests/font.c | 9 +- 4 files changed, 74 insertions(+), 114 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index be3f4b719e8..7c9fe8a6873 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -408,7 +408,6 @@ extern unsigned int opentype_get_cpal_palettecount(const struct dwrite_fonttable extern unsigned int opentype_get_cpal_paletteentrycount(const struct dwrite_fonttable *table) DECLSPEC_HIDDEN; extern HRESULT opentype_get_cpal_entries(const struct dwrite_fonttable *table, unsigned int palette, unsigned int first_entry_index, unsigned int entry_count, DWRITE_COLOR_F *entries) DECLSPEC_HIDDEN; -extern BOOL opentype_has_vertical_variants(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; extern UINT32 opentype_get_glyph_image_formats(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; extern DWRITE_CONTAINER_TYPE opentype_analyze_container_type(void const *, UINT32) DECLSPEC_HIDDEN;
@@ -650,6 +649,7 @@ extern void opentype_layout_apply_gpos_features(struct scriptshaping_context *co extern BOOL opentype_layout_check_feature(struct scriptshaping_context *context, unsigned int script_index, unsigned int language_index, struct shaping_feature *feature, unsigned int glyph_count, const UINT16 *glyphs, UINT8 *feature_applies) DECLSPEC_HIDDEN; +extern BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface) DECLSPEC_HIDDEN; extern HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, unsigned int glyph_count, const UINT16 *nominal_glyphs, UINT16 *glyphs) DECLSPEC_HIDDEN;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 9889add8899..02ac75d2419 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -4970,7 +4970,7 @@ HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_li
if (freetype_has_kerning_pairs(&fontface->IDWriteFontFace5_iface)) fontface->flags |= FONTFACE_HAS_KERNING_PAIRS; - if (opentype_has_vertical_variants(&fontface->IDWriteFontFace5_iface)) + if (opentype_has_vertical_variants(fontface)) fontface->flags |= FONTFACE_HAS_VERTICAL_VARIANTS; fontface->glyph_image_formats = opentype_get_glyph_image_formats(&fontface->IDWriteFontFace5_iface);
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 53925465a12..d7a0aaf8e51 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -2945,81 +2945,6 @@ void opentype_colr_next_glyph(const struct dwrite_fonttable *colr, struct dwrite } }
-BOOL opentype_has_vertical_variants(IDWriteFontFace5 *fontface) -{ - const struct gpos_gsub_header *header; - const struct ot_feature_list *featurelist; - const struct ot_lookup_list *lookup_list; - BOOL exists = FALSE, ret = FALSE; - unsigned int i, j; - const void *data; - void *context; - UINT32 size; - HRESULT hr; - - hr = IDWriteFontFace5_TryGetFontTable(fontface, MS_GSUB_TAG, &data, &size, &context, &exists); - if (FAILED(hr) || !exists) - return FALSE; - - header = data; - featurelist = (struct ot_feature_list *)((BYTE*)header + GET_BE_WORD(header->feature_list)); - lookup_list = (const struct ot_lookup_list *)((BYTE*)header + GET_BE_WORD(header->lookup_list)); - - for (i = 0; i < GET_BE_WORD(featurelist->feature_count); i++) { - if (featurelist->features[i].tag == DWRITE_FONT_FEATURE_TAG_VERTICAL_WRITING) { - const struct ot_feature *feature = (const struct ot_feature*)((BYTE*)featurelist + GET_BE_WORD(featurelist->features[i].offset)); - UINT16 lookup_count = GET_BE_WORD(feature->lookup_count), index, count, type; - const GSUB_SingleSubstFormat2 *subst2; - const struct ot_lookup_table *lookup_table; - UINT32 offset; - - if (lookup_count == 0) - continue; - - for (j = 0; j < lookup_count; ++j) { - /* check if lookup is empty */ - index = GET_BE_WORD(feature->lookuplist_index[j]); - lookup_table = (const struct ot_lookup_table *)((BYTE*)lookup_list + GET_BE_WORD(lookup_list->lookup[index])); - - type = GET_BE_WORD(lookup_table->lookup_type); - if (type != GSUB_LOOKUP_SINGLE_SUBST && type != GSUB_LOOKUP_EXTENSION_SUBST) - continue; - - count = GET_BE_WORD(lookup_table->subtable_count); - if (count == 0) - continue; - - offset = GET_BE_WORD(lookup_table->subtable[0]); - if (type == GSUB_LOOKUP_EXTENSION_SUBST) { - const GSUB_ExtensionPosFormat1 *ext = (const GSUB_ExtensionPosFormat1 *)((const BYTE *)lookup_table + offset); - if (GET_BE_WORD(ext->SubstFormat) == 1) - offset += GET_BE_DWORD(ext->ExtensionOffset); - else - FIXME("Unhandled Extension Substitution Format %u\n", GET_BE_WORD(ext->SubstFormat)); - } - - subst2 = (const GSUB_SingleSubstFormat2*)((BYTE*)lookup_table + offset); - index = GET_BE_WORD(subst2->SubstFormat); - if (index == 1) - FIXME("Validate Single Substitution Format 1\n"); - else if (index == 2) { - /* SimSun-ExtB has 0 glyph count for this substitution */ - if (GET_BE_WORD(subst2->GlyphCount) > 0) { - ret = TRUE; - break; - } - } - else - WARN("Unknown Single Substitution Format, %u\n", index); - } - } - } - - IDWriteFontFace5_ReleaseFontTable(fontface, context); - - return ret; -} - static BOOL opentype_has_font_table(IDWriteFontFace5 *fontface, UINT32 tag) { BOOL exists = FALSE; @@ -4329,10 +4254,16 @@ static BOOL opentype_layout_apply_gpos_mark_to_mark_attachment(struct scriptshap }
static unsigned int opentype_layout_adjust_extension_subtable(struct scriptshaping_context *context, - unsigned int *subtable_offset) + unsigned int *subtable_offset, const struct lookup *lookup) { const struct ot_gsubgpos_extension_format1 *format1;
+ if ((context->table == &context->cache->gsub && lookup->type != GSUB_LOOKUP_EXTENSION_SUBST) || + (context->table == &context->cache->gpos && lookup->type != GPOS_LOOKUP_EXTENSION_POSITION)) + { + return lookup->type; + } + if (!(format1 = table_read_ensure(&context->table->table, *subtable_offset, sizeof(*format1)))) return 0;
@@ -4361,14 +4292,7 @@ static BOOL opentype_layout_apply_gpos_lookup(struct scriptshaping_context *cont { unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, i);
- if (lookup->type == GPOS_LOOKUP_EXTENSION_POSITION) - { - lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset); - if (!lookup_type) - continue; - } - else - lookup_type = lookup->type; + lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset, lookup);
switch (lookup_type) { @@ -5679,14 +5603,7 @@ static BOOL opentype_layout_apply_gsub_lookup(struct scriptshaping_context *cont { unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, i);
- if (lookup->type == GSUB_LOOKUP_EXTENSION_SUBST) - { - lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset); - if (!lookup_type) - continue; - } - else - lookup_type = lookup->type; + lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset, lookup);
switch (lookup_type) { @@ -6005,14 +5922,7 @@ static BOOL opentype_layout_gsub_lookup_is_glyph_covered(struct scriptshaping_co { unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, i);
- if (lookup->type == GSUB_LOOKUP_EXTENSION_SUBST) - { - lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset); - if (!lookup_type) - continue; - } - else - lookup_type = lookup->type; + lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset, lookup);
format = table_read_be_word(gsub, subtable_offset);
@@ -6079,14 +5989,7 @@ static BOOL opentype_layout_gpos_lookup_is_glyph_covered(struct scriptshaping_co { unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, i);
- if (lookup->type == GPOS_LOOKUP_EXTENSION_POSITION) - { - lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset); - if (!lookup_type) - continue; - } - else - lookup_type = lookup->type; + lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset, lookup);
format = table_read_be_word(gpos, subtable_offset);
@@ -6178,6 +6081,61 @@ BOOL opentype_layout_check_feature(struct scriptshaping_context *context, unsign return ret; }
+BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface) +{ + unsigned int i, j, count = 0, lookup_type, subtable_offset; + struct shaping_features features = { 0 }; + struct shaping_feature vert_feature = { 0 }; + struct scriptshaping_context context = { 0 }; + struct lookups lookups = { 0 }; + UINT16 format; + + context.cache = fontface_get_shaping_cache(fontface); + context.table = &context.cache->gsub; + + vert_feature.tag = DWRITE_MAKE_OPENTYPE_TAG('v','e','r','t'); + vert_feature.flags = FEATURE_GLOBAL | FEATURE_GLOBAL_SEARCH; + vert_feature.max_value = 1; + vert_feature.default_value = 1; + + features.features = &vert_feature; + features.count = features.capacity = 1; + + opentype_layout_collect_lookups(&context, ~0u, ~0u, &features, context.table, &lookups); + + for (i = 0; i < lookups.count && !count; ++i) + { + const struct dwrite_fonttable *table = &context.table->table; + const struct lookup *lookup = &lookups.lookups[i]; + + for (j = 0; j < lookup->subtable_count && !count; ++j) + { + subtable_offset = opentype_layout_get_gsubgpos_subtable(&context, lookup->offset, j); + lookup_type = opentype_layout_adjust_extension_subtable(&context, &subtable_offset, lookup); + + if (lookup_type != GSUB_LOOKUP_SINGLE_SUBST) + continue; + + format = table_read_be_word(table, subtable_offset); + + if (format == 1) + { + count = 1; + } + else if (format == 2) + { + count = table_read_be_word(table, subtable_offset + FIELD_OFFSET(struct ot_gsub_singlesubst_format2, count)); + } + else + WARN("Unrecognized single substitution format %u.\n", format); + } + } + + heap_free(lookups.lookups); + + return !!count; +} + HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, unsigned int glyph_count, const UINT16 *nominal_glyphs, UINT16 *glyphs) { @@ -6215,6 +6173,7 @@ HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, u { const struct lookup *lookup = &lookups.lookups[i];
+ /* FIXME: should probably handle extension subtables. */ if (lookup->type != GSUB_LOOKUP_SINGLE_SUBST) continue;
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index becb1a741f7..193f8ed9c48 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -8208,16 +8208,17 @@ static BOOL has_vertical_glyph_variants(IDWriteFontFace1 *fontface) subst2 = (const GSUB_SingleSubstFormat2*)((BYTE*)lookup_table + offset); index = GET_BE_WORD(subst2->SubstFormat); if (index == 1) - ok(0, "validate Single Substitution Format 1\n"); + ret = TRUE; else if (index == 2) { /* SimSun-ExtB has 0 glyph count for this substitution */ - if (GET_BE_WORD(subst2->GlyphCount) > 0) { + if (GET_BE_WORD(subst2->GlyphCount) > 0) ret = TRUE; - break; - } } else ok(0, "unknown Single Substitution Format, %u\n", index); + + if (ret) + break; } } }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/opentype.c | 200 ++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 103 deletions(-)
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index d7a0aaf8e51..68da6e4ecfb 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -126,7 +126,7 @@ enum opentype_cmap_table_encoding
/* PANOSE is 10 bytes in size, need to pack the structure properly */ #include "pshpack2.h" -typedef struct +struct tt_head { USHORT majorVersion; USHORT minorVersion; @@ -146,9 +146,9 @@ typedef struct SHORT direction_hint; SHORT index_format; SHORT glyphdata_format; -} TT_HEAD; +};
-enum TT_HEAD_MACSTYLE +enum tt_head_macstyle { TT_HEAD_MACSTYLE_BOLD = 1 << 0, TT_HEAD_MACSTYLE_ITALIC = 1 << 1, @@ -159,7 +159,7 @@ enum TT_HEAD_MACSTYLE TT_HEAD_MACSTYLE_EXTENDED = 1 << 6, };
-typedef struct +struct tt_post { ULONG Version; ULONG italicAngle; @@ -170,9 +170,9 @@ typedef struct ULONG maxmemType42; ULONG minmemType1; ULONG maxmemType1; -} TT_POST; +};
-typedef struct +struct tt_os2 { USHORT version; SHORT xAvgCharWidth; @@ -217,9 +217,10 @@ typedef struct USHORT usDefaultChar; USHORT usBreakChar; USHORT usMaxContext; -} TT_OS2_V2; +};
-typedef struct { +struct tt_hhea +{ USHORT majorVersion; USHORT minorVersion; SHORT ascender; @@ -235,7 +236,7 @@ typedef struct { SHORT reserved[4]; SHORT metricDataFormat; USHORT numberOfHMetrics; -} TT_HHEA; +};
struct sbix_header { @@ -1878,31 +1879,25 @@ HRESULT opentype_cmap_get_unicode_ranges(const struct dwrite_cmap *cmap, unsigne void opentype_get_font_typo_metrics(struct file_stream_desc *stream_desc, unsigned int *ascent, unsigned int *descent) { struct dwrite_fonttable os2; - const TT_OS2_V2 *data;
opentype_get_font_table(stream_desc, MS_OS2_TAG, &os2); - data = (const TT_OS2_V2 *)os2.data;
*ascent = *descent = 0;
- if (os2.size >= FIELD_OFFSET(TT_OS2_V2, sTypoLineGap)) + if (os2.size >= FIELD_OFFSET(struct tt_os2, sTypoLineGap)) { - SHORT value = GET_BE_WORD(data->sTypoDescender); - *ascent = GET_BE_WORD(data->sTypoAscender); + SHORT value = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, sTypoDescender)); + *ascent = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, sTypoAscender)); *descent = value < 0 ? -value : 0; }
- if (data) + if (os2.data) IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, os2.context); }
void opentype_get_font_metrics(struct file_stream_desc *stream_desc, DWRITE_FONT_METRICS1 *metrics, DWRITE_CARET_METRICS *caret) { struct dwrite_fonttable os2, head, post, hhea; - const TT_OS2_V2 *tt_os2; - const TT_HEAD *tt_head; - const TT_POST *tt_post; - const TT_HHEA *tt_hhea;
memset(metrics, 0, sizeof(*metrics));
@@ -1911,88 +1906,89 @@ void opentype_get_font_metrics(struct file_stream_desc *stream_desc, DWRITE_FONT opentype_get_font_table(stream_desc, MS_POST_TAG, &post); opentype_get_font_table(stream_desc, MS_HHEA_TAG, &hhea);
- tt_head = (const TT_HEAD *)head.data; - tt_os2 = (const TT_OS2_V2 *)os2.data; - tt_post = (const TT_POST *)post.data; - tt_hhea = (const TT_HHEA *)hhea.data; - - if (tt_head) { - metrics->designUnitsPerEm = GET_BE_WORD(tt_head->unitsPerEm); - metrics->glyphBoxLeft = GET_BE_WORD(tt_head->xMin); - metrics->glyphBoxTop = GET_BE_WORD(tt_head->yMax); - metrics->glyphBoxRight = GET_BE_WORD(tt_head->xMax); - metrics->glyphBoxBottom = GET_BE_WORD(tt_head->yMin); + if (head.data) + { + metrics->designUnitsPerEm = table_read_be_word(&head, FIELD_OFFSET(struct tt_head, unitsPerEm)); + metrics->glyphBoxLeft = table_read_be_word(&head, FIELD_OFFSET(struct tt_head, xMin)); + metrics->glyphBoxTop = table_read_be_word(&head, FIELD_OFFSET(struct tt_head, yMax)); + metrics->glyphBoxRight = table_read_be_word(&head, FIELD_OFFSET(struct tt_head, xMax)); + metrics->glyphBoxBottom = table_read_be_word(&head, FIELD_OFFSET(struct tt_head, yMin)); }
if (caret) { - if (tt_hhea) { - caret->slopeRise = GET_BE_WORD(tt_hhea->caretSlopeRise); - caret->slopeRun = GET_BE_WORD(tt_hhea->caretSlopeRun); - caret->offset = GET_BE_WORD(tt_hhea->caretOffset); - } - else { - caret->slopeRise = 0; - caret->slopeRun = 0; - caret->offset = 0; + if (hhea.data) + { + caret->slopeRise = table_read_be_word(&hhea, FIELD_OFFSET(struct tt_hhea, caretSlopeRise)); + caret->slopeRun = table_read_be_word(&hhea, FIELD_OFFSET(struct tt_hhea, caretSlopeRun)); + caret->offset = table_read_be_word(&hhea, FIELD_OFFSET(struct tt_hhea, caretOffset)); } + else + memset(caret, 0, sizeof(*caret)); }
- if (tt_os2) { - USHORT version = GET_BE_WORD(tt_os2->version); + if (os2.data) + { + USHORT version = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, version));
- metrics->ascent = GET_BE_WORD(tt_os2->usWinAscent); + metrics->ascent = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, usWinAscent)); /* Some fonts have usWinDescent value stored as signed short, which could be wrongly interpreted as large unsigned value. */ - metrics->descent = abs((SHORT)GET_BE_WORD(tt_os2->usWinDescent)); + metrics->descent = abs((SHORT)table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, usWinDescent)));
- /* line gap is estimated using two sets of ascender/descender values and 'hhea' line gap */ - if (tt_hhea) { - SHORT descender = (SHORT)GET_BE_WORD(tt_hhea->descender); + /* Line gap is estimated using two sets of ascender/descender values and 'hhea' line gap. */ + if (hhea.data) + { + SHORT descender = (SHORT)table_read_be_word(&hhea, FIELD_OFFSET(struct tt_hhea, descender)); INT32 linegap;
- linegap = GET_BE_WORD(tt_hhea->ascender) + abs(descender) + GET_BE_WORD(tt_hhea->linegap) - - metrics->ascent - metrics->descent; + linegap = table_read_be_word(&hhea, FIELD_OFFSET(struct tt_hhea, ascender)) + abs(descender) + + table_read_be_word(&hhea, FIELD_OFFSET(struct tt_hhea, linegap)) - metrics->ascent - metrics->descent; metrics->lineGap = linegap > 0 ? linegap : 0; }
- metrics->strikethroughPosition = GET_BE_WORD(tt_os2->yStrikeoutPosition); - metrics->strikethroughThickness = GET_BE_WORD(tt_os2->yStrikeoutSize); - metrics->subscriptPositionX = GET_BE_WORD(tt_os2->ySubscriptXOffset); + metrics->strikethroughPosition = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, yStrikeoutPosition)); + metrics->strikethroughThickness = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, yStrikeoutSize)); + metrics->subscriptPositionX = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, ySubscriptXOffset)); /* Y offset is stored as positive offset below baseline */ - metrics->subscriptPositionY = -GET_BE_WORD(tt_os2->ySubscriptYOffset); - metrics->subscriptSizeX = GET_BE_WORD(tt_os2->ySubscriptXSize); - metrics->subscriptSizeY = GET_BE_WORD(tt_os2->ySubscriptYSize); - metrics->superscriptPositionX = GET_BE_WORD(tt_os2->ySuperscriptXOffset); - metrics->superscriptPositionY = GET_BE_WORD(tt_os2->ySuperscriptYOffset); - metrics->superscriptSizeX = GET_BE_WORD(tt_os2->ySuperscriptXSize); - metrics->superscriptSizeY = GET_BE_WORD(tt_os2->ySuperscriptYSize); + metrics->subscriptPositionY = -table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, ySubscriptYOffset)); + metrics->subscriptSizeX = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, ySubscriptXSize)); + metrics->subscriptSizeY = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, ySubscriptYSize)); + metrics->superscriptPositionX = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, ySuperscriptXOffset)); + metrics->superscriptPositionY = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, ySuperscriptYOffset)); + metrics->superscriptSizeX = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, ySuperscriptXSize)); + metrics->superscriptSizeY = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, ySuperscriptYSize));
/* version 2 fields */ - if (version >= 2) { - metrics->capHeight = GET_BE_WORD(tt_os2->sCapHeight); - metrics->xHeight = GET_BE_WORD(tt_os2->sxHeight); + if (version >= 2) + { + metrics->capHeight = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, sCapHeight)); + metrics->xHeight = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, sxHeight)); }
- if (GET_BE_WORD(tt_os2->fsSelection) & OS2_FSSELECTION_USE_TYPO_METRICS) { - SHORT descent = GET_BE_WORD(tt_os2->sTypoDescender); - metrics->ascent = GET_BE_WORD(tt_os2->sTypoAscender); + if (table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, fsSelection)) & OS2_FSSELECTION_USE_TYPO_METRICS) + { + SHORT descent = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, sTypoDescender)); + metrics->ascent = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, sTypoAscender)); metrics->descent = descent < 0 ? -descent : 0; - metrics->lineGap = GET_BE_WORD(tt_os2->sTypoLineGap); + metrics->lineGap = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, sTypoLineGap)); metrics->hasTypographicMetrics = TRUE; } } - else { + else + { metrics->strikethroughPosition = metrics->designUnitsPerEm / 3; - if (tt_hhea) { - metrics->ascent = GET_BE_WORD(tt_hhea->ascender); - metrics->descent = abs((SHORT)GET_BE_WORD(tt_hhea->descender)); + if (hhea.data) + { + metrics->ascent = table_read_be_word(&hhea, FIELD_OFFSET(struct tt_hhea, ascender)); + metrics->descent = abs((SHORT)table_read_be_word(&hhea, FIELD_OFFSET(struct tt_hhea, descender))); } }
- if (tt_post) { - metrics->underlinePosition = GET_BE_WORD(tt_post->underlinePosition); - metrics->underlineThickness = GET_BE_WORD(tt_post->underlineThickness); + if (post.data) + { + metrics->underlinePosition = table_read_be_word(&post, FIELD_OFFSET(struct tt_post, underlinePosition)); + metrics->underlineThickness = table_read_be_word(&post, FIELD_OFFSET(struct tt_post, underlineThickness)); }
if (metrics->underlineThickness == 0) @@ -2006,13 +2002,13 @@ void opentype_get_font_metrics(struct file_stream_desc *stream_desc, DWRITE_FONT if (metrics->capHeight == 0) metrics->capHeight = metrics->designUnitsPerEm * 7 / 10;
- if (tt_os2) + if (os2.data) IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, os2.context); - if (tt_head) + if (head.data) IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, head.context); - if (tt_post) + if (post.data) IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, post.context); - if (tt_hhea) + if (hhea.data) IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, hhea.context); }
@@ -2020,15 +2016,10 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d { struct dwrite_fonttable os2, head, colr, cpal; BOOL is_symbol, is_monospaced; - const TT_OS2_V2 *tt_os2; - const TT_HEAD *tt_head;
opentype_get_font_table(stream_desc, MS_OS2_TAG, &os2); opentype_get_font_table(stream_desc, MS_HEAD_TAG, &head);
- tt_os2 = (const TT_OS2_V2 *)os2.data; - tt_head = (const TT_HEAD *)head.data; - /* default stretch, weight and style to normal */ props->stretch = DWRITE_FONT_STRETCH_NORMAL; props->weight = DWRITE_FONT_WEIGHT_NORMAL; @@ -2039,12 +2030,13 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d props->flags = 0;
/* DWRITE_FONT_STRETCH enumeration values directly match font data values */ - if (tt_os2) + if (os2.data) { - USHORT version = GET_BE_WORD(tt_os2->version); - USHORT fsSelection = GET_BE_WORD(tt_os2->fsSelection); - USHORT usWeightClass = GET_BE_WORD(tt_os2->usWeightClass); - USHORT usWidthClass = GET_BE_WORD(tt_os2->usWidthClass); + USHORT version = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, version)); + USHORT fsSelection = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, fsSelection)); + USHORT usWeightClass = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, usWeightClass)); + USHORT usWidthClass = table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, usWidthClass)); + const void *panose;
if (usWidthClass > DWRITE_FONT_STRETCH_UNDEFINED && usWidthClass <= DWRITE_FONT_STRETCH_ULTRA_EXPANDED) props->stretch = usWidthClass; @@ -2063,22 +2055,24 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d props->style = DWRITE_FONT_STYLE_ITALIC; props->lf.lfItalic = !!(fsSelection & OS2_FSSELECTION_ITALIC);
- memcpy(&props->panose, &tt_os2->panose, sizeof(props->panose)); + if ((panose = table_read_ensure(&os2, FIELD_OFFSET(struct tt_os2, panose), sizeof(props->panose)))) + memcpy(&props->panose, panose, sizeof(props->panose));
/* FONTSIGNATURE */ - props->fontsig.fsUsb[0] = GET_BE_DWORD(tt_os2->ulUnicodeRange1); - props->fontsig.fsUsb[1] = GET_BE_DWORD(tt_os2->ulUnicodeRange2); - props->fontsig.fsUsb[2] = GET_BE_DWORD(tt_os2->ulUnicodeRange3); - props->fontsig.fsUsb[3] = GET_BE_DWORD(tt_os2->ulUnicodeRange4); + props->fontsig.fsUsb[0] = table_read_be_dword(&os2, FIELD_OFFSET(struct tt_os2, ulUnicodeRange1)); + props->fontsig.fsUsb[1] = table_read_be_dword(&os2, FIELD_OFFSET(struct tt_os2, ulUnicodeRange2)); + props->fontsig.fsUsb[2] = table_read_be_dword(&os2, FIELD_OFFSET(struct tt_os2, ulUnicodeRange3)); + props->fontsig.fsUsb[3] = table_read_be_dword(&os2, FIELD_OFFSET(struct tt_os2, ulUnicodeRange4));
if (version) { - props->fontsig.fsCsb[0] = GET_BE_DWORD(tt_os2->ulCodePageRange1); - props->fontsig.fsCsb[1] = GET_BE_DWORD(tt_os2->ulCodePageRange2); + props->fontsig.fsCsb[0] = table_read_be_dword(&os2, FIELD_OFFSET(struct tt_os2, ulCodePageRange1)); + props->fontsig.fsCsb[1] = table_read_be_dword(&os2, FIELD_OFFSET(struct tt_os2, ulCodePageRange2)); } } - else if (tt_head) { - USHORT macStyle = GET_BE_WORD(tt_head->macStyle); + else if (head.data) + { + USHORT macStyle = table_read_be_word(&head, FIELD_OFFSET(struct tt_head, macStyle));
if (macStyle & TT_HEAD_MACSTYLE_CONDENSED) props->stretch = DWRITE_FONT_STRETCH_CONDENSED; @@ -2137,7 +2131,7 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d
if (post.data) { - is_monospaced = !!table_read_dword(&post, FIELD_OFFSET(TT_POST, fixed_pitch)); + is_monospaced = !!table_read_dword(&post, FIELD_OFFSET(struct tt_post, fixed_pitch));
IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, post.context); } @@ -2544,20 +2538,20 @@ HRESULT opentype_get_font_info_strings(const struct file_stream_desc *stream_des HRESULT opentype_get_font_familyname(struct file_stream_desc *stream_desc, IDWriteLocalizedStrings **names) { struct dwrite_fonttable os2, name; - const TT_OS2_V2 *tt_os2; const void *name_table; + UINT16 fsselection; HRESULT hr;
opentype_get_font_table(stream_desc, MS_OS2_TAG, &os2); opentype_get_font_table(stream_desc, MS_NAME_TAG, &name);
- tt_os2 = (const TT_OS2_V2 *)os2.data; name_table = (const void *)name.data;
*names = NULL;
- /* if Preferred Family doesn't conform to WWS model try WWS name */ - if (tt_os2 && !(GET_BE_WORD(tt_os2->fsSelection) & OS2_FSSELECTION_WWS)) + /* If Preferred Family doesn't conform to WWS model try WWS name. */ + fsselection = os2.data ? table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, fsSelection)) : 0; + if (os2.data && !(fsselection & OS2_FSSELECTION_WWS)) hr = opentype_get_font_strings_from_id(name_table, OPENTYPE_STRING_WWS_FAMILY_NAME, names); else hr = E_FAIL; @@ -2581,20 +2575,20 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR * { struct dwrite_fonttable os2, name; IDWriteLocalizedStrings *lfnames; - const TT_OS2_V2 *tt_os2; const void *name_table; + UINT16 fsselection; HRESULT hr;
opentype_get_font_table(stream_desc, MS_OS2_TAG, &os2); opentype_get_font_table(stream_desc, MS_NAME_TAG, &name);
- tt_os2 = (const TT_OS2_V2 *)os2.data; name_table = name.data;
*names = NULL;
/* if Preferred Family doesn't conform to WWS model try WWS name */ - if (tt_os2 && !(GET_BE_WORD(tt_os2->fsSelection) & OS2_FSSELECTION_WWS)) + fsselection = os2.data ? table_read_be_word(&os2, FIELD_OFFSET(struct tt_os2, fsSelection)) : 0; + if (os2.data && !(fsselection & OS2_FSSELECTION_WWS)) hr = opentype_get_font_strings_from_id(name_table, OPENTYPE_STRING_WWS_SUBFAMILY_NAME, names); else hr = E_FAIL;