93619ff93f057dbbd3da262b24f2e7459bec434a
[wine/hacks.git] / dlls / winedib.drv / freetype.h
blob93619ff93f057dbbd3da262b24f2e7459bec434a
1 /*
2 * Truetype font functions
4 * Copyright 2008 Massimo Del Fedele
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_DIBDRV_FREETYPE_H
20 #define __WINE_DIBDRV__FREETYPE_H
22 /* freetype library for font support */
23 #ifdef HAVE_FREETYPE
25 #include <ft2build.h>
26 #include FT_FREETYPE_H
27 #include FT_GLYPH_H
28 #include FT_TRUETYPE_TABLES_H
29 #include FT_SFNT_NAMES_H
30 #include FT_TRUETYPE_IDS_H
32 /* freetype library handle */
33 extern FT_Library DIBDRV_ftLibrary;
35 /******************************************************************************************/
36 /* FREETYPE STUFFS */
37 /* grabbed from winex11.drv/freetype.c */
38 /******************************************************************************************/
40 /* This is basically a copy of FT_Bitmap_Size with an extra element added */
41 typedef struct {
42 FT_Short height;
43 FT_Short width;
44 FT_Pos size;
45 FT_Pos x_ppem;
46 FT_Pos y_ppem;
47 FT_Short internal_leading;
48 } Bitmap_Size;
50 /* FT_Bitmap_Size gained 3 new elements between FreeType 2.1.4 and 2.1.5
51 So to let this compile on older versions of FreeType we'll define the
52 new structure here. */
53 typedef struct {
54 FT_Short height, width;
55 FT_Pos size, x_ppem, y_ppem;
56 } My_FT_Bitmap_Size;
58 struct enum_data
60 ENUMLOGFONTEXW elf;
61 NEWTEXTMETRICEXW ntm;
62 DWORD type;
65 typedef struct tagFace {
66 struct list entry;
67 WCHAR *StyleName;
68 char *file;
69 void *font_data_ptr;
70 DWORD font_data_size;
71 FT_Long face_index;
72 FONTSIGNATURE fs;
73 FONTSIGNATURE fs_links;
74 DWORD ntmFlags;
75 FT_Fixed font_version;
76 BOOL scalable;
77 Bitmap_Size size; /* set if face is a bitmap */
78 BOOL external; /* TRUE if we should manually add this font to the registry */
79 struct tagFamily *family;
80 /* Cached data for Enum */
81 struct enum_data *cached_enum_data;
82 } Face;
84 typedef struct tagFamily {
85 struct list entry;
86 const WCHAR *FamilyName;
87 struct list faces;
88 } Family;
90 typedef struct {
91 GLYPHMETRICS gm;
92 INT adv; /* These three hold to widths of the unrotated chars */
93 INT lsb;
94 INT bbx;
95 BOOL init;
96 } GM;
98 typedef struct {
99 FLOAT eM11, eM12;
100 FLOAT eM21, eM22;
101 } FMAT2;
103 typedef struct {
104 DWORD hash;
105 LOGFONTW lf;
106 FMAT2 matrix;
107 BOOL can_use_bitmap;
108 } FONT_DESC;
110 typedef struct tagHFONTLIST {
111 struct list entry;
112 HFONT hfont;
113 } HFONTLIST;
115 typedef struct {
116 struct list entry;
117 Face *face;
118 struct tagGdiFont *font;
119 } CHILD_FONT;
121 typedef struct tagGdiFont {
122 struct list entry;
123 GM **gm;
124 DWORD gmsize;
125 struct list hfontlist;
126 OUTLINETEXTMETRICW *potm;
127 DWORD total_kern_pairs;
128 KERNINGPAIR *kern_pairs;
129 struct list child_fonts;
131 /* the following members can be accessed without locking, they are never modified after creation */
132 FT_Face ft_face;
133 struct font_mapping *mapping;
134 LPWSTR name;
135 int charset;
136 int codepage;
137 BOOL fake_italic;
138 BOOL fake_bold;
139 BYTE underline;
140 BYTE strikeout;
141 INT orientation;
142 FONT_DESC font_desc;
143 LONG aveWidth, ppem;
144 double scale_y;
145 SHORT yMax;
146 SHORT yMin;
147 DWORD ntmFlags;
148 FONTSIGNATURE fs;
149 struct tagGdiFont *base_font;
150 VOID *GSUB_Table;
151 DWORD cache_num;
152 } GdiFont;
154 /* initialize freetype library */
155 BOOL _DIBDRV_FreeType_Init(void);
157 /* terminates freetype library */
158 void _DIBDRV_FreeType_Terminate(void);
160 #define MAKE_FUNCPTR(f) extern typeof(f) * p##f;
161 MAKE_FUNCPTR(FT_Done_Face)
162 MAKE_FUNCPTR(FT_Done_FreeType)
163 MAKE_FUNCPTR(FT_Get_Char_Index)
164 MAKE_FUNCPTR(FT_Get_Glyph_Name)
165 MAKE_FUNCPTR(FT_Get_Sfnt_Name)
166 MAKE_FUNCPTR(FT_Get_Sfnt_Name_Count)
167 MAKE_FUNCPTR(FT_Get_Sfnt_Table)
168 MAKE_FUNCPTR(FT_Init_FreeType)
169 MAKE_FUNCPTR(FT_Load_Glyph)
170 MAKE_FUNCPTR(FT_Load_Char)
171 MAKE_FUNCPTR(FT_Get_Glyph)
172 MAKE_FUNCPTR(FT_Glyph_Copy)
173 MAKE_FUNCPTR(FT_Glyph_To_Bitmap)
174 MAKE_FUNCPTR(FT_Done_Glyph)
175 MAKE_FUNCPTR(FT_New_Face)
176 MAKE_FUNCPTR(FT_Set_Charmap)
177 MAKE_FUNCPTR(FT_Set_Char_Size)
178 MAKE_FUNCPTR(FT_Set_Pixel_Sizes)
179 MAKE_FUNCPTR(FT_Get_First_Char)
180 MAKE_FUNCPTR(FT_Render_Glyph)
181 MAKE_FUNCPTR(FT_Glyph_Transform)
182 #undef MAKE_FUNCPTR
184 #endif /* HAVE_FREETYPE */
186 #endif