Jacek Caban : gdi32: Move load_script_name call to EnumFontFamiliesExW.
Alexandre Julliard
julliard at winehq.org
Mon Sep 20 16:26:20 CDT 2021
Module: wine
Branch: master
Commit: c5d71400546706f9fa38275a629ec1a8c8fc9b07
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c5d71400546706f9fa38275a629ec1a8c8fc9b07
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Sep 20 13:13:47 2021 +0200
gdi32: Move load_script_name call to EnumFontFamiliesExW.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/font.c | 32 ++++----------------------------
dlls/gdi32/gdi_private.h | 2 ++
dlls/gdi32/text.c | 25 +++++++++++++++++++++++++
3 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 839244545cb..95a6bad3b92 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -32,7 +32,6 @@
#include "winternl.h"
#include "winreg.h"
#include "ntgdi_private.h"
-#include "resource.h"
#include "wine/exception.h"
#include "wine/heap.h"
#include "wine/rbtree.h"
@@ -2589,29 +2588,6 @@ struct enum_charset
DWORD script;
};
-static int load_script_name( UINT id, WCHAR buffer[LF_FACESIZE] )
-{
- HRSRC rsrc;
- HGLOBAL hMem;
- WCHAR *p;
- int i;
-
- id += IDS_FIRST_SCRIPT;
- rsrc = FindResourceW( gdi32_module, (LPCWSTR)(ULONG_PTR)((id >> 4) + 1), (LPCWSTR)6 /*RT_STRING*/ );
- if (!rsrc) return 0;
- hMem = LoadResource( gdi32_module, rsrc );
- if (!hMem) return 0;
-
- p = LockResource( hMem );
- id &= 0x000f;
- while (id--) p += *p + 1;
-
- i = min(LF_FACESIZE - 1, *p);
- memcpy(buffer, p + 1, i * sizeof(WCHAR));
- buffer[i] = 0;
- return i;
-}
-
static BOOL is_complex_script_ansi_cp( UINT ansi_cp )
{
return (ansi_cp == 874 /* Thai */
@@ -2678,7 +2654,7 @@ static DWORD create_enum_charset_list(DWORD charset, struct enum_charset *list)
{
list->mask = ~mask;
list->charset = DEFAULT_CHARSET;
- list->script = IDS_OTHER - IDS_FIRST_SCRIPT;
+ list->script = 33; /* other */
list++;
}
}
@@ -2834,7 +2810,7 @@ static BOOL enum_face_charsets( const struct gdi_font_family *family, struct gdi
if (face->fs.fsCsb[0] == 0) /* OEM */
{
elf.elfLogFont.lfCharSet = ntm.ntmTm.tmCharSet = OEM_CHARSET;
- load_script_name( IDS_OEM_DOS - IDS_FIRST_SCRIPT, elf.elfScript );
+ elf.elfScript[0] = 32;
i = count; /* break out of loop after enumeration */
}
else
@@ -2843,8 +2819,8 @@ static BOOL enum_face_charsets( const struct gdi_font_family *family, struct gdi
/* use the DEFAULT_CHARSET case only if no other charset is present */
if (list[i].charset == DEFAULT_CHARSET && (face->fs.fsCsb[0] & ~list[i].mask)) continue;
elf.elfLogFont.lfCharSet = ntm.ntmTm.tmCharSet = list[i].charset;
- load_script_name( list[i].script, elf.elfScript );
- if (!elf.elfScript[0]) FIXME("Unknown elfscript for id %u\n", list[i].script);
+ /* caller may fill elfScript with the actual string, see load_script_name */
+ elf.elfScript[0] = list[i].script;
}
TRACE( "face %s full %s style %s charset = %d type %d script %s it %d weight %d ntmflags %08x\n",
debugstr_w(elf.elfLogFont.lfFaceName), debugstr_w(elf.elfFullName), debugstr_w(elf.elfStyle),
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index 238ae3b7de1..cf09cf85ad4 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -299,4 +299,6 @@ static inline int get_dib_info_size( const BITMAPINFO *info, UINT coloruse )
return FIELD_OFFSET( BITMAPINFO, bmiColors[info->bmiHeader.biClrUsed] );
}
+extern HMODULE gdi32_module DECLSPEC_HIDDEN;
+
#endif /* __WINE_GDI_PRIVATE_H */
diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c
index 4037eaa4b65..641c15aab70 100644
--- a/dlls/gdi32/text.c
+++ b/dlls/gdi32/text.c
@@ -54,6 +54,7 @@
#include "usp10.h"
#include "wine/debug.h"
#include "gdi_private.h"
+#include "resource.h"
WINE_DEFAULT_DEBUG_CHANNEL(bidi);
@@ -2037,6 +2038,29 @@ BOOL WINAPI GdiRealizationInfo( HDC hdc, struct realization_info *info )
return TRUE;
}
+static void load_script_name( UINT id, WCHAR buffer[LF_FACESIZE] )
+{
+ HRSRC rsrc;
+ HGLOBAL hMem;
+ WCHAR *p;
+ int i;
+
+ id += IDS_FIRST_SCRIPT;
+ buffer[0] = 0;
+ rsrc = FindResourceW( gdi32_module, (LPCWSTR)(ULONG_PTR)((id >> 4) + 1), (LPCWSTR)6 /*RT_STRING*/ );
+ if (!rsrc) return;
+ hMem = LoadResource( gdi32_module, rsrc );
+ if (!hMem) return;
+
+ p = LockResource( hMem );
+ id &= 0x000f;
+ while (id--) p += *p + 1;
+
+ i = min( LF_FACESIZE - 1, *p );
+ memcpy( buffer, p + 1, i * sizeof(WCHAR) );
+ buffer[i] = 0;
+}
+
/***********************************************************************
* EnumFontFamiliesExW (GDI32.@)
*/
@@ -2072,6 +2096,7 @@ INT WINAPI EnumFontFamiliesExW( HDC hdc, LOGFONTW *lf, FONTENUMPROCW efproc,
count /= sizeof(*entries);
for (i = 0; ret && i < count; i++)
{
+ load_script_name( entries[i].lf.elfScript[0], entries[i].lf.elfScript );
ret = efproc( (const LOGFONTW *)&entries[i].lf, (const TEXTMETRICW *)&entries[i].tm,
entries[i].type, lparam );
}
More information about the wine-cvs
mailing list