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