| 1 | /* $Id: font.cpp,v 1.20 2001-07-16 20:17:39 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 | //****************************************************************************** | 
|---|
| 147 | //****************************************************************************** | 
|---|
| 148 | ODINFUNCTIONNODBG14(HFONT,  CreateFontA, int,    nHeight, | 
|---|
| 149 | int,    nWidth, | 
|---|
| 150 | int,    nEscapement, | 
|---|
| 151 | int,    nOrientation, | 
|---|
| 152 | int,    fnWeight, | 
|---|
| 153 | DWORD,  fdwItalic, | 
|---|
| 154 | DWORD,  fdwUnderline, | 
|---|
| 155 | DWORD,  fdwStrikeOut, | 
|---|
| 156 | DWORD,  fdwCharSet, | 
|---|
| 157 | DWORD,  fdwOutputPrecision, | 
|---|
| 158 | DWORD,  fdwClipPrecision, | 
|---|
| 159 | DWORD,  fdwQuality, | 
|---|
| 160 | DWORD,  fdwPitchAndFamily, | 
|---|
| 161 | LPCSTR, lpszFace) | 
|---|
| 162 | { | 
|---|
| 163 | CHAR  lpstrFaceNew[LF_FACESIZE]; | 
|---|
| 164 | HFONT hFont; | 
|---|
| 165 |  | 
|---|
| 166 | if(lpszFace == NULL) | 
|---|
| 167 | lpszFace = ""; | 
|---|
| 168 |  | 
|---|
| 169 | if(strlen(lpszFace) >= LF_FACESIZE) | 
|---|
| 170 | { | 
|---|
| 171 | dprintf(("ERROR: Invalid string length for font name!!")); | 
|---|
| 172 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 173 | return 0; | 
|---|
| 174 | } | 
|---|
| 175 |  | 
|---|
| 176 | iFontRename(lpszFace, lpstrFaceNew); | 
|---|
| 177 |  | 
|---|
| 178 | dprintf(("lpszFace = %s -> %s\n", lpszFace, lpstrFaceNew)); | 
|---|
| 179 |  | 
|---|
| 180 | LOGFONTA logFont = | 
|---|
| 181 | { | 
|---|
| 182 | nHeight, | 
|---|
| 183 | nWidth, | 
|---|
| 184 | nEscapement, | 
|---|
| 185 | nOrientation, | 
|---|
| 186 | fnWeight, | 
|---|
| 187 | (BYTE)fdwItalic, | 
|---|
| 188 | (BYTE)fdwUnderline, | 
|---|
| 189 | (BYTE)fdwStrikeOut, | 
|---|
| 190 | (BYTE)fdwCharSet, | 
|---|
| 191 | (BYTE)fdwOutputPrecision, | 
|---|
| 192 | (BYTE)fdwClipPrecision, | 
|---|
| 193 | (BYTE)fdwQuality, | 
|---|
| 194 | (BYTE)fdwPitchAndFamily | 
|---|
| 195 | }; | 
|---|
| 196 | strcpy(logFont.lfFaceName, lpszFace); | 
|---|
| 197 |  | 
|---|
| 198 | return CreateFontIndirectA(&logFont); | 
|---|
| 199 | } | 
|---|
| 200 | //****************************************************************************** | 
|---|
| 201 | //****************************************************************************** | 
|---|
| 202 | ODINFUNCTIONNODBG14(HFONT,  CreateFontW, | 
|---|
| 203 | int,    nHeight, | 
|---|
| 204 | int,    nWidth, | 
|---|
| 205 | int,    nEscapement, | 
|---|
| 206 | int,    nOrientation, | 
|---|
| 207 | int,    fnWeight, | 
|---|
| 208 | DWORD,  fdwItalic, | 
|---|
| 209 | DWORD,  fdwUnderline, | 
|---|
| 210 | DWORD,  fdwStrikeOut, | 
|---|
| 211 | DWORD,  fdwCharSet, | 
|---|
| 212 | DWORD,  fdwOutputPrecision, | 
|---|
| 213 | DWORD,  fdwClipPrecision, | 
|---|
| 214 | DWORD,  fdwQuality, | 
|---|
| 215 | DWORD,  fdwPitchAndFamily, | 
|---|
| 216 | LPCWSTR,lpszFace) | 
|---|
| 217 | { | 
|---|
| 218 | char *astring; | 
|---|
| 219 | HFONT hFont; | 
|---|
| 220 |  | 
|---|
| 221 | // NULL is valid for lpszFace | 
|---|
| 222 | if(lpszFace != NULL) | 
|---|
| 223 | astring = UnicodeToAsciiString((LPWSTR)lpszFace); | 
|---|
| 224 | else | 
|---|
| 225 | astring = NULL; | 
|---|
| 226 |  | 
|---|
| 227 | // @@@PH switch to ODIN_ later | 
|---|
| 228 | hFont =    CreateFontA(nHeight, | 
|---|
| 229 | nWidth, | 
|---|
| 230 | nEscapement, | 
|---|
| 231 | nOrientation, | 
|---|
| 232 | fnWeight, | 
|---|
| 233 | fdwItalic, | 
|---|
| 234 | fdwUnderline, | 
|---|
| 235 | fdwStrikeOut, | 
|---|
| 236 | fdwCharSet, | 
|---|
| 237 | fdwOutputPrecision, | 
|---|
| 238 | fdwClipPrecision, | 
|---|
| 239 | fdwQuality, | 
|---|
| 240 | fdwPitchAndFamily, | 
|---|
| 241 | astring); | 
|---|
| 242 | if (astring != NULL) | 
|---|
| 243 | FreeAsciiString(astring); | 
|---|
| 244 |  | 
|---|
| 245 | return(hFont); | 
|---|
| 246 | } | 
|---|
| 247 |  | 
|---|
| 248 | //****************************************************************************** | 
|---|
| 249 | //****************************************************************************** | 
|---|
| 250 | ODINFUNCTION1(HFONT,CreateFontIndirectA,const LOGFONTA*, lplf) | 
|---|
| 251 | { | 
|---|
| 252 | HFONT    hFont; | 
|---|
| 253 | LOGFONTA afont; | 
|---|
| 254 |  | 
|---|
| 255 | // don't touch user buffer! | 
|---|
| 256 | memcpy(&afont, lplf, sizeof(LOGFONTA)); | 
|---|
| 257 | iFontRename(lplf->lfFaceName, afont.lfFaceName); | 
|---|
| 258 |  | 
|---|
| 259 | dprintf(("lpszFace = (%x) %s -> %s\n", lplf->lfFaceName, lplf->lfFaceName, afont.lfFaceName)); | 
|---|
| 260 |  | 
|---|
| 261 | dprintf(("GDI32: CreateFontIndirectA\n")); | 
|---|
| 262 | dprintf(("GDI32: lfHeight        = %d\n", lplf->lfHeight)); | 
|---|
| 263 | dprintf(("GDI32: lfWidth          = %d\n", lplf->lfWidth)); | 
|---|
| 264 | dprintf(("GDI32: lfEscapement    = %d\n", lplf->lfEscapement)); | 
|---|
| 265 | dprintf(("GDI32: lfOrientation   = %d\n", lplf->lfOrientation)); | 
|---|
| 266 | dprintf(("GDI32: lfWeight        = %d\n", lplf->lfWeight)); | 
|---|
| 267 | dprintf(("GDI32: lfItalic        = %d\n", lplf->lfItalic)); | 
|---|
| 268 | dprintf(("GDI32: lfUnderline     = %d\n", lplf->lfUnderline)); | 
|---|
| 269 | dprintf(("GDI32: lfStrikeOut     = %d\n", lplf->lfStrikeOut)); | 
|---|
| 270 | dprintf(("GDI32: lfCharSet       = %X\n", lplf->lfCharSet)); | 
|---|
| 271 | dprintf(("GDI32: lfOutPrecision  = %X\n", lplf->lfOutPrecision)); | 
|---|
| 272 | dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision)); | 
|---|
| 273 | dprintf(("GDI32: lfQuality       = %X\n", lplf->lfQuality)); | 
|---|
| 274 | dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily)); | 
|---|
| 275 | dprintf(("GDI32: lfFaceName      = %s\n", lplf->lfFaceName)); | 
|---|
| 276 |  | 
|---|
| 277 | hFont = O32_CreateFontIndirect(&afont); | 
|---|
| 278 |  | 
|---|
| 279 | return(hFont); | 
|---|
| 280 | } | 
|---|
| 281 | //****************************************************************************** | 
|---|
| 282 | //****************************************************************************** | 
|---|
| 283 | ODINFUNCTION1(HFONT, CreateFontIndirectW,const LOGFONTW *, lplf) | 
|---|
| 284 | { | 
|---|
| 285 | LOGFONTA afont; | 
|---|
| 286 | HFONT    hfont; | 
|---|
| 287 |  | 
|---|
| 288 | //memcpy(&afont, lplf, ((ULONG)&afont.lfFaceName - (ULONG)&afont)); | 
|---|
| 289 | memcpy(&afont, lplf, sizeof(LOGFONTA)); | 
|---|
| 290 | memset(afont.lfFaceName, 0, LF_FACESIZE); | 
|---|
| 291 | dprintf(("lpszFace = (%x)", lplf->lfFaceName)); | 
|---|
| 292 |  | 
|---|
| 293 | UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1); | 
|---|
| 294 | hfont = CreateFontIndirectA(&afont); | 
|---|
| 295 | return(hfont); | 
|---|
| 296 | } | 
|---|
| 297 | //****************************************************************************** | 
|---|
| 298 | //****************************************************************************** | 
|---|
| 299 | int  EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA | 
|---|
| 300 | lpTextM, DWORD arg3, LPARAM arg4) | 
|---|
| 301 | { | 
|---|
| 302 | ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; | 
|---|
| 303 | FONTENUMPROCA proc = (FONTENUMPROCA)lpEnumData->userProc; | 
|---|
| 304 | USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel | 
|---|
| 305 |  | 
|---|
| 306 | int rc = proc(lpLogFont, lpTextM, arg3, lpEnumData->userData); | 
|---|
| 307 | SetFS(selTIB);           // switch back to the saved FS selector | 
|---|
| 308 | return rc; | 
|---|
| 309 | } | 
|---|
| 310 | //****************************************************************************** | 
|---|
| 311 | //****************************************************************************** | 
|---|
| 312 | int  EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM, | 
|---|
| 313 | DWORD arg3, LPARAM arg4) | 
|---|
| 314 | { | 
|---|
| 315 | ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; | 
|---|
| 316 | FONTENUMPROCW proc = (FONTENUMPROCW)lpEnumData->userProc; | 
|---|
| 317 | ENUMLOGFONTW LogFont; | 
|---|
| 318 | NEWTEXTMETRICW textM; | 
|---|
| 319 | USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel | 
|---|
| 320 | int rc; | 
|---|
| 321 |  | 
|---|
| 322 | memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - | 
|---|
| 323 | (ULONG)&LogFont)); | 
|---|
| 324 | AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1); | 
|---|
| 325 | AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1); | 
|---|
| 326 | AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1); | 
|---|
| 327 |  | 
|---|
| 328 | textM.tmHeight = lpTextM->tmHeight; | 
|---|
| 329 | textM.tmAscent = lpTextM->tmAscent; | 
|---|
| 330 | textM.tmDescent = lpTextM->tmDescent; | 
|---|
| 331 | textM.tmInternalLeading = lpTextM->tmInternalLeading; | 
|---|
| 332 | textM.tmExternalLeading = lpTextM->tmExternalLeading; | 
|---|
| 333 | textM.tmAveCharWidth = lpTextM->tmAveCharWidth; | 
|---|
| 334 | textM.tmMaxCharWidth = lpTextM->tmMaxCharWidth; | 
|---|
| 335 | textM.tmWeight = lpTextM->tmWeight; | 
|---|
| 336 | textM.tmOverhang = lpTextM->tmOverhang; | 
|---|
| 337 | textM.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX; | 
|---|
| 338 | textM.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY; | 
|---|
| 339 | textM.tmFirstChar = lpTextM->tmFirstChar; | 
|---|
| 340 | textM.tmLastChar = lpTextM->tmLastChar; | 
|---|
| 341 | textM.tmDefaultChar = lpTextM->tmDefaultChar; | 
|---|
| 342 | textM.tmBreakChar = lpTextM->tmBreakChar; | 
|---|
| 343 | textM.tmItalic = lpTextM->tmItalic; | 
|---|
| 344 | textM.tmUnderlined = lpTextM->tmUnderlined; | 
|---|
| 345 | textM.tmStruckOut = lpTextM->tmStruckOut; | 
|---|
| 346 | textM.tmPitchAndFamily = lpTextM->tmPitchAndFamily; | 
|---|
| 347 | textM.tmCharSet = lpTextM->tmCharSet; | 
|---|
| 348 | textM.ntmFlags = 0; | 
|---|
| 349 | textM.ntmSizeEM = 0; | 
|---|
| 350 | textM.ntmCellHeight = 0; | 
|---|
| 351 | textM.ntmAvgWidth = 0; | 
|---|
| 352 |  | 
|---|
| 353 | rc = proc(&LogFont, &textM, arg3, lpEnumData->userData); | 
|---|
| 354 | SetFS(selTIB);           // switch back to the saved FS selector | 
|---|
| 355 | return rc; | 
|---|
| 356 | } | 
|---|
| 357 | //****************************************************************************** | 
|---|
| 358 | //TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part) | 
|---|
| 359 | //****************************************************************************** | 
|---|
| 360 | int  EXPENTRY_O32 EnumFontProcExA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA | 
|---|
| 361 | lpTextM, DWORD arg3, LPARAM arg4) | 
|---|
| 362 | { | 
|---|
| 363 | ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; | 
|---|
| 364 | FONTENUMPROCEXA proc = (FONTENUMPROCEXA)lpEnumData->userProc; | 
|---|
| 365 | ENUMLOGFONTEXA logFont; | 
|---|
| 366 | NEWTEXTMETRICEXA textM; | 
|---|
| 367 | USHORT selTIB = SetWin32TIB(); // save current FS selector and set win32 sel | 
|---|
| 368 |  | 
|---|
| 369 | memcpy(&logFont, lpLogFont, sizeof(ENUMLOGFONTA)); | 
|---|
| 370 | memset(logFont.elfScript, 0, sizeof(logFont.elfScript)); | 
|---|
| 371 | memcpy(&textM.ntmetm, lpTextM, sizeof(textM.ntmetm)); | 
|---|
| 372 | memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature)); | 
|---|
| 373 |  | 
|---|
| 374 | dprintf(("EnumFontProcExA %s", logFont.elfLogFont.lfFaceName)); | 
|---|
| 375 |  | 
|---|
| 376 | int rc = proc(&logFont, &textM, arg3, lpEnumData->userData); | 
|---|
| 377 | SetFS(selTIB);           // switch back to the saved FS selector | 
|---|
| 378 | return rc; | 
|---|
| 379 | } | 
|---|
| 380 | //****************************************************************************** | 
|---|
| 381 | //TODO: FontEnumdwFlagsEx, script, font signature & NEWTEXTMETRICEX (last part) | 
|---|
| 382 | //****************************************************************************** | 
|---|
| 383 | int EXPENTRY_O32 EnumFontProcExW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM, | 
|---|
| 384 | DWORD arg3, LPARAM arg4) | 
|---|
| 385 | { | 
|---|
| 386 | ENUMUSERDATA *lpEnumData = (ENUMUSERDATA *)arg4; | 
|---|
| 387 | FONTENUMPROCEXW proc = (FONTENUMPROCEXW)lpEnumData->userProc; | 
|---|
| 388 | ENUMLOGFONTEXW LogFont; | 
|---|
| 389 | NEWTEXTMETRICEXW textM; | 
|---|
| 390 | int rc; | 
|---|
| 391 |  | 
|---|
| 392 | memcpy(&LogFont, lpLogFont, ((ULONG)&LogFont.elfLogFont.lfFaceName - (ULONG)&LogFont)); | 
|---|
| 393 | memset(LogFont.elfScript, 0, sizeof(LogFont.elfScript)); | 
|---|
| 394 | AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1); | 
|---|
| 395 | AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1); | 
|---|
| 396 | AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1); | 
|---|
| 397 |  | 
|---|
| 398 | textM.ntmetm.tmHeight = lpTextM->tmHeight; | 
|---|
| 399 | textM.ntmetm.tmAscent = lpTextM->tmAscent; | 
|---|
| 400 | textM.ntmetm.tmDescent = lpTextM->tmDescent; | 
|---|
| 401 | textM.ntmetm.tmInternalLeading = lpTextM->tmInternalLeading; | 
|---|
| 402 | textM.ntmetm.tmExternalLeading = lpTextM->tmExternalLeading; | 
|---|
| 403 | textM.ntmetm.tmAveCharWidth = lpTextM->tmAveCharWidth; | 
|---|
| 404 | textM.ntmetm.tmMaxCharWidth = lpTextM->tmMaxCharWidth; | 
|---|
| 405 | textM.ntmetm.tmWeight = lpTextM->tmWeight; | 
|---|
| 406 | textM.ntmetm.tmOverhang = lpTextM->tmOverhang; | 
|---|
| 407 | textM.ntmetm.tmDigitizedAspectX = lpTextM->tmDigitizedAspectX; | 
|---|
| 408 | textM.ntmetm.tmDigitizedAspectY = lpTextM->tmDigitizedAspectY; | 
|---|
| 409 | textM.ntmetm.tmFirstChar = lpTextM->tmFirstChar; | 
|---|
| 410 | textM.ntmetm.tmLastChar = lpTextM->tmLastChar; | 
|---|
| 411 | textM.ntmetm.tmDefaultChar = lpTextM->tmDefaultChar; | 
|---|
| 412 | textM.ntmetm.tmBreakChar = lpTextM->tmBreakChar; | 
|---|
| 413 | textM.ntmetm.tmItalic = lpTextM->tmItalic; | 
|---|
| 414 | textM.ntmetm.tmUnderlined = lpTextM->tmUnderlined; | 
|---|
| 415 | textM.ntmetm.tmStruckOut = lpTextM->tmStruckOut; | 
|---|
| 416 | textM.ntmetm.tmPitchAndFamily = lpTextM->tmPitchAndFamily; | 
|---|
| 417 | textM.ntmetm.tmCharSet = lpTextM->tmCharSet; | 
|---|
| 418 | textM.ntmetm.ntmFlags = 0; | 
|---|
| 419 | textM.ntmetm.ntmSizeEM = 0; | 
|---|
| 420 | textM.ntmetm.ntmCellHeight = 0; | 
|---|
| 421 | textM.ntmetm.ntmAvgWidth = 0; | 
|---|
| 422 | memset(&textM.ntmeFontSignature, 0, sizeof(textM.ntmeFontSignature)); | 
|---|
| 423 |  | 
|---|
| 424 | dprintf(("EnumFontProcExW %s", lpLogFont->elfLogFont.lfFaceName)); | 
|---|
| 425 | return proc(&LogFont, &textM, arg3, lpEnumData->userData); | 
|---|
| 426 | } | 
|---|
| 427 | //****************************************************************************** | 
|---|
| 428 | //****************************************************************************** | 
|---|
| 429 | ODINFUNCTION4(int, EnumFontsA, | 
|---|
| 430 | HDC, arg1, | 
|---|
| 431 | LPCSTR, arg2, | 
|---|
| 432 | FONTENUMPROCA, arg3, | 
|---|
| 433 | LPARAM,  arg4) | 
|---|
| 434 | { | 
|---|
| 435 | //@@@PH shouldn't this rather be O32_EnumFonts ? | 
|---|
| 436 | return EnumFontFamiliesA(arg1, arg2, arg3, arg4); | 
|---|
| 437 | } | 
|---|
| 438 | //****************************************************************************** | 
|---|
| 439 | //****************************************************************************** | 
|---|
| 440 | ODINFUNCTION4(int, EnumFontsW, | 
|---|
| 441 | HDC, arg1, | 
|---|
| 442 | LPCWSTR, arg2, | 
|---|
| 443 | FONTENUMPROCW, arg3, | 
|---|
| 444 | LPARAM,  arg4) | 
|---|
| 445 | { | 
|---|
| 446 | //@@@PH shouldn't this rather be O32_EnumFonts ? | 
|---|
| 447 | return EnumFontFamiliesW(arg1, arg2, arg3, arg4); | 
|---|
| 448 | } | 
|---|
| 449 | //****************************************************************************** | 
|---|
| 450 | //****************************************************************************** | 
|---|
| 451 | ODINFUNCTION4(int, EnumFontFamiliesA, | 
|---|
| 452 | HDC, arg1, | 
|---|
| 453 | LPCSTR, arg2, | 
|---|
| 454 | FONTENUMPROCA, arg3, | 
|---|
| 455 | LPARAM, arg4) | 
|---|
| 456 | { | 
|---|
| 457 | ENUMUSERDATA enumData; | 
|---|
| 458 | int rc; | 
|---|
| 459 |  | 
|---|
| 460 | dprintf(("GDI32: EnumFontFamiliesA %s", arg2)); | 
|---|
| 461 |  | 
|---|
| 462 | enumData.userProc = (DWORD)arg3; | 
|---|
| 463 | enumData.userData = arg4; | 
|---|
| 464 |  | 
|---|
| 465 | rc = O32_EnumFontFamilies(arg1, arg2, &EnumFontProcA, (LPARAM)&enumData); | 
|---|
| 466 |  | 
|---|
| 467 | return rc; | 
|---|
| 468 | } | 
|---|
| 469 | //****************************************************************************** | 
|---|
| 470 | //****************************************************************************** | 
|---|
| 471 | ODINFUNCTION4(int, EnumFontFamiliesW, | 
|---|
| 472 | HDC, arg1, | 
|---|
| 473 | LPCWSTR, arg2, | 
|---|
| 474 | FONTENUMPROCW, arg3, | 
|---|
| 475 | LPARAM, arg4) | 
|---|
| 476 | { | 
|---|
| 477 | ENUMUSERDATA enumData; | 
|---|
| 478 | int rc; | 
|---|
| 479 | char *astring = UnicodeToAsciiString((LPWSTR)arg2); | 
|---|
| 480 |  | 
|---|
| 481 | dprintf(("GDI32: EnumFontFamiliesW %s", astring)); | 
|---|
| 482 |  | 
|---|
| 483 | enumData.userProc = (DWORD)arg3; | 
|---|
| 484 | enumData.userData = arg4; | 
|---|
| 485 |  | 
|---|
| 486 | rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcW, (LPARAM)&enumData); | 
|---|
| 487 |  | 
|---|
| 488 | FreeAsciiString(astring); | 
|---|
| 489 | return rc; | 
|---|
| 490 | } | 
|---|
| 491 | //****************************************************************************** | 
|---|
| 492 | //****************************************************************************** | 
|---|
| 493 | ODINFUNCTION5(INT, EnumFontFamiliesExA, | 
|---|
| 494 | HDC, arg1, | 
|---|
| 495 | LPLOGFONTA, arg2, | 
|---|
| 496 | FONTENUMPROCEXA, arg3, | 
|---|
| 497 | LPARAM, arg4, | 
|---|
| 498 | DWORD, dwFlags) | 
|---|
| 499 | { | 
|---|
| 500 | ENUMUSERDATA enumData; | 
|---|
| 501 | int rc; | 
|---|
| 502 |  | 
|---|
| 503 | dprintf(("GDI32: EnumFontFamiliesExA not complete %s", arg2->lfFaceName)); | 
|---|
| 504 |  | 
|---|
| 505 | enumData.userProc = (DWORD)arg3; | 
|---|
| 506 | enumData.userData = arg4; | 
|---|
| 507 | enumData.dwFlags  = dwFlags; | 
|---|
| 508 |  | 
|---|
| 509 | rc = O32_EnumFontFamilies(arg1, arg2->lfFaceName, &EnumFontProcExA, (LPARAM)&enumData); | 
|---|
| 510 |  | 
|---|
| 511 | return rc; | 
|---|
| 512 | } | 
|---|
| 513 | //****************************************************************************** | 
|---|
| 514 | //****************************************************************************** | 
|---|
| 515 | ODINFUNCTION5(INT, EnumFontFamiliesExW, | 
|---|
| 516 | HDC, arg1, | 
|---|
| 517 | LPLOGFONTW, arg2, | 
|---|
| 518 | FONTENUMPROCEXW, arg3, | 
|---|
| 519 | LPARAM, arg4, | 
|---|
| 520 | DWORD, dwFlags) | 
|---|
| 521 | { | 
|---|
| 522 | ENUMUSERDATA enumData; | 
|---|
| 523 | int rc; | 
|---|
| 524 | char *astring = UnicodeToAsciiString((LPWSTR)arg2->lfFaceName); | 
|---|
| 525 |  | 
|---|
| 526 | dprintf(("GDI32: EnumFontFamiliesExW not complete %s", astring)); | 
|---|
| 527 |  | 
|---|
| 528 | enumData.userProc = (DWORD)arg3; | 
|---|
| 529 | enumData.userData = arg4; | 
|---|
| 530 | enumData.dwFlags  = dwFlags; | 
|---|
| 531 |  | 
|---|
| 532 | rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcExW, (LPARAM)&enumData); | 
|---|
| 533 |  | 
|---|
| 534 | FreeAsciiString(astring); | 
|---|
| 535 | return rc; | 
|---|
| 536 | } | 
|---|
| 537 | //****************************************************************************** | 
|---|
| 538 | //****************************************************************************** | 
|---|
| 539 | ODINFUNCTION5(DWORD, GetFontData, | 
|---|
| 540 | HDC, hdc, | 
|---|
| 541 | DWORD, dwTable, | 
|---|
| 542 | DWORD, dwOffset, | 
|---|
| 543 | LPVOID, lpvBuffer, | 
|---|
| 544 | DWORD, dbData) | 
|---|
| 545 | { | 
|---|
| 546 | dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n")); | 
|---|
| 547 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); | 
|---|
| 548 |  | 
|---|
| 549 | return(GDI_ERROR); | 
|---|
| 550 | } | 
|---|
| 551 | //****************************************************************************** | 
|---|
| 552 | //****************************************************************************** | 
|---|
| 553 | ODINFUNCTION1(int, AddFontResourceA, | 
|---|
| 554 | LPCSTR, szFont) | 
|---|
| 555 | { | 
|---|
| 556 | HINSTANCE hInstance; | 
|---|
| 557 |  | 
|---|
| 558 | dprintf(("GDI32: AddFontResourceA %s", szFont)); | 
|---|
| 559 | hInstance = LoadLibraryA(szFont); | 
|---|
| 560 | if(hInstance) { | 
|---|
| 561 | dprintf(("AddFontResourceA: executable file; NOT IMPLEMENTED")); | 
|---|
| 562 | FreeLibrary(hInstance); | 
|---|
| 563 | return 1; | 
|---|
| 564 | } | 
|---|
| 565 | return O32_AddFontResource(szFont); | 
|---|
| 566 | } | 
|---|
| 567 | //****************************************************************************** | 
|---|
| 568 | //****************************************************************************** | 
|---|
| 569 | ODINFUNCTION1(int, AddFontResourceW, | 
|---|
| 570 | LPCWSTR, szFont) | 
|---|
| 571 | { | 
|---|
| 572 | char *astring = UnicodeToAsciiString((LPWSTR)szFont); | 
|---|
| 573 | BOOL  rc; | 
|---|
| 574 |  | 
|---|
| 575 | dprintf(("GDI32: AddFontResourceW")); | 
|---|
| 576 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 577 | rc = AddFontResourceA(astring); | 
|---|
| 578 | FreeAsciiString(astring); | 
|---|
| 579 | return rc; | 
|---|
| 580 | } | 
|---|
| 581 | //****************************************************************************** | 
|---|
| 582 | //****************************************************************************** | 
|---|
| 583 | ODINFUNCTION1(BOOL, RemoveFontResourceA, | 
|---|
| 584 | LPCSTR, arg1) | 
|---|
| 585 | { | 
|---|
| 586 | dprintf(("GDI32: RemoveFontResourceA %s\n", arg1)); | 
|---|
| 587 | return O32_RemoveFontResource(arg1); | 
|---|
| 588 | } | 
|---|
| 589 | //****************************************************************************** | 
|---|
| 590 | //****************************************************************************** | 
|---|
| 591 | ODINFUNCTION1(BOOL, RemoveFontResourceW, | 
|---|
| 592 | LPCWSTR, szFont) | 
|---|
| 593 | { | 
|---|
| 594 | char *astring = UnicodeToAsciiString((LPWSTR)szFont); | 
|---|
| 595 | BOOL  rc; | 
|---|
| 596 |  | 
|---|
| 597 | dprintf(("GDI32: RemoveFontResourceW")); | 
|---|
| 598 | rc = RemoveFontResourceA(astring); | 
|---|
| 599 | FreeAsciiString(astring); | 
|---|
| 600 | return(rc); | 
|---|
| 601 | } | 
|---|
| 602 | /***************************************************************************** | 
|---|
| 603 | * Name      : BOOL CreateScalableFontResourceA | 
|---|
| 604 | * Purpose   : The CreateScalableFontResourceA function creates a font resource | 
|---|
| 605 | *             file for a scalable font. | 
|---|
| 606 | * Parameters: DWORD   fdwHidden       flag for read-only embedded font | 
|---|
| 607 | *             LPCSTR lpszFontRes     address of filename for font resource | 
|---|
| 608 | *             LPCSTR lpszFontFile    address of filename for scalable font | 
|---|
| 609 | *             LPCSTR lpszCurrentPath address of path to font file | 
|---|
| 610 | * Variables : | 
|---|
| 611 | * Result    : TRUE / FALSE | 
|---|
| 612 | * Remark    : | 
|---|
| 613 | * Status    : UNTESTED STUB | 
|---|
| 614 | * | 
|---|
| 615 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 616 | *****************************************************************************/ | 
|---|
| 617 |  | 
|---|
| 618 | ODINFUNCTION4(BOOL, CreateScalableFontResourceA, | 
|---|
| 619 | DWORD, fdwHidden, | 
|---|
| 620 | LPCSTR, lpszFontRes, | 
|---|
| 621 | LPCSTR, lpszFontFile, | 
|---|
| 622 | LPCSTR, lpszCurrentPath) | 
|---|
| 623 | { | 
|---|
| 624 | dprintf(("GDI32: CreateScalableFontResourceA not implemented.\n")); | 
|---|
| 625 |  | 
|---|
| 626 | return (FALSE); | 
|---|
| 627 | } | 
|---|
| 628 |  | 
|---|
| 629 |  | 
|---|
| 630 | /***************************************************************************** | 
|---|
| 631 | * Name      : BOOL CreateScalableFontResourceW | 
|---|
| 632 | * Purpose   : The CreateScalableFontResourceW function creates a font resource | 
|---|
| 633 | *             file for a scalable font. | 
|---|
| 634 | * Parameters: DWORD   fdwHidden       flag for read-only embedded font | 
|---|
| 635 | *             LPCSTR lpszFontRes     address of filename for font resource | 
|---|
| 636 | *             LPCSTR lpszFontFile    address of filename for scalable font | 
|---|
| 637 | *             LPCSTR lpszCurrentPath address of path to font file | 
|---|
| 638 | * Variables : | 
|---|
| 639 | * Result    : TRUE / FALSE | 
|---|
| 640 | * Remark    : | 
|---|
| 641 | * Status    : UNTESTED STUB | 
|---|
| 642 | * | 
|---|
| 643 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 644 | *****************************************************************************/ | 
|---|
| 645 |  | 
|---|
| 646 | ODINFUNCTION4(BOOL, CreateScalableFontResourceW, | 
|---|
| 647 | DWORD, fdwHidden, | 
|---|
| 648 | LPCWSTR, lpszFontRes, | 
|---|
| 649 | LPCWSTR, lpszFontFile, | 
|---|
| 650 | LPCWSTR, lpszCurrentPath) | 
|---|
| 651 | { | 
|---|
| 652 | dprintf(("GDI32: CreateScalableFontResourceW not implemented.\n")); | 
|---|
| 653 |  | 
|---|
| 654 | return (FALSE); | 
|---|
| 655 | } | 
|---|
| 656 |  | 
|---|
| 657 |  | 
|---|
| 658 | /***************************************************************************** | 
|---|
| 659 | * Name      : DWORD GetFontLanguageInfo | 
|---|
| 660 | * Purpose   : The GetFontLanguageInfo function returns information about the | 
|---|
| 661 | *             currently selected font for the specified display context. | 
|---|
| 662 | *             Applications typically use this information and the | 
|---|
| 663 | *             GetCharacterPlacement function to prepare a character string for display. | 
|---|
| 664 | * Parameters: HDC     hdc        handle to device context | 
|---|
| 665 | * Variables : | 
|---|
| 666 | * Result    : | 
|---|
| 667 | * Remark    : | 
|---|
| 668 | * Status    : UNTESTED STUB | 
|---|
| 669 | * | 
|---|
| 670 | * Author    : Patrick Haller [Mon, 1998/06/15 08:00] | 
|---|
| 671 | *****************************************************************************/ | 
|---|
| 672 |  | 
|---|
| 673 | ODINFUNCTION1(DWORD, GetFontLanguageInfo, | 
|---|
| 674 | HDC, hdc) | 
|---|
| 675 | { | 
|---|
| 676 | dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n", | 
|---|
| 677 | hdc)); | 
|---|
| 678 |  | 
|---|
| 679 | return (0); | 
|---|
| 680 | } | 
|---|
| 681 |  | 
|---|
| 682 |  | 
|---|
| 683 | /************************************************************************* | 
|---|
| 684 | * TranslateCharsetInfo [GDI32.382] | 
|---|
| 685 | * | 
|---|
| 686 | * Fills a CHARSETINFO structure for a character set, code page, or | 
|---|
| 687 | * font. This allows making the correspondance between different labelings | 
|---|
| 688 | * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges) | 
|---|
| 689 | * of the same encoding. | 
|---|
| 690 | * | 
|---|
| 691 | * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used, | 
|---|
| 692 | * only one codepage should be set in *lpSrc. | 
|---|
| 693 | * | 
|---|
| 694 | * RETURNS | 
|---|
| 695 | *   TRUE on success, FALSE on failure. | 
|---|
| 696 | * | 
|---|
| 697 | * | 
|---|
| 698 | * LPDWORD lpSrc, if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE | 
|---|
| 699 | *                if flags == TCI_SRCCHARSET: a character set value | 
|---|
| 700 | *                if flags == TCI_SRCCODEPAGE: a code page value | 
|---|
| 701 | * LPCHARSETINFO lpCs, structure to receive charset information | 
|---|
| 702 | * DWORD flags  determines interpretation of lpSrc | 
|---|
| 703 | */ | 
|---|
| 704 | ODINFUNCTION3(BOOL, TranslateCharsetInfo, | 
|---|
| 705 | LPDWORD, lpSrc, | 
|---|
| 706 | LPCHARSETINFO, lpCs, | 
|---|
| 707 | DWORD, flags) | 
|---|
| 708 | { | 
|---|
| 709 | int index = 0; | 
|---|
| 710 | switch (flags) { | 
|---|
| 711 | case TCI_SRCFONTSIG: | 
|---|
| 712 | while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++; | 
|---|
| 713 | break; | 
|---|
| 714 | case TCI_SRCCODEPAGE: | 
|---|
| 715 | while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++; | 
|---|
| 716 | break; | 
|---|
| 717 | case TCI_SRCCHARSET: | 
|---|
| 718 | while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++; | 
|---|
| 719 | break; | 
|---|
| 720 | default: | 
|---|
| 721 | return FALSE; | 
|---|
| 722 | } | 
|---|
| 723 | if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE; | 
|---|
| 724 | memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO)); | 
|---|
| 725 | return TRUE; | 
|---|
| 726 | } | 
|---|
| 727 | //****************************************************************************** | 
|---|
| 728 | //****************************************************************************** | 
|---|