2 * Windows driver font functions
4 * Copyright 1996 John Harvey
9 #include "wine/winbase16.h"
16 DEFAULT_DEBUG_CHANNEL(win16drv)
19 /***********************************************************************
20 * WIN16DRV_GetTextExtentPoint
22 BOOL WIN16DRV_GetTextExtentPoint( DC *dc, LPCSTR str, INT count,
25 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
28 TRACE(win16drv, "%04x %s %d %p\n",
29 dc->hSelf, str, count, size);
31 dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0,
33 -count, physDev->FontInfo,
34 win16drv_SegPtr_DrawMode,
35 win16drv_SegPtr_TextXForm, NULL, NULL, 0);
36 size->cx = XDSTOLS(dc,LOWORD(dwRet));
37 size->cy = YDSTOLS(dc,HIWORD(dwRet));
38 TRACE(win16drv, "cx=0x%x, cy=0x%x\n",
44 /***********************************************************************
45 * WIN16DRV_GetTextMetrics
47 BOOL WIN16DRV_GetTextMetrics( DC *dc, TEXTMETRICA *metrics )
49 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
51 TRACE(win16drv, "%04x \n", dc->hSelf);
53 FONT_TextMetric16to32A( &physDev->tm, metrics );
56 "H %ld, A %ld, D %ld, Int %ld, Ext %ld, AW %ld, MW %ld, W %ld\n",
60 metrics->tmInternalLeading,
61 metrics->tmExternalLeading,
62 metrics->tmAveCharWidth,
63 metrics->tmMaxCharWidth,
69 HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font)
71 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
72 HPEN prevHandle = dc->w.hFont;
77 TRACE(win16drv, "WIN16DRV_FONT_SelectObject '%s' h=%d\n",
78 font->logfont.lfFaceName, font->logfont.lfHeight);
81 if( physDev->FontInfo )
83 TRACE(win16drv, "UnRealizing FontInfo\n");
84 nSize = PRTDRV_RealizeObject (physDev->segptrPDEVICE, -DRVOBJ_FONT,
86 physDev->FontInfo, 0);
89 memcpy(&physDev->lf, &font->logfont, sizeof(LOGFONT16));
90 nSize = PRTDRV_RealizeObject (physDev->segptrPDEVICE, DRVOBJ_FONT,
93 if( physDev->FontInfo &&
94 HeapSize( SegptrHeap, 0, physDev->FontInfo ) < nSize )
96 SEGPTR_FREE( physDev->FontInfo );
97 physDev->FontInfo = NULL;
100 if( !physDev->FontInfo )
101 physDev->FontInfo = SEGPTR_ALLOC( nSize );
104 nSize = PRTDRV_RealizeObject(physDev->segptrPDEVICE, DRVOBJ_FONT,
107 win16drv_SegPtr_TextXForm );
109 #define fi physDev->FontInfo
110 physDev->tm.tmHeight = YDSTOLS(dc, fi->dfPixHeight);
111 physDev->tm.tmAscent = YDSTOLS(dc, fi->dfAscent);
112 physDev->tm.tmDescent = physDev->tm.tmHeight -
113 physDev->tm.tmAscent;
114 physDev->tm.tmInternalLeading = YDSTOLS(dc, fi->dfInternalLeading);
115 physDev->tm.tmExternalLeading = YDSTOLS(dc, fi->dfExternalLeading);
116 physDev->tm.tmAveCharWidth = XDSTOLS(dc, fi->dfAvgWidth);
117 physDev->tm.tmMaxCharWidth = XDSTOLS(dc, fi->dfMaxWidth);
118 physDev->tm.tmWeight = fi->dfWeight;
119 physDev->tm.tmOverhang = 0; /*FIXME*/
120 physDev->tm.tmDigitizedAspectX = fi->dfHorizRes;
121 physDev->tm.tmDigitizedAspectY = fi->dfVertRes;
122 physDev->tm.tmFirstChar = fi->dfFirstChar;
123 physDev->tm.tmLastChar = fi->dfLastChar;
124 physDev->tm.tmDefaultChar = fi->dfDefaultChar;
125 physDev->tm.tmBreakChar = fi->dfBreakChar;
126 physDev->tm.tmItalic = fi->dfItalic;
127 physDev->tm.tmUnderlined = fi->dfUnderline;
128 physDev->tm.tmStruckOut = fi->dfStrikeOut;
129 physDev->tm.tmPitchAndFamily = fi->dfPitchAndFamily;
130 physDev->tm.tmCharSet = fi->dfCharSet;
133 TRACE(win16drv, "H %d, A %d, D %d, Int %d, Ext %d, AW %d, MW %d, W %d\n",
134 physDev->tm.tmHeight,
135 physDev->tm.tmAscent,
136 physDev->tm.tmDescent,
137 physDev->tm.tmInternalLeading,
138 physDev->tm.tmExternalLeading,
139 physDev->tm.tmAveCharWidth,
140 physDev->tm.tmMaxCharWidth,
141 physDev->tm.tmWeight);
146 /***********************************************************************
147 * GetCharWidth32A (GDI32.155)
149 BOOL WIN16DRV_GetCharWidth( DC *dc, UINT firstChar, UINT lastChar,
155 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
157 TRACE(win16drv, "%d - %d into %p\n",
158 firstChar, lastChar, buffer );
160 wRet = PRTDRV_GetCharWidth( physDev->segptrPDEVICE, buffer, firstChar,
161 lastChar, physDev->FontInfo,
162 win16drv_SegPtr_DrawMode,
163 win16drv_SegPtr_TextXForm );
164 if( TRACE_ON(win16drv) ){
165 for(i = 0; i <= lastChar - firstChar; i++)
166 TRACE(win16drv, "Char %x: width %d\n", i + firstChar,
173 /***********************************************************************
175 * WIN16DRV_EnumDeviceFonts
178 BOOL WIN16DRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
179 DEVICEFONTENUMPROC proc, LPARAM lp )
181 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
184 /* EnumDFontCallback is GDI.158 */
185 FARPROC16 pfnCallback = NE_GetEntryPoint( GetModuleHandle16("GDI"), 158 );
190 wRet = PRTDRV_EnumDFonts(physDev->segptrPDEVICE, plf->lfFaceName[0] ?
191 plf->lfFaceName : NULL , pfnCallback , &wepfc );
196 * EnumCallback (GDI.158)
198 * This is the callback function used when EnumDFonts is called.
199 * (The printer drivers uses it to pass info on available fonts).
201 * lpvClientData is the pointer passed to EnumDFonts, which points to a WEPFC
202 * structure (WEPFC = WINE_ENUM_PRINTER_FONT_CALLBACK).
207 WORD WINAPI WineEnumDFontCallback(LPENUMLOGFONT16 lpLogFont,
208 LPNEWTEXTMETRIC16 lpTextMetrics,
209 WORD wFontType, LONG lpClientData)
211 TRACE(win16drv, "In WineEnumDFontCallback plf=%p\n", lpLogFont);
212 return (*(((WEPFC *)lpClientData)->proc))( lpLogFont, lpTextMetrics,
213 wFontType, ((WEPFC *)lpClientData)->lp );