gdi32: Use ntdll functions for codepage conversions.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
fd9e1612d9
commit
8db165000d
|
@ -561,14 +561,11 @@ static LPWSTR strdupW(LPCWSTR p)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WCHAR *towstr(UINT cp, const char *str)
|
static WCHAR *towstr(const char *str)
|
||||||
{
|
{
|
||||||
int len;
|
DWORD len = strlen(str) + 1;
|
||||||
WCHAR *wstr;
|
WCHAR *wstr = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
||||||
|
RtlMultiByteToUnicodeN( wstr, len * sizeof(WCHAR), &len, str, len );
|
||||||
len = MultiByteToWideChar(cp, 0, str, -1, NULL, 0);
|
|
||||||
wstr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
||||||
MultiByteToWideChar(cp, 0, str, -1, wstr, len);
|
|
||||||
return wstr;
|
return wstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,10 +694,21 @@ static const LANGID mac_langid_table[] =
|
||||||
MAKELANGID(LANG_AZERI,SUBLANG_AZERI_LATIN), /* TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT */
|
MAKELANGID(LANG_AZERI,SUBLANG_AZERI_LATIN), /* TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT */
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline WORD get_mac_code_page( const FT_SfntName *name )
|
static CPTABLEINFO *get_mac_code_page( const FT_SfntName *name )
|
||||||
{
|
{
|
||||||
if (name->encoding_id == TT_MAC_ID_SIMPLIFIED_CHINESE) return 10008; /* special case */
|
static CPTABLEINFO tables[100];
|
||||||
return 10000 + name->encoding_id;
|
int id = name->encoding_id;
|
||||||
|
USHORT *ptr;
|
||||||
|
SIZE_T size;
|
||||||
|
|
||||||
|
if (name->encoding_id == TT_MAC_ID_SIMPLIFIED_CHINESE) id = 8; /* special case */
|
||||||
|
if (id >= ARRAY_SIZE(tables)) return NULL;
|
||||||
|
if (!tables[id].CodePage)
|
||||||
|
{
|
||||||
|
if (NtGetNlsSectionPtr( 11, 10000 + id, NULL, (void **)&ptr, &size )) return NULL;
|
||||||
|
RtlInitCodePageTable( ptr, &tables[id] );
|
||||||
|
}
|
||||||
|
return &tables[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int match_name_table_language( const FT_SfntName *name, LANGID lang )
|
static int match_name_table_language( const FT_SfntName *name, LANGID lang )
|
||||||
|
@ -723,7 +731,7 @@ static int match_name_table_language( const FT_SfntName *name, LANGID lang )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TT_PLATFORM_MACINTOSH:
|
case TT_PLATFORM_MACINTOSH:
|
||||||
if (!IsValidCodePage( get_mac_code_page( name ))) return 0;
|
if (!get_mac_code_page( name )) return 0;
|
||||||
if (name->language_id >= ARRAY_SIZE( mac_langid_table )) return 0;
|
if (name->language_id >= ARRAY_SIZE( mac_langid_table )) return 0;
|
||||||
name_lang = mac_langid_table[name->language_id];
|
name_lang = mac_langid_table[name->language_id];
|
||||||
break;
|
break;
|
||||||
|
@ -754,8 +762,8 @@ static int match_name_table_language( const FT_SfntName *name, LANGID lang )
|
||||||
static WCHAR *copy_name_table_string( const FT_SfntName *name )
|
static WCHAR *copy_name_table_string( const FT_SfntName *name )
|
||||||
{
|
{
|
||||||
WCHAR *ret;
|
WCHAR *ret;
|
||||||
WORD codepage;
|
CPTABLEINFO *cp;
|
||||||
int i;
|
DWORD i;
|
||||||
|
|
||||||
switch (name->platform_id)
|
switch (name->platform_id)
|
||||||
{
|
{
|
||||||
|
@ -767,11 +775,11 @@ static WCHAR *copy_name_table_string( const FT_SfntName *name )
|
||||||
ret[i] = 0;
|
ret[i] = 0;
|
||||||
return ret;
|
return ret;
|
||||||
case TT_PLATFORM_MACINTOSH:
|
case TT_PLATFORM_MACINTOSH:
|
||||||
codepage = get_mac_code_page( name );
|
if (!(cp = get_mac_code_page( name ))) return NULL;
|
||||||
i = MultiByteToWideChar( codepage, 0, (char *)name->string, name->string_len, NULL, 0 );
|
ret = RtlAllocateHeap( GetProcessHeap(), 0, (name->string_len + 1) * sizeof(WCHAR) );
|
||||||
ret = HeapAlloc( GetProcessHeap(), 0, (i + 1) * sizeof(WCHAR) );
|
RtlCustomCPToUnicodeN( cp, ret, name->string_len * sizeof(WCHAR), &i,
|
||||||
MultiByteToWideChar( codepage, 0, (char *)name->string, name->string_len, ret, i );
|
(char *)name->string, name->string_len );
|
||||||
ret[i] = 0;
|
ret[i / sizeof(WCHAR)] = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -816,7 +824,7 @@ static WCHAR *ft_face_get_family_name( FT_Face ft_face, LANGID langid )
|
||||||
if ((family_name = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, langid )))
|
if ((family_name = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, langid )))
|
||||||
return family_name;
|
return family_name;
|
||||||
|
|
||||||
return towstr( CP_ACP, ft_face->family_name );
|
return towstr( ft_face->family_name );
|
||||||
}
|
}
|
||||||
|
|
||||||
static WCHAR *ft_face_get_style_name( FT_Face ft_face, LANGID langid )
|
static WCHAR *ft_face_get_style_name( FT_Face ft_face, LANGID langid )
|
||||||
|
@ -826,7 +834,7 @@ static WCHAR *ft_face_get_style_name( FT_Face ft_face, LANGID langid )
|
||||||
if ((style_name = get_face_name( ft_face, TT_NAME_ID_FONT_SUBFAMILY, langid )))
|
if ((style_name = get_face_name( ft_face, TT_NAME_ID_FONT_SUBFAMILY, langid )))
|
||||||
return style_name;
|
return style_name;
|
||||||
|
|
||||||
return towstr( CP_ACP, ft_face->style_name );
|
return towstr( ft_face->style_name );
|
||||||
}
|
}
|
||||||
|
|
||||||
static WCHAR *ft_face_get_full_name( FT_Face ft_face, LANGID langid )
|
static WCHAR *ft_face_get_full_name( FT_Face ft_face, LANGID langid )
|
||||||
|
@ -2053,16 +2061,17 @@ static BOOL CDECL fontconfig_enum_family_fallbacks( DWORD pitch_and_family, int
|
||||||
{
|
{
|
||||||
#ifdef SONAME_LIBFONTCONFIG
|
#ifdef SONAME_LIBFONTCONFIG
|
||||||
FcPattern *pat;
|
FcPattern *pat;
|
||||||
FcChar8 *str;
|
char *str;
|
||||||
|
DWORD len;
|
||||||
|
|
||||||
if ((pitch_and_family & FIXED_PITCH) || (pitch_and_family & 0xf0) == FF_MODERN) pat = pattern_fixed;
|
if ((pitch_and_family & FIXED_PITCH) || (pitch_and_family & 0xf0) == FF_MODERN) pat = pattern_fixed;
|
||||||
else if ((pitch_and_family & 0xf0) == FF_ROMAN) pat = pattern_serif;
|
else if ((pitch_and_family & 0xf0) == FF_ROMAN) pat = pattern_serif;
|
||||||
else pat = pattern_sans;
|
else pat = pattern_sans;
|
||||||
|
|
||||||
if (!pat) return FALSE;
|
if (!pat) return FALSE;
|
||||||
if (pFcPatternGetString( pat, FC_FAMILY, index, &str ) != FcResultMatch) return FALSE;
|
if (pFcPatternGetString( pat, FC_FAMILY, index, (FcChar8 **)&str ) != FcResultMatch) return FALSE;
|
||||||
if (!MultiByteToWideChar( CP_UTF8, 0, (char *)str, -1, buffer, LF_FACESIZE ))
|
RtlUTF8ToUnicodeN( buffer, (LF_FACESIZE - 1) * sizeof(WCHAR), &len, str, strlen(str) );
|
||||||
buffer[LF_FACESIZE - 1] = 0;
|
buffer[len / sizeof(WCHAR)] = 0;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2228,10 +2237,11 @@ static BOOL CDECL freetype_get_glyph_index( struct gdi_font *font, UINT *glyph,
|
||||||
if (!(*glyph = get_glyph_index_symbol( font, *glyph )))
|
if (!(*glyph = get_glyph_index_symbol( font, *glyph )))
|
||||||
{
|
{
|
||||||
WCHAR wc = *glyph;
|
WCHAR wc = *glyph;
|
||||||
|
DWORD len;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
if (WideCharToMultiByte( CP_ACP, 0, &wc, 1, &ch, 1, NULL, NULL ))
|
RtlUnicodeToMultiByteN( &ch, 1, &len, &wc, sizeof(wc) );
|
||||||
*glyph = get_glyph_index_symbol( font, (unsigned char)ch );
|
if (len) *glyph = get_glyph_index_symbol( font, (unsigned char)ch );
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue