Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-fonts
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aleksandr Isakov
wine-fonts
Commits
5cc2d4ad
Commit
5cc2d4ad
authored
Apr 12, 2022
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32u: Support UTF-8 as the default Ansi codepage.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d8db12a9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
27 deletions
+45
-27
font.c
dlls/win32u/font.c
+35
-1
gdiobj.c
dlls/win32u/gdiobj.c
+10
-26
No files found.
dlls/win32u/font.c
View file @
5cc2d4ad
...
...
@@ -199,6 +199,7 @@ static struct font_gamma_ramp font_gamma_ramp;
static
void
add_face_to_cache
(
struct
gdi_font_face
*
face
);
static
void
remove_face_from_cache
(
struct
gdi_font_face
*
face
);
static
CPTABLEINFO
utf8_cp
;
static
CPTABLEINFO
oem_cp
;
CPTABLEINFO
ansi_cp
=
{
0
};
...
...
@@ -370,6 +371,11 @@ static const struct nls_update_font_list
"coure.fon"
,
"serife.fon"
,
"smalle.fon"
,
"sserife.fon"
,
"sseriff.fon"
,
"Tahoma"
,
"Times New Roman"
/* FIXME unverified */
},
/* UTF-8 */
{
CP_UTF8
,
CP_UTF8
,
"vga850.fon"
,
"vgafix.fon"
,
"vgasys.fon"
,
"coure.fon"
,
"serife.fon"
,
"smalle.fon"
,
"sserife.fon"
,
"sseriff.fon"
,
"Tahoma"
,
"Times New Roman"
/* FIXME unverified */
},
/* Eastern Europe */
{
1250
,
852
,
"vga852.fon"
,
"vgafixe.fon"
,
"vgasyse.fon"
,
"couree.fon"
,
"serifee.fon"
,
"smallee.fon"
,
"sserifee.fon"
,
"sseriffe.fon"
,
...
...
@@ -2717,6 +2723,7 @@ static void update_font_system_link_info(void)
static
void
update_codepage
(
UINT
screen_dpi
)
{
USHORT
utf8_hdr
[
2
]
=
{
0
,
CP_UTF8
};
char
value_buffer
[
FIELD_OFFSET
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
[
40
*
sizeof
(
WCHAR
)])];
KEY_VALUE_PARTIAL_INFORMATION
*
info
=
(
void
*
)
value_buffer
;
char
cpbuf
[
40
];
...
...
@@ -2733,8 +2740,15 @@ static void update_codepage( UINT screen_dpi )
if
(
size
==
sizeof
(
DWORD
)
&&
info
->
Type
==
REG_DWORD
)
font_dpi
=
*
(
DWORD
*
)
info
->
Data
;
RtlInitCodePageTable
(
utf8_hdr
,
&
utf8_cp
);
if
(
NtCurrentTeb
()
->
Peb
->
AnsiCodePageData
)
RtlInitCodePageTable
(
NtCurrentTeb
()
->
Peb
->
AnsiCodePageData
,
&
ansi_cp
);
else
ansi_cp
=
utf8_cp
;
if
(
NtCurrentTeb
()
->
Peb
->
OemCodePageData
)
RtlInitCodePageTable
(
NtCurrentTeb
()
->
Peb
->
OemCodePageData
,
&
oem_cp
);
else
oem_cp
=
utf8_cp
;
sprintf
(
cpbuf
,
"%u,%u"
,
ansi_cp
.
CodePage
,
oem_cp
.
CodePage
);
asciiz_to_unicode
(
cpbufW
,
cpbuf
);
...
...
@@ -3210,6 +3224,7 @@ CPTABLEINFO *get_cptable( WORD cp )
SIZE_T
size
;
if
(
cp
==
CP_ACP
)
return
&
ansi_cp
;
if
(
cp
==
CP_UTF8
)
return
&
utf8_cp
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tables
)
&&
tables
[
i
].
CodePage
;
i
++
)
if
(
tables
[
i
].
CodePage
==
cp
)
return
&
tables
[
i
];
...
...
@@ -3227,7 +3242,11 @@ DWORD win32u_wctomb( CPTABLEINFO *info, char *dst, DWORD dstlen, const WCHAR *sr
{
DWORD
ret
;
if
(
info
->
CodePage
==
CP_UTF8
)
RtlUnicodeToUTF8N
(
dst
,
dstlen
,
&
ret
,
src
,
srclen
*
sizeof
(
WCHAR
)
);
else
RtlUnicodeToCustomCPN
(
info
,
dst
,
dstlen
,
&
ret
,
src
,
srclen
*
sizeof
(
WCHAR
)
);
return
ret
;
}
...
...
@@ -3235,7 +3254,11 @@ DWORD win32u_mbtowc( CPTABLEINFO *info, WCHAR *dst, DWORD dstlen, const char *sr
{
DWORD
ret
;
if
(
info
->
CodePage
==
CP_UTF8
)
RtlUTF8ToUnicodeN
(
dst
,
dstlen
*
sizeof
(
WCHAR
),
&
ret
,
src
,
srclen
);
else
RtlCustomCPToUnicodeN
(
info
,
dst
,
dstlen
*
sizeof
(
WCHAR
),
&
ret
,
src
,
srclen
);
return
ret
/
sizeof
(
WCHAR
);
}
...
...
@@ -3245,7 +3268,18 @@ static BOOL wc_to_index( UINT cp, WCHAR wc, unsigned char *dst, BOOL allow_defau
if
(
!
(
info
=
get_cptable
(
cp
)))
return
FALSE
;
if
(
info
->
DBCSCodePage
)
if
(
info
->
CodePage
==
CP_UTF8
)
{
if
(
wc
<
0x80
)
{
*
dst
=
wc
;
return
TRUE
;
}
if
(
!
allow_default
)
return
FALSE
;
*
dst
=
info
->
DefaultChar
;
return
TRUE
;
}
else
if
(
info
->
DBCSCodePage
)
{
WCHAR
*
uni2cp
=
info
->
WideCharTable
;
if
(
uni2cp
[
wc
]
&
0xff00
)
return
FALSE
;
...
...
dlls/win32u/gdiobj.c
View file @
5cc2d4ad
...
...
@@ -464,41 +464,25 @@ void make_gdi_object_system( HGDIOBJ handle, BOOL set)
/******************************************************************************
* get_default_fonts
*/
static
const
struct
DefaultFontInfo
*
get_default_fonts
(
UINT
charset
)
static
const
struct
DefaultFontInfo
*
get_default_fonts
(
void
)
{
unsigned
int
n
;
CHARSETINFO
csi
;
if
(
ansi_cp
.
CodePage
==
CP_UTF8
)
return
&
default_fonts
[
0
];
csi
.
ciCharset
=
ANSI_CHARSET
;
translate_charset_info
(
ULongToPtr
(
ansi_cp
.
CodePage
),
&
csi
,
TCI_SRCCODEPAGE
);
for
(
n
=
0
;
n
<
ARRAY_SIZE
(
default_fonts
);
n
++
)
{
if
(
default_fonts
[
n
].
charset
==
charset
)
if
(
default_fonts
[
n
].
charset
==
csi
.
ciCharset
)
return
&
default_fonts
[
n
];
}
FIXME
(
"unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects
\n
"
,
c
harset
);
FIXME
(
"unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects
\n
"
,
csi
.
ciC
harset
);
return
&
default_fonts
[
0
];
}
/******************************************************************************
* get_default_charset (internal)
*
* get the language-dependent charset that can handle CP_ACP correctly.
*/
static
UINT
get_default_charset
(
void
)
{
CHARSETINFO
csi
;
csi
.
ciCharset
=
ANSI_CHARSET
;
if
(
!
translate_charset_info
(
ULongToPtr
(
ansi_cp
.
CodePage
),
&
csi
,
TCI_SRCCODEPAGE
)
)
{
FIXME
(
"unhandled codepage %u - use ANSI_CHARSET for default stock objects
\n
"
,
ansi_cp
.
CodePage
);
return
ANSI_CHARSET
;
}
return
csi
.
ciCharset
;
}
/***********************************************************************
* GDI_get_ref_count
*
...
...
@@ -654,7 +638,7 @@ static void init_stock_objects( unsigned int dpi )
create_font
(
&
AnsiVarFont
);
/* language-dependent stock fonts */
deffonts
=
get_default_fonts
(
get_default_charset
()
);
deffonts
=
get_default_fonts
();
create_font
(
&
deffonts
->
SystemFont
);
create_font
(
&
deffonts
->
DeviceDefaultFont
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment