From d59d3daf21d178e2ec0ee787d35a9086d8fce526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Fri, 12 Dec 2003 20:51:42 +0000 Subject: [PATCH] Retrieve tmAveCharWidth font metric svn path=/trunk/; revision=6977 --- reactos/subsys/win32k/objects/text.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index b681cd58e11..d155fb1e7e6 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: text.c,v 1.55 2003/12/08 20:58:44 chorns Exp $ */ +/* $Id: text.c,v 1.56 2003/12/12 20:51:42 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN @@ -30,6 +30,7 @@ #include #include #include FT_FREETYPE_H +#include #include "../eng/handle.h" @@ -917,6 +918,7 @@ NtGdiGetTextMetrics(HDC hDC, NTSTATUS Status = STATUS_SUCCESS; TEXTMETRICW SafeTm; FT_Face Face; + TT_OS2 *pOS2; ULONG Error; dc = DC_LockDc(hDC); @@ -947,6 +949,16 @@ NtGdiGetTextMetrics(HDC hDC, else { memcpy(&SafeTm, &FontGDI->TextMetric, sizeof(TEXTMETRICW)); + pOS2 = FT_Get_Sfnt_Table(Face, ft_sfnt_os2); + if (NULL == pOS2) + { + DPRINT1("Can't find OS/2 table - not TT font?\n"); + Status = STATUS_UNSUCCESSFUL; + } + else + { + SafeTm.tmAveCharWidth = (pOS2->xAvgCharWidth + 32) / 64; + } SafeTm.tmAscent = (Face->size->metrics.ascender + 32) / 64; // units above baseline SafeTm.tmDescent = (- Face->size->metrics.descender + 32) / 64; // units below baseline SafeTm.tmHeight = SafeTm.tmAscent + SafeTm.tmDescent;