Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
c6eeda46
Commit
c6eeda46
authored
May 16, 2001
by
Ian Pilcher
Committed by
Alexandre Julliard
May 16, 2001
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guesstimate Windows font metrics for Type 1 fonts.
parent
4323004b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
134 additions
and
6 deletions
+134
-6
afm.c
dlls/wineps/afm.c
+125
-0
psdrv.h
dlls/wineps/psdrv.h
+9
-6
No files found.
dlls/wineps/afm.c
View file @
c6eeda46
...
...
@@ -28,6 +28,38 @@ FONTFAMILY *PSDRV_AFMFontList = NULL;
typedef
int
(
*
compar_callback_fn
)
(
const
void
*
,
const
void
*
);
/*******************************************************************************
* IsWinANSI
*
* Checks whether Unicode value is part of Microsoft code page 1252
*
*/
static
const
INT
ansiChars
[
21
]
=
{
0x0152
,
0x0153
,
0x0160
,
0x0161
,
0x0178
,
0x017d
,
0x017e
,
0x0192
,
0x02c6
,
0x02c9
,
0x02dc
,
0x03bc
,
0x2013
,
0x2014
,
0x2026
,
0x2030
,
0x2039
,
0x203a
,
0x20ac
,
0x2122
,
0x2219
};
static
int
cmpUV
(
const
INT
*
a
,
const
INT
*
b
)
{
return
*
a
-
*
b
;
}
inline
static
BOOL
IsWinANSI
(
INT
uv
)
{
if
((
0x0020
<=
uv
&&
uv
<=
0x007e
)
||
(
0x00a0
<=
uv
&&
uv
<=
0x00ff
)
||
(
0x2018
<=
uv
&&
uv
<=
0x201a
)
||
(
0x201c
<=
uv
&&
uv
<=
0x201e
)
||
(
0x2020
<=
uv
&&
uv
<=
2022
))
return
TRUE
;
if
(
bsearch
(
&
uv
,
ansiChars
,
21
,
sizeof
(
INT
),
(
compar_callback_fn
)
cmpUV
)
!=
NULL
)
return
TRUE
;
return
FALSE
;
}
/*******************************************************************************
* CheckMetrics
*
* Check an AFMMETRICS structure to make sure all elements have been properly
...
...
@@ -750,6 +782,98 @@ static BOOL SortFontMetrics()
return
TRUE
;
}
/*******************************************************************************
* CalcWindowsMetrics
*
* Calculates several Windows-specific font metrics for each font. Relies on
* the fact that AFMs are allocated with HEAP_ZERO_MEMORY to distinguish
* TrueType fonts (when implemented), which already have these filled in.
*
*/
static
VOID
CalcWindowsMetrics
()
{
FONTFAMILY
*
family
=
PSDRV_AFMFontList
;
while
(
family
!=
NULL
)
{
AFMLISTENTRY
*
afmle
=
family
->
afmlist
;
while
(
afmle
!=
NULL
)
{
WINMETRICS
wm
;
AFM
*
afm
=
afmle
->
afm
;
/* should always be valid */
INT
i
;
if
(
afm
->
WinMetrics
.
usUnitsPerEm
!=
0
)
continue
;
/* TrueType font */
wm
.
usUnitsPerEm
=
1000
;
/* for PostScript fonts */
wm
.
sTypoAscender
=
(
SHORT
)(
afm
->
Ascender
+
0
.
5
);
wm
.
sTypoDescender
=
(
SHORT
)(
afm
->
Descender
+
0
.
5
);
wm
.
sTypoLineGap
=
1200
-
(
wm
.
sTypoAscender
-
wm
.
sTypoDescender
);
if
(
wm
.
sTypoLineGap
<
0
)
wm
.
sTypoLineGap
=
0
;
wm
.
usWinAscent
=
0
;
wm
.
usWinDescent
=
0
;
for
(
i
=
0
;
i
<
afm
->
NumofMetrics
;
++
i
)
{
if
(
IsWinANSI
(
afm
->
Metrics
[
i
].
UV
)
==
FALSE
)
continue
;
if
(
afm
->
Metrics
[
i
].
B
.
ury
>
0
)
{
USHORT
ascent
=
(
USHORT
)(
afm
->
Metrics
[
i
].
B
.
ury
+
0
.
5
);
if
(
ascent
>
wm
.
usWinAscent
)
wm
.
usWinAscent
=
ascent
;
}
if
(
afm
->
Metrics
[
i
].
B
.
lly
<
0
)
{
USHORT
descent
=
(
USHORT
)(
-
(
afm
->
Metrics
[
i
].
B
.
lly
)
+
0
.
5
);
if
(
descent
>
wm
.
usWinDescent
)
wm
.
usWinDescent
=
descent
;
}
}
if
(
wm
.
usWinAscent
==
0
&&
afm
->
FontBBox
.
ury
>
0
)
wm
.
usWinAscent
=
(
USHORT
)(
afm
->
FontBBox
.
ury
+
0
.
5
);
if
(
wm
.
usWinDescent
==
0
&&
afm
->
FontBBox
.
lly
<
0
)
wm
.
usWinDescent
=
(
USHORT
)(
-
(
afm
->
FontBBox
.
lly
)
+
0
.
5
);
wm
.
sAscender
=
wm
.
usWinAscent
;
wm
.
sDescender
=
-
(
wm
.
usWinDescent
);
wm
.
sLineGap
=
1150
-
(
wm
.
sAscender
-
wm
.
sDescender
);
if
(
wm
.
sLineGap
<
0
)
wm
.
sLineGap
=
0
;
TRACE
(
"Windows metrics for '%s':
\n
"
,
afm
->
FullName
);
TRACE
(
"
\t
sAscender = %i
\n
"
,
wm
.
sAscender
);
TRACE
(
"
\t
sDescender = %i
\n
"
,
wm
.
sDescender
);
TRACE
(
"
\t
sLineGap = %i
\n
"
,
wm
.
sLineGap
);
TRACE
(
"
\t
usUnitsPerEm = %u
\n
"
,
wm
.
usUnitsPerEm
);
TRACE
(
"
\t
sTypoAscender = %i
\n
"
,
wm
.
sTypoAscender
);
TRACE
(
"
\t
sTypoDescender = %i
\n
"
,
wm
.
sTypoDescender
);
TRACE
(
"
\t
sTypoLineGap = %i
\n
"
,
wm
.
sTypoLineGap
);
TRACE
(
"
\t
usWinAscent = %u
\n
"
,
wm
.
usWinAscent
);
TRACE
(
"
\t
usWinDescent = %u
\n
"
,
wm
.
usWinDescent
);
afm
->
WinMetrics
=
wm
;
afmle
=
afmle
->
next
;
}
family
=
family
->
next
;
}
}
/***********************************************************
*
* PSDRV_GetFontMetrics
...
...
@@ -844,6 +968,7 @@ BOOL PSDRV_GetFontMetrics(void)
PSDRV_IndexGlyphList
();
if
(
SortFontMetrics
()
==
FALSE
)
return
FALSE
;
CalcWindowsMetrics
();
PSDRV_DumpFontList
();
return
TRUE
;
}
dlls/wineps/psdrv.h
View file @
c6eeda46
...
...
@@ -53,12 +53,15 @@ typedef struct _tagAFMMETRICS {
}
AFMMETRICS
;
typedef
struct
{
USHORT
usUnitsPerEm
;
/* 1000 for Type 1 fonts */
SHORT
sTypoAscender
;
/* AFM Ascender */
SHORT
sTypoDescender
;
/* AFM Descender */
SHORT
sTypoLineGap
;
/* guess for Type 1 fonts */
USHORT
usWinAscent
;
USHORT
usWinDescent
;
USHORT
usUnitsPerEm
;
/* head:unitsPerEm */
SHORT
sAscender
;
/* hhea:Ascender */
SHORT
sDescender
;
/* hhea:Descender */
SHORT
sLineGap
;
/* hhea:LineGap */
SHORT
sTypoAscender
;
/* OS/2:sTypoAscender */
SHORT
sTypoDescender
;
/* OS/2:sTypoDescender */
SHORT
sTypoLineGap
;
/* OS/2:sTypeLineGap */
USHORT
usWinAscent
;
/* OS/2:usWinAscent */
USHORT
usWinDescent
;
/* OS/2:usWinDescent */
}
WINMETRICS
;
typedef
struct
_tagAFM
{
...
...
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