diff --git a/reactos/win32ss/gdi/ntgdi/font.c b/reactos/win32ss/gdi/ntgdi/font.c index 1b05399..62ef4d4 100644 --- a/reactos/win32ss/gdi/ntgdi/font.c +++ b/reactos/win32ss/gdi/ntgdi/font.c @@ -827,6 +827,7 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC, return 0; } FontGDI = ObjToGDI(TextObj->Font, FONT); + TextIntUpdateSize(dc, TextObj, FontGDI, TRUE); TEXTOBJ_UnlockText(TextObj); Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL); if (!otm) return Size; diff --git a/reactos/win32ss/gdi/ntgdi/freetype.c b/reactos/win32ss/gdi/ntgdi/freetype.c index 7f4f124..904db2c 100644 --- a/reactos/win32ss/gdi/ntgdi/freetype.c +++ b/reactos/win32ss/gdi/ntgdi/freetype.c @@ -2324,6 +2324,72 @@ static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int b return needed; } + +BOOL +FASTCALL +TextIntUpdateSize(PDC dc, + PTEXTOBJ TextObj, + PFONTGDI FontGDI, + BOOL bDoLock) +{ + FT_Face face; + INT error, n; + FT_CharMap charmap, found; + LOGFONTW *plf; + + if (bDoLock) + IntLockFreeType; + + face = FontGDI->SharedFace->Face; + if (face->charmap == NULL) + { + DPRINT("WARNING: No charmap selected!\n"); + DPRINT("This font face has %d charmaps\n", face->num_charmaps); + + for (n = 0; n < face->num_charmaps; n++) + { + charmap = face->charmaps[n]; + DPRINT("Found charmap encoding: %i\n", charmap->encoding); + if (charmap->encoding != 0) + { + found = charmap; + break; + } + } + if (!found) + { + DPRINT1("WARNING: Could not find desired charmap!\n"); + } + error = FT_Set_Charmap(face, found); + if (error) + { + DPRINT1("WARNING: Could not set the charmap!\n"); + } + } + + plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont; + + error = FT_Set_Pixel_Sizes( + face, + plf->lfWidth, + /* FIXME: Should set character height if neg */ + (plf->lfHeight == 0 ? + dc->ppdev->devinfo.lfDefaultFont.lfHeight : + abs(plf->lfHeight))); + + if (bDoLock) + IntUnLockFreeType; + + if (error) + { + DPRINT1("Error in setting pixel sizes: %d\n", error); + return FALSE; + } + + return TRUE; +} + + /* * Based on WineEngGetGlyphOutline * @@ -2362,8 +2428,6 @@ ftGdiGetGlyphOutline( LONG aveWidth; INT adv, lsb, bbx; /* These three hold to widths of the unrotated chars */ OUTLINETEXTMETRICW *potm; - int n = 0; - FT_CharMap found = 0, charmap; XFORM xForm; LOGFONTW *plf; @@ -2401,40 +2465,7 @@ ftGdiGetGlyphOutline( IntGetOutlineTextMetrics(FontGDI, Size, potm); IntLockFreeType; - - /* During testing, I never saw this used. It is here just in case. */ - if (ft_face->charmap == NULL) - { - DPRINT("WARNING: No charmap selected!\n"); - DPRINT("This font face has %d charmaps\n", ft_face->num_charmaps); - - for (n = 0; n < ft_face->num_charmaps; n++) - { - charmap = ft_face->charmaps[n]; - DPRINT("Found charmap encoding: %i\n", charmap->encoding); - if (charmap->encoding != 0) - { - found = charmap; - break; - } - } - if (!found) - { - DPRINT1("WARNING: Could not find desired charmap!\n"); - } - error = FT_Set_Charmap(ft_face, found); - if (error) - { - DPRINT1("WARNING: Could not set the charmap!\n"); - } - } - - FT_Set_Pixel_Sizes(ft_face, - abs(plf->lfWidth), - /* FIXME: Should set character height if neg */ - (plf->lfHeight == 0 ? - dc->ppdev->devinfo.lfDefaultFont.lfHeight : - abs(plf->lfHeight))); + TextIntUpdateSize(dc, TextObj, FontGDI, FALSE); FtSetCoordinateTransform(ft_face, DC_pmxWorldToDevice(dc)); TEXTOBJ_UnlockText(TextObj); @@ -2832,9 +2863,8 @@ TextIntGetTextExtentPoint(PDC dc, FT_Face face; FT_GlyphSlot glyph; FT_BitmapGlyph realglyph; - INT error, n, glyph_index, i, previous; + INT error, glyph_index, i, previous; ULONGLONG TotalWidth = 0; - FT_CharMap charmap, found = NULL; BOOL use_kerning; FT_Render_Mode RenderMode; BOOLEAN Render; @@ -2851,33 +2881,8 @@ TextIntGetTextExtentPoint(PDC dc, } IntLockFreeType; - if (face->charmap == NULL) - { - DPRINT("WARNING: No charmap selected!\n"); - DPRINT("This font face has %d charmaps\n", face->num_charmaps); - for (n = 0; n < face->num_charmaps; n++) - { - charmap = face->charmaps[n]; - DPRINT("Found charmap encoding: %i\n", charmap->encoding); - if (charmap->encoding != 0) - { - found = charmap; - break; - } - } - - if (! found) - { - DPRINT1("WARNING: Could not find desired charmap!\n"); - } - - error = FT_Set_Charmap(face, found); - if (error) - { - DPRINT1("WARNING: Could not set the charmap!\n"); - } - } + TextIntUpdateSize(dc, TextObj, FontGDI, FALSE); plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont; EmuBold = (plf->lfWeight >= FW_BOLD && FontGDI->OriginalWeight <= FW_NORMAL); @@ -2889,16 +2894,6 @@ TextIntGetTextExtentPoint(PDC dc, else RenderMode = FT_RENDER_MODE_MONO; - error = FT_Set_Pixel_Sizes(face, - plf->lfWidth, - /* FIXME: Should set character height if neg */ - (plf->lfHeight == 0 ? - dc->ppdev->devinfo.lfDefaultFont.lfHeight : - abs(plf->lfHeight))); - if (error) - { - DPRINT1("Error in setting pixel sizes: %d\n", error); - } /* Get the DC's world-to-device transformation matrix */ pmxWorldToDevice = DC_pmxWorldToDevice(dc); @@ -4543,7 +4538,7 @@ GreExtTextOutW( PDC_ATTR pdcattr; SURFOBJ *SurfObj; SURFACE *psurf = NULL; - int error, glyph_index, n, i; + int error, glyph_index, i; FT_Face face; FT_GlyphSlot glyph; FT_BitmapGlyph realglyph; @@ -4555,7 +4550,6 @@ GreExtTextOutW( HBITMAP HSourceGlyph; SURFOBJ *SourceGlyphSurf; SIZEL bitSize; - FT_CharMap found = 0, charmap; INT yoff; FONTOBJ *FontObj; PFONTGDI FontGDI; @@ -4707,31 +4701,6 @@ GreExtTextOutW( IntLockFreeType; face = FontGDI->SharedFace->Face; - if (face->charmap == NULL) - { - DPRINT("WARNING: No charmap selected!\n"); - DPRINT("This font face has %d charmaps\n", face->num_charmaps); - - for (n = 0; n < face->num_charmaps; n++) - { - charmap = face->charmaps[n]; - DPRINT("Found charmap encoding: %i\n", charmap->encoding); - if (charmap->encoding != 0) - { - found = charmap; - break; - } - } - if (!found) - { - DPRINT1("WARNING: Could not find desired charmap!\n"); - } - error = FT_Set_Charmap(face, found); - if (error) - { - DPRINT1("WARNING: Could not set the charmap!\n"); - } - } plf = &TextObj->logfont.elfEnumLogfontEx.elfLogFont; EmuBold = (plf->lfWeight >= FW_BOLD && FontGDI->OriginalWeight <= FW_NORMAL); @@ -4743,16 +4712,8 @@ GreExtTextOutW( else RenderMode = FT_RENDER_MODE_MONO; - error = FT_Set_Pixel_Sizes( - face, - plf->lfWidth, - /* FIXME: Should set character height if neg */ - (plf->lfHeight == 0 ? - dc->ppdev->devinfo.lfDefaultFont.lfHeight : - abs(plf->lfHeight))); - if (error) + if (!TextIntUpdateSize(dc, TextObj, FontGDI, FALSE)) { - DPRINT1("Error in setting pixel sizes: %d\n", error); IntUnLockFreeType; goto fail; } diff --git a/reactos/win32ss/gdi/ntgdi/text.h b/reactos/win32ss/gdi/ntgdi/text.h index ae73f8f..3bd0029 100644 --- a/reactos/win32ss/gdi/ntgdi/text.h +++ b/reactos/win32ss/gdi/ntgdi/text.h @@ -115,6 +115,7 @@ VOID FASTCALL IntLoadSystemFonts(VOID); INT FASTCALL IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics); ULONG FASTCALL ftGdiGetGlyphOutline(PDC,WCHAR,UINT,LPGLYPHMETRICS,ULONG,PVOID,LPMAT2,BOOL); INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI,UINT,OUTLINETEXTMETRICW *); +BOOL FASTCALL TextIntUpdateSize(PDC,PTEXTOBJ,PFONTGDI,BOOL); BOOL FASTCALL ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS); BOOL FASTCALL TextIntGetTextExtentPoint(PDC,PTEXTOBJ,LPCWSTR,INT,ULONG,LPINT,LPINT,LPSIZE,FLONG); BOOL FASTCALL ftGdiGetTextMetricsW(HDC,PTMW_INTERNAL);