font.c 61.1 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4
/*
 * GDI font objects
 *
 * Copyright 1993 Alexandre Julliard
Alexandre Julliard's avatar
Alexandre Julliard committed
5
 *           1997 Alex Korobka
Alexandre Julliard's avatar
Alexandre Julliard committed
6
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
7 8

#include <stdlib.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
9
#include <string.h>
10 11
#include "winerror.h"
#include "winnls.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
12
#include "font.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
13
#include "heap.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
14
#include "metafile.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
15
#include "options.h"
16
#include "debugtools.h"
17
#include "gdi.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
18

19 20
DEFAULT_DEBUG_CHANNEL(font);
DECLARE_DEBUG_CHANNEL(gdi);
21

Alexandre Julliard's avatar
Alexandre Julliard committed
22
#define ENUM_UNICODE	0x00000001
Alexandre Julliard's avatar
Alexandre Julliard committed
23

Alexandre Julliard's avatar
Alexandre Julliard committed
24 25 26 27 28
typedef struct
{
  LPLOGFONT16           lpLogFontParam;
  FONTENUMPROCEX16      lpEnumFunc;
  LPARAM                lpData;
Alexandre Julliard's avatar
Alexandre Julliard committed
29

Alexandre Julliard's avatar
Alexandre Julliard committed
30 31 32 33 34
  LPNEWTEXTMETRICEX16   lpTextMetric;
  LPENUMLOGFONTEX16     lpLogFont;
  SEGPTR                segTextMetric;
  SEGPTR                segLogFont;
} fontEnum16;
Alexandre Julliard's avatar
Alexandre Julliard committed
35

Alexandre Julliard's avatar
Alexandre Julliard committed
36 37
typedef struct
{
38
  LPLOGFONTW          lpLogFontParam;
39
  FONTENUMPROCEXW     lpEnumFunc;
40
  LPARAM              lpData;
Alexandre Julliard's avatar
Alexandre Julliard committed
41

Alexandre Julliard's avatar
Alexandre Julliard committed
42 43 44
  DWORD                 dwFlags;
} fontEnum32;
 
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
/*
 *  For TranslateCharsetInfo
 */
#define FS(x) {{0,0,0,0},{0x1<<(x),0}}
#define MAXTCIINDEX 32
static CHARSETINFO FONT_tci[MAXTCIINDEX] = {
  /* ANSI */
  { ANSI_CHARSET, 1252, FS(0)},
  { EASTEUROPE_CHARSET, 1250, FS(1)},
  { RUSSIAN_CHARSET, 1251, FS(2)},
  { GREEK_CHARSET, 1253, FS(3)},
  { TURKISH_CHARSET, 1254, FS(4)},
  { HEBREW_CHARSET, 1255, FS(5)},
  { ARABIC_CHARSET, 1256, FS(6)},
  { BALTIC_CHARSET, 1257, FS(7)},
  /* reserved by ANSI */
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  /* ANSI and OEM */
  { THAI_CHARSET,  874,  FS(16)},
  { SHIFTJIS_CHARSET, 932, FS(17)},
  { GB2312_CHARSET, 936, FS(18)},
  { HANGEUL_CHARSET, 949, FS(19)},
  { CHINESEBIG5_CHARSET, 950, FS(20)},
  { JOHAB_CHARSET, 1361, FS(21)}, 
  /* reserved for alternate ANSI and OEM */
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
  /* reserved for system */
  { DEFAULT_CHARSET, 0, FS(0)},
  { DEFAULT_CHARSET, 0, FS(0)},
};

Alexandre Julliard's avatar
Alexandre Julliard committed
90
/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
91
 *              LOGFONT conversion functions.
Alexandre Julliard's avatar
Alexandre Julliard committed
92
 */
93
void FONT_LogFontATo16( const LOGFONTA* font32, LPLOGFONT16 font16 )
Alexandre Julliard's avatar
Alexandre Julliard committed
94
{
95 96 97 98 99 100 101 102 103 104 105 106 107
    font16->lfHeight = font32->lfHeight;
    font16->lfWidth = font32->lfWidth;
    font16->lfEscapement = font32->lfEscapement;
    font16->lfOrientation = font32->lfOrientation;
    font16->lfWeight = font32->lfWeight;
    font16->lfItalic = font32->lfItalic;
    font16->lfUnderline = font32->lfUnderline;
    font16->lfStrikeOut = font32->lfStrikeOut;
    font16->lfCharSet = font32->lfCharSet;
    font16->lfOutPrecision = font32->lfOutPrecision;
    font16->lfClipPrecision = font32->lfClipPrecision;
    font16->lfQuality = font32->lfQuality;
    font16->lfPitchAndFamily = font32->lfPitchAndFamily;
108
    lstrcpynA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
Alexandre Julliard's avatar
Alexandre Julliard committed
109 110
}

111
void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 )
Alexandre Julliard's avatar
Alexandre Julliard committed
112
{
113 114 115 116 117 118 119 120 121 122 123 124 125
    font16->lfHeight = font32->lfHeight;
    font16->lfWidth = font32->lfWidth;
    font16->lfEscapement = font32->lfEscapement;
    font16->lfOrientation = font32->lfOrientation;
    font16->lfWeight = font32->lfWeight;
    font16->lfItalic = font32->lfItalic;
    font16->lfUnderline = font32->lfUnderline;
    font16->lfStrikeOut = font32->lfStrikeOut;
    font16->lfCharSet = font32->lfCharSet;
    font16->lfOutPrecision = font32->lfOutPrecision;
    font16->lfClipPrecision = font32->lfClipPrecision;
    font16->lfQuality = font32->lfQuality;
    font16->lfPitchAndFamily = font32->lfPitchAndFamily;
126 127 128
    WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1,
                         font16->lfFaceName, LF_FACESIZE, NULL, NULL );
    font16->lfFaceName[LF_FACESIZE-1] = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
129 130
}

131
void FONT_LogFont16ToA( const LOGFONT16 *font16, LPLOGFONTA font32 )
Alexandre Julliard's avatar
Alexandre Julliard committed
132
{
133 134 135 136 137 138 139 140 141 142 143 144 145
    font32->lfHeight = font16->lfHeight;
    font32->lfWidth = font16->lfWidth;
    font32->lfEscapement = font16->lfEscapement;
    font32->lfOrientation = font16->lfOrientation;
    font32->lfWeight = font16->lfWeight;
    font32->lfItalic = font16->lfItalic;
    font32->lfUnderline = font16->lfUnderline;
    font32->lfStrikeOut = font16->lfStrikeOut;
    font32->lfCharSet = font16->lfCharSet;
    font32->lfOutPrecision = font16->lfOutPrecision;
    font32->lfClipPrecision = font16->lfClipPrecision;
    font32->lfQuality = font16->lfQuality;
    font32->lfPitchAndFamily = font16->lfPitchAndFamily;
146
    lstrcpynA( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
Alexandre Julliard's avatar
Alexandre Julliard committed
147 148
}

149
void FONT_LogFont16ToW( const LOGFONT16 *font16, LPLOGFONTW font32 )
Alexandre Julliard's avatar
Alexandre Julliard committed
150
{
151 152 153 154 155 156 157 158 159 160 161 162 163
    font32->lfHeight = font16->lfHeight;
    font32->lfWidth = font16->lfWidth;
    font32->lfEscapement = font16->lfEscapement;
    font32->lfOrientation = font16->lfOrientation;
    font32->lfWeight = font16->lfWeight;
    font32->lfItalic = font16->lfItalic;
    font32->lfUnderline = font16->lfUnderline;
    font32->lfStrikeOut = font16->lfStrikeOut;
    font32->lfCharSet = font16->lfCharSet;
    font32->lfOutPrecision = font16->lfOutPrecision;
    font32->lfClipPrecision = font16->lfClipPrecision;
    font32->lfQuality = font16->lfQuality;
    font32->lfPitchAndFamily = font16->lfPitchAndFamily;
164 165
    MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
    font32->lfFaceName[LF_FACESIZE-1] = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
166 167
}

168
void FONT_LogFontAToW( const LOGFONTA *fontA, LPLOGFONTW fontW )
169
{
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
    memcpy(fontW, fontA, sizeof(LOGFONTA) - LF_FACESIZE);
    MultiByteToWideChar(CP_ACP, 0, fontA->lfFaceName, -1, fontW->lfFaceName,
			LF_FACESIZE);
}

void FONT_LogFontWToA( const LOGFONTW *fontW, LPLOGFONTA fontA )
{
    memcpy(fontA, fontW, sizeof(LOGFONTA) - LF_FACESIZE);
    WideCharToMultiByte(CP_ACP, 0, fontW->lfFaceName, -1, fontA->lfFaceName,
			LF_FACESIZE, NULL, NULL);
}

void FONT_EnumLogFontEx16ToA( const ENUMLOGFONTEX16 *font16, LPENUMLOGFONTEXA font32 )
{
    FONT_LogFont16ToA( (LPLOGFONT16)font16, (LPLOGFONTA)font32);
185 186 187 188 189
    lstrcpynA( font32->elfFullName, font16->elfFullName, LF_FULLFACESIZE );
    lstrcpynA( font32->elfStyle, font16->elfStyle, LF_FACESIZE );
    lstrcpynA( font32->elfScript, font16->elfScript, LF_FACESIZE );
}

190
void FONT_EnumLogFontEx16ToW( const ENUMLOGFONTEX16 *font16, LPENUMLOGFONTEXW font32 )
191
{
192
    FONT_LogFont16ToW( (LPLOGFONT16)font16, (LPLOGFONTW)font32);
193 194 195 196 197 198 199

    MultiByteToWideChar( CP_ACP, 0, font16->elfFullName, -1, font32->elfFullName, LF_FULLFACESIZE );
    font32->elfFullName[LF_FULLFACESIZE-1] = 0;
    MultiByteToWideChar( CP_ACP, 0, font16->elfStyle, -1, font32->elfStyle, LF_FACESIZE );
    font32->elfStyle[LF_FACESIZE-1] = 0;
    MultiByteToWideChar( CP_ACP, 0, font16->elfScript, -1, font32->elfScript, LF_FACESIZE );
    font32->elfScript[LF_FACESIZE-1] = 0;
200 201
}

202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
void FONT_EnumLogFontExWTo16( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEX16 font16 )
{
    FONT_LogFontWTo16( (LPLOGFONTW)fontW, (LPLOGFONT16)font16);

    WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
			 font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
    font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
    WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
			 font16->elfStyle, LF_FACESIZE, NULL, NULL );
    font16->elfStyle[LF_FACESIZE-1] = '\0';
    WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
			 font16->elfScript, LF_FACESIZE, NULL, NULL );
    font16->elfScript[LF_FACESIZE-1] = '\0';
}

void FONT_EnumLogFontExWToA( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEXA fontA )
{
    FONT_LogFontWToA( (LPLOGFONTW)fontW, (LPLOGFONTA)fontA);

    WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
			 fontA->elfFullName, LF_FULLFACESIZE, NULL, NULL );
    fontA->elfFullName[LF_FULLFACESIZE-1] = '\0';
    WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
			 fontA->elfStyle, LF_FACESIZE, NULL, NULL );
    fontA->elfStyle[LF_FACESIZE-1] = '\0';
    WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
			 fontA->elfScript, LF_FACESIZE, NULL, NULL );
    fontA->elfScript[LF_FACESIZE-1] = '\0';
}

Alexandre Julliard's avatar
Alexandre Julliard committed
232
/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
233 234
 *              TEXTMETRIC conversion functions.
 */
235
void FONT_TextMetricATo16(const TEXTMETRICA *ptm32, LPTEXTMETRIC16 ptm16 )
Alexandre Julliard's avatar
Alexandre Julliard committed
236 237 238 239 240 241 242 243 244 245 246 247
{
    ptm16->tmHeight = ptm32->tmHeight;
    ptm16->tmAscent = ptm32->tmAscent;
    ptm16->tmDescent = ptm32->tmDescent;
    ptm16->tmInternalLeading = ptm32->tmInternalLeading;
    ptm16->tmExternalLeading = ptm32->tmExternalLeading;
    ptm16->tmAveCharWidth = ptm32->tmAveCharWidth;
    ptm16->tmMaxCharWidth = ptm32->tmMaxCharWidth;
    ptm16->tmWeight = ptm32->tmWeight;
    ptm16->tmOverhang = ptm32->tmOverhang;
    ptm16->tmDigitizedAspectX = ptm32->tmDigitizedAspectX;
    ptm16->tmDigitizedAspectY = ptm32->tmDigitizedAspectY;
Alexandre Julliard's avatar
Alexandre Julliard committed
248 249 250 251
    ptm16->tmFirstChar = ptm32->tmFirstChar;
    ptm16->tmLastChar = ptm32->tmLastChar;
    ptm16->tmDefaultChar = ptm32->tmDefaultChar;
    ptm16->tmBreakChar = ptm32->tmBreakChar;
Alexandre Julliard's avatar
Alexandre Julliard committed
252 253 254 255 256 257 258
    ptm16->tmItalic = ptm32->tmItalic;
    ptm16->tmUnderlined = ptm32->tmUnderlined;
    ptm16->tmStruckOut = ptm32->tmStruckOut;
    ptm16->tmPitchAndFamily = ptm32->tmPitchAndFamily;
    ptm16->tmCharSet = ptm32->tmCharSet;
}

259
void FONT_TextMetricWTo16(const TEXTMETRICW *ptm32, LPTEXTMETRIC16 ptm16 )
Alexandre Julliard's avatar
Alexandre Julliard committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
{
    ptm16->tmHeight = ptm32->tmHeight;
    ptm16->tmAscent = ptm32->tmAscent;
    ptm16->tmDescent = ptm32->tmDescent;
    ptm16->tmInternalLeading = ptm32->tmInternalLeading;
    ptm16->tmExternalLeading = ptm32->tmExternalLeading;
    ptm16->tmAveCharWidth = ptm32->tmAveCharWidth;
    ptm16->tmMaxCharWidth = ptm32->tmMaxCharWidth;
    ptm16->tmWeight = ptm32->tmWeight;
    ptm16->tmOverhang = ptm32->tmOverhang;
    ptm16->tmDigitizedAspectX = ptm32->tmDigitizedAspectX;
    ptm16->tmDigitizedAspectY = ptm32->tmDigitizedAspectY;
    ptm16->tmFirstChar = ptm32->tmFirstChar;
    ptm16->tmLastChar = ptm32->tmLastChar;
    ptm16->tmDefaultChar = ptm32->tmDefaultChar;
    ptm16->tmBreakChar = ptm32->tmBreakChar;
    ptm16->tmItalic = ptm32->tmItalic;
    ptm16->tmUnderlined = ptm32->tmUnderlined;
    ptm16->tmStruckOut = ptm32->tmStruckOut;
    ptm16->tmPitchAndFamily = ptm32->tmPitchAndFamily;
    ptm16->tmCharSet = ptm32->tmCharSet;
}

283
void FONT_TextMetric16ToA(const TEXTMETRIC16 *ptm16, LPTEXTMETRICA ptm32 )
Alexandre Julliard's avatar
Alexandre Julliard committed
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
{
    ptm32->tmHeight = ptm16->tmHeight;
    ptm32->tmAscent = ptm16->tmAscent;
    ptm32->tmDescent = ptm16->tmDescent;
    ptm32->tmInternalLeading = ptm16->tmInternalLeading;
    ptm32->tmExternalLeading = ptm16->tmExternalLeading;
    ptm32->tmAveCharWidth = ptm16->tmAveCharWidth;
    ptm32->tmMaxCharWidth = ptm16->tmMaxCharWidth;
    ptm32->tmWeight = ptm16->tmWeight;
    ptm32->tmOverhang = ptm16->tmOverhang;
    ptm32->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
    ptm32->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
    ptm32->tmFirstChar = ptm16->tmFirstChar;
    ptm32->tmLastChar = ptm16->tmLastChar;
    ptm32->tmDefaultChar = ptm16->tmDefaultChar;
    ptm32->tmBreakChar = ptm16->tmBreakChar;
    ptm32->tmItalic = ptm16->tmItalic;
    ptm32->tmUnderlined = ptm16->tmUnderlined;
    ptm32->tmStruckOut = ptm16->tmStruckOut;
    ptm32->tmPitchAndFamily = ptm16->tmPitchAndFamily;
    ptm32->tmCharSet = ptm16->tmCharSet;
}

307
void FONT_TextMetric16ToW(const TEXTMETRIC16 *ptm16, LPTEXTMETRICW ptm32 )
Alexandre Julliard's avatar
Alexandre Julliard committed
308 309 310 311 312 313 314 315 316 317 318 319
{
    ptm32->tmHeight = ptm16->tmHeight;
    ptm32->tmAscent = ptm16->tmAscent;
    ptm32->tmDescent = ptm16->tmDescent;
    ptm32->tmInternalLeading = ptm16->tmInternalLeading;
    ptm32->tmExternalLeading = ptm16->tmExternalLeading;
    ptm32->tmAveCharWidth = ptm16->tmAveCharWidth;
    ptm32->tmMaxCharWidth = ptm16->tmMaxCharWidth;
    ptm32->tmWeight = ptm16->tmWeight;
    ptm32->tmOverhang = ptm16->tmOverhang;
    ptm32->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
    ptm32->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
Alexandre Julliard's avatar
Alexandre Julliard committed
320 321 322 323
    ptm32->tmFirstChar = ptm16->tmFirstChar;
    ptm32->tmLastChar = ptm16->tmLastChar;
    ptm32->tmDefaultChar = ptm16->tmDefaultChar;
    ptm32->tmBreakChar = ptm16->tmBreakChar;
Alexandre Julliard's avatar
Alexandre Julliard committed
324 325 326 327 328 329 330
    ptm32->tmItalic = ptm16->tmItalic;
    ptm32->tmUnderlined = ptm16->tmUnderlined;
    ptm32->tmStruckOut = ptm16->tmStruckOut;
    ptm32->tmPitchAndFamily = ptm16->tmPitchAndFamily;
    ptm32->tmCharSet = ptm16->tmCharSet;
}

331
void FONT_TextMetricAToW(const TEXTMETRICA *ptm32A, LPTEXTMETRICW ptm32W )
Alexandre Julliard's avatar
Alexandre Julliard committed
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
{
    ptm32W->tmHeight = ptm32A->tmHeight;
    ptm32W->tmAscent = ptm32A->tmAscent;
    ptm32W->tmDescent = ptm32A->tmDescent;
    ptm32W->tmInternalLeading = ptm32A->tmInternalLeading;
    ptm32W->tmExternalLeading = ptm32A->tmExternalLeading;
    ptm32W->tmAveCharWidth = ptm32A->tmAveCharWidth;
    ptm32W->tmMaxCharWidth = ptm32A->tmMaxCharWidth;
    ptm32W->tmWeight = ptm32A->tmWeight;
    ptm32W->tmOverhang = ptm32A->tmOverhang;
    ptm32W->tmDigitizedAspectX = ptm32A->tmDigitizedAspectX;
    ptm32W->tmDigitizedAspectY = ptm32A->tmDigitizedAspectY;
    ptm32W->tmFirstChar = ptm32A->tmFirstChar;
    ptm32W->tmLastChar = ptm32A->tmLastChar;
    ptm32W->tmDefaultChar = ptm32A->tmDefaultChar;
    ptm32W->tmBreakChar = ptm32A->tmBreakChar;
    ptm32W->tmItalic = ptm32A->tmItalic;
    ptm32W->tmUnderlined = ptm32A->tmUnderlined;
    ptm32W->tmStruckOut = ptm32A->tmStruckOut;
    ptm32W->tmPitchAndFamily = ptm32A->tmPitchAndFamily;
    ptm32W->tmCharSet = ptm32A->tmCharSet;
Alexandre Julliard's avatar
Alexandre Julliard committed
353
}
Alexandre Julliard's avatar
Alexandre Julliard committed
354

355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
void FONT_TextMetricWToA(const TEXTMETRICW *ptmW, LPTEXTMETRICA ptmA )
{
    ptmA->tmHeight = ptmW->tmHeight;
    ptmA->tmAscent = ptmW->tmAscent;
    ptmA->tmDescent = ptmW->tmDescent;
    ptmA->tmInternalLeading = ptmW->tmInternalLeading;
    ptmA->tmExternalLeading = ptmW->tmExternalLeading;
    ptmA->tmAveCharWidth = ptmW->tmAveCharWidth;
    ptmA->tmMaxCharWidth = ptmW->tmMaxCharWidth;
    ptmA->tmWeight = ptmW->tmWeight;
    ptmA->tmOverhang = ptmW->tmOverhang;
    ptmA->tmDigitizedAspectX = ptmW->tmDigitizedAspectX;
    ptmA->tmDigitizedAspectY = ptmW->tmDigitizedAspectY;
    ptmA->tmFirstChar = ptmW->tmFirstChar;
    ptmA->tmLastChar = ptmW->tmLastChar;
    ptmA->tmDefaultChar = ptmW->tmDefaultChar;
    ptmA->tmBreakChar = ptmW->tmBreakChar;
    ptmA->tmItalic = ptmW->tmItalic;
    ptmA->tmUnderlined = ptmW->tmUnderlined;
    ptmA->tmStruckOut = ptmW->tmStruckOut;
    ptmA->tmPitchAndFamily = ptmW->tmPitchAndFamily;
    ptmA->tmCharSet = ptmW->tmCharSet;
}


void FONT_NewTextMetricExWTo16(const NEWTEXTMETRICEXW *ptmW, LPNEWTEXTMETRICEX16 ptm16 )
{
    FONT_TextMetricWTo16((LPTEXTMETRICW)ptmW, (LPTEXTMETRIC16)ptm16);
383 384 385 386 387
    ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
    ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
    ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
    ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
    memcpy(&ptm16->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
388 389 390 391 392
}

void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, LPNEWTEXTMETRICEXA ptmA )
{
    FONT_TextMetricWToA((LPTEXTMETRICW)ptmW, (LPTEXTMETRICA)ptmA);
393 394 395 396 397
    ptmA->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
    ptmA->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
    ptmA->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
    ptmA->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
    memcpy(&ptmA->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
398 399 400 401 402
}

void FONT_NewTextMetricEx16ToW(const NEWTEXTMETRICEX16 *ptm16, LPNEWTEXTMETRICEXW ptmW )
{
    FONT_TextMetric16ToW((LPTEXTMETRIC16)ptm16, (LPTEXTMETRICW)ptmW);
403 404 405 406 407
    ptmW->ntmTm.ntmFlags = ptm16->ntmTm.ntmFlags;
    ptmW->ntmTm.ntmSizeEM = ptm16->ntmTm.ntmSizeEM;
    ptmW->ntmTm.ntmCellHeight = ptm16->ntmTm.ntmCellHeight;
    ptmW->ntmTm.ntmAvgWidth = ptm16->ntmTm.ntmAvgWidth;
    memcpy(&ptmW->ntmFontSig, &ptm16->ntmFontSig, sizeof(FONTSIGNATURE));
408 409 410
}


Alexandre Julliard's avatar
Alexandre Julliard committed
411
/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
412
 *           CreateFontIndirect16   (GDI.57)
Alexandre Julliard's avatar
Alexandre Julliard committed
413
 */
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *plf16 )
{
    LOGFONTW lfW;

    if(plf16) {
        FONT_LogFont16ToW( plf16, &lfW );
	return CreateFontIndirectW( &lfW );
    } else {
        return CreateFontIndirectW( NULL );
    }
}


/***********************************************************************
 *           CreateFontIndirectA   (GDI32.@)
 */
HFONT WINAPI CreateFontIndirectA( const LOGFONTA *plfA )
{
    LOGFONTW lfW;

    if (plfA) {
	FONT_LogFontAToW( plfA, &lfW );
	return CreateFontIndirectW( &lfW );
     } else
	return CreateFontIndirectW( NULL );

}

/***********************************************************************
 *           CreateFontIndirectW   (GDI32.@)
 */
HFONT WINAPI CreateFontIndirectW( const LOGFONTW *plf )
Alexandre Julliard's avatar
Alexandre Julliard committed
446
{
447
    HFONT hFont = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
448

449
    if (plf)
Alexandre Julliard's avatar
Alexandre Julliard committed
450
    {
451
        FONTOBJ* fontPtr;
452 453
	if ((fontPtr = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC, &hFont )))
	{
454
	    memcpy( &fontPtr->logfont, plf, sizeof(LOGFONTW) );
Alexandre Julliard's avatar
Alexandre Julliard committed
455

456 457 458 459 460 461
	    TRACE("(%ld %ld %ld %ld) '%s' %s %s => %04x\n",
                  plf->lfHeight, plf->lfWidth, 
                  plf->lfEscapement, plf->lfOrientation,
                  debugstr_w(plf->lfFaceName),
                  plf->lfWeight > 400 ? "Bold" : "",
                  plf->lfItalic ? "Italic" : "", hFont);
Alexandre Julliard's avatar
Alexandre Julliard committed
462

463
	    if (plf->lfEscapement != plf->lfOrientation) {
Alexandre Julliard's avatar
Alexandre Julliard committed
464 465
	      /* this should really depend on whether GM_ADVANCED is set */
	      fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement;
466 467
	      WARN("orientation angle %f set to "
                   "escapement angle %f for new font %04x\n", 
468
                   plf->lfOrientation/10., plf->lfEscapement/10., hFont);
Alexandre Julliard's avatar
Alexandre Julliard committed
469
	    }
470
	    GDI_ReleaseObj( hFont );
Alexandre Julliard's avatar
Alexandre Julliard committed
471
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
472
    }
473
    else WARN("(NULL) => NULL\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
474

Alexandre Julliard's avatar
Alexandre Julliard committed
475 476
    return hFont;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
477 478

/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
479
 *           CreateFont16    (GDI.56)
Alexandre Julliard's avatar
Alexandre Julliard committed
480
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
481 482 483 484 485
HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
                            INT16 weight, BYTE italic, BYTE underline,
                            BYTE strikeout, BYTE charset, BYTE outpres,
                            BYTE clippres, BYTE quality, BYTE pitch,
                            LPCSTR name )
Alexandre Julliard's avatar
Alexandre Julliard committed
486
{
487
    LOGFONT16 logfont;
Alexandre Julliard's avatar
Alexandre Julliard committed
488

489 490 491 492 493 494 495 496 497 498 499 500 501 502
    logfont.lfHeight = height;
    logfont.lfWidth = width;
    logfont.lfEscapement = esc;
    logfont.lfOrientation = orient;
    logfont.lfWeight = weight;
    logfont.lfItalic = italic;
    logfont.lfUnderline = underline;
    logfont.lfStrikeOut = strikeout;
    logfont.lfCharSet = charset;
    logfont.lfOutPrecision = outpres;
    logfont.lfClipPrecision = clippres;
    logfont.lfQuality = quality;
    logfont.lfPitchAndFamily = pitch;
   
Alexandre Julliard's avatar
Alexandre Julliard committed
503
    if (name) 
504
	lstrcpynA(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
Alexandre Julliard's avatar
Alexandre Julliard committed
505 506
    else 
	logfont.lfFaceName[0] = '\0';
507

Alexandre Julliard's avatar
Alexandre Julliard committed
508
    return CreateFontIndirect16( &logfont );
Alexandre Julliard's avatar
Alexandre Julliard committed
509 510
}

Alexandre Julliard's avatar
Alexandre Julliard committed
511
/*************************************************************************
512
 *           CreateFontA    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
513
 */
514 515
HFONT WINAPI CreateFontA( INT height, INT width, INT esc,
                              INT orient, INT weight, DWORD italic,
Alexandre Julliard's avatar
Alexandre Julliard committed
516 517 518
                              DWORD underline, DWORD strikeout, DWORD charset,
                              DWORD outpres, DWORD clippres, DWORD quality,
                              DWORD pitch, LPCSTR name )
Alexandre Julliard's avatar
Alexandre Julliard committed
519
{
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
    LOGFONTA logfont;

    logfont.lfHeight = height;
    logfont.lfWidth = width;
    logfont.lfEscapement = esc;
    logfont.lfOrientation = orient;
    logfont.lfWeight = weight;
    logfont.lfItalic = italic;
    logfont.lfUnderline = underline;
    logfont.lfStrikeOut = strikeout;
    logfont.lfCharSet = charset;
    logfont.lfOutPrecision = outpres;
    logfont.lfClipPrecision = clippres;
    logfont.lfQuality = quality;
    logfont.lfPitchAndFamily = pitch;
   
    if (name) 
	lstrcpynA(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
    else 
	logfont.lfFaceName[0] = '\0';

    return CreateFontIndirectA( &logfont );
Alexandre Julliard's avatar
Alexandre Julliard committed
542 543 544
}

/*************************************************************************
545
 *           CreateFontW    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
546
 */
547 548
HFONT WINAPI CreateFontW( INT height, INT width, INT esc,
                              INT orient, INT weight, DWORD italic,
Alexandre Julliard's avatar
Alexandre Julliard committed
549 550 551
                              DWORD underline, DWORD strikeout, DWORD charset,
                              DWORD outpres, DWORD clippres, DWORD quality,
                              DWORD pitch, LPCWSTR name )
Alexandre Julliard's avatar
Alexandre Julliard committed
552
{
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
    LOGFONTW logfont;

    logfont.lfHeight = height;
    logfont.lfWidth = width;
    logfont.lfEscapement = esc;
    logfont.lfOrientation = orient;
    logfont.lfWeight = weight;
    logfont.lfItalic = italic;
    logfont.lfUnderline = underline;
    logfont.lfStrikeOut = strikeout;
    logfont.lfCharSet = charset;
    logfont.lfOutPrecision = outpres;
    logfont.lfClipPrecision = clippres;
    logfont.lfQuality = quality;
    logfont.lfPitchAndFamily = pitch;
   
    if (name) 
	lstrcpynW(logfont.lfFaceName, name, 
		  sizeof(logfont.lfFaceName) / sizeof(WCHAR));
    else 
	logfont.lfFaceName[0] = '\0';

    return CreateFontIndirectW( &logfont );
Alexandre Julliard's avatar
Alexandre Julliard committed
576 577 578
}


Alexandre Julliard's avatar
Alexandre Julliard committed
579
/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
580
 *           FONT_GetObject16
Alexandre Julliard's avatar
Alexandre Julliard committed
581
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
582
INT16 FONT_GetObject16( FONTOBJ * font, INT16 count, LPSTR buffer )
Alexandre Julliard's avatar
Alexandre Julliard committed
583
{
584 585 586 587
    LOGFONT16 lf16;

    FONT_LogFontWTo16( &font->logfont, &lf16 );

Alexandre Julliard's avatar
Alexandre Julliard committed
588
    if (count > sizeof(LOGFONT16)) count = sizeof(LOGFONT16);
589
    memcpy( buffer, &lf16, count );
Alexandre Julliard's avatar
Alexandre Julliard committed
590 591 592
    return count;
}

Alexandre Julliard's avatar
Alexandre Julliard committed
593
/***********************************************************************
594
 *           FONT_GetObjectA
Alexandre Julliard's avatar
Alexandre Julliard committed
595
 */
596
INT FONT_GetObjectA( FONTOBJ *font, INT count, LPSTR buffer )
Alexandre Julliard's avatar
Alexandre Julliard committed
597
{
598
    LOGFONTA lfA;
Alexandre Julliard's avatar
Alexandre Julliard committed
599

600
    FONT_LogFontWToA( &font->logfont, &lfA );
Alexandre Julliard's avatar
Alexandre Julliard committed
601

602 603
    if (count > sizeof(lfA)) count = sizeof(lfA);
    memcpy( buffer, &lfA, count );
Alexandre Julliard's avatar
Alexandre Julliard committed
604 605
    return count;
}
606
/***********************************************************************
607
 *           FONT_GetObjectW
608
 */
609
INT FONT_GetObjectW( FONTOBJ *font, INT count, LPSTR buffer )
610
{
611 612
    if (count > sizeof(LOGFONTW)) count = sizeof(LOGFONTW);
    memcpy( buffer, &font->logfont, count );
613 614
    return count;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
615 616


Alexandre Julliard's avatar
Alexandre Julliard committed
617 618 619 620 621 622
/***********************************************************************
 *              FONT_EnumInstance16
 *
 * Called by the device driver layer to pass font info
 * down to the application.
 */
623 624
static INT FONT_EnumInstance16( LPENUMLOGFONTEXW plf, LPNEWTEXTMETRICEXW ptm,
				DWORD fType, LPARAM lp )
Alexandre Julliard's avatar
Alexandre Julliard committed
625 626 627 628 629
{
#define pfe ((fontEnum16*)lp)
    if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET || 
	pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
    {
630 631 632 633
        FONT_EnumLogFontExWTo16(plf, pfe->lpLogFont);
	FONT_NewTextMetricExWTo16(ptm, pfe->lpTextMetric);
        return pfe->lpEnumFunc( pfe->segLogFont, pfe->segTextMetric,
				(UINT16)fType, (LPARAM)(pfe->lpData) );
Alexandre Julliard's avatar
Alexandre Julliard committed
634 635 636 637 638 639
    }
#undef pfe
    return 1;
}

/***********************************************************************
640
 *              FONT_EnumInstance
Alexandre Julliard's avatar
Alexandre Julliard committed
641
 */
642 643
static INT FONT_EnumInstance( LPENUMLOGFONTEXW plf, LPNEWTEXTMETRICEXW ptm,
			      DWORD fType, LPARAM lp )
Alexandre Julliard's avatar
Alexandre Julliard committed
644
{
645
    /* lfCharSet is at the same offset in both LOGFONTA and LOGFONTW */
Alexandre Julliard's avatar
Alexandre Julliard committed
646 647 648 649 650 651 652 653 654

#define pfe ((fontEnum32*)lp)
    if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET || 
	pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
    {
	/* convert font metrics */

	if( pfe->dwFlags & ENUM_UNICODE )
	{
655
	    return pfe->lpEnumFunc( plf, ptm, fType, pfe->lpData );
Alexandre Julliard's avatar
Alexandre Julliard committed
656 657 658
	}
	else
	{
659
	    ENUMLOGFONTEXA logfont;
660
	    NEWTEXTMETRICEXA tmA;
661

662 663
	    FONT_EnumLogFontExWToA( plf, &logfont);
	    FONT_NewTextMetricExWToA( ptm, &tmA );
Alexandre Julliard's avatar
Alexandre Julliard committed
664

665
	    return pfe->lpEnumFunc( (LPENUMLOGFONTEXW)&logfont, 
666 667
				    (LPNEWTEXTMETRICEXW)&tmA, fType,
				    pfe->lpData );
668
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
669 670 671 672 673 674 675 676
    }
#undef pfe
    return 1;
}

/***********************************************************************
 *              EnumFontFamiliesEx16	(GDI.613)
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
677 678 679
INT16 WINAPI EnumFontFamiliesEx16( HDC16 hDC, LPLOGFONT16 plf,
                                   FONTENUMPROCEX16 efproc, LPARAM lParam,
                                   DWORD dwFlags)
Alexandre Julliard's avatar
Alexandre Julliard committed
680
{
681
    BOOL (*enum_func)(HDC,LPLOGFONTW,DEVICEFONTENUMPROC,LPARAM);
Alexandre Julliard's avatar
Alexandre Julliard committed
682
    INT16	retVal = 0;
683 684 685 686 687
    DC* 	dc = DC_GetDCPtr( hDC );

    if (!dc) return 0;
    enum_func = dc->funcs->pEnumDeviceFonts;
    GDI_ReleaseObj( hDC );
Alexandre Julliard's avatar
Alexandre Julliard committed
688

689
    if (enum_func)
Alexandre Julliard's avatar
Alexandre Julliard committed
690
    {
691
	LPNEWTEXTMETRICEX16 lptm16 = SEGPTR_ALLOC( sizeof(NEWTEXTMETRICEX16) );
Alexandre Julliard's avatar
Alexandre Julliard committed
692 693
	if( lptm16 )
	{
694
	    LPENUMLOGFONTEX16 lplf16 = SEGPTR_ALLOC( sizeof(ENUMLOGFONTEX16) );
Alexandre Julliard's avatar
Alexandre Julliard committed
695 696
	    if( lplf16 )
	    {
697
		fontEnum16	fe16;
698 699
		LOGFONTW        lfW;
		FONT_LogFont16ToW(plf, &lfW);
700 701 702 703 704 705 706 707 708

		fe16.lpLogFontParam = plf;
		fe16.lpEnumFunc = efproc;
		fe16.lpData = lParam;
		
		fe16.lpTextMetric = lptm16;
		fe16.lpLogFont = lplf16;
		fe16.segTextMetric = SEGPTR_GET(lptm16);
		fe16.segLogFont = SEGPTR_GET(lplf16);
Alexandre Julliard's avatar
Alexandre Julliard committed
709

710 711
		retVal = enum_func( hDC, &lfW, FONT_EnumInstance16,
				    (LPARAM)&fe16 );
Alexandre Julliard's avatar
Alexandre Julliard committed
712 713 714 715 716 717 718 719 720
		SEGPTR_FREE(lplf16);
	    }
	    SEGPTR_FREE(lptm16);
	}
    }
    return retVal;
}

/***********************************************************************
721
 *		FONT_EnumFontFamiliesEx
Alexandre Julliard's avatar
Alexandre Julliard committed
722
 */
723 724 725
static INT FONT_EnumFontFamiliesEx( HDC hDC, LPLOGFONTW plf,
				    FONTENUMPROCEXW efproc, 
				    LPARAM lParam, DWORD dwUnicode)
Alexandre Julliard's avatar
Alexandre Julliard committed
726
{
727
    BOOL (*enum_func)(HDC,LPLOGFONTW,DEVICEFONTENUMPROC,LPARAM);
728 729 730 731 732 733
    INT ret = 0;
    DC *dc = DC_GetDCPtr( hDC );

    if (!dc) return 0;
    enum_func = dc->funcs->pEnumDeviceFonts;
    GDI_ReleaseObj( hDC );
Alexandre Julliard's avatar
Alexandre Julliard committed
734

735
    if (enum_func)
Alexandre Julliard's avatar
Alexandre Julliard committed
736
    {
737
	fontEnum32 fe32;
738 739 740 741 742 743

	fe32.lpLogFontParam = plf;
	fe32.lpEnumFunc = efproc;
	fe32.lpData = lParam;
	
	fe32.dwFlags = dwUnicode;
Alexandre Julliard's avatar
Alexandre Julliard committed
744

745
	ret = enum_func( hDC, plf, FONT_EnumInstance, (LPARAM)&fe32 );
Alexandre Julliard's avatar
Alexandre Julliard committed
746
    }
747
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
748 749 750
}

/***********************************************************************
751
 *              EnumFontFamiliesExW	(GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
752
 */
753 754
INT WINAPI EnumFontFamiliesExW( HDC hDC, LPLOGFONTW plf,
                                    FONTENUMPROCEXW efproc, 
Alexandre Julliard's avatar
Alexandre Julliard committed
755
                                    LPARAM lParam, DWORD dwFlags )
Alexandre Julliard's avatar
Alexandre Julliard committed
756
{
757
    return  FONT_EnumFontFamiliesEx( hDC, plf, efproc, lParam, ENUM_UNICODE );
Alexandre Julliard's avatar
Alexandre Julliard committed
758 759 760
}

/***********************************************************************
761
 *              EnumFontFamiliesExA	(GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
762
 */
763 764
INT WINAPI EnumFontFamiliesExA( HDC hDC, LPLOGFONTA plf,
                                    FONTENUMPROCEXA efproc, 
Alexandre Julliard's avatar
Alexandre Julliard committed
765
                                    LPARAM lParam, DWORD dwFlags)
Alexandre Julliard's avatar
Alexandre Julliard committed
766
{
767 768 769 770 771
    LOGFONTW lfW;
    FONT_LogFontAToW( plf, &lfW );

    return  FONT_EnumFontFamiliesEx( hDC, &lfW,
				     (FONTENUMPROCEXW)efproc, lParam, 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
772 773 774 775 776
}

/***********************************************************************
 *              EnumFontFamilies16	(GDI.330)
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
777 778
INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
                                 FONTENUMPROC16 efproc, LPARAM lpData )
Alexandre Julliard's avatar
Alexandre Julliard committed
779 780 781 782
{
    LOGFONT16	lf;

    lf.lfCharSet = DEFAULT_CHARSET;
783
    if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
Alexandre Julliard's avatar
Alexandre Julliard committed
784 785 786 787 788 789
    else lf.lfFaceName[0] = '\0';

    return EnumFontFamiliesEx16( hDC, &lf, (FONTENUMPROCEX16)efproc, lpData, 0 );
}

/***********************************************************************
790
 *              EnumFontFamiliesA	(GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
791
 */
792 793
INT WINAPI EnumFontFamiliesA( HDC hDC, LPCSTR lpFamily,
                                  FONTENUMPROCA efproc, LPARAM lpData )
Alexandre Julliard's avatar
Alexandre Julliard committed
794
{
795
    LOGFONTA	lf;
Alexandre Julliard's avatar
Alexandre Julliard committed
796 797

    lf.lfCharSet = DEFAULT_CHARSET;
798
    if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
Alexandre Julliard's avatar
Alexandre Julliard committed
799 800
    else lf.lfFaceName[0] = lf.lfFaceName[1] = '\0';

801
    return EnumFontFamiliesExA( hDC, &lf, (FONTENUMPROCEXA)efproc, lpData, 0 );
Alexandre Julliard's avatar
Alexandre Julliard committed
802 803 804
}

/***********************************************************************
805
 *              EnumFontFamiliesW	(GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
806
 */
807 808
INT WINAPI EnumFontFamiliesW( HDC hDC, LPCWSTR lpFamily,
                                  FONTENUMPROCW efproc, LPARAM lpData )
Alexandre Julliard's avatar
Alexandre Julliard committed
809
{
810
    LOGFONTW  lf;
Alexandre Julliard's avatar
Alexandre Julliard committed
811 812

    lf.lfCharSet = DEFAULT_CHARSET;
813
    if( lpFamily ) lstrcpynW( lf.lfFaceName, lpFamily, LF_FACESIZE );
Alexandre Julliard's avatar
Alexandre Julliard committed
814 815
    else lf.lfFaceName[0] = 0;

816
    return EnumFontFamiliesExW( hDC, &lf, (FONTENUMPROCEXW)efproc, lpData, 0 );
Alexandre Julliard's avatar
Alexandre Julliard committed
817 818 819 820 821
}

/***********************************************************************
 *              EnumFonts16		(GDI.70)
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
822 823
INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
                          LPARAM lpData )
Alexandre Julliard's avatar
Alexandre Julliard committed
824 825 826 827 828
{
    return EnumFontFamilies16( hDC, lpName, (FONTENUMPROCEX16)efproc, lpData );
}

/***********************************************************************
829
 *              EnumFontsA		(GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
830
 */
831
INT WINAPI EnumFontsA( HDC hDC, LPCSTR lpName, FONTENUMPROCA efproc,
Alexandre Julliard's avatar
Alexandre Julliard committed
832
                           LPARAM lpData )
Alexandre Julliard's avatar
Alexandre Julliard committed
833
{
834
    return EnumFontFamiliesA( hDC, lpName, efproc, lpData );
Alexandre Julliard's avatar
Alexandre Julliard committed
835 836 837
}

/***********************************************************************
838
 *              EnumFontsW		(GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
839
 */
840
INT WINAPI EnumFontsW( HDC hDC, LPCWSTR lpName, FONTENUMPROCW efproc,
Alexandre Julliard's avatar
Alexandre Julliard committed
841
                           LPARAM lpData )
Alexandre Julliard's avatar
Alexandre Julliard committed
842
{
843
    return EnumFontFamiliesW( hDC, lpName, efproc, lpData );
Alexandre Julliard's avatar
Alexandre Julliard committed
844
}
Alexandre Julliard's avatar
Alexandre Julliard committed
845 846 847


/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
848
 *           GetTextCharacterExtra16    (GDI.89)
Alexandre Julliard's avatar
Alexandre Julliard committed
849
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
850
INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
Alexandre Julliard's avatar
Alexandre Julliard committed
851
{
852
    return (INT16)GetTextCharacterExtra( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
853 854 855 856
}


/***********************************************************************
857
 *           GetTextCharacterExtra    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
858
 */
859
INT WINAPI GetTextCharacterExtra( HDC hdc )
Alexandre Julliard's avatar
Alexandre Julliard committed
860
{
861
    INT ret;
862
    DC *dc = DC_GetDCPtr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
863
    if (!dc) return 0;
864
    ret = abs( (dc->charExtra * dc->wndExtX + dc->vportExtX / 2)
Alexandre Julliard's avatar
Alexandre Julliard committed
865
                 / dc->vportExtX );
866 867
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
868 869 870 871 872 873
}


/***********************************************************************
 *           SetTextCharacterExtra16    (GDI.8)
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
874
INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
Alexandre Julliard's avatar
Alexandre Julliard committed
875
{
876
    return (INT16)SetTextCharacterExtra( hdc, extra );
Alexandre Julliard's avatar
Alexandre Julliard committed
877 878 879 880
}


/***********************************************************************
881
 *           SetTextCharacterExtra    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
882
 */
883
INT WINAPI SetTextCharacterExtra( HDC hdc, INT extra )
Alexandre Julliard's avatar
Alexandre Julliard committed
884
{
885
    INT prev;
886
    DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
887
    if (!dc) return 0;
888
    if (dc->funcs->pSetTextCharacterExtra)
889 890 891 892
        prev = dc->funcs->pSetTextCharacterExtra( dc, extra );
    else
    {
        extra = (extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX;
893 894
        prev = (dc->charExtra * dc->wndExtX + dc->vportExtX / 2) / dc->vportExtX;
        dc->charExtra = abs(extra);
895 896 897
    }
    GDI_ReleaseObj( hdc );
    return prev;
Alexandre Julliard's avatar
Alexandre Julliard committed
898 899 900 901
}


/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
902
 *           SetTextJustification16    (GDI.10)
Alexandre Julliard's avatar
Alexandre Julliard committed
903
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
904
INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
Alexandre Julliard's avatar
Alexandre Julliard committed
905
{
906
    return SetTextJustification( hdc, extra, breaks );
Alexandre Julliard's avatar
Alexandre Julliard committed
907 908 909 910
}


/***********************************************************************
911
 *           SetTextJustification    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
912
 */
913
BOOL WINAPI SetTextJustification( HDC hdc, INT extra, INT breaks )
Alexandre Julliard's avatar
Alexandre Julliard committed
914
{
915
    BOOL ret = TRUE;
916
    DC * dc = DC_GetDCPtr( hdc );
917
    if (!dc) return FALSE;
918
    if (dc->funcs->pSetTextJustification)
919
        ret = dc->funcs->pSetTextJustification( dc, extra, breaks );
Alexandre Julliard's avatar
Alexandre Julliard committed
920 921
    else
    {
922 923
        extra = abs((extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX);
        if (!extra) breaks = 0;
924 925
        dc->breakTotalExtra = extra;
        dc->breakCount = breaks;
926 927
        if (breaks)
        {
928 929
            dc->breakExtra = extra / breaks;
            dc->breakRem   = extra - (dc->breakCount * dc->breakExtra);
930 931 932
        }
        else
        {
933 934
            dc->breakExtra = 0;
            dc->breakRem   = 0;
935
        }
Alexandre Julliard's avatar
Alexandre Julliard committed
936
    }
937 938
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
939 940
}

Alexandre Julliard's avatar
Alexandre Julliard committed
941

Alexandre Julliard's avatar
Alexandre Julliard committed
942 943 944
/***********************************************************************
 *           GetTextFace16    (GDI.92)
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
945
INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
Alexandre Julliard's avatar
Alexandre Julliard committed
946
{
947
        return GetTextFaceA(hdc,count,name);
Alexandre Julliard's avatar
Alexandre Julliard committed
948
}
Alexandre Julliard's avatar
Alexandre Julliard committed
949

Alexandre Julliard's avatar
Alexandre Julliard committed
950
/***********************************************************************
951
 *           GetTextFaceA    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
952
 */
953
INT WINAPI GetTextFaceA( HDC hdc, INT count, LPSTR name )
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971
{
    INT res = GetTextFaceW(hdc, 0, NULL);
    LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 );
    GetTextFaceW( hdc, res, nameW );
    
    if (name)
        res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count,
				   NULL, NULL);
    else
        res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
    HeapFree( GetProcessHeap(), 0, nameW );
    return res;
}

/***********************************************************************
 *           GetTextFaceW    (GDI32.@)
 */
INT WINAPI GetTextFaceW( HDC hdc, INT count, LPWSTR name )
Alexandre Julliard's avatar
Alexandre Julliard committed
972 973
{
    FONTOBJ *font;
974
    INT     ret = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
975

976
    DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
977
    if (!dc) return 0;
978

979
    if ((font = (FONTOBJ *) GDI_GetObjPtr( dc->hFont, FONT_MAGIC )))
980 981 982
    {
        if (name)
        {
983 984
            lstrcpynW( name, font->logfont.lfFaceName, count );
            ret = strlenW(name);
985
        }
986
        else ret = strlenW(font->logfont.lfFaceName) + 1;
987
        GDI_ReleaseObj( dc->hFont );
988 989 990
    }
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
991 992 993
}


Alexandre Julliard's avatar
Alexandre Julliard committed
994
/***********************************************************************
995
 *           GetTextExtent16    (GDI.91)
Alexandre Julliard's avatar
Alexandre Julliard committed
996
 */
997
DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
Alexandre Julliard's avatar
Alexandre Julliard committed
998
{
Alexandre Julliard's avatar
Alexandre Julliard committed
999 1000
    SIZE16 size;
    if (!GetTextExtentPoint16( hdc, str, count, &size )) return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1001
    return MAKELONG( size.cx, size.cy );
Alexandre Julliard's avatar
Alexandre Julliard committed
1002 1003 1004 1005
}


/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1006
 *           GetTextExtentPoint16    (GDI.471)
Alexandre Julliard's avatar
Alexandre Julliard committed
1007 1008 1009
 *
 * FIXME: Should this have a bug for compatibility?
 * Original Windows versions of GetTextExtentPoint{A,W} have documented
1010
 * bugs (-> MSDN KB q147647.txt).
Alexandre Julliard's avatar
Alexandre Julliard committed
1011
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1012 1013
BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count,
                                    LPSIZE16 size )
Alexandre Julliard's avatar
Alexandre Julliard committed
1014
{
1015
    SIZE size32;
1016
    BOOL ret;
1017
    TRACE("%04x, %p (%s), %d, %p\n", hdc, str, debugstr_an(str, count), count, size);
1018
    ret = GetTextExtentPoint32A( hdc, str, count, &size32 );
1019 1020
    size->cx = size32.cx;
    size->cy = size32.cy;
Alexandre Julliard's avatar
Alexandre Julliard committed
1021 1022 1023 1024 1025
    return (BOOL16)ret;
}


/***********************************************************************
1026
 *           GetTextExtentPoint32A    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1027
 */
1028 1029
BOOL WINAPI GetTextExtentPoint32A( HDC hdc, LPCSTR str, INT count,
                                     LPSIZE size )
Alexandre Julliard's avatar
Alexandre Julliard committed
1030
{
1031
    BOOL ret = FALSE;
1032
    UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
1033
    DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
1034

1035
    if (!dc) return FALSE;
Hidenori Takeshima's avatar
Hidenori Takeshima committed
1036

1037 1038 1039 1040 1041
    if (dc->funcs->pGetTextExtentPoint)
    {
        /* str may not be 0 terminated so we can't use HEAP_strdupWtoA.
         * So we use MultiByteToWideChar.
         */
1042
        UINT wlen = MultiByteToWideChar(codepage,0,str,count,NULL,0);
1043 1044 1045
        LPWSTR p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) );
        if (p)
        {
1046
            wlen = MultiByteToWideChar(codepage,0,str,count,p,wlen);
1047 1048 1049 1050 1051
            ret = dc->funcs->pGetTextExtentPoint( dc, p, wlen, size );
            HeapFree( GetProcessHeap(), 0, p );
        }
    }
    GDI_ReleaseObj( hdc );
Gerald Pfeifer's avatar
Gerald Pfeifer committed
1052
    TRACE("(%08x %s %d %p): returning %ld x %ld\n",
1053
          hdc, debugstr_an (str, count), count, size, size->cx, size->cy );
1054
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1055 1056 1057
}


Alexandre Julliard's avatar
Alexandre Julliard committed
1058
/***********************************************************************
1059
 * GetTextExtentPoint32W [GDI32.@]  Computes width/height for a string
Alexandre Julliard's avatar
Alexandre Julliard committed
1060 1061 1062 1063 1064 1065
 *
 * Computes width and height of the specified string.
 *
 * RETURNS
 *    Success: TRUE
 *    Failure: FALSE
Alexandre Julliard's avatar
Alexandre Julliard committed
1066
 */
1067 1068
BOOL WINAPI GetTextExtentPoint32W(
    HDC hdc,     /* [in]  Handle of device context */
Alexandre Julliard's avatar
Alexandre Julliard committed
1069
    LPCWSTR str,   /* [in]  Address of text string */
1070 1071
    INT count,   /* [in]  Number of characters in string */
    LPSIZE size) /* [out] Address of structure for string size */
Alexandre Julliard's avatar
Alexandre Julliard committed
1072
{
1073
    BOOL ret = FALSE;
1074
    DC * dc = DC_GetDCPtr( hdc );
1075 1076 1077 1078 1079 1080
    if (dc)
    {
	if(dc->funcs->pGetTextExtentPoint)
	    ret = dc->funcs->pGetTextExtentPoint( dc, str, count, size );
        GDI_ReleaseObj( hdc );
    }
Gerald Pfeifer's avatar
Gerald Pfeifer committed
1081
    TRACE("(%08x %s %d %p): returning %ld x %ld\n",
1082
          hdc, debugstr_wn (str, count), count, size, size->cx, size->cy );
1083
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1084 1085
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1086

Alexandre Julliard's avatar
Alexandre Julliard committed
1087
/***********************************************************************
1088
 *           GetTextExtentPointA    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1089
 */
1090 1091
BOOL WINAPI GetTextExtentPointA( HDC hdc, LPCSTR str, INT count,
                                          LPSIZE size )
Alexandre Julliard's avatar
Alexandre Julliard committed
1092
{
1093
    TRACE("not bug compatible.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
1094 1095 1096 1097
    return GetTextExtentPoint32A( hdc, str, count, size );
}

/***********************************************************************
1098
 *           GetTextExtentPointW   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1099
 */
1100 1101
BOOL WINAPI GetTextExtentPointW( HDC hdc, LPCWSTR str, INT count,
                                          LPSIZE size )
Alexandre Julliard's avatar
Alexandre Julliard committed
1102
{
1103
    TRACE("not bug compatible.\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
1104 1105 1106
    return GetTextExtentPoint32W( hdc, str, count, size );
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1107

Alexandre Julliard's avatar
Alexandre Julliard committed
1108
/***********************************************************************
1109
 *           GetTextExtentExPointA    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1110
 */
1111
BOOL WINAPI GetTextExtentExPointA( HDC hdc, LPCSTR str, INT count,
1112 1113 1114 1115 1116
				   INT maxExt, LPINT lpnFit,
				   LPINT alpDx, LPSIZE size )
{
    BOOL ret;

1117 1118 1119 1120
    DWORD len = MultiByteToWideChar( CP_ACP, 0, str, count, NULL, 0 );
    LPWSTR p = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
    MultiByteToWideChar( CP_ACP, 0, str, count, p, len );
    ret = GetTextExtentExPointW( hdc, p, len, maxExt, lpnFit, alpDx, size);
1121 1122 1123 1124 1125 1126
    HeapFree( GetProcessHeap(), 0, p );
    return ret;
}


/***********************************************************************
1127
 *           GetTextExtentExPointW    (GDI32.@)
1128 1129 1130 1131 1132
 */

BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count,
				   INT maxExt, LPINT lpnFit,
				   LPINT alpDx, LPSIZE size )
Alexandre Julliard's avatar
Alexandre Julliard committed
1133
{
Alexandre Julliard's avatar
Alexandre Julliard committed
1134
    int index, nFit, extent;
1135
    SIZE tSize;
1136
    BOOL ret = FALSE;
1137
    DC * dc = DC_GetDCPtr( hdc );
1138
    if (!dc) return FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1139

1140
    if (!dc->funcs->pGetTextExtentPoint) goto done;
Alexandre Julliard's avatar
Alexandre Julliard committed
1141

Alexandre Julliard's avatar
Alexandre Julliard committed
1142 1143
    size->cx = size->cy = nFit = extent = 0;
    for(index = 0; index < count; index++)
Alexandre Julliard's avatar
Alexandre Julliard committed
1144
    {
1145
 	if(!dc->funcs->pGetTextExtentPoint( dc, str, 1, &tSize )) goto done;
Alexandre Julliard's avatar
Alexandre Julliard committed
1146 1147 1148 1149 1150 1151 1152 1153 1154
	if( extent+tSize.cx < maxExt )
        {
	    extent+=tSize.cx;
	    nFit++;
	    str++;
	    if( alpDx ) alpDx[index] = extent;
	    if( tSize.cy > size->cy ) size->cy = tSize.cy;
        }
        else break;
Alexandre Julliard's avatar
Alexandre Julliard committed
1155
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
1156
    size->cx = extent;
1157
    if(lpnFit) *lpnFit = nFit;
1158
    ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1159

Gerald Pfeifer's avatar
Gerald Pfeifer committed
1160
    TRACE("(%08x %s %d) returning %d %ld x %ld\n",
1161
          hdc,debugstr_wn(str,count),maxExt,nFit, size->cx,size->cy);
Gerald Pfeifer's avatar
Gerald Pfeifer committed
1162

1163 1164 1165
done:
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1166 1167
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1168
/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1169
 *           GetTextMetrics16    (GDI.93)
Alexandre Julliard's avatar
Alexandre Julliard committed
1170
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1171
BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *metrics )
Alexandre Julliard's avatar
Alexandre Julliard committed
1172
{
1173
    TEXTMETRICW tm32;
Alexandre Julliard's avatar
Alexandre Julliard committed
1174

1175 1176
    if (!GetTextMetricsW( (HDC)hdc, &tm32 )) return FALSE;
    FONT_TextMetricWTo16( &tm32, metrics );
Alexandre Julliard's avatar
Alexandre Julliard committed
1177 1178
    return TRUE;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1179

Alexandre Julliard's avatar
Alexandre Julliard committed
1180 1181

/***********************************************************************
1182
 *           GetTextMetricsA    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1183
 */
1184
BOOL WINAPI GetTextMetricsA( HDC hdc, TEXTMETRICA *metrics )
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
{
    TEXTMETRICW tm32;

    if (!GetTextMetricsW( hdc, &tm32 )) return FALSE;
    FONT_TextMetricWToA( &tm32, metrics );
    return TRUE;
}

/***********************************************************************
 *           GetTextMetricsW    (GDI32.@)
 */
BOOL WINAPI GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
{
1198 1199 1200
    BOOL ret = FALSE;
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1201

1202 1203
    if (dc->funcs->pGetTextMetrics && dc->funcs->pGetTextMetrics( dc, metrics ))
    {
Alexandre Julliard's avatar
Alexandre Julliard committed
1204 1205 1206
    /* device layer returns values in device units
     * therefore we have to convert them to logical */

Alexandre Julliard's avatar
Alexandre Julliard committed
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
#define WDPTOLP(x) ((x<0)?					\
		(-abs((x)*dc->wndExtX/dc->vportExtX)):		\
		(abs((x)*dc->wndExtX/dc->vportExtX)))
#define HDPTOLP(y) ((y<0)?					\
		(-abs((y)*dc->wndExtY/dc->vportExtY)):		\
		(abs((y)*dc->wndExtY/dc->vportExtY)))
	
    metrics->tmHeight           = HDPTOLP(metrics->tmHeight);
    metrics->tmAscent           = HDPTOLP(metrics->tmAscent);
    metrics->tmDescent          = HDPTOLP(metrics->tmDescent);
    metrics->tmInternalLeading  = HDPTOLP(metrics->tmInternalLeading);
    metrics->tmExternalLeading  = HDPTOLP(metrics->tmExternalLeading);
    metrics->tmAveCharWidth     = WDPTOLP(metrics->tmAveCharWidth);
    metrics->tmMaxCharWidth     = WDPTOLP(metrics->tmMaxCharWidth);
    metrics->tmOverhang         = WDPTOLP(metrics->tmOverhang);
1222
        ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1223

1224
    TRACE("text metrics:\n"
1225 1226 1227 1228
          "    Weight = %03li\t FirstChar = %i\t AveCharWidth = %li\n"
          "    Italic = % 3i\t LastChar = %i\t\t MaxCharWidth = %li\n"
          "    UnderLined = %01i\t DefaultChar = %i\t Overhang = %li\n"
          "    StruckOut = %01i\t BreakChar = %i\t CharSet = %i\n"
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243
          "    PitchAndFamily = %02x\n"
          "    --------------------\n"
          "    InternalLeading = %li\n"
          "    Ascent = %li\n"
          "    Descent = %li\n"
          "    Height = %li\n",
          metrics->tmWeight, metrics->tmFirstChar, metrics->tmAveCharWidth,
          metrics->tmItalic, metrics->tmLastChar, metrics->tmMaxCharWidth,
          metrics->tmUnderlined, metrics->tmDefaultChar, metrics->tmOverhang,
          metrics->tmStruckOut, metrics->tmBreakChar, metrics->tmCharSet,
          metrics->tmPitchAndFamily,
          metrics->tmInternalLeading,
          metrics->tmAscent,
          metrics->tmDescent,
          metrics->tmHeight );
1244 1245 1246
    }
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1247 1248 1249
}


Alexandre Julliard's avatar
Alexandre Julliard committed
1250
/***********************************************************************
1251
 * GetOutlineTextMetrics16 [GDI.308]  Gets metrics for TrueType fonts.
Alexandre Julliard's avatar
Alexandre Julliard committed
1252 1253 1254 1255 1256 1257 1258 1259
 *
 * NOTES
 *    lpOTM should be LPOUTLINETEXTMETRIC
 *
 * RETURNS
 *    Success: Non-zero or size of required buffer
 *    Failure: 0
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1260
UINT16 WINAPI GetOutlineTextMetrics16(
Alexandre Julliard's avatar
Alexandre Julliard committed
1261
    HDC16 hdc,    /* [in]  Handle of device context */
Alexandre Julliard's avatar
Alexandre Julliard committed
1262
    UINT16 cbData, /* [in]  Size of metric data array */
1263
    LPOUTLINETEXTMETRIC16 lpOTM)  /* [out] Address of metric data array */
Alexandre Julliard's avatar
Alexandre Julliard committed
1264
{
1265
    FIXME("(%04x,%04x,%p): stub\n", hdc,cbData,lpOTM);
Alexandre Julliard's avatar
Alexandre Julliard committed
1266 1267 1268 1269
    return 0;
}


1270
/***********************************************************************
1271 1272 1273
 *		GetOutlineTextMetrics (GDI.207)
 *		GetOutlineTextMetricsA (GDI32.@)
 * Gets metrics for TrueType fonts.
1274 1275 1276 1277 1278 1279
 *
 *
 * RETURNS
 *    Success: Non-zero or size of required buffer
 *    Failure: 0
 */
1280 1281 1282 1283
UINT WINAPI GetOutlineTextMetricsA(
    HDC hdc,    /* [in]  Handle of device context */
    UINT cbData, /* [in]  Size of metric data array */
    LPOUTLINETEXTMETRICA lpOTM)  /* [out] Address of metric data array */
1284 1285 1286
{


1287 1288
    UINT rtn = FALSE;
    LPTEXTMETRICA lptxtMetr;
1289 1290 1291 1292 1293 1294



    if (lpOTM == 0)
    {
        
1295 1296
        lpOTM = (LPOUTLINETEXTMETRICA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(OUTLINETEXTMETRICA));
        rtn = sizeof(OUTLINETEXTMETRICA);
1297 1298 1299 1300 1301 1302 1303 1304 1305
        cbData = rtn;
    } else
    {
        cbData = sizeof(*lpOTM);
        rtn = cbData;
    };

    lpOTM->otmSize = cbData;

1306
    lptxtMetr =HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TEXTMETRICA));
1307
    
1308
    if (!GetTextMetricsA(hdc,lptxtMetr))
1309 1310 1311 1312
    {
        return 0;
    } else
    {
1313
       memcpy(&(lpOTM->otmTextMetrics),lptxtMetr,sizeof(TEXTMETRICA));
1314 1315 1316 1317
    };

    HeapFree(GetProcessHeap(),HEAP_ZERO_MEMORY,lptxtMetr);
    
1318
    lpOTM->otmFiller = 0;
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341

    lpOTM->otmPanoseNumber.bFamilyType  = 0;
    lpOTM->otmPanoseNumber.bSerifStyle  = 0;
    lpOTM->otmPanoseNumber.bWeight      = 0;
    lpOTM->otmPanoseNumber.bProportion  = 0;
    lpOTM->otmPanoseNumber.bContrast    = 0;
    lpOTM->otmPanoseNumber.bStrokeVariation = 0;
    lpOTM->otmPanoseNumber.bArmStyle    = 0;
    lpOTM->otmPanoseNumber.bLetterform  = 0;
    lpOTM->otmPanoseNumber.bMidline     = 0;
    lpOTM->otmPanoseNumber.bXHeight     = 0;

    lpOTM->otmfsSelection     = 0;
    lpOTM->otmfsType          = 0;

    /*
     Further fill of the structure not implemented,
     Needs real values for the structure members
     */
    
    return rtn;
}

1342
/***********************************************************************
1343
 *           GetOutlineTextMetricsW [GDI32.@]
1344
 */
1345 1346 1347 1348
UINT WINAPI GetOutlineTextMetricsW(
    HDC hdc,    /* [in]  Handle of device context */
    UINT cbData, /* [in]  Size of metric data array */
    LPOUTLINETEXTMETRICW lpOTM)  /* [out] Address of metric data array */
1349
{
1350
    FIXME("(%d,%d,%p): stub\n", hdc, cbData, lpOTM);
1351 1352
    return 0; 
}
1353

Alexandre Julliard's avatar
Alexandre Julliard committed
1354 1355
/***********************************************************************
 *           GetCharWidth16    (GDI.350)
1356
 *           GetCharWidth16    (DISPLAY.350)
Alexandre Julliard's avatar
Alexandre Julliard committed
1357
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1358 1359
BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
                              LPINT16 buffer )
Alexandre Julliard's avatar
Alexandre Julliard committed
1360
{
1361
    BOOL	retVal = FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1362 1363

    if( firstChar != lastChar )
Alexandre Julliard's avatar
Alexandre Julliard committed
1364
    {
1365 1366
	LPINT	buf32 = (LPINT)HeapAlloc(GetProcessHeap(), 0,
				 sizeof(INT)*(1 + (lastChar - firstChar)));
Alexandre Julliard's avatar
Alexandre Julliard committed
1367
	if( buf32 )
Alexandre Julliard's avatar
Alexandre Julliard committed
1368
	{
1369
	    LPINT	obuf32 = buf32;
Alexandre Julliard's avatar
Alexandre Julliard committed
1370 1371 1372 1373 1374 1375 1376 1377
	    int		i;

            retVal = GetCharWidth32A(hdc, firstChar, lastChar, buf32);
	    if (retVal)
	    {
		for (i = firstChar; i <= lastChar; i++)
		    *buffer++ = *buf32++;
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
1378
	    HeapFree(GetProcessHeap(), 0, obuf32);
Alexandre Julliard's avatar
Alexandre Julliard committed
1379
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
1380
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
1381
    else /* happens quite often to warrant a special treatment */
Alexandre Julliard's avatar
Alexandre Julliard committed
1382
    {
1383
	INT chWidth;
Alexandre Julliard's avatar
Alexandre Julliard committed
1384
	retVal = GetCharWidth32A(hdc, firstChar, lastChar, &chWidth );
Alexandre Julliard's avatar
Alexandre Julliard committed
1385
       *buffer = chWidth;
Alexandre Julliard's avatar
Alexandre Julliard committed
1386
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
1387
    return retVal;
Alexandre Julliard's avatar
Alexandre Julliard committed
1388 1389 1390 1391
}


/***********************************************************************
1392
 *           GetCharWidth32A    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1393
 */
1394 1395
BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
                               LPINT buffer )
Alexandre Julliard's avatar
Alexandre Julliard committed
1396
{
1397
    UINT i, extra;
1398 1399 1400
    BOOL ret = FALSE;
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1401

1402 1403 1404
    if (dc->funcs->pGetCharWidth && dc->funcs->pGetCharWidth( dc, firstChar, lastChar, buffer))
    {
        /* convert device units to logical */
Alexandre Julliard's avatar
Alexandre Julliard committed
1405

1406 1407 1408 1409 1410 1411 1412
        extra = dc->vportExtX >> 1;
        for( i = firstChar; i <= lastChar; i++, buffer++ )
            *buffer = (*buffer * dc->wndExtX + extra) / dc->vportExtX;
        ret = TRUE;
    }
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1413
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1414

Alexandre Julliard's avatar
Alexandre Julliard committed
1415

Alexandre Julliard's avatar
Alexandre Julliard committed
1416
/***********************************************************************
1417
 *           GetCharWidth32W    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1418
 */
1419 1420
BOOL WINAPI GetCharWidth32W( HDC hdc, UINT firstChar, UINT lastChar,
                               LPINT buffer )
Alexandre Julliard's avatar
Alexandre Julliard committed
1421 1422 1423 1424 1425
{
    return GetCharWidth32A( hdc, firstChar, lastChar, buffer );
}


1426 1427
/* FIXME: all following APIs ******************************************/
 
Alexandre Julliard's avatar
Alexandre Julliard committed
1428

1429
/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1430
 *           SetMapperFlags16    (GDI.349)
Alexandre Julliard's avatar
Alexandre Julliard committed
1431
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1432
DWORD WINAPI SetMapperFlags16( HDC16 hDC, DWORD dwFlag )
Alexandre Julliard's avatar
Alexandre Julliard committed
1433
{
1434
    return SetMapperFlags( hDC, dwFlag );
Alexandre Julliard's avatar
Alexandre Julliard committed
1435 1436 1437 1438
}


/***********************************************************************
1439
 *           SetMapperFlags    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1440
 */
1441
DWORD WINAPI SetMapperFlags( HDC hDC, DWORD dwFlag )
Alexandre Julliard's avatar
Alexandre Julliard committed
1442
{
1443 1444 1445 1446 1447 1448
    DC *dc = DC_GetDCPtr( hDC );
    DWORD ret = 0; 
    if(!dc) return 0;
    if(dc->funcs->pSetMapperFlags)
        ret = dc->funcs->pSetMapperFlags( dc, dwFlag );
    else
1449
        FIXME("(0x%04x, 0x%08lx): stub - harmless\n", hDC, dwFlag);
1450
    GDI_ReleaseObj( hDC );
1451
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1452 1453
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1454 1455 1456
/***********************************************************************
 *          GetAspectRatioFilterEx16  (GDI.486)
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1457
BOOL16 WINAPI GetAspectRatioFilterEx16( HDC16 hdc, LPSIZE16 pAspectRatio )
Alexandre Julliard's avatar
Alexandre Julliard committed
1458
{
1459
  FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
Alexandre Julliard's avatar
Alexandre Julliard committed
1460 1461 1462
  return FALSE;
}

1463
/***********************************************************************
1464
 *          GetAspectRatioFilterEx  (GDI32.@)
1465
 */
1466
BOOL WINAPI GetAspectRatioFilterEx( HDC hdc, LPSIZE pAspectRatio )
1467
{
1468
  FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
1469 1470
  return FALSE;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1471 1472

/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1473
 *           GetCharABCWidths16   (GDI.307)
Alexandre Julliard's avatar
Alexandre Julliard committed
1474
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1475 1476
BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
                                  LPABC16 abc )
Alexandre Julliard's avatar
Alexandre Julliard committed
1477
{
1478 1479
    ABC abc32;
    if (!GetCharABCWidthsA( hdc, firstChar, lastChar, &abc32 )) return FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1480 1481 1482 1483
    abc->abcA = abc32.abcA;
    abc->abcB = abc32.abcB;
    abc->abcC = abc32.abcC;
    return TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1484 1485 1486 1487
}


/***********************************************************************
1488
 *           GetCharABCWidthsA   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1489
 */
1490 1491
BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
                                  LPABC abc )
Alexandre Julliard's avatar
Alexandre Julliard committed
1492
{
1493
    return GetCharABCWidthsW( hdc, firstChar, lastChar, abc );
Alexandre Julliard's avatar
Alexandre Julliard committed
1494 1495 1496
}


Alexandre Julliard's avatar
Alexandre Julliard committed
1497
/******************************************************************************
1498
 * GetCharABCWidthsW [GDI32.@]  Retrieves widths of characters in range
Alexandre Julliard's avatar
Alexandre Julliard committed
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511
 *
 * PARAMS
 *    hdc       [I] Handle of device context
 *    firstChar [I] First character in range to query
 *    lastChar  [I] Last character in range to query
 *    abc       [O] Address of character-width structure
 *
 * NOTES
 *    Only works with TrueType fonts
 *
 * RETURNS
 *    Success: TRUE
 *    Failure: FALSE
Alexandre Julliard's avatar
Alexandre Julliard committed
1512
 */
1513 1514
BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar,
                                   LPABC abc )
Alexandre Julliard's avatar
Alexandre Julliard committed
1515
{
Alexandre Julliard's avatar
Alexandre Julliard committed
1516
    /* No TrueType fonts in Wine so far */
1517
    FIXME("(%04x,%04x,%04x,%p): stub\n", hdc, firstChar, lastChar, abc);
Alexandre Julliard's avatar
Alexandre Julliard committed
1518
    return FALSE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1519 1520
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1521 1522

/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1523
 *           GetGlyphOutline16    (GDI.309)
Alexandre Julliard's avatar
Alexandre Julliard committed
1524
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1525 1526 1527
DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
                                LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
                                LPVOID lpBuffer, const MAT2 *lpmat2 )
Alexandre Julliard's avatar
Alexandre Julliard committed
1528
{
1529
    FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
Alexandre Julliard's avatar
Alexandre Julliard committed
1530
	  hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
Alexandre Julliard's avatar
Alexandre Julliard committed
1531
    return (DWORD)-1; /* failure */
Alexandre Julliard's avatar
Alexandre Julliard committed
1532 1533
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1534

Alexandre Julliard's avatar
Alexandre Julliard committed
1535
/***********************************************************************
1536
 *           GetGlyphOutlineA    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1537
 */
1538 1539
DWORD WINAPI GetGlyphOutlineA( HDC hdc, UINT uChar, UINT fuFormat,
                                 LPGLYPHMETRICS lpgm, DWORD cbBuffer,
Alexandre Julliard's avatar
Alexandre Julliard committed
1540
                                 LPVOID lpBuffer, const MAT2 *lpmat2 )
Alexandre Julliard's avatar
Alexandre Julliard committed
1541
{
1542
    FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
Alexandre Julliard's avatar
Alexandre Julliard committed
1543
	  hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
Alexandre Julliard's avatar
Alexandre Julliard committed
1544
    return (DWORD)-1; /* failure */
Alexandre Julliard's avatar
Alexandre Julliard committed
1545 1546
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1547
/***********************************************************************
1548
 *           GetGlyphOutlineW    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1549
 */
1550 1551
DWORD WINAPI GetGlyphOutlineW( HDC hdc, UINT uChar, UINT fuFormat,
                                 LPGLYPHMETRICS lpgm, DWORD cbBuffer,
Alexandre Julliard's avatar
Alexandre Julliard committed
1552
                                 LPVOID lpBuffer, const MAT2 *lpmat2 )
Alexandre Julliard's avatar
Alexandre Julliard committed
1553
{
1554
    FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
Alexandre Julliard's avatar
Alexandre Julliard committed
1555
	  hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
Alexandre Julliard's avatar
Alexandre Julliard committed
1556
    return (DWORD)-1; /* failure */
Alexandre Julliard's avatar
Alexandre Julliard committed
1557
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1558

Alexandre Julliard's avatar
Alexandre Julliard committed
1559 1560
/***********************************************************************
 *           CreateScalableFontResource16   (GDI.310)
Alexandre Julliard's avatar
Alexandre Julliard committed
1561
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1562 1563 1564
BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden,
                                            LPCSTR lpszResourceFile,
                                            LPCSTR fontFile, LPCSTR path )
Alexandre Julliard's avatar
Alexandre Julliard committed
1565
{
1566
    return CreateScalableFontResourceA( fHidden, lpszResourceFile,
Alexandre Julliard's avatar
Alexandre Julliard committed
1567
                                          fontFile, path );
Alexandre Julliard's avatar
Alexandre Julliard committed
1568 1569
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1570
/***********************************************************************
1571
 *           CreateScalableFontResourceA   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1572
 */
1573
BOOL WINAPI CreateScalableFontResourceA( DWORD fHidden,
Alexandre Julliard's avatar
Alexandre Julliard committed
1574 1575 1576
                                             LPCSTR lpszResourceFile,
                                             LPCSTR lpszFontFile,
                                             LPCSTR lpszCurrentPath )
Alexandre Julliard's avatar
Alexandre Julliard committed
1577
{
Alexandre Julliard's avatar
Alexandre Julliard committed
1578 1579 1580 1581
    /* fHidden=1 - only visible for the calling app, read-only, not
     * enumbered with EnumFonts/EnumFontFamilies
     * lpszCurrentPath can be NULL
     */
1582
    FIXME("(%ld,%s,%s,%s): stub\n",
Alexandre Julliard's avatar
Alexandre Julliard committed
1583
	  fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
Alexandre Julliard's avatar
Alexandre Julliard committed
1584
    return FALSE; /* create failed */
Alexandre Julliard's avatar
Alexandre Julliard committed
1585 1586
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1587
/***********************************************************************
1588
 *           CreateScalableFontResourceW   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1589
 */
1590
BOOL WINAPI CreateScalableFontResourceW( DWORD fHidden,
Alexandre Julliard's avatar
Alexandre Julliard committed
1591 1592 1593
                                             LPCWSTR lpszResourceFile,
                                             LPCWSTR lpszFontFile,
                                             LPCWSTR lpszCurrentPath )
Alexandre Julliard's avatar
Alexandre Julliard committed
1594
{
1595
    FIXME("(%ld,%p,%p,%p): stub\n",
Alexandre Julliard's avatar
Alexandre Julliard committed
1596
	  fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
Alexandre Julliard's avatar
Alexandre Julliard committed
1597
    return FALSE; /* create failed */
Alexandre Julliard's avatar
Alexandre Julliard committed
1598 1599 1600
}


Alexandre Julliard's avatar
Alexandre Julliard committed
1601
/*************************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1602
 *             GetRasterizerCaps16   (GDI.313)
Alexandre Julliard's avatar
Alexandre Julliard committed
1603
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1604
BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes)
Alexandre Julliard's avatar
Alexandre Julliard committed
1605
{
1606
    return GetRasterizerCaps( lprs, cbNumBytes );
Alexandre Julliard's avatar
Alexandre Julliard committed
1607
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1608

Alexandre Julliard's avatar
Alexandre Julliard committed
1609 1610

/*************************************************************************
1611
 *             GetRasterizerCaps   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1612
 */
1613
BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
Alexandre Julliard's avatar
Alexandre Julliard committed
1614
{
Alexandre Julliard's avatar
Alexandre Julliard committed
1615 1616 1617
  lprs->nSize = sizeof(RASTERIZER_STATUS);
  lprs->wFlags = TT_AVAILABLE|TT_ENABLED;
  lprs->nLanguageID = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1618
  return TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
1619
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1620

Alexandre Julliard's avatar
Alexandre Julliard committed
1621

Alexandre Julliard's avatar
Alexandre Julliard committed
1622
/*************************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1623
 *             GetKerningPairs16   (GDI.332)
Alexandre Julliard's avatar
Alexandre Julliard committed
1624
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
1625 1626
INT16 WINAPI GetKerningPairs16( HDC16 hDC, INT16 cPairs,
                                LPKERNINGPAIR16 lpKerningPairs )
Alexandre Julliard's avatar
Alexandre Julliard committed
1627
{
Alexandre Julliard's avatar
Alexandre Julliard committed
1628
    /* At this time kerning is ignored (set to 0) */
Alexandre Julliard's avatar
Alexandre Julliard committed
1629
    int i;
1630
    FIXME("(%x,%d,%p): almost empty stub!\n", hDC, cPairs, lpKerningPairs);
Alexandre Julliard's avatar
Alexandre Julliard committed
1631 1632
    for (i = 0; i < cPairs; i++) 
        lpKerningPairs[i].iKernAmount = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1633 1634 1635
    return 0;
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1636

Alexandre Julliard's avatar
Alexandre Julliard committed
1637

Alexandre Julliard's avatar
Alexandre Julliard committed
1638
/*************************************************************************
1639
 *             GetKerningPairsA   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1640
 */
1641 1642
DWORD WINAPI GetKerningPairsA( HDC hDC, DWORD cPairs,
                                 LPKERNINGPAIR lpKerningPairs )
Alexandre Julliard's avatar
Alexandre Julliard committed
1643
{
Alexandre Julliard's avatar
Alexandre Julliard committed
1644
    int i;
1645
    FIXME("(%x,%ld,%p): almost empty stub!\n", hDC, cPairs, lpKerningPairs);
Alexandre Julliard's avatar
Alexandre Julliard committed
1646 1647
    for (i = 0; i < cPairs; i++) 
        lpKerningPairs[i].iKernAmount = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1648
    return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1649
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1650

Alexandre Julliard's avatar
Alexandre Julliard committed
1651 1652

/*************************************************************************
1653
 *             GetKerningPairsW   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1654
 */
1655 1656
DWORD WINAPI GetKerningPairsW( HDC hDC, DWORD cPairs,
                                 LPKERNINGPAIR lpKerningPairs )
Alexandre Julliard's avatar
Alexandre Julliard committed
1657
{
1658
    return GetKerningPairsA( hDC, cPairs, lpKerningPairs );
Alexandre Julliard's avatar
Alexandre Julliard committed
1659
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1660

Alexandre Julliard's avatar
Alexandre Julliard committed
1661
/*************************************************************************
1662
 * TranslateCharsetInfo [GDI32.@]
1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675
 *
 * Fills a CHARSETINFO structure for a character set, code page, or
 * font. This allows making the correspondance between different labelings
 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges) 
 * of the same encoding.
 *
 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
 * only one codepage should be set in *lpSrc.
 *
 * RETURNS
 *   TRUE on success, FALSE on failure.
 *
 */
1676
BOOL WINAPI TranslateCharsetInfo(
1677
  LPDWORD lpSrc, /* [in]
1678 1679 1680 1681
       if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
       if flags == TCI_SRCCHARSET: a character set value
       if flags == TCI_SRCCODEPAGE: a code page value
		 */
1682 1683
  LPCHARSETINFO lpCs, /* [out] structure to receive charset information */
  DWORD flags /* [in] determines interpretation of lpSrc */
1684
) {
1685 1686 1687 1688 1689 1690
    int index = 0;
    switch (flags) {
    case TCI_SRCFONTSIG:
	while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
      break;
    case TCI_SRCCODEPAGE:
1691
      while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
1692 1693
      break;
    case TCI_SRCCHARSET:
1694
      while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
1695 1696 1697 1698 1699 1700
      break;
    default:
      return FALSE;
    }
    if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
    memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
Alexandre Julliard's avatar
Alexandre Julliard committed
1701 1702 1703
    return TRUE;
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1704
/*************************************************************************
1705
 *             GetFontLanguageInfo   (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
1706
 */
1707
DWORD WINAPI GetFontLanguageInfo(HDC hdc) {
Alexandre Julliard's avatar
Alexandre Julliard committed
1708
	/* return value 0 is correct for most cases anyway */
1709
        FIXME("(%x):stub!\n", hdc);
Alexandre Julliard's avatar
Alexandre Julliard committed
1710 1711 1712 1713 1714 1715 1716 1717
	return 0;
}

/*************************************************************************
 *             GetFontLanguageInfo   (GDI.616)
 */
DWORD WINAPI GetFontLanguageInfo16(HDC16 hdc) {
	/* return value 0 is correct for most cases anyway */
1718
	FIXME("(%x):stub!\n",hdc);
Alexandre Julliard's avatar
Alexandre Julliard committed
1719 1720
	return 0;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1721

Alexandre Julliard's avatar
Alexandre Julliard committed
1722
/*************************************************************************
1723
 * GetFontData [GDI32.@] Retrieve data for TrueType font
Alexandre Julliard's avatar
Alexandre Julliard committed
1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737
 *
 * RETURNS
 *
 * success: Number of bytes returned 
 * failure: GDI_ERROR
 *
 * NOTES
 *
 * Calls SetLastError()  
 *
 * BUGS
 *
 * Unimplemented
 */
1738
DWORD WINAPI GetFontData(HDC hdc, DWORD table, DWORD offset, 
Alexandre Julliard's avatar
Alexandre Julliard committed
1739 1740
    LPVOID buffer, DWORD length)
{
1741
    FIXME("(%x,%ld,%ld,%p,%ld): stub\n", hdc, table, offset, buffer, length);
Alexandre Julliard's avatar
Alexandre Julliard committed
1742 1743 1744
    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    return GDI_ERROR;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1745

Huw D M Davies's avatar
Huw D M Davies committed
1746 1747 1748 1749 1750 1751 1752 1753 1754 1755
/*************************************************************************
 * GetFontData16 [GDI.311]
 *
 */
DWORD WINAPI GetFontData16(HDC16 hdc, DWORD dwTable, DWORD dwOffset,
			    LPVOID lpvBuffer, DWORD cbData)
{
    return GetFontData(hdc, dwTable, dwOffset, lpvBuffer, cbData);
}

Alexandre Julliard's avatar
Alexandre Julliard committed
1756
/*************************************************************************
1757
 * GetCharacterPlacementA [GDI32.@]
1758 1759 1760
 *
 * NOTES:
 *  the web browser control of ie4 calls this with dwFlags=0
Alexandre Julliard's avatar
Alexandre Julliard committed
1761 1762
 */
DWORD WINAPI
1763 1764
GetCharacterPlacementA(HDC hdc, LPCSTR lpString, INT uCount,
			 INT nMaxExtent, GCP_RESULTSA *lpResults,
Alexandre Julliard's avatar
Alexandre Julliard committed
1765 1766
			 DWORD dwFlags)
{
1767 1768 1769
    DWORD ret=0;
    SIZE size;

1770 1771
    TRACE("%s 0x%08x 0x%08x 0x%08lx:stub!\n",
          debugstr_a(lpString), uCount, nMaxExtent, dwFlags);
1772

1773 1774 1775 1776
    TRACE("lpOrder=%p lpDx=%p lpCaretPos=%p lpClass=%p "
          "lpOutString=%p lpGlyphs=%p\n",
          lpResults->lpOrder, lpResults->lpDx, lpResults->lpCaretPos,
          lpResults->lpClass, lpResults->lpOutString, lpResults->lpGlyphs);
1777

1778 1779 1780 1781 1782
    if(dwFlags)			FIXME("flags 0x%08lx ignored\n", dwFlags);
    if(lpResults->lpOrder)	FIXME("reordering not implemented\n");
    if(lpResults->lpCaretPos)	FIXME("caret positions not implemented\n");
    if(lpResults->lpClass)	FIXME("classes not implemented\n");
    if(lpResults->lpGlyphs)	FIXME("glyphs not implemented\n");
1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803

    /* copy will do if the GCP_REORDER flag is not set */
    if(lpResults->lpOutString)
    {
      lstrcpynA(lpResults->lpOutString, lpString, uCount);
    }

    if (lpResults->lpDx)
    {
      int i, c;
      for (i=0; i<uCount;i++)
      { 
        if (GetCharWidth32A(hdc, lpString[i], lpString[i], &c))
          lpResults->lpDx[i]= c;
      }
    }

    if (GetTextExtentPoint32A(hdc, lpString, uCount, &size))
      ret = MAKELONG(size.cx, size.cy);

    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
1804 1805 1806
}

/*************************************************************************
1807
 * GetCharacterPlacementW [GDI32.@]
Alexandre Julliard's avatar
Alexandre Julliard committed
1808 1809
 */
DWORD WINAPI
1810 1811
GetCharacterPlacementW(HDC hdc, LPCWSTR lpString, INT uCount,
			 INT nMaxExtent, GCP_RESULTSW *lpResults,
Alexandre Julliard's avatar
Alexandre Julliard committed
1812 1813 1814
			 DWORD dwFlags)
{
    /* return value 0 is correct for most cases anyway */
1815
    FIXME(":stub!\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
1816 1817
    return 0;
}
1818 1819

/*************************************************************************
1820
 *      GetCharABCWidthsFloatA [GDI32.@]
1821
 */
1822
BOOL WINAPI GetCharABCWidthsFloatA(HDC hdc, UINT iFirstChar, UINT iLastChar,
1823 1824
		                        LPABCFLOAT lpABCF)
{
1825
       FIXME_(gdi)("GetCharABCWidthsFloatA, stub\n");
1826 1827 1828 1829
       return 0;
}

/*************************************************************************
1830
 *      GetCharABCWidthsFloatW [GDI32.@]
1831
 */
1832 1833
BOOL WINAPI GetCharABCWidthsFloatW(HDC hdc, UINT iFirstChar,
		                        UINT iLastChar, LPABCFLOAT lpABCF)
1834
{
1835
       FIXME_(gdi)("GetCharABCWidthsFloatW, stub\n");
1836 1837 1838 1839
       return 0;
}

/*************************************************************************
1840
 *      GetCharWidthFloatA [GDI32.@]
1841
 */
1842 1843
BOOL WINAPI GetCharWidthFloatA(HDC hdc, UINT iFirstChar,
		                    UINT iLastChar, PFLOAT pxBuffer)
1844
{
1845
       FIXME_(gdi)("GetCharWidthFloatA, stub\n");
1846 1847 1848 1849
       return 0;
}

/*************************************************************************
1850
 *      GetCharWidthFloatW [GDI32.@]
1851
 */
1852 1853
BOOL WINAPI GetCharWidthFloatW(HDC hdc, UINT iFirstChar,
		                    UINT iLastChar, PFLOAT pxBuffer)
1854
{
1855
       FIXME_(gdi)("GetCharWidthFloatW, stub\n");
1856 1857 1858
       return 0;
}
 
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883

/***********************************************************************
 *								       *
 *           Font Resource API					       *
 *								       *
 ***********************************************************************/
/***********************************************************************
 *           AddFontResource16    (GDI.119)
 *
 *  Can be either .FON, or .FNT, or .TTF, or .FOT font file.
 *
 *  FIXME: Load header and find the best-matching font in the fontList;
 * 	   fixup dfPoints if all metrics are identical, otherwise create
 *	   new fontAlias. When soft font support is ready this will
 *	   simply create a new fontResource ('filename' will go into
 *	   the pfr->resource field) with FR_SOFTFONT/FR_SOFTRESOURCE 
 *	   flag set. 
 */
INT16 WINAPI AddFontResource16( LPCSTR filename )
{
    return AddFontResourceA( filename );
}


/***********************************************************************
1884
 *           AddFontResourceA    (GDI32.@)
1885 1886 1887
 */
INT WINAPI AddFontResourceA( LPCSTR str )
{
Andreas Mohr's avatar
Andreas Mohr committed
1888
    FIXME("(%s): stub! Read the Wine User Guide on how to install "
1889 1890 1891 1892 1893 1894
            "this font manually.\n", debugres_a(str));
    return 1;
}


/***********************************************************************
1895
 *           AddFontResourceW    (GDI32.@)
1896 1897 1898
 */
INT WINAPI AddFontResourceW( LPCWSTR str )
{
Andreas Mohr's avatar
Andreas Mohr committed
1899
    FIXME("(%s): stub! Read the Wine User Guide on how to install "
1900 1901 1902 1903 1904 1905 1906
            "this font manually.\n", debugres_w(str));
    return 1;
}

/***********************************************************************
 *           RemoveFontResource16    (GDI.136)
 */
1907
BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
1908
{
Andreas Mohr's avatar
Andreas Mohr committed
1909
    FIXME("(%s): stub\n", debugres_a(str));
1910 1911 1912 1913 1914
    return TRUE;
}


/***********************************************************************
1915
 *           RemoveFontResourceA    (GDI32.@)
1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946
 */
BOOL WINAPI RemoveFontResourceA( LPCSTR str )
{
/*  This is how it should look like */
/*
    fontResource** ppfr;
    BOOL32 retVal = FALSE;

    EnterCriticalSection( &crtsc_fonts_X11 );
    for( ppfr = &fontList; *ppfr; ppfr = &(*ppfr)->next )
	 if( !strcasecmp( (*ppfr)->lfFaceName, str ) )
	 {
	     if(((*ppfr)->fr_flags & (FR_SOFTFONT | FR_SOFTRESOURCE)) &&
		 (*ppfr)->hOwnerProcess == GetCurrentProcess() )
	     {
		 if( (*ppfr)->fo_count )
		     (*ppfr)->fr_flags |= FR_REMOVED;
		 else
		     XFONT_RemoveFontResource( ppfr );
	     }
	     retVal = TRUE;
	 }
    LeaveCriticalSection( &crtsc_fonts_X11 );
    return retVal;
 */
    FIXME("(%s): stub\n", debugres_a(str));
    return TRUE;
}


/***********************************************************************
1947
 *           RemoveFontResourceW    (GDI32.@)
1948 1949 1950 1951 1952 1953
 */
BOOL WINAPI RemoveFontResourceW( LPCWSTR str )
{
    FIXME("(%s): stub\n", debugres_w(str) );
    return TRUE;
}