diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index e267190fb64..8abaf2c42dd 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -4016,21 +4016,6 @@ static void FONT_EnumLogFontExWToA( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEX fontA->elfScript[LF_FACESIZE-1] = '\0'; } -static void FONT_EnumLogFontExAToW( const ENUMLOGFONTEXA *fontA, LPENUMLOGFONTEXW fontW ) -{ - FONT_LogFontAToW( &fontA->elfLogFont, &fontW->elfLogFont ); - - MultiByteToWideChar( CP_ACP, 0, (LPCSTR)fontA->elfFullName, -1, - fontW->elfFullName, LF_FULLFACESIZE ); - fontW->elfFullName[LF_FULLFACESIZE-1] = '\0'; - MultiByteToWideChar( CP_ACP, 0, (LPCSTR)fontA->elfStyle, -1, - fontW->elfStyle, LF_FACESIZE ); - fontW->elfStyle[LF_FACESIZE-1] = '\0'; - MultiByteToWideChar( CP_ACP, 0, (LPCSTR)fontA->elfScript, -1, - fontW->elfScript, LF_FACESIZE ); - fontW->elfScript[LF_FACESIZE-1] = '\0'; -} - /*********************************************************************** * TEXTMETRIC conversion functions. */ @@ -4228,23 +4213,10 @@ static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) } /*********************************************************************** - * CreateFontIndirectExA (GDI32.@) + * NtGdiHfontCreate (win32u.@) */ -HFONT WINAPI CreateFontIndirectExA( const ENUMLOGFONTEXDVA *penumexA ) -{ - ENUMLOGFONTEXDVW enumexW; - - if (!penumexA) return 0; - - FONT_EnumLogFontExAToW( &penumexA->elfEnumLogfontEx, &enumexW.elfEnumLogfontEx ); - enumexW.elfDesignVector = penumexA->elfDesignVector; - return CreateFontIndirectExW( &enumexW ); -} - -/*********************************************************************** - * CreateFontIndirectExW (GDI32.@) - */ -HFONT WINAPI CreateFontIndirectExW( const ENUMLOGFONTEXDVW *penumex ) +HFONT WINAPI NtGdiHfontCreate( const ENUMLOGFONTEXDVW *penumex, ULONG size, ULONG type, + ULONG flags, void *data ) { HFONT hFont; FONTOBJ *fontPtr; @@ -4287,101 +4259,6 @@ HFONT WINAPI CreateFontIndirectExW( const ENUMLOGFONTEXDVW *penumex ) return hFont; } -/*********************************************************************** - * CreateFontIndirectA (GDI32.@) - */ -HFONT WINAPI CreateFontIndirectA( const LOGFONTA *plfA ) -{ - LOGFONTW lfW; - - if (!plfA) return 0; - - FONT_LogFontAToW( plfA, &lfW ); - return CreateFontIndirectW( &lfW ); -} - -/*********************************************************************** - * CreateFontIndirectW (GDI32.@) - */ -HFONT WINAPI CreateFontIndirectW( const LOGFONTW *plf ) -{ - ENUMLOGFONTEXDVW exdv; - - if (!plf) return 0; - - exdv.elfEnumLogfontEx.elfLogFont = *plf; - exdv.elfEnumLogfontEx.elfFullName[0] = 0; - exdv.elfEnumLogfontEx.elfStyle[0] = 0; - exdv.elfEnumLogfontEx.elfScript[0] = 0; - return CreateFontIndirectExW( &exdv ); -} - -/************************************************************************* - * CreateFontA (GDI32.@) - */ -HFONT WINAPI CreateFontA( INT height, INT width, INT esc, - INT orient, INT weight, DWORD italic, - DWORD underline, DWORD strikeout, DWORD charset, - DWORD outpres, DWORD clippres, DWORD quality, - DWORD pitch, LPCSTR name ) -{ - LOGFONTA logfont; - - logfont.lfHeight = height; - logfont.lfWidth = width; - logfont.lfEscapement = esc; - logfont.lfOrientation = orient; - logfont.lfWeight = weight; - logfont.lfItalic = italic; - logfont.lfUnderline = underline; - logfont.lfStrikeOut = strikeout; - logfont.lfCharSet = charset; - logfont.lfOutPrecision = outpres; - logfont.lfClipPrecision = clippres; - logfont.lfQuality = quality; - logfont.lfPitchAndFamily = pitch; - - if (name) - lstrcpynA(logfont.lfFaceName,name,sizeof(logfont.lfFaceName)); - else - logfont.lfFaceName[0] = '\0'; - - return CreateFontIndirectA( &logfont ); -} - -/************************************************************************* - * CreateFontW (GDI32.@) - */ -HFONT WINAPI CreateFontW( INT height, INT width, INT esc, - INT orient, INT weight, DWORD italic, - DWORD underline, DWORD strikeout, DWORD charset, - DWORD outpres, DWORD clippres, DWORD quality, - DWORD pitch, LPCWSTR name ) -{ - LOGFONTW logfont; - - logfont.lfHeight = height; - logfont.lfWidth = width; - logfont.lfEscapement = esc; - logfont.lfOrientation = orient; - logfont.lfWeight = weight; - logfont.lfItalic = italic; - logfont.lfUnderline = underline; - logfont.lfStrikeOut = strikeout; - logfont.lfCharSet = charset; - logfont.lfOutPrecision = outpres; - logfont.lfClipPrecision = clippres; - logfont.lfQuality = quality; - logfont.lfPitchAndFamily = pitch; - - if (name) - lstrcpynW(logfont.lfFaceName, name, ARRAY_SIZE(logfont.lfFaceName)); - else - logfont.lfFaceName[0] = '\0'; - - return CreateFontIndirectW( &logfont ); -} - #define ASSOC_CHARSET_OEM 1 #define ASSOC_CHARSET_ANSI 2 #define ASSOC_CHARSET_SYMBOL 4 diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c index ffbc9806e78..525b5a2a542 100644 --- a/dlls/gdi32/text.c +++ b/dlls/gdi32/text.c @@ -737,6 +737,29 @@ static void text_metric_WtoA( const TEXTMETRICW *tmW, TEXTMETRICA *tmA ) tmA->tmCharSet = tmW->tmCharSet; } +static void logfont_AtoW( const LOGFONTA *fontA, LPLOGFONTW fontW ) +{ + memcpy( fontW, fontA, sizeof(LOGFONTA) - LF_FACESIZE ); + MultiByteToWideChar( CP_ACP, 0, fontA->lfFaceName, -1, fontW->lfFaceName, + LF_FACESIZE ); + fontW->lfFaceName[LF_FACESIZE - 1] = 0; +} + +static void logfontex_AtoW( const ENUMLOGFONTEXA *fontA, LPENUMLOGFONTEXW fontW ) +{ + logfont_AtoW( &fontA->elfLogFont, &fontW->elfLogFont ); + + MultiByteToWideChar( CP_ACP, 0, (LPCSTR)fontA->elfFullName, -1, + fontW->elfFullName, LF_FULLFACESIZE ); + fontW->elfFullName[LF_FULLFACESIZE - 1] = '\0'; + MultiByteToWideChar( CP_ACP, 0, (LPCSTR)fontA->elfStyle, -1, + fontW->elfStyle, LF_FACESIZE ); + fontW->elfStyle[LF_FACESIZE - 1] = '\0'; + MultiByteToWideChar( CP_ACP, 0, (LPCSTR)fontA->elfScript, -1, + fontW->elfScript, LF_FACESIZE ); + fontW->elfScript[LF_FACESIZE - 1] = '\0'; +} + /*********************************************************************** * GdiGetCodePage (GDI32.@) */ @@ -746,6 +769,121 @@ DWORD WINAPI GdiGetCodePage( HDC hdc ) return dc_attr ? dc_attr->font_code_page : CP_ACP; } +/*********************************************************************** + * CreateFontIndirectExA (GDI32.@) + */ +HFONT WINAPI CreateFontIndirectExA( const ENUMLOGFONTEXDVA *enumexA ) +{ + ENUMLOGFONTEXDVW enumexW; + + if (!enumexA) return 0; + + logfontex_AtoW( &enumexA->elfEnumLogfontEx, &enumexW.elfEnumLogfontEx ); + enumexW.elfDesignVector = enumexA->elfDesignVector; + return CreateFontIndirectExW( &enumexW ); +} + +/*********************************************************************** + * CreateFontIndirectExW (GDI32.@) + */ +HFONT WINAPI CreateFontIndirectExW( const ENUMLOGFONTEXDVW *enumex ) +{ + return NtGdiHfontCreate( enumex, sizeof(*enumex), 0, 0, NULL ); +} + +/*********************************************************************** + * CreateFontIndirectA (GDI32.@) + */ +HFONT WINAPI CreateFontIndirectA( const LOGFONTA *lfA ) +{ + LOGFONTW lfW; + + if (!lfA) return 0; + + logfont_AtoW( lfA, &lfW ); + return CreateFontIndirectW( &lfW ); +} + +/*********************************************************************** + * CreateFontIndirectW (GDI32.@) + */ +HFONT WINAPI CreateFontIndirectW( const LOGFONTW *lf ) +{ + ENUMLOGFONTEXDVW exdv; + + if (!lf) return 0; + + exdv.elfEnumLogfontEx.elfLogFont = *lf; + exdv.elfEnumLogfontEx.elfFullName[0] = 0; + exdv.elfEnumLogfontEx.elfStyle[0] = 0; + exdv.elfEnumLogfontEx.elfScript[0] = 0; + return CreateFontIndirectExW( &exdv ); +} + +/************************************************************************* + * CreateFontA (GDI32.@) + */ +HFONT WINAPI CreateFontA( INT height, INT width, INT esc, INT orient, INT weight, + DWORD italic, DWORD underline, DWORD strikeout, + DWORD charset, DWORD outpres, DWORD clippres, + DWORD quality, DWORD pitch, const char *name ) +{ + LOGFONTA logfont; + + logfont.lfHeight = height; + logfont.lfWidth = width; + logfont.lfEscapement = esc; + logfont.lfOrientation = orient; + logfont.lfWeight = weight; + logfont.lfItalic = italic; + logfont.lfUnderline = underline; + logfont.lfStrikeOut = strikeout; + logfont.lfCharSet = charset; + logfont.lfOutPrecision = outpres; + logfont.lfClipPrecision = clippres; + logfont.lfQuality = quality; + logfont.lfPitchAndFamily = pitch; + + if (name) + lstrcpynA( logfont.lfFaceName, name, sizeof(logfont.lfFaceName) ); + else + logfont.lfFaceName[0] = '\0'; + + return CreateFontIndirectA( &logfont ); +} + +/************************************************************************* + * CreateFontW (GDI32.@) + */ +HFONT WINAPI CreateFontW( INT height, INT width, INT esc, INT orient, INT weight, + DWORD italic, DWORD underline, DWORD strikeout, + DWORD charset, DWORD outpres, DWORD clippres, + DWORD quality, DWORD pitch, const WCHAR *name ) +{ + LOGFONTW logfont; + + logfont.lfHeight = height; + logfont.lfWidth = width; + logfont.lfEscapement = esc; + logfont.lfOrientation = orient; + logfont.lfWeight = weight; + logfont.lfItalic = italic; + logfont.lfUnderline = underline; + logfont.lfStrikeOut = strikeout; + logfont.lfCharSet = charset; + logfont.lfOutPrecision = outpres; + logfont.lfClipPrecision = clippres; + logfont.lfQuality = quality; + logfont.lfPitchAndFamily = pitch; + + if (name) + lstrcpynW( logfont.lfFaceName, name, ARRAY_SIZE(logfont.lfFaceName) ); + else + logfont.lfFaceName[0] = '\0'; + + return CreateFontIndirectW( &logfont ); +} + /*********************************************************************** * ExtTextOutW (GDI32.@) */