| 1 | /* $Id: font.cpp,v 1.1 1999-10-20 22:36:53 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * GDI32 font apis
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1999 Edgar Buerkle (Edgar.Buerkle@gmx.ne)
|
|---|
| 7 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 8 | * Copyright 1998 Patrick Haller
|
|---|
| 9 | *
|
|---|
| 10 | * TODO: EnumFontsA/W, EnumFontFamiliesExA/W + others
|
|---|
| 11 | *
|
|---|
| 12 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 13 | *
|
|---|
| 14 | */
|
|---|
| 15 | #include <os2win.h>
|
|---|
| 16 | #include <stdlib.h>
|
|---|
| 17 | #include <stdarg.h>
|
|---|
| 18 | #include <string.h>
|
|---|
| 19 | #include "misc.h"
|
|---|
| 20 | #include "unicode.h"
|
|---|
| 21 | #include <vmutex.h>
|
|---|
| 22 |
|
|---|
| 23 | VMutex mutexProcWinA;
|
|---|
| 24 | VMutex mutexProcWinW;
|
|---|
| 25 | FONTENUMPROCA FontEnumProcWinA;
|
|---|
| 26 | FONTENUMPROCW FontEnumProcWinW;
|
|---|
| 27 |
|
|---|
| 28 | //******************************************************************************
|
|---|
| 29 | //******************************************************************************
|
|---|
| 30 | HFONT WIN32API CreateFontA(int arg1, int arg2, int arg3, int arg4, int arg5,
|
|---|
| 31 | DWORD arg6, DWORD arg7, DWORD arg8, DWORD arg9,
|
|---|
| 32 | DWORD arg10, DWORD arg11, DWORD arg12, DWORD arg13, LPCSTR arg14)
|
|---|
| 33 | {
|
|---|
| 34 | HFONT hfont;
|
|---|
| 35 |
|
|---|
| 36 | hfont = O32_CreateFont(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
|
|---|
| 37 | dprintf(("GDI32: CreateFontA '%s' returned %D\n", arg14, hfont));
|
|---|
| 38 | return(hfont);
|
|---|
| 39 | }
|
|---|
| 40 | //******************************************************************************
|
|---|
| 41 | //******************************************************************************
|
|---|
| 42 | HFONT WIN32API CreateFontW(int arg1, int arg2, int arg3, int arg4, int arg5,
|
|---|
| 43 | DWORD arg6, DWORD arg7, DWORD arg8, DWORD arg9,
|
|---|
| 44 | DWORD arg10, DWORD arg11, DWORD arg12, DWORD arg13, LPCWSTR arg14)
|
|---|
| 45 | {
|
|---|
| 46 | char *astring = UnicodeToAsciiString((LPWSTR)arg14);
|
|---|
| 47 | HFONT rc;
|
|---|
| 48 |
|
|---|
| 49 | dprintf(("GDI32: OS2CreateFontW\n"));
|
|---|
| 50 | rc = O32_CreateFont(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, astring);
|
|---|
| 51 | FreeAsciiString(astring);
|
|---|
| 52 | return(rc);
|
|---|
| 53 | }
|
|---|
| 54 | //******************************************************************************
|
|---|
| 55 | //******************************************************************************
|
|---|
| 56 | HFONT WIN32API CreateFontIndirectA(const LOGFONTA *lplf)
|
|---|
| 57 | {
|
|---|
| 58 | HFONT rc;
|
|---|
| 59 |
|
|---|
| 60 | dprintf(("GDI32: CreateFontIndirectA\n"));
|
|---|
| 61 | dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight));
|
|---|
| 62 | dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth));
|
|---|
| 63 | dprintf(("GDI32: lfEscapement = %d\n", lplf->lfEscapement));
|
|---|
| 64 | dprintf(("GDI32: lfOrientation = %d\n", lplf->lfOrientation));
|
|---|
| 65 | dprintf(("GDI32: lfWeight = %d\n", lplf->lfWeight));
|
|---|
| 66 | dprintf(("GDI32: lfItalic = %d\n", lplf->lfItalic));
|
|---|
| 67 | dprintf(("GDI32: lfUnderline = %d\n", lplf->lfUnderline));
|
|---|
| 68 | dprintf(("GDI32: lfStrikeOut = %d\n", lplf->lfStrikeOut));
|
|---|
| 69 | dprintf(("GDI32: lfCharSet = %X\n", lplf->lfCharSet));
|
|---|
| 70 | dprintf(("GDI32: lfOutPrecision = %X\n", lplf->lfOutPrecision));
|
|---|
| 71 | dprintf(("GDI32: lfClipPrecision = %X\n", lplf->lfClipPrecision));
|
|---|
| 72 | dprintf(("GDI32: lfQuality = %X\n", lplf->lfQuality));
|
|---|
| 73 | dprintf(("GDI32: lfPitchAndFamily= %X\n", lplf->lfPitchAndFamily));
|
|---|
| 74 | dprintf(("GDI32: lfFaceName = %s\n", lplf->lfFaceName));
|
|---|
| 75 | rc = O32_CreateFontIndirect(lplf);
|
|---|
| 76 | dprintf(("GDI32: OS2CreateFontIndirectA returned %X\n", rc));
|
|---|
| 77 | return(rc);
|
|---|
| 78 | }
|
|---|
| 79 | //******************************************************************************
|
|---|
| 80 | //******************************************************************************
|
|---|
| 81 | HFONT WIN32API CreateFontIndirectW(const LOGFONTW *lplf)
|
|---|
| 82 | {
|
|---|
| 83 | LOGFONTA afont;
|
|---|
| 84 | HFONT hfont;
|
|---|
| 85 |
|
|---|
| 86 | memcpy(&afont, lplf, ((int)&afont.lfFaceName - (int)&afont));
|
|---|
| 87 | memcpy(&afont, lplf, ((int)&afont.lfFaceName - (int)&afont));
|
|---|
| 88 | UnicodeToAsciiN((WCHAR *)lplf->lfFaceName, afont.lfFaceName, LF_FACESIZE-1);
|
|---|
| 89 |
|
|---|
| 90 | hfont = O32_CreateFontIndirect(&afont);
|
|---|
| 91 | dprintf(("GDI32: CreateFontIndirectW\n"));
|
|---|
| 92 | dprintf(("GDI32: lfHeight = %d\n", lplf->lfHeight));
|
|---|
| 93 | dprintf(("GDI32: lfWidth = %d\n", lplf->lfWidth));
|
|---|
| 94 | dprintf(("GDI32: lfHeight = %d\n", afont.lfHeight));
|
|---|
| 95 | dprintf(("GDI32: lfWidth = %d\n", afont.lfWidth));
|
|---|
| 96 | dprintf(("GDI32: lfEscapement = %d\n", afont.lfEscapement));
|
|---|
| 97 | dprintf(("GDI32: lfOrientation = %d\n", afont.lfOrientation));
|
|---|
| 98 | dprintf(("GDI32: lfWeight = %d\n", afont.lfWeight));
|
|---|
| 99 | dprintf(("GDI32: lfItalic = %d\n", afont.lfItalic));
|
|---|
| 100 | dprintf(("GDI32: lfUnderline = %d\n", afont.lfUnderline));
|
|---|
| 101 | dprintf(("GDI32: lfStrikeOut = %d\n", afont.lfStrikeOut));
|
|---|
| 102 | dprintf(("GDI32: lfCharSet = %X\n", afont.lfCharSet));
|
|---|
| 103 | dprintf(("GDI32: lfOutPrecision = %X\n", afont.lfOutPrecision));
|
|---|
| 104 | dprintf(("GDI32: lfClipPrecision = %X\n", afont.lfClipPrecision));
|
|---|
| 105 | dprintf(("GDI32: lfQuality = %X\n", afont.lfQuality));
|
|---|
| 106 | dprintf(("GDI32: lfPitchAndFamily= %X\n", afont.lfPitchAndFamily));
|
|---|
| 107 | dprintf(("GDI32: lfFaceName = %s\n", afont.lfFaceName));
|
|---|
| 108 | dprintf(("GDI32: CreateFontIndirectW %s returned %X\n", afont.lfFaceName, hfont));
|
|---|
| 109 |
|
|---|
| 110 | return(hfont);
|
|---|
| 111 | }
|
|---|
| 112 | //******************************************************************************
|
|---|
| 113 | //******************************************************************************
|
|---|
| 114 | int EXPENTRY_O32 EnumFontProcA(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA
|
|---|
| 115 | lpTextM, DWORD arg3, LPARAM arg4)
|
|---|
| 116 | {
|
|---|
| 117 | return FontEnumProcWinA(lpLogFont, lpTextM, arg3, arg4);
|
|---|
| 118 | }
|
|---|
| 119 | //******************************************************************************
|
|---|
| 120 | //******************************************************************************
|
|---|
| 121 | int EXPENTRY_O32 EnumFontProcW(LPENUMLOGFONTA lpLogFont, LPNEWTEXTMETRICA lpTextM,
|
|---|
| 122 | DWORD arg3, LPARAM arg4)
|
|---|
| 123 | {
|
|---|
| 124 | ENUMLOGFONTW LogFont;
|
|---|
| 125 | int rc;
|
|---|
| 126 |
|
|---|
| 127 | memcpy(&LogFont, lpLogFont, ((int)&LogFont.elfLogFont.lfFaceName -
|
|---|
| 128 | (int)&LogFont));
|
|---|
| 129 | AsciiToUnicodeN(lpLogFont->elfLogFont.lfFaceName, LogFont.elfLogFont.lfFaceName, LF_FACESIZE-1);
|
|---|
| 130 | AsciiToUnicodeN((char *) lpLogFont->elfFullName, LogFont.elfFullName, LF_FULLFACESIZE-1);
|
|---|
| 131 | AsciiToUnicodeN((char *) lpLogFont->elfStyle, LogFont.elfStyle, LF_FACESIZE-1);
|
|---|
| 132 |
|
|---|
| 133 | rc = FontEnumProcWinW(&LogFont, (LPNEWTEXTMETRICW) lpTextM, arg3, arg4);
|
|---|
| 134 | return rc;
|
|---|
| 135 | }
|
|---|
| 136 | //******************************************************************************
|
|---|
| 137 | //******************************************************************************
|
|---|
| 138 | int WIN32API EnumFontsA( HDC arg1, LPCSTR arg2, FONTENUMPROCA arg3, LPARAM arg4)
|
|---|
| 139 | {
|
|---|
| 140 | dprintf(("GDI32: OS2EnumFontsA"));
|
|---|
| 141 | // return O32_EnumFonts(arg1, arg2, arg3, arg4);
|
|---|
| 142 | return 1;
|
|---|
| 143 | }
|
|---|
| 144 | //******************************************************************************
|
|---|
| 145 | //TODO: Callback
|
|---|
| 146 | //******************************************************************************
|
|---|
| 147 | int WIN32API EnumFontsW( HDC arg1, LPCWSTR arg2, FONTENUMPROCW arg3, LPARAM arg4)
|
|---|
| 148 | {
|
|---|
| 149 | dprintf(("GDI32: OS2EnumFontsW - stub (1)"));
|
|---|
| 150 | // NOTE: This will not work as is (needs UNICODE support)
|
|---|
| 151 | // return O32_EnumFonts(arg1, arg2, arg3, arg4);
|
|---|
| 152 | return 1;
|
|---|
| 153 | }
|
|---|
| 154 | //******************************************************************************
|
|---|
| 155 | //******************************************************************************
|
|---|
| 156 | int WIN32API EnumFontFamiliesA(HDC arg1,
|
|---|
| 157 | LPCSTR arg2,
|
|---|
| 158 | FONTENUMPROCA arg3,
|
|---|
| 159 | LPARAM arg4)
|
|---|
| 160 | {
|
|---|
| 161 | int rc;
|
|---|
| 162 |
|
|---|
| 163 | dprintf(("GDI32: OS2EnumFontFamiliesA "));
|
|---|
| 164 |
|
|---|
| 165 | mutexProcWinA.enter();
|
|---|
| 166 |
|
|---|
| 167 | FontEnumProcWinA = arg3;
|
|---|
| 168 |
|
|---|
| 169 | rc = O32_EnumFontFamilies(arg1, arg2, &EnumFontProcA, arg4);
|
|---|
| 170 |
|
|---|
| 171 | mutexProcWinA.leave();
|
|---|
| 172 | return rc;
|
|---|
| 173 | }
|
|---|
| 174 | //******************************************************************************
|
|---|
| 175 | //******************************************************************************
|
|---|
| 176 | int WIN32API EnumFontFamiliesW(HDC arg1,
|
|---|
| 177 | LPCWSTR arg2,
|
|---|
| 178 | FONTENUMPROCW arg3,
|
|---|
| 179 | LPARAM arg4)
|
|---|
| 180 | {
|
|---|
| 181 | int rc;
|
|---|
| 182 | char *astring = UnicodeToAsciiString((LPWSTR)arg2);
|
|---|
| 183 |
|
|---|
| 184 | dprintf(("GDI32: OS2EnumFontFamiliesW "));
|
|---|
| 185 |
|
|---|
| 186 | mutexProcWinW.enter();
|
|---|
| 187 |
|
|---|
| 188 | FontEnumProcWinW = arg3;
|
|---|
| 189 |
|
|---|
| 190 | rc = O32_EnumFontFamilies(arg1, astring, &EnumFontProcW, arg4);
|
|---|
| 191 |
|
|---|
| 192 | mutexProcWinW.leave();
|
|---|
| 193 |
|
|---|
| 194 | FreeAsciiString(astring);
|
|---|
| 195 | return rc;
|
|---|
| 196 | }
|
|---|
| 197 | //******************************************************************************
|
|---|
| 198 | //******************************************************************************
|
|---|
| 199 | INT WIN32API EnumFontFamiliesExA( HDC arg1, LPLOGFONTA arg2, FONTENUMPROCEXA arg3, LPARAM arg4, DWORD dwFlags)
|
|---|
| 200 | {
|
|---|
| 201 | dprintf(("GDI32: OS2EnumFontFamiliesExA, not implemented\n"));
|
|---|
| 202 | return 0;
|
|---|
| 203 | }
|
|---|
| 204 | //******************************************************************************
|
|---|
| 205 | //******************************************************************************
|
|---|
| 206 | INT WIN32API EnumFontFamiliesExW( HDC arg1, LPLOGFONTW arg2, FONTENUMPROCEXW arg3, LPARAM arg4, DWORD dwFlags)
|
|---|
| 207 | {
|
|---|
| 208 | dprintf(("GDI32: OS2EnumFontFamiliesW, not implemented\n"));
|
|---|
| 209 | // NOTE: This will not work as is (needs UNICODE support)
|
|---|
| 210 | return 0;
|
|---|
| 211 | }
|
|---|
| 212 | //******************************************************************************
|
|---|
| 213 | //******************************************************************************
|
|---|
| 214 | DWORD WIN32API GetFontData(HDC hdc, DWORD dwTable, DWORD dwOffset, LPVOID lpvBuffer,
|
|---|
| 215 | DWORD dbData)
|
|---|
| 216 | {
|
|---|
| 217 | dprintf(("GDI32: GetFontData, not implemented (GDI_ERROR)\n"));
|
|---|
| 218 | return(GDI_ERROR);
|
|---|
| 219 | }
|
|---|
| 220 | //******************************************************************************
|
|---|
| 221 | //******************************************************************************
|
|---|
| 222 | int WIN32API AddFontResourceA( LPCSTR arg1)
|
|---|
| 223 | {
|
|---|
| 224 | dprintf(("GDI32: OS2AddFontResourceA"));
|
|---|
| 225 | return O32_AddFontResource(arg1);
|
|---|
| 226 | }
|
|---|
| 227 | //******************************************************************************
|
|---|
| 228 | //******************************************************************************
|
|---|
| 229 | int WIN32API AddFontResourceW( LPCWSTR arg1)
|
|---|
| 230 | {
|
|---|
| 231 | dprintf(("GDI32: OS2AddFontResourceW STUB"));
|
|---|
| 232 | // NOTE: This will not work as is (needs UNICODE support)
|
|---|
| 233 | // return O32_AddFontResource(arg1);
|
|---|
| 234 | return 0;
|
|---|
| 235 | }
|
|---|
| 236 | //******************************************************************************
|
|---|
| 237 | //******************************************************************************
|
|---|
| 238 | BOOL WIN32API RemoveFontResourceA( LPCSTR arg1)
|
|---|
| 239 | {
|
|---|
| 240 | dprintf(("GDI32: OS2RemoveFontResourceA %s\n", arg1));
|
|---|
| 241 | return O32_RemoveFontResource(arg1);
|
|---|
| 242 | }
|
|---|
| 243 | //******************************************************************************
|
|---|
| 244 | //******************************************************************************
|
|---|
| 245 | BOOL WIN32API RemoveFontResourceW(LPCWSTR arg1)
|
|---|
| 246 | {
|
|---|
| 247 | char *astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 248 | BOOL rc;
|
|---|
| 249 |
|
|---|
| 250 | dprintf(("GDI32: OS2RemoveFontResourceW\n"));
|
|---|
| 251 | rc = O32_RemoveFontResource(astring);
|
|---|
| 252 | FreeAsciiString(astring);
|
|---|
| 253 | return(rc);
|
|---|
| 254 | }
|
|---|
| 255 | /*****************************************************************************
|
|---|
| 256 | * Name : BOOL CreateScalableFontResourceA
|
|---|
| 257 | * Purpose : The CreateScalableFontResourceA function creates a font resource
|
|---|
| 258 | * file for a scalable font.
|
|---|
| 259 | * Parameters: DWORD fdwHidden flag for read-only embedded font
|
|---|
| 260 | * LPCSTR lpszFontRes address of filename for font resource
|
|---|
| 261 | * LPCSTR lpszFontFile address of filename for scalable font
|
|---|
| 262 | * LPCSTR lpszCurrentPath address of path to font file
|
|---|
| 263 | * Variables :
|
|---|
| 264 | * Result : TRUE / FALSE
|
|---|
| 265 | * Remark :
|
|---|
| 266 | * Status : UNTESTED STUB
|
|---|
| 267 | *
|
|---|
| 268 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 269 | *****************************************************************************/
|
|---|
| 270 |
|
|---|
| 271 | BOOL WIN32API CreateScalableFontResourceA(DWORD fdwHidden,
|
|---|
| 272 | LPCSTR lpszFontRes,
|
|---|
| 273 | LPCSTR lpszFontFile,
|
|---|
| 274 | LPCSTR lpszCurrentPath)
|
|---|
| 275 | {
|
|---|
| 276 | dprintf(("GDI32: CreateScalableFontResourceA(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 277 | fdwHidden,
|
|---|
| 278 | lpszFontRes,
|
|---|
| 279 | lpszFontFile,
|
|---|
| 280 | lpszCurrentPath));
|
|---|
| 281 |
|
|---|
| 282 | return (FALSE);
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 | /*****************************************************************************
|
|---|
| 287 | * Name : BOOL CreateScalableFontResourceW
|
|---|
| 288 | * Purpose : The CreateScalableFontResourceW function creates a font resource
|
|---|
| 289 | * file for a scalable font.
|
|---|
| 290 | * Parameters: DWORD fdwHidden flag for read-only embedded font
|
|---|
| 291 | * LPCSTR lpszFontRes address of filename for font resource
|
|---|
| 292 | * LPCSTR lpszFontFile address of filename for scalable font
|
|---|
| 293 | * LPCSTR lpszCurrentPath address of path to font file
|
|---|
| 294 | * Variables :
|
|---|
| 295 | * Result : TRUE / FALSE
|
|---|
| 296 | * Remark :
|
|---|
| 297 | * Status : UNTESTED STUB
|
|---|
| 298 | *
|
|---|
| 299 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 300 | *****************************************************************************/
|
|---|
| 301 |
|
|---|
| 302 | BOOL WIN32API CreateScalableFontResourceW(DWORD fdwHidden,
|
|---|
| 303 | LPCWSTR lpszFontRes,
|
|---|
| 304 | LPCWSTR lpszFontFile,
|
|---|
| 305 | LPCWSTR lpszCurrentPath)
|
|---|
| 306 | {
|
|---|
| 307 | dprintf(("GDI32: CreateScalableFontResourceW(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 308 | fdwHidden,
|
|---|
| 309 | lpszFontRes,
|
|---|
| 310 | lpszFontFile,
|
|---|
| 311 | lpszCurrentPath));
|
|---|
| 312 |
|
|---|
| 313 | return (FALSE);
|
|---|
| 314 | }
|
|---|
| 315 | /*****************************************************************************
|
|---|
| 316 | * Name : DWORD GetFontLanguageInfo
|
|---|
| 317 | * Purpose : The GetFontLanguageInfo function returns information about the
|
|---|
| 318 | * currently selected font for the specified display context.
|
|---|
| 319 | * Applications typically use this information and the
|
|---|
| 320 | * GetCharacterPlacement function to prepare a character string for display.
|
|---|
| 321 | * Parameters: HDC hdc handle to device context
|
|---|
| 322 | * Variables :
|
|---|
| 323 | * Result :
|
|---|
| 324 | * Remark :
|
|---|
| 325 | * Status : UNTESTED STUB
|
|---|
| 326 | *
|
|---|
| 327 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 328 | *****************************************************************************/
|
|---|
| 329 |
|
|---|
| 330 | DWORD WIN32API GetFontLanguageInfo(HDC hdc)
|
|---|
| 331 | {
|
|---|
| 332 | dprintf(("GDI32: GetFontLanguageInfo(%08xh) not implemented.\n",
|
|---|
| 333 | hdc));
|
|---|
| 334 |
|
|---|
| 335 | return (0);
|
|---|
| 336 | }
|
|---|
| 337 | //******************************************************************************
|
|---|
| 338 | //******************************************************************************
|
|---|