2 * Windows driver font functions
4 * Copyright 1996 John Harvey
9 #include "wine/winbase16.h"
14 #include "debugtools.h"
16 DEFAULT_DEBUG_CHANNEL(win16drv
)
19 /***********************************************************************
20 * WIN16DRV_GetTextExtentPoint
22 BOOL
WIN16DRV_GetTextExtentPoint( DC
*dc
, LPCWSTR wstr
, INT count
,
25 WIN16DRV_PDEVICE
*physDev
= (WIN16DRV_PDEVICE
*)dc
->physDev
;
29 TRACE("%04x %s %d %p\n",
30 dc
->hSelf
, debugstr_wn(wstr
, count
), count
, size
);
32 str
= HeapAlloc( GetProcessHeap(), 0, count
+1 );
33 lstrcpynWtoA( str
, wstr
, count
+1 );
34 dwRet
= PRTDRV_ExtTextOut(physDev
->segptrPDEVICE
, 0, 0,
36 -count
, physDev
->FontInfo
,
37 win16drv_SegPtr_DrawMode
,
38 win16drv_SegPtr_TextXForm
, NULL
, NULL
, 0);
39 size
->cx
= XDSTOLS(dc
,LOWORD(dwRet
));
40 size
->cy
= YDSTOLS(dc
,HIWORD(dwRet
));
41 TRACE("cx=0x%x, cy=0x%x\n",
43 HeapFree( GetProcessHeap(), 0, str
);
48 /***********************************************************************
49 * WIN16DRV_GetTextMetrics
51 BOOL
WIN16DRV_GetTextMetrics( DC
*dc
, TEXTMETRICA
*metrics
)
53 WIN16DRV_PDEVICE
*physDev
= (WIN16DRV_PDEVICE
*)dc
->physDev
;
55 TRACE("%04x \n", dc
->hSelf
);
57 FONT_TextMetric16to32A( &physDev
->tm
, metrics
);
60 "H %ld, A %ld, D %ld, Int %ld, Ext %ld, AW %ld, MW %ld, W %ld\n",
64 metrics
->tmInternalLeading
,
65 metrics
->tmExternalLeading
,
66 metrics
->tmAveCharWidth
,
67 metrics
->tmMaxCharWidth
,
73 HFONT
WIN16DRV_FONT_SelectObject( DC
* dc
, HFONT hfont
, FONTOBJ
* font
)
75 WIN16DRV_PDEVICE
*physDev
= (WIN16DRV_PDEVICE
*)dc
->physDev
;
76 HPEN prevHandle
= dc
->w
.hFont
;
81 TRACE("WIN16DRV_FONT_SelectObject '%s' h=%d\n",
82 font
->logfont
.lfFaceName
, font
->logfont
.lfHeight
);
85 if( physDev
->FontInfo
)
87 TRACE("UnRealizing FontInfo\n");
88 nSize
= PRTDRV_RealizeObject (physDev
->segptrPDEVICE
, -DRVOBJ_FONT
,
90 physDev
->FontInfo
, 0);
93 memcpy(&physDev
->lf
, &font
->logfont
, sizeof(LOGFONT16
));
94 nSize
= PRTDRV_RealizeObject (physDev
->segptrPDEVICE
, DRVOBJ_FONT
,
97 if( physDev
->FontInfo
&&
98 HeapSize( SegptrHeap
, 0, physDev
->FontInfo
) < nSize
)
100 SEGPTR_FREE( physDev
->FontInfo
);
101 physDev
->FontInfo
= NULL
;
104 if( !physDev
->FontInfo
)
105 physDev
->FontInfo
= SEGPTR_ALLOC( nSize
);
108 nSize
= PRTDRV_RealizeObject(physDev
->segptrPDEVICE
, DRVOBJ_FONT
,
111 win16drv_SegPtr_TextXForm
);
113 #define fi physDev->FontInfo
114 physDev
->tm
.tmHeight
= YDSTOLS(dc
, fi
->dfPixHeight
);
115 physDev
->tm
.tmAscent
= YDSTOLS(dc
, fi
->dfAscent
);
116 physDev
->tm
.tmDescent
= physDev
->tm
.tmHeight
-
117 physDev
->tm
.tmAscent
;
118 physDev
->tm
.tmInternalLeading
= YDSTOLS(dc
, fi
->dfInternalLeading
);
119 physDev
->tm
.tmExternalLeading
= YDSTOLS(dc
, fi
->dfExternalLeading
);
120 physDev
->tm
.tmAveCharWidth
= XDSTOLS(dc
, fi
->dfAvgWidth
);
121 physDev
->tm
.tmMaxCharWidth
= XDSTOLS(dc
, fi
->dfMaxWidth
);
122 physDev
->tm
.tmWeight
= fi
->dfWeight
;
123 physDev
->tm
.tmOverhang
= 0; /*FIXME*/
124 physDev
->tm
.tmDigitizedAspectX
= fi
->dfHorizRes
;
125 physDev
->tm
.tmDigitizedAspectY
= fi
->dfVertRes
;
126 physDev
->tm
.tmFirstChar
= fi
->dfFirstChar
;
127 physDev
->tm
.tmLastChar
= fi
->dfLastChar
;
128 physDev
->tm
.tmDefaultChar
= fi
->dfDefaultChar
;
129 physDev
->tm
.tmBreakChar
= fi
->dfBreakChar
;
130 physDev
->tm
.tmItalic
= fi
->dfItalic
;
131 physDev
->tm
.tmUnderlined
= fi
->dfUnderline
;
132 physDev
->tm
.tmStruckOut
= fi
->dfStrikeOut
;
133 physDev
->tm
.tmPitchAndFamily
= fi
->dfPitchAndFamily
;
134 physDev
->tm
.tmCharSet
= fi
->dfCharSet
;
137 TRACE("H %d, A %d, D %d, Int %d, Ext %d, AW %d, MW %d, W %d\n",
138 physDev
->tm
.tmHeight
,
139 physDev
->tm
.tmAscent
,
140 physDev
->tm
.tmDescent
,
141 physDev
->tm
.tmInternalLeading
,
142 physDev
->tm
.tmExternalLeading
,
143 physDev
->tm
.tmAveCharWidth
,
144 physDev
->tm
.tmMaxCharWidth
,
145 physDev
->tm
.tmWeight
);
150 /***********************************************************************
151 * GetCharWidth32A (GDI32.155)
153 BOOL
WIN16DRV_GetCharWidth( DC
*dc
, UINT firstChar
, UINT lastChar
,
159 WIN16DRV_PDEVICE
*physDev
= (WIN16DRV_PDEVICE
*)dc
->physDev
;
161 TRACE("%d - %d into %p\n",
162 firstChar
, lastChar
, buffer
);
164 wRet
= PRTDRV_GetCharWidth( physDev
->segptrPDEVICE
, buffer
, firstChar
,
165 lastChar
, physDev
->FontInfo
,
166 win16drv_SegPtr_DrawMode
,
167 win16drv_SegPtr_TextXForm
);
168 if( TRACE_ON(win16drv
) ){
169 for(i
= 0; i
<= lastChar
- firstChar
; i
++)
170 TRACE("Char %x: width %d\n", i
+ firstChar
,
177 /***********************************************************************
179 * WIN16DRV_EnumDeviceFonts
182 BOOL
WIN16DRV_EnumDeviceFonts( DC
* dc
, LPLOGFONT16 plf
,
183 DEVICEFONTENUMPROC proc
, LPARAM lp
)
185 WIN16DRV_PDEVICE
*physDev
= (WIN16DRV_PDEVICE
*)dc
->physDev
;
188 /* EnumDFontCallback is GDI.158 */
189 FARPROC16 pfnCallback
= NE_GetEntryPoint( GetModuleHandle16("GDI"), 158 );
191 wepfc
.proc
= (int (*)(LPENUMLOGFONT16
,LPNEWTEXTMETRIC16
,UINT16
,LPARAM
))proc
;
194 wRet
= PRTDRV_EnumDFonts(physDev
->segptrPDEVICE
, plf
->lfFaceName
[0] ?
195 plf
->lfFaceName
: NULL
, pfnCallback
, &wepfc
);
200 * EnumCallback (GDI.158)
202 * This is the callback function used when EnumDFonts is called.
203 * (The printer drivers uses it to pass info on available fonts).
205 * lpvClientData is the pointer passed to EnumDFonts, which points to a WEPFC
206 * structure (WEPFC = WINE_ENUM_PRINTER_FONT_CALLBACK).
211 WORD WINAPI
WineEnumDFontCallback(LPENUMLOGFONT16 lpLogFont
,
212 LPNEWTEXTMETRIC16 lpTextMetrics
,
213 WORD wFontType
, LONG lpClientData
)
215 TRACE("In WineEnumDFontCallback plf=%p\n", lpLogFont
);
216 return (*(((WEPFC
*)lpClientData
)->proc
))( lpLogFont
, lpTextMetrics
,
217 wFontType
, ((WEPFC
*)lpClientData
)->lp
);