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
834d2002
Commit
834d2002
authored
Dec 06, 2006
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Only mmap a given font file once.
FT_New_Face always creates a new mapping of the font file, so do the mapping by hand and use FT_New_Memory_Face instead.
parent
47456184
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
1 deletion
+78
-1
freetype.c
dlls/gdi32/freetype.c
+78
-1
No files found.
dlls/gdi32/freetype.c
View file @
834d2002
...
...
@@ -29,6 +29,9 @@
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
#include <string.h>
#include <dirent.h>
#include <stdio.h>
...
...
@@ -125,6 +128,7 @@ MAKE_FUNCPTR(FT_Load_Glyph);
MAKE_FUNCPTR
(
FT_Matrix_Multiply
);
MAKE_FUNCPTR
(
FT_MulFix
);
MAKE_FUNCPTR
(
FT_New_Face
);
MAKE_FUNCPTR
(
FT_New_Memory_Face
);
MAKE_FUNCPTR
(
FT_Outline_Get_Bitmap
);
MAKE_FUNCPTR
(
FT_Outline_Transform
);
MAKE_FUNCPTR
(
FT_Outline_Translate
);
...
...
@@ -253,6 +257,7 @@ typedef struct {
struct
tagGdiFont
{
struct
list
entry
;
FT_Face
ft_face
;
struct
font_mapping
*
mapping
;
LPWSTR
name
;
int
charset
;
int
codepage
;
...
...
@@ -385,6 +390,18 @@ typedef struct tagFontSubst {
NameCs
to
;
}
FontSubst
;
struct
font_mapping
{
struct
list
entry
;
int
refcount
;
dev_t
dev
;
ino_t
ino
;
void
*
data
;
size_t
size
;
};
static
struct
list
mappings_list
=
LIST_INIT
(
mappings_list
);
static
BOOL
have_installed_roman_font
=
FALSE
;
/* CreateFontInstance will fail if this is still FALSE */
static
const
WCHAR
font_mutex_nameW
[]
=
{
'_'
,
'_'
,
'W'
,
'I'
,
'N'
,
'E'
,
'_'
,
'F'
,
'O'
,
'N'
,
'T'
,
'_'
,
'M'
,
'U'
,
'T'
,
'E'
,
'X'
,
'_'
,
'_'
,
'\0'
};
...
...
@@ -1644,6 +1661,7 @@ BOOL WineEngInit(void)
LOAD_FUNCPTR
(
FT_Matrix_Multiply
)
LOAD_FUNCPTR
(
FT_MulFix
)
LOAD_FUNCPTR
(
FT_New_Face
)
LOAD_FUNCPTR
(
FT_New_Memory_Face
)
LOAD_FUNCPTR
(
FT_Outline_Get_Bitmap
)
LOAD_FUNCPTR
(
FT_Outline_Transform
)
LOAD_FUNCPTR
(
FT_Outline_Translate
)
...
...
@@ -1867,6 +1885,57 @@ static LONG calc_ppem_for_height(FT_Face ft_face, LONG height)
return
ppem
;
}
static
struct
font_mapping
*
map_font
(
const
char
*
name
)
{
struct
font_mapping
*
mapping
;
struct
stat
st
;
int
fd
;
if
((
fd
=
open
(
name
,
O_RDONLY
))
==
-
1
)
return
NULL
;
if
(
fstat
(
fd
,
&
st
)
==
-
1
)
goto
error
;
LIST_FOR_EACH_ENTRY
(
mapping
,
&
mappings_list
,
struct
font_mapping
,
entry
)
{
if
(
mapping
->
dev
==
st
.
st_dev
&&
mapping
->
ino
==
st
.
st_ino
)
{
mapping
->
refcount
++
;
close
(
fd
);
return
mapping
;
}
}
if
(
!
(
mapping
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
mapping
)
)))
goto
error
;
mapping
->
data
=
mmap
(
NULL
,
st
.
st_size
,
PROT_READ
,
MAP_PRIVATE
,
fd
,
0
);
close
(
fd
);
if
(
mapping
->
data
==
MAP_FAILED
)
{
HeapFree
(
GetProcessHeap
(),
0
,
mapping
);
return
NULL
;
}
mapping
->
refcount
=
1
;
mapping
->
dev
=
st
.
st_dev
;
mapping
->
ino
=
st
.
st_ino
;
mapping
->
size
=
st
.
st_size
;
list_add_tail
(
&
mappings_list
,
&
mapping
->
entry
);
return
mapping
;
error:
close
(
fd
);
return
NULL
;
}
static
void
unmap_font
(
struct
font_mapping
*
mapping
)
{
if
(
!--
mapping
->
refcount
)
{
list_remove
(
&
mapping
->
entry
);
munmap
(
mapping
->
data
,
mapping
->
size
);
HeapFree
(
GetProcessHeap
(),
0
,
mapping
);
}
}
static
LONG
load_VDMX
(
GdiFont
*
,
LONG
);
static
FT_Face
OpenFontFile
(
GdiFont
*
font
,
char
*
file
,
FT_Long
face_index
,
LONG
width
,
LONG
height
)
...
...
@@ -1875,7 +1944,14 @@ static FT_Face OpenFontFile(GdiFont *font, char *file, FT_Long face_index, LONG
FT_Face
ft_face
;
TRACE
(
"%s, %ld, %d x %d
\n
"
,
debugstr_a
(
file
),
face_index
,
width
,
height
);
err
=
pFT_New_Face
(
library
,
file
,
face_index
,
&
ft_face
);
if
(
!
(
font
->
mapping
=
map_font
(
file
)))
{
WARN
(
"failed to map %s
\n
"
,
debugstr_a
(
file
));
return
0
;
}
err
=
pFT_New_Memory_Face
(
library
,
font
->
mapping
->
data
,
font
->
mapping
->
size
,
face_index
,
&
ft_face
);
if
(
err
)
{
ERR
(
"FT_New_Face rets %d
\n
"
,
err
);
return
0
;
...
...
@@ -1973,6 +2049,7 @@ static void free_font(GdiFont *font)
}
if
(
font
->
ft_face
)
pFT_Done_Face
(
font
->
ft_face
);
if
(
font
->
mapping
)
unmap_font
(
font
->
mapping
);
HeapFree
(
GetProcessHeap
(),
0
,
font
->
kern_pairs
);
HeapFree
(
GetProcessHeap
(),
0
,
font
->
potm
);
HeapFree
(
GetProcessHeap
(),
0
,
font
->
name
);
...
...
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