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
a77b9ed0
Commit
a77b9ed0
authored
Nov 21, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
Nov 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Load freetype on module attach, create one FT_Face per fontface.
parent
9a68ef40
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
173 additions
and
0 deletions
+173
-0
Makefile.in
dlls/dwrite/Makefile.in
+2
-0
dwrite_private.h
dlls/dwrite/dwrite_private.h
+7
-0
font.c
dlls/dwrite/font.c
+25
-0
freetype.c
dlls/dwrite/freetype.c
+138
-0
main.c
dlls/dwrite/main.c
+1
-0
No files found.
dlls/dwrite/Makefile.in
View file @
a77b9ed0
MODULE
=
dwrite.dll
IMPORTLIB
=
dwrite
IMPORTS
=
user32 gdi32
EXTRAINCL
=
$(FREETYPE_CFLAGS)
C_SRCS
=
\
analyzer.c
\
bidi.c
\
bracket.c
\
font.c
\
freetype.c
\
gdiinterop.c
\
layout.c
\
linebreak.c
\
...
...
dlls/dwrite/dwrite_private.h
View file @
a77b9ed0
...
...
@@ -119,9 +119,16 @@ extern void opentype_get_font_properties(const void*,const void*,DWRITE_FONT_STR
extern
void
opentype_get_font_metrics
(
const
void
*
,
const
void
*
,
const
void
*
,
DWRITE_FONT_METRICS1
*
)
DECLSPEC_HIDDEN
;
extern
HRESULT
opentype_get_font_strings_from_id
(
const
void
*
,
DWRITE_INFORMATIONAL_STRING_ID
,
IDWriteLocalizedStrings
**
)
DECLSPEC_HIDDEN
;
/* BiDi helpers */
extern
HRESULT
bidi_computelevels
(
const
WCHAR
*
,
UINT32
,
UINT8
,
UINT8
*
,
UINT8
*
)
DECLSPEC_HIDDEN
;
extern
WCHAR
bidi_get_mirrored_char
(
WCHAR
)
DECLSPEC_HIDDEN
;
/* FreeType integration */
struct
ft_fontface
;
extern
BOOL
init_freetype
(
void
)
DECLSPEC_HIDDEN
;
extern
HRESULT
alloc_ft_fontface
(
const
void
*
,
UINT32
,
UINT32
,
struct
ft_fontface
**
)
DECLSPEC_HIDDEN
;
extern
void
release_ft_fontface
(
struct
ft_fontface
*
)
DECLSPEC_HIDDEN
;
/* Glyph shaping */
enum
SCRIPT_JUSTIFY
{
...
...
dlls/dwrite/font.c
View file @
a77b9ed0
...
...
@@ -119,6 +119,7 @@ struct dwrite_fontface {
DWRITE_FONT_METRICS1
metrics
;
struct
dwrite_fonttable
cmap
;
struct
ft_fontface
*
ft
;
};
struct
dwrite_fontfile
{
...
...
@@ -254,6 +255,7 @@ static ULONG WINAPI dwritefontface_Release(IDWriteFontFace2 *iface)
if
(
This
->
files
[
i
])
IDWriteFontFile_Release
(
This
->
files
[
i
]);
}
release_ft_fontface
(
This
->
ft
);
heap_free
(
This
);
}
...
...
@@ -1928,9 +1930,14 @@ HRESULT create_fontface(DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDW
DWRITE_FONT_SIMULATIONS
simulations
,
IDWriteFontFace2
**
ret
)
{
struct
dwrite_fontface
*
fontface
;
const
void
*
data_ptr
;
HRESULT
hr
=
S_OK
;
void
*
context
;
UINT64
size
;
int
i
;
*
ret
=
NULL
;
fontface
=
heap_alloc
(
sizeof
(
struct
dwrite_fontface
));
if
(
!
fontface
)
return
E_OUTOFMEMORY
;
...
...
@@ -1954,6 +1961,7 @@ HRESULT create_fontface(DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDW
fontface
->
cmap
.
size
=
0
;
fontface
->
index
=
index
;
fontface
->
simulations
=
simulations
;
fontface
->
ft
=
NULL
;
for
(
i
=
0
;
i
<
fontface
->
file_count
;
i
++
)
{
hr
=
get_stream_from_file
(
font_files
[
i
],
&
fontface
->
streams
[
i
]);
...
...
@@ -1968,8 +1976,25 @@ HRESULT create_fontface(DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDW
get_font_properties_from_stream
(
fontface
->
streams
[
0
],
facetype
,
index
,
&
fontface
->
metrics
,
NULL
,
NULL
,
NULL
);
hr
=
IDWriteFontFileStream_GetFileSize
(
fontface
->
streams
[
0
],
&
size
);
if
(
FAILED
(
hr
))
goto
fail
;
hr
=
IDWriteFontFileStream_ReadFileFragment
(
fontface
->
streams
[
0
],
&
data_ptr
,
0
,
size
,
&
context
);
if
(
FAILED
(
hr
))
goto
fail
;
hr
=
alloc_ft_fontface
(
data_ptr
,
size
,
fontface
->
index
,
&
fontface
->
ft
);
IDWriteFontFileStream_ReleaseFileFragment
(
fontface
->
streams
[
0
],
context
);
if
(
FAILED
(
hr
))
goto
fail
;
*
ret
=
&
fontface
->
IDWriteFontFace2_iface
;
return
S_OK
;
fail:
IDWriteFontFace2_Release
(
&
fontface
->
IDWriteFontFace2_iface
);
return
hr
;
}
/* IDWriteLocalFontFileLoader and its required IDWriteFontFileStream */
...
...
dlls/dwrite/freetype.c
0 → 100644
View file @
a77b9ed0
/*
* FreeType integration
*
* Copyright 2014 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#ifdef HAVE_FT2BUILD_H
#include <ft2build.h>
#include FT_FREETYPE_H
#endif
/* HAVE_FT2BUILD_H */
#include "windef.h"
#include "wine/library.h"
#include "wine/debug.h"
#include "dwrite_private.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
dwrite
);
#ifdef HAVE_FREETYPE
static
void
*
ft_handle
=
NULL
;
static
FT_Library
library
=
0
;
typedef
struct
{
FT_Int
major
;
FT_Int
minor
;
FT_Int
patch
;
}
FT_Version_t
;
#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
MAKE_FUNCPTR
(
FT_Done_Face
);
MAKE_FUNCPTR
(
FT_Init_FreeType
);
MAKE_FUNCPTR
(
FT_Library_Version
);
MAKE_FUNCPTR
(
FT_New_Memory_Face
);
#undef MAKE_FUNCPTR
struct
ft_fontface
{
FT_Face
face
;
};
BOOL
init_freetype
(
void
)
{
FT_Version_t
FT_Version
;
ft_handle
=
wine_dlopen
(
SONAME_LIBFREETYPE
,
RTLD_NOW
,
NULL
,
0
);
if
(
!
ft_handle
)
{
WINE_MESSAGE
(
"Wine cannot find the FreeType font library.
\n
"
);
return
FALSE
;
}
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(ft_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;}
LOAD_FUNCPTR
(
FT_Done_Face
)
LOAD_FUNCPTR
(
FT_Init_FreeType
)
LOAD_FUNCPTR
(
FT_Library_Version
)
LOAD_FUNCPTR
(
FT_New_Memory_Face
)
#undef LOAD_FUNCPTR
if
(
pFT_Init_FreeType
(
&
library
)
!=
0
)
{
ERR
(
"Can't init FreeType library
\n
"
);
wine_dlclose
(
ft_handle
,
NULL
,
0
);
ft_handle
=
NULL
;
return
FALSE
;
}
pFT_Library_Version
(
library
,
&
FT_Version
.
major
,
&
FT_Version
.
minor
,
&
FT_Version
.
patch
);
TRACE
(
"FreeType version is %d.%d.%d
\n
"
,
FT_Version
.
major
,
FT_Version
.
minor
,
FT_Version
.
patch
);
return
TRUE
;
sym_not_found:
WINE_MESSAGE
(
"Wine cannot find certain functions that it needs from FreeType library.
\n
"
);
wine_dlclose
(
ft_handle
,
NULL
,
0
);
ft_handle
=
NULL
;
return
FALSE
;
}
HRESULT
alloc_ft_fontface
(
const
void
*
data_ptr
,
UINT32
data_size
,
UINT32
index
,
struct
ft_fontface
**
ftface
)
{
FT_Face
face
;
FT_Error
err
;
*
ftface
=
heap_alloc_zero
(
sizeof
(
struct
ft_fontface
));
if
(
!*
ftface
)
return
E_OUTOFMEMORY
;
err
=
pFT_New_Memory_Face
(
library
,
data_ptr
,
data_size
,
index
,
&
face
);
if
(
err
)
{
ERR
(
"FT_New_Memory_Face rets %d
\n
"
,
err
);
return
E_FAIL
;
}
(
*
ftface
)
->
face
=
face
;
return
S_OK
;
}
void
release_ft_fontface
(
struct
ft_fontface
*
ftface
)
{
if
(
!
ftface
)
return
;
pFT_Done_Face
(
ftface
->
face
);
heap_free
(
ftface
);
}
#else
/* HAVE_FREETYPE */
BOOL
init_freetype
(
void
)
{
return
FALSE
;
}
HRESULT
alloc_ft_fontface
(
const
void
*
data_ptr
,
UINT32
data_size
,
UINT32
index
,
struct
ft_fontface
**
face
)
{
*
face
=
NULL
;
return
S_FALSE
;
}
void
release_ft_fontface
(
struct
ft_fontface
*
face
)
{
}
#endif
/* HAVE_FREETYPE */
dlls/dwrite/main.c
View file @
a77b9ed0
...
...
@@ -45,6 +45,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
return
FALSE
;
/* prefer native version */
case
DLL_PROCESS_ATTACH
:
DisableThreadLibraryCalls
(
hinstDLL
);
init_freetype
();
break
;
case
DLL_PROCESS_DETACH
:
if
(
reserved
)
break
;
...
...
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