| 1 | /* $Id: font.cpp,v 1.21 2001-11-13 15:42:05 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * GDI32 font apis | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1999 Edgar Buerkle (Edgar.Buerkle@gmx.ne) | 
|---|
| 7 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 8 | * Copyright 1998 Patrick Haller | 
|---|
| 9 | * | 
|---|
| 10 | * TODO: EnumFontsA/W, EnumFontFamiliesExA/W not complete | 
|---|
| 11 | * | 
|---|
| 12 | * Parts based on Wine code (991031) | 
|---|
| 13 | * | 
|---|
| 14 | * Copyright 1993 Alexandre Julliard | 
|---|
| 15 | *           1997 Alex Korobka | 
|---|
| 16 | * | 
|---|
| 17 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 18 | * | 
|---|
| 19 | */ | 
|---|
| 20 |  | 
|---|
| 21 | /***************************************************************************** | 
|---|
| 22 | * Includes                                                                  * | 
|---|
| 23 | *****************************************************************************/ | 
|---|
| 24 |  | 
|---|
| 25 | #include <odin.h> | 
|---|
| 26 | #include <odinwrap.h> | 
|---|
| 27 | #include <os2sel.h> | 
|---|
| 28 |  | 
|---|
| 29 | #include <os2win.h> | 
|---|
| 30 | #include <stdlib.h> | 
|---|
| 31 | #include <stdarg.h> | 
|---|
| 32 | #include <ctype.h> | 
|---|
| 33 | #include <string.h> | 
|---|
| 34 | #include "misc.h" | 
|---|
| 35 | #include "unicode.h" | 
|---|
| 36 | #include <heapstring.h> | 
|---|
| 37 | #include <win\options.h> | 
|---|
| 38 | #include <wprocess.h> | 
|---|
| 39 | #include <odininst.h> | 
|---|
| 40 |  | 
|---|
| 41 | #define DBG_LOCALLOG    DBG_font | 
|---|
| 42 | #include "dbglocal.h" | 
|---|
| 43 |  | 
|---|
| 44 | ODINDEBUGCHANNEL(GDI32-FONT) | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 | typedef struct { | 
|---|
| 48 | DWORD userProc; | 
|---|
| 49 | DWORD userData; | 
|---|
| 50 | DWORD dwFlags; | 
|---|
| 51 | } ENUMUSERDATA; | 
|---|
| 52 |  | 
|---|
| 53 | /* | 
|---|
| 54 | *  For TranslateCharsetInfo | 
|---|
| 55 | */ | 
|---|
| 56 | #define FS(x) {{0,0,0,0},{0x1<<(x),0}} | 
|---|
| 57 | #define MAXTCIINDEX 32 | 
|---|
| 58 | static CHARSETINFO FONT_tci[MAXTCIINDEX] = { | 
|---|
| 59 | /* ANSI */ | 
|---|
| 60 | { ANSI_CHARSET, 1252, FS(0)}, | 
|---|
| 61 | { EASTEUROPE_CHARSET, 1250, FS(1)}, | 
|---|
| 62 | { RUSSIAN_CHARSET, 1251, FS(2)}, | 
|---|
| 63 | { GREEK_CHARSET, 1253, FS(3)}, | 
|---|
| 64 | { TURKISH_CHARSET, 1254, FS(4)}, | 
|---|
| 65 | { HEBREW_CHARSET, 1255, FS(5)}, | 
|---|
| 66 | { ARABIC_CHARSET, 1256, FS(6)}, | 
|---|
| 67 | { BALTIC_CHARSET, 1257, FS(7)}, | 
|---|
| 68 | /* reserved by ANSI */ | 
|---|
| 69 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 70 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 71 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 72 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 73 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 74 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 75 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 76 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 77 | /* ANSI and OEM */ | 
|---|
| 78 | { THAI_CHARSET,  874,  FS(16)}, | 
|---|
| 79 | { SHIFTJIS_CHARSET, 932, FS(17)}, | 
|---|
| 80 | { GB2312_CHARSET, 936, FS(18)}, | 
|---|
| 81 | { HANGEUL_CHARSET, 949, FS(19)}, | 
|---|
| 82 | { CHINESEBIG5_CHARSET, 950, FS(20)}, | 
|---|
| 83 | { JOHAB_CHARSET, 1361, FS(21)}, | 
|---|
| 84 | /* reserved for alternate ANSI and OEM */ | 
|---|
| 85 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 86 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 87 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 88 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 89 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 90 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 91 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 92 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 93 | /* reserved for system */ | 
|---|
| 94 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 95 | { DEFAULT_CHARSET, 0, FS(0)}, | 
|---|
| 96 | }; | 
|---|
| 97 |  | 
|---|
| 98 | /***************************************************************************** | 
|---|
| 99 | * Name      : static void iFontRename | 
|---|
| 100 | * Purpose   : font remapping table to map win32 fonts to OS/2 pendants | 
|---|
| 101 | * Parameters: LPSTR lpstrFaceOriginal - the win32 face name | 
|---|
| 102 | *             LPSTR lpstrFaceBuffer   - [LF_FACESIZE] buffer to new name | 
|---|
| 103 | * Variables : | 
|---|
| 104 | * Result    : | 
|---|
| 105 | * Remark    : remapped name is passed back in the buffer | 
|---|
| 106 | *             if no mapping pendant is available, return input parameter | 
|---|
| 107 | *             as default. | 
|---|
| 108 | * Status    : | 
|---|
| 109 | * | 
|---|
| 110 | * Author    : Patrick Haller [Fri, 1998/06/12 03:44] | 
|---|
| 111 | *****************************************************************************/ | 
|---|
| 112 |  | 
|---|
| 113 | static void iFontRename(LPCSTR lpstrFaceOriginal, | 
|---|
| 114 | LPSTR  lpstrFaceTemp) | 
|---|
| 115 | { | 
|---|
| 116 | int   iRet; | 
|---|
| 117 |  | 
|---|
| 118 | // NULL is a valid parameter | 
|---|
| 119 | if (lpstrFaceOriginal == NULL) | 
|---|
| 120 | return; | 
|---|
| 121 |  | 
|---|
| 122 | strncpy(lpstrFaceTemp, lpstrFaceOriginal, LF_FACESIZE); | 
|---|
| 123 | lpstrFaceTemp[LF_FACESIZE-1] = 0; | 
|---|
| 124 |  | 
|---|
| 125 | { | 
|---|
| 126 | char *y = lpstrFaceTemp; | 
|---|
| 127 | while(*y) { | 
|---|
| 128 | if(IsDBCSLeadByte( *y )) { | 
|---|
| 129 | y += 2; // DBCS skip | 
|---|
| 130 | } else { | 
|---|
| 131 | *y = toupper( *y ); | 
|---|
| 132 | y++; | 
|---|
| 133 | } | 
|---|
| 134 | } | 
|---|
| 135 | } | 
|---|
| 136 |  | 
|---|
| 137 | //lookup table | 
|---|
| 138 | iRet = PROFILE_GetOdinIniString(ODINFONTSECTION, | 
|---|
| 139 | lpstrFaceTemp, | 
|---|
| 140 | lpstrFaceOriginal, | 
|---|
| 141 | lpstrFaceTemp, | 
|---|
| 142 | LF_FACESIZE); | 
|---|
| 143 | } | 
|---|
| 144 |  | 
|---|
| 145 | //****************************************************************************** | 
|---|
| 146 | HFONT hFntDefaultGui = NULL; | 
|---|
| 147 | //TODO: more?? | 
|---|
| 148 | //****************************************************************************** | 
|---|
| 149 | BOOL WIN32API IsSystemFont(HFONT hFont) | 
|---|
| 150 | { | 
|---|
| 151 | if(hFont == hFntDefaultGui) { | 
|---|
| 152 | return TRUE; | 
|---|
| 153 | } | 
|---|
| 154 | return FALSE; | 
|---|
| 155 | } | 
|---|
| 156 | //****************************************************************************** | 
|---|
| 157 | //****************************************************************************** | 
|---|
| 158 | ODINFUNCTIONNODBG14(HFONT,  CreateFontA, int,    nHeight, | 
|---|
| 159 | int,    nWidth, | 
|---|
| 160 | int,    nEscapement, | 
|---|
| 161 | int,    nOrientation, | 
|---|
| 162 | int,    fnWeight, | 
|---|
| 163 | DWORD,  fdwItalic, | 
|---|
| 164 | DWORD,  fdwUnderline, | 
|---|
| 165 | DWORD,  fdwStrikeOut, | 
|---|
| 166 | DWORD,  fdwCharSet, | 
|---|
| 167 | DWORD,  fdwOutputPrecision, | 
|---|
| 168 | DWORD,  fdwClipPrecision, | 
|---|
| 169 | DWORD,  fdwQuality, | 
|---|
| 170 | DWORD,  fdwPitchAndFamily, | 
|---|
| 171 | LPCSTR, lpszFace) | 
|---|
| 172 | { | 
|---|
| 173 | CHAR  lpstrFaceNew[LF_FACESIZE]; | 
|---|
| 174 | HFONT hFont; | 
|---|
| 175 |  | 
|---|
| 176 | if(lpszFace == NULL) | 
|---|
| 177 | lpszFace = ""; | 
|---|
| 178 |  | 
|---|
| 179 | if(strlen(lpszFace) >= LF_FACESIZE) | 
|---|
| 180 | { | 
|---|
| 181 | dprintf(("ERROR: Invalid string length for font name!!")); | 
|---|
| 182 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 183 | return 0; | 
|---|
| 184 | } | 
|---|
| 185 |  | 
|---|
| 186 | iFontRename(lpszFace, lpstrFaceNew); | 
|---|
| 187 |  | 
|---|
| 188 | dprintf(("lpszFace = %s -> %s\n", lpszFace, lpstrFaceNew)); | 
|---|
| 189 |  | 
|---|
| 190 | LOGFONTA logFont = | 
|---|
| 191 | { | 
|---|
| 192 | nHeight, | 
|---|
| 193 | nWidth, | 
|---|
| 194 | nEscapement, | 
|---|
| 195 | nOrientation, | 
|---|
| 196 | fnWeight, | 
|---|
| 197 | (BYTE)fdwItalic, | 
|---|
| 198 | (BYTE)fdwUnderline, | 
|---|
| 199 | (BYTE)fdwStrikeOut, | 
|---|
| 200 | (BYTE)fdwCharSet, | 
|---|
| 201 | (BYTE)fdwOutputPrecision, | 
|---|
| 202 | (BYTE)fdwClipPrecision, | 
|---|
| 203 | (BYTE)fdwQuality, | 
|---|
| 204 | (BYTE)fdwPitchAndFamily | 
|---|
| 205 | }; | 
|---|
| 206 | strcpy(logFont.lfFaceName, lpszFace); | 
|---|
| 207 |  | 
|---|
| 208 | return CreateFontIndirectA(&logFont); | 
|---|
| 209 | } | 
|---|
| 210 | //****************************************************************************** | 
|---|
| 211 | //****************************************************************************** | 
|---|
| 212 | ODINFUNCTIONNODBG14(HFONT,  CreateFontW, | 
|---|
| 213 | int,    nHeight, | 
|---|
| 214 | int,    nWidth, | 
|---|
| 215 | int,    nEscapement, | 
|---|
| 216 | int,    nOrientation, | 
|---|
| 217 | int,    fnWeight, | 
|---|
| 218 | DWORD,  fdwItalic, | 
|---|
| 219 | DWORD,  fdwUnderline, | 
|---|
| 220 | DWORD,  fdwStrikeOut, | 
|---|
| 221 | DWORD,  fdwCharSet, | 
|---|
| 222 | DWORD,  fdwOutputPrecision, | 
|---|
| 223 | DWORD,  fdwClipPrecision, | 
|---|
| 224 | DWORD,  fdwQuality, | 
|---|
| 225 | DWORD,  fdwPitchAndFamily, | 
|---|
| 226 | LPCWSTR,lpszFace) | 
|---|
| 227 | { | 
|---|
| 228 | char *astring; | 
|---|
| 229 | HFONT hFont; | 
|---|
| 230 |  | 
|---|
| 231 | // NULL is valid for lpszFace | 
|---|
| 232 | if(lpszFace != NULL) | 
|---|
| 233 | astring = UnicodeToAsciiString((LPWSTR)lpszFace); | 
|---|
| 234 | else | 
|---|
| 235 | astring = NULL; | 
|---|
| 236 |  | 
|---|
| 237 | // @@@PH switch to ODIN_ later | 
|---|
| 238 | hFont =    CreateFontA(nHeight, | 
|---|
| 239 | nWidth, | 
|---|
| 240 | nEscapement, | 
|---|
| 241 | nOrientation, | 
|---|
| 242 | fnWeight, | 
|---|
| 243 | fdwItalic, | 
|---|
| 244 | fdwUnderline, | 
|---|
| 245 | fdwStrikeOut, | 
|---|
| 246 | fdwCharSet, | 
|---|
| 247 | fdwOutputPrecision, | 
|---|
| 248 | fdwClipPrecision, | 
|---|
| 249 | fdwQuality, | 
|---|
| 250 | fdwPitchAndFamily, | 
|---|
| 251 | astring); | 
|---|
| 252 | if (astring != NULL) | 
|---|
| 253 | FreeAsciiString(astring); | 
|---|
| 254 |  | 
|---|
| 255 | return(hFont); | 
|---|
| 256 | } | 
|---|
| 257 |  | 
|---|
| 258 | //****************************************************************************** | 
|---|
| 259 | //****************************************************************************** | 
|---|
| 260 | ODINFUNCTION1(HFONT,CreateFontIndirectA,const LOGFONTA*, lplf) | 
|---|
| 261 | { | 
|---|
| 262 | HFONT    hFont; | 
|---|
| 263 | LOGFONTA afont; | 
|---|
| 264 |  | 
|---|
| 265 | // don't touch user buffer! | 
|---|
| 266 | memcpy(&afont, lplf, sizeof(LOGFONTA)); | 
|---|
| 267 | iFontRename(lplf->lfFaceName, afont.lfFaceName); | 
|---|
| 268 |  | 
|---|
| 269 | dprintf(("lpszFace = (%x) %s -> %s\n", lplf->lfFaceName, lplf->lfFaceName, afont.lfFaceName)); | 
|---|
| 270 |  | 
|---|
| 271 | dprintf(("GDI32: CreateFontIndirectA\n")); | 
|---|
| 272 | dprintf(("GDI32: lfHeight        = %d\n", lplf->lfHeight)); | 
|---|
| 273 | dprintf(("GDI32: lfWidth          = %d\n", lplf->lfWidth)); | 
|---|
| 274 | dprintf(("GDI32: lfEscapement    = %d\n", lplf->lfEscapement)); | 
|---|
| 275 | dprintf(("GDI32: lfOrientation   = %d\n", lplf->lfOrientation)); | 
|---|
| 276 | dprintf(("GDI32: lfWeight        = %d\n", lplf->lfWeight)); | 
|---|
| 277 | dprintf(("GDI32: lfItalic        = %d\n", lplf->lfItalic)); | 
|---|
| 278 | dprintf(("GDI32: lfUnderline     = %d\n", lplf->lfUnderline)); | 
|---|
| 279 | dprintf(("GDI32: lfStrikeOut     = %d\n", lplf->lfStrikeOut)); | 
|---|
| 280 | dprintf(("GDI32: lfCharSet       = %X\n", lplf->lfCharSet)); | 
|---|
| 281 | dprintf(("GDI32: lfOutPrecision  = %X\n", lplf->lfOutPrecision)); | 
|---|
| 282 | dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision)); | 
|---|
| 283 | dprintf(("GDI32: lfQuality       = %X\n", lplf->lfQuality)); | 
|---|
| 284 | dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily)); | 
|---|
| 285 | dprintf(("GDI32: lfFaceName      = %s\n", lplf->lfFaceName)); | 
|---|
| 286 |  | 
|---|
| 287 | hFont = O32_CreateFontIndirect(&afont); | 
|---|
| 288 |  | 
|---|
| 289 | return(hFont); | 
|---|
| 290 | } | 
|---|
| 291 | //****************************************************************************** | 
|---|
| 292 | //****************************************************************************** | 
|---|
| 293 | ODINFUNCTION1(HFONT, CreateFontIndirectW,const LOGFONTW *, lplf) | 
|---|
| 294 | { | 
|---|
| 295 | LOGFONTA afont; | 
|---|
| 296 | HFONT    hfont; | 
|---|
| 297 |  | 
|---|
| 298 | //memcpy(&afont, lplf, ((ULONG)&afont.lfFaceName - (ULONG)&afont)); | 
|---|
| 299 | memcpy(&afont, lplf, sizeof(LOGFONTA)); | 
|---|
| 300 | memset(afont.lfFaceName, 0, LF_FACESIZE); | 
|---|
| 301 | dprintf(("lpszFace = (%x)", lplf->lfFaceName)); | 
|---|
| 302 |  | 
|---|
| 303 | UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1); | 
|---|
| 304 | hfont = CreateFontIndirectA(&afont); | 
|---|
| 305 | return(hfont); | 
|---|
| 306 | } | 
|---|
| 307 | //****************************************************************************** | 
|---|
| 308 | //****************************************************************************** | 
|---|
| 309 | int  EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA | 
|---|
| 310 | lpTextM, DWORD arg3, LPARAM arg4) | 
|---|
| 311 | { | 
|---|
| 312 | ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; | 
|---|
| 313 | FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc; | 
|---|
| 314 | USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel | 
|---|
| 315 |  | 
|---|
| 316 | int rc = proc(lpLogFont, lpTextM, arg3, lpEnumData->userData); | 
|---|
| 317 | SetFS(selTIB);           // switch back to the saved FS selector | 
|---|
| 318 | return rc; | 
|---|
| 319 | } | 
|---|
| 320 | //****************************************************************************** | 
|---|
| 321 | //****************************************************************************** | 
|---|
| 322 | int  EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM, | 
|---|
| 323 | DWORD arg3, LPARAM arg4) | 
|---|
| 324 | { | 
|---|
| 325 | ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; | 
|---|
| 326 | FONTENUMPROCW proc = (FONTENUMPROCW)lpEnumData->userProc; | 
|---|
| 327 | ENUMLOGFONTW LogFont; | 
|---|
| 328 | NEWTEXTMETRICW textM; | 
|---|
| 329 | USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel | 
|---|
| 330 | int rc; | 
|---|
| 331 |  | 
|---|
| 332 | memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - | 
|---|
| 333 | (ULONG)&LogFont)); | 
|---|
| 334 | AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1); | 
|---|
| 335 | AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1); | 
|---|
| 336 | AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1); | 
|---|
| 337 |  | 
|---|
| 338 | textM.tmHeight = lpTextM->tmHeight; | 
|---|
| 339 | textM.tmAscent = lpTextM->tmAscent; | 
|---|
| 340 | textM.tmDescent = lpTextM->tmDescent; | 
|---|
| 341 | textM.tmInternalLeading = lpTextM->tmInternalLeading; | 
|---|
| 342 | textM.tmExternalLeading = lpTextM->tmExternalLeading; | 
|---|
| 343 | textM.tmAveCharWidth = lpTextM->tmAveCharWidth; | 
|---|
| 344 | textM.tmMaxCharWidth = lpTextM->tmMaxCharWidth; | 
|---|
| 345 | textM.tmWeight = lpTextM->tmWeight; | 
|---|
| 346 | textM.tmOverhang = lpTextM->tmOverhang; | 
|---|
| 347 | textM.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX; | 
|---|
| 348 | textM.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY; | 
|---|
| 349 | textM.tmFirstChar = lpTextM->tmFirstChar; | 
|---|
| 350 | textM.tmLastChar = lpTextM->tmLastChar; | 
|---|
| 351 | textM.tmDefaultChar = lpTextM->tmDefaultChar; | 
|---|
| 352 | textM.tmBreakChar = lpTextM->tmBreakChar; | 
|---|
| 353 | textM.tmItalic = lpTextM->tmItalic; | 
|---|
| 354 | textM.tmUnderlined = lpTextM->tmUnderlined; | 
|---|
| 355 | textM.tmStruckOut = lpTextM->tmStruckOut; | 
|---|
| 356 | textM.tmPitchAndFamily = lpTextM->tmPitchAndFamily; | 
|---|
| 357 | textM.tmCharSet = lpTextM->tmCharSet; | 
|---|
| 358 | textM.ntmFlags = 0; | 
|---|
| 359 | textM.ntmSizeEM = 0; | 
|---|
| 360 | textM.ntmCellHeight = 0; | 
|---|
| 361 | textM.ntmAvgWidth = 0; | 
|---|
| 362 |  | 
|---|
| 363 | rc = proc(&LogFont, &textM, arg3, lpEnumData->userData); | 
|---|
| 364 | SetFS(selTIB);           // switch back to the saved FS selector | 
|---|
| 365 | return rc; | 
|---|
| 366 | } | 
|---|
| 367 | //****************************************************************************** | 
|---|
| 368 | //TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part) | 
|---|
| 369 | //****************************************************************************** | 
|---|
| 370 | int  EXPENTRY_O32 EnumFontProcExA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA | 
|---|
| 371 | lpTextM, DWORD arg3, LPARAM arg4) | 
|---|
| 372 | { | 
|---|
| 373 | ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; | 
|---|
| 374 | FONTENUMPROCEXA proc = (FONTENUMPROCEXA)lpEnumData->userProc; | 
|---|
| 375 | ENUMLOGFONTEXA logFont; | 
|---|
| 376 | NEWTEXTMETRICEXA textM; | 
|---|
| 377 | USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel | 
|---|
| 378 |  | 
|---|
| 379 | memcpy(&logFont, lpLogFont, sizeof(ENUMLOGFONTA)); | 
|---|
| 380 | memset(logFont.elfScript, 0, sizeof(logFont.elfScript)); | 
|---|
| 381 | memcpy(&textM.ntmetm, lpTextM, sizeof(textM.ntmetm)); | 
|---|
| 382 | memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature)); | 
|---|
| 383 |  | 
|---|
| 384 | dprintf(("EnumFontProcExA %s", logFont.elfLogFont.lfFaceName)); | 
|---|
| 385 |  | 
|---|
| 386 | int rc = proc(&logFont, &textM, arg3, lpEnumData->userData); | 
|---|
| 387 | SetFS(selTIB);           // switch back to the saved FS selector | 
|---|
| 388 | return rc; | 
|---|
| 389 | } | 
|---|
| 390 | //****************************************************************************** | 
|---|
| 391 | //TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part) | 
|---|
| 392 | //****************************************************************************** | 
|---|
| 393 | int EXPENTRY_O32 EnumFontProcExW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM, | 
|---|
| 394 | DWORD arg3, LPARAM arg4) | 
|---|
| 395 | { | 
|---|
| 396 | ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; | 
|---|
| 397 | FONTENUMPROCEXW proc = (FONTENUMPROCEXW)lpEnumData->userProc; | 
|---|
| 398 | ENUMLOGFONTEXW LogFont; | 
|---|
| 399 | NEWTEXTMETRICEXW textM; | 
|---|
| 400 | int rc; | 
|---|
| 401 |  | 
|---|
| 402 | memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - (ULONG)&LogFont)); | 
|---|
| 403 | memset(LogFont.elfScript, 0, sizeof(LogFont.elfScript)); | 
|---|
| 404 | AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1); | 
|---|
| 405 | AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1); | 
|---|
| 406 | AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1); | 
|---|
| 407 |  | 
|---|
| 408 | textM.ntmetm.tmHeight = lpTextM->tmHeight; | 
|---|
| 409 | textM.ntmetm.tmAscent = lpTextM->tmAscent; | 
|---|
| 410 | textM.ntmetm.tmDescent = lpTextM->tmDescent; | 
|---|
| 411 | textM.ntmetm.tmInternalLeading = lpTextM->tmInternalLeading; | 
|---|
| 412 | textM.ntmetm.tmExternalLeading = lpTextM->tmExternalLeading; | 
|---|
| 413 | textM.ntmetm.tmAveCharWidth = lpTextM->tmAveCharWidth; | 
|---|
| 414 | textM.ntmetm.tmMaxCharWidth = lpTextM->tmMaxCharWidth; | 
|---|
| 415 | textM.ntmetm.tmWeight = lpTextM->tmWeight; | 
|---|
| 416 | textM.ntmetm.tmOverhang = lpTextM->tmOverhang; | 
|---|
| 417 | textM.ntmetm.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX; | 
|---|
| 418 | textM.ntmetm.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY; | 
|---|
| 419 | textM.ntmetm.tmFirstChar = lpTextM->tmFirstChar; | 
|---|
| 420 | textM.ntmetm.tmLastChar = lpTextM->tmLastChar; | 
|---|
| 421 | textM.ntmetm.tmDefaultChar = lpTextM->tmDefaultChar; | 
|---|
| 422 | textM.ntmetm.tmBreakChar = lpTextM->tmBreakChar; | 
|---|
| 423 | textM.ntmetm.tmItalic = lpTextM->tmItalic; | 
|---|
| 424 | textM.ntmetm.tmUnderlined = lpTextM->tmUnderlined; | 
|---|
| 425 | textM.ntmetm.tmStruckOut = lpTextM->tmStruckOut; | 
|---|
| 426 | textM.ntmetm.tmPitchAndFamily = lpTextM->tmPitchAndFamily; | 
|---|
| 427 | textM.ntmetm.tmCharSet = lpTextM->tmCharSet; | 
|---|
| 428 | textM.ntmetm.ntmFlags = 0; | 
|---|
| 429 | textM.ntmetm.ntmSizeEM = 0; | 
|---|
| 430 | textM.ntmetm.ntmCellHeight = 0; | 
|---|
| 431 | textM.ntmetm.ntmAvgWidth = 0; | 
|---|
| 432 | memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature)); | 
|---|
| 433 |  | 
|---|
| 434 | dprintf(("EnumFontProcExW %s", lpLogFont->elfLogFont.lfFaceName)); | 
|---|
| 435 | return proc(&LogFont, &textM, arg3, lpEnumData->userData); | 
|---|
| 436 | } | 
|---|
| 437 | //****************************************************************************** | 
|---|
| 438 | //****************************************************************************** | 
|---|
| 439 | ODINFUNCTION4(int, EnumFontsA, | 
|---|
| 440 | HDC, arg1, | 
|---|
| 441 | LPCSTR, arg2, | 
|---|
| 442 | FONTENUMPROCA, arg3, | 
|---|
| 443 | LPARAM,  arg4) | 
|---|
| 444 | { | 
|---|
| 445 | //@@@PH shouldn't this rather be O32_EnumFonts ? | 
|---|
| 446 | return EnumFontFamiliesA(arg1, arg2, arg3, arg4); | 
|---|
| 447 | } | 
|---|
| 448 | //****************************************************************************** | 
|---|
| 449 | //****************************************************************************** | 
|---|
| 450 | ODINFUNCTION4(int, EnumFontsW, | 
|---|
| 451 | HDC, arg1, | 
|---|
| 452 | LPCWSTR, arg2, | 
|---|
| 453 | FONTENUMPROCW, arg3, | 
|---|
| 454 | LPARAM,  arg4) | 
|---|
| 455 | { | 
|---|
| 456 | //@@@PH shouldn't this rather be O32_EnumFonts ? | 
|---|
| 457 | return EnumFontFamiliesW(arg1, arg2, arg3, arg4); | 
|---|
| 458 | } | 
|---|
| 459 | //****************************************************************************** | 
|---|
| 460 | //****************************************************************************** | 
|---|
| 461 | ODINFUNCTION4(int, EnumFontFamiliesA, | 
|---|
| 462 | HDC, arg1, | 
|---|
| 463 | LPCSTR, arg2, | 
|---|
| 464 | FONTENUMPROCA, arg3, | 
|---|
| 465 | LPARAM, arg4) | 
|---|
| 466 | { | 
|---|
| 467 | ENUMUSERDATA enumData; | 
|---|
| 468 | int rc; | 
|---|
| 469 |  | 
|---|
| 470 | dprintf(("GDI32: EnumFontFamiliesA %s", arg2)); | 
|---|
| 471 |  | 
|---|
| 472 | enumData.userProc = (DWORD)arg3; | 
|---|
| 473 | enumData.userData = arg4; | 
|---|
| 474 |  | 
|---|
| 475 | rc = O32_EnumFontFamilies(arg1, arg2, &EnumFontProcA, (LPARAM)&enumData); | 
|---|
| 476 |  | 
|---|
| 477 | return rc; | 
|---|
| 478 | } | 
|---|
| 479 | //****************************************************************************** | 
|---|
| 480 | //****************************************************************************** | 
|---|
| 481 | ODINFUNCTION4(int, EnumFontFamiliesW, | 
|---|
| 482 | HDC, arg1, | 
|---|
| 483 | LPCWSTR, arg2, | 
|---|
| 484 | FONTENUMPROCW, arg3, | 
|---|
| 485 | LPARAM, arg4) | 
|---|
| 486 | { | 
|---|
| 487 | ENUMUSERDATA enumData; | 
|---|
| 488 | int rc; | 
|---|
| 489 | char *astring = UnicodeToAsciiString((LPWSTR)arg2); | 
|---|
| 490 |  | 
|---|
| 491 | dprintf(("GDI32: EnumFontFamiliesW %s", astring)); | 
|---|
| 492 |  | 
|---|
| 493 | enumData.userProc = (DWORD)arg3; | 
|---|
| 494 | enumData.userData = arg4; | 
|---|
| 495 |  | 
|---|
| 496 | rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcW, (LPARAM)&enumData); | 
|---|
| 497 |  | 
|---|
| 498 | FreeAsciiString(astring); | 
|---|
| 499 | return rc; | 
|---|
| 500 | } | 
|---|
| 501 | //****************************************************************************** | 
|---|
| 502 | //****************************************************************************** | 
|---|
| 503 | ODINFUNCTION5(INT, EnumFontFamiliesExA, | 
|---|
| 504 | HDC, arg1, | 
|---|
| 505 | LPLOGFONTA, arg2, | 
|---|
| 506 | FONTENUMPROCEXA, arg3, | 
|---|
| 507 | LPARAM, arg4, | 
|---|
| 508 | DWORD, dwFlags) | 
|---|
| 509 | { | 
|---|
| 510 | ENUMUSERDATA enumData; | 
|---|
| 511 | int rc; | 
|---|
| 512 |  | 
|---|
| 513 | dprintf(("GDI32: EnumFontFamiliesExA not complete %s", arg2->lfFaceName)); | 
|---|
| 514 |  | 
|---|
| 515 | enumData.userProc = (DWORD)arg3; | 
|---|
| 516 | enumData.userData = arg4; | 
|---|
| 517 | enumData.dwFlags  = dwFlags; | 
|---|
| 518 |  | 
|---|
| 519 | rc = O32_EnumFontFamilies(arg1, arg2->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData); | 
|---|
| 520 |  | 
|---|
| 521 | return rc; | 
|---|
| 522 | } | 
|---|
| 523 | //****************************************************************************** | 
|---|
| 524 | //****************************************************************************** | 
|---|
| 525 | ODINFUNCTION5(INT, EnumFontFamiliesExW, | 
|---|
| 526 | HDC, arg1, | 
|---|
| 527 | LPLOGFONTW, arg2, | 
|---|
| 528 | FONTENUMPROCEXW, arg3, | 
|---|
| 529 | LPARAM, arg4, | 
|---|
| 530 | DWORD, dwFlags) | 
|---|
| 531 | { | 
|---|
| 532 | ENUMUSERDATA enumData; | 
|---|
| 533 | int rc; | 
|---|
| 534 | char *astring = UnicodeToAsciiString((LPWSTR)arg2->lfFaceName); | 
|---|
| 535 |  | 
|---|
| 536 | dprintf(("GDI32: EnumFontFamiliesExW not complete %s", astring)); | 
|---|
| 537 |  | 
|---|
| 538 | enumData.userProc = (DWORD)arg3; | 
|---|
| 539 | enumData.userData = arg4; | 
|---|
| 540 | enumData.dwFlags  = dwFlags; | 
|---|
| 541 |  | 
|---|
| 542 | rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcExW, (LPARAM)&enumData); | 
|---|
| 543 |  | 
|---|
| 544 | FreeAsciiString(astring); | 
|---|
| 545 | return rc; | 
|---|
| 546 | } | 
|---|
| 547 | //****************************************************************************** | 
|---|
| 548 | //****************************************************************************** | 
|---|
| 549 | ODINFUNCTION5(DWORD, GetFontData, | 
|---|
| 550 | HDC, hdc, | 
|---|
| 551 | DWORD, dwTable, | 
|---|
| 552 | DWORD, dwOffset, | 
|---|
| 553 | LPVOID, lpvBuffer, | 
|---|
| 554 | DWORD, dbData) | 
|---|
| 555 | { | 
|---|
| 556 | dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n")); | 
|---|
| 557 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); | 
|---|
| 558 |  | 
|---|
| 559 | return(GDI_ERROR); | 
|---|
| 560 | } | 
|---|
| 561 | //****************************************************************************** | 
|---|
| 562 | //****************************************************************************** | 
|---|
| 563 | ODINFUNCTION1(int, AddFontResourceA, | 
|---|
| 564 | LPCSTR, szFont) | 
|---|
| 565 | { | 
|---|
| 566 | HINSTANCE hInstance; | 
|---|
| 567 |  | 
|---|
| 568 | dprintf(("GDI32: AddFontResourceA %s", szFont)); | 
|---|
| 569 | hInstance = LoadLibraryA(szFont); | 
|---|
| 570 | if(hInstance) { | 
|---|
| 571 | dprintf(("AddFontResourceA: executable file; NOT IMPLEMENTED")); | 
|---|
| 572 | FreeLibrary(hInstance); | 
|---|
| 573 | return 1; | 
|---|
| 574 | } | 
|---|
| 575 | return O32_AddFontResource(szFont); | 
|---|
| 576 | } | 
|---|
| 577 | //****************************************************************************** | 
|---|
| 578 | //****************************************************************************** | 
|---|
| 579 | ODINFUNCTION1(int, AddFontResourceW, | 
|---|
| 580 | LPCWSTR, szFont) | 
|---|
| 581 | { | 
|---|
| 582 | char *astring = UnicodeToAsciiString((LPWSTR)szFont); | 
|---|
| 583 | BOOL  rc; | 
|---|
| 584 |  | 
|---|
| 585 | dprintf(("GDI32: AddFontResourceW")); | 
|---|
| 586 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 587 | rc = AddFontResourceA(astring); | 
|---|
| 588 | FreeAsciiString(astring); | 
|---|
| 589 | return rc; | 
|---|
| 590 | } | 
|---|
| 591 | //****************************************************************************** | 
|---|
| 592 | //****************************************************************************** | 
|---|
| 593 | ODINFUNCTION1(BOOL, RemoveFontResourceA, | 
|---|
| 594 | LPCSTR, arg1) | 
|---|
| 595 | { | 
|---|
| 596 | dprintf(("GDI32: RemoveFontResourceA %s\n", arg1)); | 
|---|
| 597 | return O32_RemoveFontResource(arg1); | 
|---|
| 598 | } | 
|---|
| 599 | //****************************************************************************** | 
|---|
| 600 | //****************************************************************************** | 
|---|
| 601 | ODINFUNCTION1(BOOL, RemoveFontResourceW, | 
|---|
| 602 | LPCWSTR, szFont) | 
|---|
| 603 | { | 
|---|
| 604 | char *astring = UnicodeToAsciiString((LPWSTR)szFont); | 
|---|
| 605 | BOOL  rc; | 
|---|
| 606 |  | 
|---|
| 607 | dprintf(("GDI32: RemoveFontResourceW")); | 
|---|
| 608 | rc = RemoveFontResourceA(astring); | 
|---|
| 609 | FreeAsciiString(astring); | 
|---|
| 610 | return(rc); | 
|---|
| 611 | } | 
|---|
| 612 | /***************************************************************************** | 
|---|
| 613 | * Name      : BOOL CreateScalableFontResourceA | 
|---|
| 614 | * Purpose   : The CreateScalableFontResourceA function creates a font resource | 
|---|
| 615 | *             file for a scalable font. | 
|---|
| 616 | * Parameters: DWORD   fdwHidden       flag for read-only embedded font | 
|---|
| 617 | *             LPCSTR lpszFontRes     address of filename for font resource | 
|---|
| 618 | *             LPCSTR lpszFontFile    address of filename for scalable font | 
|---|
| 619 | *             LPCSTR lpszCurrentPath address of path to font file | 
|---|
| 620 | * Variables : | 
|---|
| 621 | * Result    : TRUE / FALSE | 
|---|
| 622 | * Remark    : | 
|---|
| 623 | * Status    : UNTESTED STUB | 
|---|
| 624 | * | 
|---|
| 625 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 626 | *****************************************************************************/ | 
|---|
| 627 |  | 
|---|
| 628 | ODINFUNCTION4(BOOL, CreateScalableFontResourceA, | 
|---|
| 629 | DWORD, fdwHidden, | 
|---|
| 630 | LPCSTR, lpszFontRes, | 
|---|
| 631 | LPCSTR, lpszFontFile, | 
|---|
| 632 | LPCSTR, lpszCurrentPath) | 
|---|
| 633 | { | 
|---|
| 634 | dprintf(("GDI32: CreateScalableFontResourceA not implemented.\n")); | 
|---|
| 635 |  | 
|---|
| 636 | return (FALSE); | 
|---|
| 637 | } | 
|---|
| 638 |  | 
|---|
| 639 |  | 
|---|
| 640 | /***************************************************************************** | 
|---|
| 641 | * Name      : BOOL CreateScalableFontResourceW | 
|---|
| 642 | * Purpose   : The CreateScalableFontResourceW function creates a font resource | 
|---|
| 643 | *             file for a scalable font. | 
|---|
| 644 | * Parameters: DWORD   fdwHidden       flag for read-only embedded font | 
|---|
| 645 | *             LPCSTR lpszFontRes     address of filename for font resource | 
|---|
| 646 | *             LPCSTR lpszFontFile    address of filename for scalable font | 
|---|
| 647 | *             LPCSTR lpszCurrentPath address of path to font file | 
|---|
| 648 | * Variables : | 
|---|
| 649 | * Result    : TRUE / FALSE | 
|---|
| 650 | * Remark    : | 
|---|
| 651 | * Status    : UNTESTED STUB | 
|---|
| 652 | * | 
|---|
| 653 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 654 | *****************************************************************************/ | 
|---|
| 655 |  | 
|---|
| 656 | ODINFUNCTION4(BOOL, CreateScalableFontResourceW, | 
|---|
| 657 | DWORD, fdwHidden, | 
|---|
| 658 | LPCWSTR, lpszFontRes, | 
|---|
| 659 | LPCWSTR, lpszFontFile, | 
|---|
| 660 | LPCWSTR, lpszCurrentPath) | 
|---|
| 661 | { | 
|---|
| 662 | dprintf(("GDI32: CreateScalableFontResourceW not implemented.\n")); | 
|---|
| 663 |  | 
|---|
| 664 | return (FALSE); | 
|---|
| 665 | } | 
|---|
| 666 |  | 
|---|
| 667 |  | 
|---|
| 668 | /***************************************************************************** | 
|---|
| 669 | * Name      : DWORD GetFontLanguageInfo | 
|---|
| 670 | * Purpose   : The GetFontLanguageInfo function returns information about the | 
|---|
| 671 | *             currently selected font for the specified display context. | 
|---|
| 672 | *             Applications typically use this information and the | 
|---|
| 673 | *             GetCharacterPlacement function to prepare a character string for display. | 
|---|
| 674 | * Parameters: HDC     hdc        handle to device context | 
|---|
| 675 | * Variables : | 
|---|
| 676 | * Result    : | 
|---|
| 677 | * Remark    : | 
|---|
| 678 | * Status    : UNTESTED STUB | 
|---|
| 679 | * | 
|---|
| 680 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 681 | *****************************************************************************/ | 
|---|
| 682 |  | 
|---|
| 683 | ODINFUNCTION1(DWORD, GetFontLanguageInfo, | 
|---|
| 684 | HDC, hdc) | 
|---|
| 685 | { | 
|---|
| 686 | dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n", | 
|---|
| 687 | hdc)); | 
|---|
| 688 |  | 
|---|
| 689 | return (0); | 
|---|
| 690 | } | 
|---|
| 691 |  | 
|---|
| 692 |  | 
|---|
| 693 | /************************************************************************* | 
|---|
| 694 | * TranslateCharsetInfo [GDI32.382] | 
|---|
| 695 | * | 
|---|
| 696 | * Fills a CHARSETINFO structure for a character set, code page, or | 
|---|
| 697 | * font. This allows making the correspondance between different labelings | 
|---|
| 698 | * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges) | 
|---|
| 699 | * of the same encoding. | 
|---|
| 700 | * | 
|---|
| 701 | * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used, | 
|---|
| 702 | * only one codepage should be set in *lpSrc. | 
|---|
| 703 | * | 
|---|
| 704 | * RETURNS | 
|---|
| 705 | *   TRUE on success, FALSE on failure. | 
|---|
| 706 | * | 
|---|
| 707 | * | 
|---|
| 708 | * LPDWORD lpSrc, if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE | 
|---|
| 709 | *                if flags == TCI_SRCCHARSET: a character set value | 
|---|
| 710 | *                if flags == TCI_SRCCODEPAGE: a code page value | 
|---|
| 711 | * LPCHARSETINFO lpCs, structure to receive charset information | 
|---|
| 712 | * DWORD flags  determines interpretation of lpSrc | 
|---|
| 713 | */ | 
|---|
| 714 | ODINFUNCTION3(BOOL, TranslateCharsetInfo, | 
|---|
| 715 | LPDWORD, lpSrc, | 
|---|
| 716 | LPCHARSETINFO, lpCs, | 
|---|
| 717 | DWORD, flags) | 
|---|
| 718 | { | 
|---|
| 719 | int index = 0; | 
|---|
| 720 | switch (flags) { | 
|---|
| 721 | case TCI_SRCFONTSIG: | 
|---|
| 722 | while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++; | 
|---|
| 723 | break; | 
|---|
| 724 | case TCI_SRCCODEPAGE: | 
|---|
| 725 | while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++; | 
|---|
| 726 | break; | 
|---|
| 727 | case TCI_SRCCHARSET: | 
|---|
| 728 | while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++; | 
|---|
| 729 | break; | 
|---|
| 730 | default: | 
|---|
| 731 | return FALSE; | 
|---|
| 732 | } | 
|---|
| 733 | if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE; | 
|---|
| 734 | memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO)); | 
|---|
| 735 | return TRUE; | 
|---|
| 736 | } | 
|---|
| 737 | //****************************************************************************** | 
|---|
| 738 | //****************************************************************************** | 
|---|