4 * Copyright 2014 Nikolay Sivov for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
24 #ifdef HAVE_FT2BUILD_H
26 #include FT_FREETYPE_H
27 #endif /* HAVE_FT2BUILD_H */
30 #include "wine/library.h"
31 #include "wine/debug.h"
33 #include "dwrite_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(dwrite
);
39 static void *ft_handle
= NULL
;
40 static FT_Library library
= 0;
48 #define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
49 MAKE_FUNCPTR(FT_Done_Face
);
50 MAKE_FUNCPTR(FT_Init_FreeType
);
51 MAKE_FUNCPTR(FT_Library_Version
);
52 MAKE_FUNCPTR(FT_New_Memory_Face
);
60 BOOL
init_freetype(void)
62 FT_Version_t FT_Version
;
64 ft_handle
= wine_dlopen(SONAME_LIBFREETYPE
, RTLD_NOW
, NULL
, 0);
66 WINE_MESSAGE("Wine cannot find the FreeType font library.\n");
70 #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;}
71 LOAD_FUNCPTR(FT_Done_Face
)
72 LOAD_FUNCPTR(FT_Init_FreeType
)
73 LOAD_FUNCPTR(FT_Library_Version
)
74 LOAD_FUNCPTR(FT_New_Memory_Face
)
77 if (pFT_Init_FreeType(&library
) != 0) {
78 ERR("Can't init FreeType library\n");
79 wine_dlclose(ft_handle
, NULL
, 0);
83 pFT_Library_Version(library
, &FT_Version
.major
, &FT_Version
.minor
, &FT_Version
.patch
);
85 TRACE("FreeType version is %d.%d.%d\n", FT_Version
.major
, FT_Version
.minor
, FT_Version
.patch
);
89 WINE_MESSAGE("Wine cannot find certain functions that it needs from FreeType library.\n");
90 wine_dlclose(ft_handle
, NULL
, 0);
95 HRESULT
alloc_ft_fontface(const void *data_ptr
, UINT32 data_size
, UINT32 index
, struct ft_fontface
**ftface
)
100 *ftface
= heap_alloc_zero(sizeof(struct ft_fontface
));
102 return E_OUTOFMEMORY
;
104 err
= pFT_New_Memory_Face(library
, data_ptr
, data_size
, index
, &face
);
106 ERR("FT_New_Memory_Face rets %d\n", err
);
109 (*ftface
)->face
= face
;
114 void release_ft_fontface(struct ft_fontface
*ftface
)
117 pFT_Done_Face(ftface
->face
);
121 #else /* HAVE_FREETYPE */
123 BOOL
init_freetype(void)
128 HRESULT
alloc_ft_fontface(const void *data_ptr
, UINT32 data_size
, UINT32 index
, struct ft_fontface
**face
)
134 void release_ft_fontface(struct ft_fontface
*face
)
138 #endif /* HAVE_FREETYPE */