Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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
wine
wine-winehq
Commits
3c29cc44
Commit
3c29cc44
authored
Apr 12, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sfnt2fon: Avoid using wine/unicode.h on Windows.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ab6e4c8b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
23 deletions
+41
-23
sfnt2fon.c
tools/sfnt2fon/sfnt2fon.c
+41
-23
No files found.
tools/sfnt2fon/sfnt2fon.c
View file @
3c29cc44
...
...
@@ -41,7 +41,8 @@
#include FT_TRUETYPE_TABLES_H
#include FT_TRUETYPE_TAGS_H
#include "wine/unicode.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "basetsd.h"
...
...
@@ -340,15 +341,40 @@ static int lookup_charset(int enc)
return
OEM_CHARSET
;
}
static
int
get_char
(
const
union
cptable
*
cptable
,
int
enc
,
int
index
)
#ifdef _WIN32
static
void
get_char_table
(
int
enc
,
WCHAR
tableW
[
0x100
])
{
/* Korean has the Won sign in place of '\\' */
if
(
enc
==
949
&&
index
==
'\\'
)
return
0x20a9
;
int
i
;
char
tableA
[
0x100
];
return
cptable
->
sbcs
.
cp2uni
[
index
];
if
(
!
GetCPInfo
(
enc
,
&
info
))
error
(
"Can't find codepage %d
\n
"
,
enc
);
if
(
info
.
MaxCharSize
>
1
)
enc
=
1252
;
for
(
i
=
0
;
i
<
0x100
;
i
++
)
tableA
[
i
]
=
i
;
MultiByteToWideChar
(
enc
,
0
,
tableA
,
0x100
,
tableW
,
0x100
);
}
#else
/* _WIN32 */
#include "wine/unicode.h"
static
void
get_char_table
(
int
enc
,
WCHAR
tableW
[
0x100
])
{
int
i
;
char
tableA
[
0x100
];
const
union
cptable
*
cptable
=
wine_cp_get_table
(
enc
);
if
(
!
cptable
)
error
(
"Can't find codepage %d
\n
"
,
enc
);
/* for double byte charsets we actually want to use cp1252 */
if
(
cptable
->
info
.
char_size
!=
1
)
cptable
=
wine_cp_get_table
(
1252
);
for
(
i
=
0
;
i
<
0x100
;
i
++
)
tableA
[
i
]
=
i
;
wine_cp_mbstowcs
(
cptable
,
0
,
tableA
,
0x100
,
tableW
,
0x100
);
}
#endif
/* _WIN32 */
static
struct
fontinfo
*
fill_fontinfo
(
const
char
*
face_name
,
int
ppem
,
int
enc
,
int
dpi
,
unsigned
char
def_char
,
int
avg_width
)
{
...
...
@@ -359,7 +385,6 @@ static struct fontinfo *fill_fontinfo( const char *face_name, int ppem, int enc,
int
i
,
x
,
y
,
x_off
,
x_end
,
first_char
;
FT_UInt
gi
;
int
num_names
;
const
union
cptable
*
cptable
;
FT_SfntName
sfntname
;
TT_OS2
*
os2
;
FT_ULong
needed
;
...
...
@@ -368,22 +393,17 @@ static struct fontinfo *fill_fontinfo( const char *face_name, int ppem, int enc,
int
num_sizes
;
struct
fontinfo
*
info
;
size_t
data_pos
;
WCHAR
table
[
0x100
];
if
(
FT_New_Face
(
ft_library
,
face_name
,
0
,
&
face
))
error
(
"Cannot open face %s
\n
"
,
face_name
);
if
(
FT_Set_Pixel_Sizes
(
face
,
ppem
,
ppem
))
error
(
"cannot set face size to %u
\n
"
,
ppem
);
cptable
=
wine_cp_get_table
(
enc
);
if
(
!
cptable
)
error
(
"Can't find codepage %d
\n
"
,
enc
);
assert
(
face
->
size
->
metrics
.
y_ppem
==
ppem
);
if
(
cptable
->
info
.
char_size
!=
1
)
{
/* for double byte charsets we actually want to use cp1252 */
cptable
=
wine_cp_get_table
(
1252
);
if
(
!
cptable
)
error
(
"Can't find codepage 1252
\n
"
);
}
get_char_table
(
enc
,
table
);
assert
(
face
->
size
->
metrics
.
y_ppem
==
ppem
);
/* Korean has the Won sign in place of '\\' */
if
(
enc
==
949
)
table
[
'\\'
]
=
0x20a9
;
needed
=
0
;
if
(
FT_Load_Sfnt_Table
(
face
,
TTAG_EBLC
,
0
,
NULL
,
&
needed
))
...
...
@@ -462,12 +482,11 @@ static struct fontinfo *fill_fontinfo( const char *face_name, int ppem, int enc,
os2
=
FT_Get_Sfnt_Table
(
face
,
ft_sfnt_os2
);
for
(
i
=
first_char
;
i
<
0x100
;
i
++
)
{
int
c
=
get_char
(
cptable
,
enc
,
i
);
gi
=
FT_Get_Char_Index
(
face
,
c
);
gi
=
FT_Get_Char_Index
(
face
,
table
[
i
]);
if
(
gi
==
0
&&
!
option_quiet
)
fprintf
(
stderr
,
"warning: %s %u: missing glyph for char %04x
\n
"
,
face
->
family_name
,
ppem
,
cptable
->
sbcs
.
cp2uni
[
i
]);
if
(
FT_Load_Char
(
face
,
c
,
FT_LOAD_DEFAULT
))
{
face
->
family_name
,
ppem
,
table
[
i
]);
if
(
FT_Load_Char
(
face
,
table
[
i
]
,
FT_LOAD_DEFAULT
))
{
fprintf
(
stderr
,
"error loading char %d - bad news!
\n
"
,
i
);
continue
;
}
...
...
@@ -546,8 +565,7 @@ static struct fontinfo *fill_fontinfo( const char *face_name, int ppem, int enc,
data_pos
=
0
;
for
(
i
=
first_char
;
i
<
0x100
;
i
++
)
{
int
c
=
get_char
(
cptable
,
enc
,
i
);
if
(
FT_Load_Char
(
face
,
c
,
FT_LOAD_DEFAULT
))
{
if
(
FT_Load_Char
(
face
,
table
[
i
],
FT_LOAD_DEFAULT
))
{
continue
;
}
assert
(
info
->
dfCharTable
[
i
].
width
==
face
->
glyph
->
metrics
.
horiAdvance
>>
6
);
...
...
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