diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 8386d927cfb..c06a27032b5 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -113,7 +113,8 @@ extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,UINT32*,DWRITE_FONT_ extern HRESULT opentype_get_font_table(IDWriteFontFileStream*,DWRITE_FONT_FACE_TYPE,UINT32,UINT32,const void**,void**,UINT32*,BOOL*) DECLSPEC_HIDDEN; extern void opentype_cmap_get_glyphindex(void*,UINT32,UINT16*) DECLSPEC_HIDDEN; extern HRESULT opentype_cmap_get_unicode_ranges(void*,UINT32,DWRITE_UNICODE_RANGE*,UINT32*) DECLSPEC_HIDDEN; -extern VOID get_font_properties(LPCVOID os2, LPCVOID head, LPCVOID post, DWRITE_FONT_METRICS *metrics, DWRITE_FONT_STRETCH *stretch, DWRITE_FONT_WEIGHT *weight, DWRITE_FONT_STYLE *style) DECLSPEC_HIDDEN; +extern void opentype_get_font_properties(const void*,const void*,DWRITE_FONT_STRETCH*,DWRITE_FONT_WEIGHT*,DWRITE_FONT_STYLE*) DECLSPEC_HIDDEN; +extern void opentype_get_font_metrics(const void*,const void*,const void*,DWRITE_FONT_METRICS*) DECLSPEC_HIDDEN; extern HRESULT opentype_get_font_strings_from_id(const void*,DWRITE_INFORMATIONAL_STRING_ID,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN; extern HRESULT bidi_computelevels(const WCHAR*,UINT32,UINT8,UINT8*,UINT8*) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 16172b69a78..d5d6b41553f 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -646,7 +646,8 @@ static void get_font_properties_from_stream(IDWriteFontFileStream *stream, DWRIT opentype_get_font_table(stream, face_type, face_index, MS_HEAD_TAG, &tt_head, &head_context, NULL, NULL); opentype_get_font_table(stream, face_type, face_index, MS_POST_TAG, &tt_post, &post_context, NULL, NULL); - get_font_properties(tt_os2, tt_head, tt_post, metrics, stretch, weight, style); + opentype_get_font_properties(tt_os2, tt_head, stretch, weight, style); + opentype_get_font_metrics(tt_os2, tt_head, tt_post, metrics); if (tt_os2) IDWriteFontFileStream_ReleaseFileFragment(stream, os2_context); @@ -1489,7 +1490,8 @@ static HRESULT init_font_data(IDWriteFactory *factory, IDWriteFontFile *file, UI opentype_get_font_table(stream, face_type, face_index, MS_HEAD_TAG, &tt_head, &head_context, NULL, NULL); opentype_get_font_table(stream, face_type, face_index, MS_POST_TAG, &tt_post, &post_context, NULL, NULL); - get_font_properties(tt_os2, tt_head, tt_post, &data->metrics, &data->stretch, &data->weight, &data->style); + opentype_get_font_properties(tt_os2, tt_head, &data->stretch, &data->weight, &data->style); + opentype_get_font_metrics(tt_os2, tt_head, tt_post, &data->metrics); if (tt_os2) IDWriteFontFileStream_ReleaseFileFragment(stream, os2_context); diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 8a143362cf8..5d56899e650 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -858,28 +858,15 @@ HRESULT opentype_cmap_get_unicode_ranges(void *data, UINT32 max_count, DWRITE_UN return *count > max_count ? E_NOT_SUFFICIENT_BUFFER : S_OK; } -VOID get_font_properties(LPCVOID os2, LPCVOID head, LPCVOID post, DWRITE_FONT_METRICS *metrics, DWRITE_FONT_STRETCH *stretch, DWRITE_FONT_WEIGHT *weight, DWRITE_FONT_STYLE *style) +void opentype_get_font_metrics(const void *os2, const void *head, const void *post, DWRITE_FONT_METRICS *metrics) { TT_OS2_V2 *tt_os2 = (TT_OS2_V2*)os2; TT_HEAD *tt_head = (TT_HEAD*)head; TT_POST *tt_post = (TT_POST*)post; - /* default stretch, weight and style to normal */ - *stretch = DWRITE_FONT_STRETCH_NORMAL; - *weight = DWRITE_FONT_WEIGHT_NORMAL; - *style = DWRITE_FONT_STYLE_NORMAL; - memset(metrics, 0, sizeof(*metrics)); - /* DWRITE_FONT_STRETCH enumeration values directly match font data values */ - if (tt_os2) - { - if (GET_BE_WORD(tt_os2->usWidthClass) <= DWRITE_FONT_STRETCH_ULTRA_EXPANDED) - *stretch = GET_BE_WORD(tt_os2->usWidthClass); - - *weight = GET_BE_WORD(tt_os2->usWeightClass); - TRACE("stretch=%d, weight=%d\n", *stretch, *weight); - + if (tt_os2) { metrics->ascent = GET_BE_WORD(tt_os2->sTypoAscender); metrics->descent = GET_BE_WORD(tt_os2->sTypoDescender); metrics->lineGap = GET_BE_WORD(tt_os2->sTypoLineGap); @@ -890,21 +877,40 @@ VOID get_font_properties(LPCVOID os2, LPCVOID head, LPCVOID post, DWRITE_FONT_ME } if (tt_head) - { - USHORT macStyle = GET_BE_WORD(tt_head->macStyle); metrics->designUnitsPerEm = GET_BE_WORD(tt_head->unitsPerEm); - if (macStyle & 0x0002) - *style = DWRITE_FONT_STYLE_ITALIC; - } - - if (tt_post) - { + if (tt_post) { metrics->underlinePosition = GET_BE_WORD(tt_post->underlinePosition); metrics->underlineThickness = GET_BE_WORD(tt_post->underlineThickness); } } +void opentype_get_font_properties(const void *os2, const void *head, DWRITE_FONT_STRETCH *stretch, DWRITE_FONT_WEIGHT *weight, DWRITE_FONT_STYLE *style) +{ + TT_OS2_V2 *tt_os2 = (TT_OS2_V2*)os2; + TT_HEAD *tt_head = (TT_HEAD*)head; + + /* default stretch, weight and style to normal */ + *stretch = DWRITE_FONT_STRETCH_NORMAL; + *weight = DWRITE_FONT_WEIGHT_NORMAL; + *style = DWRITE_FONT_STYLE_NORMAL; + + /* DWRITE_FONT_STRETCH enumeration values directly match font data values */ + if (tt_os2) { + if (GET_BE_WORD(tt_os2->usWidthClass) <= DWRITE_FONT_STRETCH_ULTRA_EXPANDED) + *stretch = GET_BE_WORD(tt_os2->usWidthClass); + + *weight = GET_BE_WORD(tt_os2->usWeightClass); + TRACE("stretch=%d, weight=%d\n", *stretch, *weight); + } + + if (tt_head) { + USHORT macStyle = GET_BE_WORD(tt_head->macStyle); + if (macStyle & 0x0002) + *style = DWRITE_FONT_STYLE_ITALIC; + } +} + static UINT get_name_record_codepage(enum OPENTYPE_PLATFORM_ID platform, USHORT encoding) { UINT codepage = 0;