OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef PUBLIC_FPDF_SYSFONTINFO_H_ | 7 #ifndef PUBLIC_FPDF_SYSFONTINFO_H_ |
8 #define PUBLIC_FPDF_SYSFONTINFO_H_ | 8 #define PUBLIC_FPDF_SYSFONTINFO_H_ |
9 | 9 |
10 #include "fpdfview.h" | 10 #include "fpdfview.h" |
11 | 11 |
12 /* Character sets for the font */ | 12 /* Character sets for the font */ |
13 #define FXFONT_ANSI_CHARSET 0 | 13 #define FXFONT_ANSI_CHARSET 0 |
14 #define FXFONT_DEFAULT_CHARSET 1 | 14 #define FXFONT_DEFAULT_CHARSET 1 |
15 #define FXFONT_SYMBOL_CHARSET 2 | 15 #define FXFONT_SYMBOL_CHARSET 2 |
16 #define FXFONT_SHIFTJIS_CHARSET 128 | 16 #define FXFONT_SHIFTJIS_CHARSET 128 |
17 #define FXFONT_HANGEUL_CHARSET 129 | 17 #define FXFONT_HANGEUL_CHARSET 129 |
18 #define FXFONT_GB2312_CHARSET 134 | 18 #define FXFONT_GB2312_CHARSET 134 |
19 #define FXFONT_CHINESEBIG5_CHARSET 136 | 19 #define FXFONT_CHINESEBIG5_CHARSET 136 |
20 | 20 |
21 /* Font pitch and family flags */ | 21 /* Font pitch and family flags */ |
22 #define FXFONT_FF_FIXEDPITCH 1 | 22 #define FXFONT_FF_FIXEDPITCH 1 |
23 #define FXFONT_FF_ROMAN (1<<4) | 23 #define FXFONT_FF_ROMAN (1 << 4) |
24 #define FXFONT_FF_SCRIPT (4<<4) | 24 #define FXFONT_FF_SCRIPT (4 << 4) |
25 | 25 |
26 /* Typical weight values */ | 26 /* Typical weight values */ |
27 #define FXFONT_FW_NORMAL 400 | 27 #define FXFONT_FW_NORMAL 400 |
28 #define FXFONT_FW_BOLD 700 | 28 #define FXFONT_FW_BOLD 700 |
29 | 29 |
30 // Exported Functions | 30 // Exported Functions |
31 #ifdef __cplusplus | 31 #ifdef __cplusplus |
32 extern "C" { | 32 extern "C" { |
33 #endif | 33 #endif |
34 | 34 |
35 /** | 35 /** |
36 * Interface: FPDF_SYSFONTINFO | 36 * Interface: FPDF_SYSFONTINFO |
37 * Interface for getting system font information and font mapping | 37 * Interface for getting system font information and font mapping |
38 */ | 38 */ |
39 typedef struct _FPDF_SYSFONTINFO { | 39 typedef struct _FPDF_SYSFONTINFO { |
40 /** | 40 /** |
41 * Version number of the interface. Currently must be 1. | 41 * Version number of the interface. Currently must be 1. |
42 **/ | 42 **/ |
43 int version; | 43 int version; |
44 | 44 |
45 /** | 45 /** |
46 * Method: Release | 46 * Method: Release |
47 * Give implementation a chance to release any data after the inter
face is no longer used | 47 * Give implementation a chance to release any data after the |
48 * Interface Version: | 48 * interface is no longer used |
49 * 1 | 49 * Interface Version: |
50 * Implementation Required: | 50 * 1 |
51 * No | 51 * Implementation Required: |
52 * Comments: | 52 * No |
53 * Called by Foxit SDK during the final cleanup process. | 53 * Comments: |
54 * Parameters: | 54 * Called by Foxit SDK during the final cleanup process. |
55 * pThis - Pointer to the interface structure itself | 55 * Parameters: |
56 * Return Value: | 56 * pThis - Pointer to the interface structure itself |
57 * None | 57 * Return Value: |
58 */ | 58 * None |
59 void (*Release)(struct _FPDF_SYSFONTINFO* pThis); | 59 */ |
60 | 60 void (*Release)(struct _FPDF_SYSFONTINFO* pThis); |
61 /** | 61 |
62 * Method: EnumFonts | 62 /** |
63 * Enumerate all fonts installed on the system | 63 * Method: EnumFonts |
64 * Interface Version: | 64 * Enumerate all fonts installed on the system |
65 * 1 | 65 * Interface Version: |
66 * Implementation Required: | 66 * 1 |
67 * No | 67 * Implementation Required: |
68 * Comments: | 68 * No |
69 * Implementation should call FPDF_AddIntalledFont() function for e
ach font found. | 69 * Comments: |
70 * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK
. | 70 * Implementation should call FPDF_AddIntalledFont() function for |
71 * Parameters: | 71 * each font found. |
72 * pThis - Pointer to the interface structure itself | 72 * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. |
73 * pMapper - An opaque pointer to internal font mapper, used
when calling FPDF_AddInstalledFont | 73 * Parameters: |
74 * Return Value: | 74 * pThis - Pointer to the interface structure itself |
75 * None | 75 * pMapper - An opaque pointer to internal font mapper, used |
76 */ | 76 * when calling FPDF_AddInstalledFont |
77 void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper); | 77 * Return Value: |
78 | 78 * None |
79 /** | 79 */ |
80 * Method: MapFont | 80 void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper); |
81 * Use the system font mapper to get a font handle from requested p
arameters | 81 |
82 * Interface Version: | 82 /** |
83 * 1 | 83 * Method: MapFont |
84 * Implementation Required: | 84 * Use the system font mapper to get a font handle from requested |
85 * Yes only if GetFont method is not implemented. | 85 *parameters |
86 * Comments: | 86 * Interface Version: |
87 * If the system supports native font mapper (like Windows), implem
entation can implement this method to get a font handle. | 87 * 1 |
88 * Otherwise, Foxit SDK will do the mapping and then call GetFont m
ethod. | 88 * Implementation Required: |
89 * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK
. | 89 * Yes only if GetFont method is not implemented. |
90 * Parameters: | 90 * Comments: |
91 * pThis - Pointer to the interface structure itself | 91 * If the system supports native font mapper (like Windows), |
92 * weight - Weight of the requested font. 400 is normal and
700 is bold. | 92 *implementation can implement this method to get a font handle. |
93 * bItalic - Italic option of the requested font, TRUE or FAL
SE. | 93 * Otherwise, Foxit SDK will do the mapping and then call GetFont |
94 * charset - Character set identifier for the requested font.
See above defined constants. | 94 *method. |
95 * pitch_family - A combination of flags. See above defined consta
nts. | 95 * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. |
96 * face - Typeface name. Currently use system local encodi
ng only. | 96 * Parameters: |
97 * bExact - Pointer to a boolean value receiving the indicat
or whether mapper found the exact match. | 97 * pThis - Pointer to the interface structure itself |
98 * If mapper is not sure whether it's exact match,
ignore this paramter. | 98 * weight - Weight of the requested font. 400 is normal and |
99 * Return Value: | 99 *700 is bold. |
100 * An opaque pointer for font handle, or NULL if system mapping is
not supported. | 100 * bItalic - Italic option of the requested font, TRUE or |
101 **/ | 101 *FALSE. |
102 void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, int weight, FPDF_BOOL bIta
lic, int charset, int pitch_family, | 102 * charset - Character set identifier for the requested font. |
103 const char* face, FPDF_BOOL* bExact); | 103 *See above defined constants. |
104 | 104 * pitch_family - A combination of flags. See above defined |
105 /** | 105 *constants. |
106 * Method: GetFont | 106 * face - Typeface name. Currently use system local encoding |
107 * Get a handle to a particular font by its internal ID | 107 *only. |
108 * Interface Version: | 108 * bExact - Pointer to a boolean value receiving the indicator |
109 * 1 | 109 *whether mapper found the exact match. |
110 * Implementation Required: | 110 * If mapper is not sure whether it's exact match, |
111 * Yes only if MapFont method is not implemented. | 111 *ignore this paramter. |
112 * Comments: | 112 * Return Value: |
113 * If the system mapping not supported, Foxit SDK will do the font
mapping and use this method to get a font handle. | 113 * An opaque pointer for font handle, or NULL if system mapping is |
114 * Parameters: | 114 *not supported. |
115 * pThis - Pointer to the interface structure itself | 115 **/ |
116 * face - Typeface name. Currently use system local encodi
ng only. | 116 void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, |
117 * Return Value: | 117 int weight, |
118 * An opaque pointer for font handle. | 118 FPDF_BOOL bItalic, |
119 **/ | 119 int charset, |
120 void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face); | 120 int pitch_family, |
121 | 121 const char* face, |
122 /** | 122 FPDF_BOOL* bExact); |
123 * Method: GetFontData | 123 |
124 * Get font data from a font | 124 /** |
125 * Interface Version: | 125 * Method: GetFont |
126 * 1 | 126 * Get a handle to a particular font by its internal ID |
127 * Implementation Required: | 127 * Interface Version: |
128 * Yes | 128 * 1 |
129 * Comments: | 129 * Implementation Required: |
130 * Can read either full font file, or a particular TrueType/OpenTyp
e table | 130 * Yes only if MapFont method is not implemented. |
131 * Parameters: | 131 * Comments: |
132 * pThis - Pointer to the interface structure itself | 132 * If the system mapping not supported, Foxit SDK will do the font |
133 * hFont - Font handle returned by MapFont or GetFont metho
d | 133 *mapping and use this method to get a font handle. |
134 * table - TrueType/OpenType table identifier (refer to Tru
eType specification). | 134 * Parameters: |
135 * 0 for the whole font file. | 135 * pThis - Pointer to the interface structure itself |
136 * buffer - The buffer receiving the font data. Can be NULL
if not provided | 136 * face - Typeface name. Currently use system local encoding |
137 * buf_size - Buffer size, can be zero if not provided | 137 *only. |
138 * Return Value: | 138 * Return Value: |
139 * Number of bytes needed, if buffer not provided or not large enou
gh, | 139 * An opaque pointer for font handle. |
140 * or number of bytes written into buffer otherwise. | 140 **/ |
141 **/ | 141 void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face); |
142 unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, | 142 |
143 unsigned int table, unsigned char* buffer, unsigned long buf_size); | 143 /** |
144 | 144 * Method: GetFontData |
145 /** | 145 * Get font data from a font |
146 * Method: GetFaceName | 146 * Interface Version: |
147 * Get face name from a font handle | 147 * 1 |
148 * Interface Version: | 148 * Implementation Required: |
149 * 1 | 149 * Yes |
150 * Implementation Required: | 150 * Comments: |
151 * No | 151 * Can read either full font file, or a particular TrueType/OpenType |
152 * Parameters: | 152 *table |
153 * pThis - Pointer to the interface structure itself | 153 * Parameters: |
154 * hFont - Font handle returned by MapFont or GetFont metho
d | 154 * pThis - Pointer to the interface structure itself |
155 * buffer - The buffer receiving the face name. Can be NULL
if not provided | 155 * hFont - Font handle returned by MapFont or GetFont method |
156 * buf_size - Buffer size, can be zero if not provided | 156 * table - TrueType/OpenType table identifier (refer to |
157 * Return Value: | 157 *TrueType specification). |
158 * Number of bytes needed, if buffer not provided or not large enou
gh, | 158 * 0 for the whole font file. |
159 * or number of bytes written into buffer otherwise. | 159 * buffer - The buffer receiving the font data. Can be NULL if |
160 **/ | 160 *not provided |
161 unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, c
har* buffer, unsigned long buf_size); | 161 * buf_size - Buffer size, can be zero if not provided |
162 | 162 * Return Value: |
163 /** | 163 * Number of bytes needed, if buffer not provided or not large |
164 * Method: GetFontCharset | 164 *enough, |
165 * Get character set information for a font handle | 165 * or number of bytes written into buffer otherwise. |
166 * Interface Version: | 166 **/ |
167 * 1 | 167 unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis, |
168 * Implementation Required: | 168 void* hFont, |
169 * No | 169 unsigned int table, |
170 * Parameters: | 170 unsigned char* buffer, |
171 * pThis - Pointer to the interface structure itself | 171 unsigned long buf_size); |
172 * hFont - Font handle returned by MapFont or GetFont metho
d | 172 |
173 * Return Value: | 173 /** |
174 * Character set identifier. See defined constants above. | 174 * Method: GetFaceName |
175 **/ | 175 * Get face name from a font handle |
176 int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); | 176 * Interface Version: |
177 | 177 * 1 |
178 /** | 178 * Implementation Required: |
179 * Method: DeleteFont | 179 * No |
180 * Delete a font handle | 180 * Parameters: |
181 * Interface Version: | 181 * pThis - Pointer to the interface structure itself |
182 * 1 | 182 * hFont - Font handle returned by MapFont or GetFont method |
183 * Implementation Required: | 183 * buffer - The buffer receiving the face name. Can be NULL if |
184 * Yes | 184 *not provided |
185 * Parameters: | 185 * buf_size - Buffer size, can be zero if not provided |
186 * pThis - Pointer to the interface structure itself | 186 * Return Value: |
187 * hFont - Font handle returned by MapFont or GetFont metho
d | 187 * Number of bytes needed, if buffer not provided or not large |
188 * Return Value: | 188 *enough, |
189 * None | 189 * or number of bytes written into buffer otherwise. |
190 **/ | 190 **/ |
191 void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); | 191 unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis, |
| 192 void* hFont, |
| 193 char* buffer, |
| 194 unsigned long buf_size); |
| 195 |
| 196 /** |
| 197 * Method: GetFontCharset |
| 198 * Get character set information for a font handle |
| 199 * Interface Version: |
| 200 * 1 |
| 201 * Implementation Required: |
| 202 * No |
| 203 * Parameters: |
| 204 * pThis - Pointer to the interface structure itself |
| 205 * hFont - Font handle returned by MapFont or GetFont method |
| 206 * Return Value: |
| 207 * Character set identifier. See defined constants above. |
| 208 **/ |
| 209 int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); |
| 210 |
| 211 /** |
| 212 * Method: DeleteFont |
| 213 * Delete a font handle |
| 214 * Interface Version: |
| 215 * 1 |
| 216 * Implementation Required: |
| 217 * Yes |
| 218 * Parameters: |
| 219 * pThis - Pointer to the interface structure itself |
| 220 * hFont - Font handle returned by MapFont or GetFont method |
| 221 * Return Value: |
| 222 * None |
| 223 **/ |
| 224 void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); |
192 } FPDF_SYSFONTINFO; | 225 } FPDF_SYSFONTINFO; |
193 | 226 |
194 /** | 227 /** |
195 * Struct: FPDF_CharsetFontMap | 228 * Struct: FPDF_CharsetFontMap |
196 * Provides the name of a font to use for a given charset value. | 229 * Provides the name of a font to use for a given charset value. |
197 **/ | 230 **/ |
198 typedef struct FPDF_CharsetFontMap_ | 231 typedef struct FPDF_CharsetFontMap_ { |
199 { | 232 int charset; // Character Set Enum value, see FXFONT_*_CHARSET above. |
200 int charset; // Character Set Enum value, see FXFONT_*_CHARSET above. | 233 const char* fontname; // Name of default font to use with that charset. |
201 const char* fontname; // Name of default font to use with that charset. | |
202 } FPDF_CharsetFontMap; | 234 } FPDF_CharsetFontMap; |
203 | 235 |
204 /** | 236 /** |
205 * Function: FPDF_GetDefaultTTFMap | 237 * Function: FPDF_GetDefaultTTFMap |
206 * Returns a pointer to the default character set to TT Font name map. The | 238 * Returns a pointer to the default character set to TT Font name map. The |
207 * map is an array of FPDF_CharsetFontMap structs, with its end indicated | 239 * map is an array of FPDF_CharsetFontMap structs, with its end indicated |
208 * by a { -1, NULL } entry. | 240 * by a { -1, NULL } entry. |
209 * Parameters: | 241 * Parameters: |
210 * None. | 242 * None. |
211 * Return Value: | 243 * Return Value: |
212 * Pointer to the Charset Font Map. | 244 * Pointer to the Charset Font Map. |
213 **/ | 245 **/ |
214 DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap(); | 246 DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap(); |
215 | 247 |
216 /** | 248 /** |
217 * Function: FPDF_AddInstalledFont | 249 * Function: FPDF_AddInstalledFont |
218 * Add a system font to the list in Foxit SDK. | 250 * Add a system font to the list in Foxit SDK. |
219 * Comments: | 251 * Comments: |
220 * This function is only called during the system font list building pr
ocess. | 252 * This function is only called during the system font list building |
| 253 *process. |
221 * Parameters: | 254 * Parameters: |
222 * mapper - Opaque pointer to Foxit font mapper | 255 * mapper - Opaque pointer to Foxit font mapper |
223 * face - The font face name | 256 * face - The font face name |
224 * charset - Font character set. See above defined constants. | 257 * charset - Font character set. See above defined constants. |
225 * Return Value: | 258 * Return Value: |
226 * None. | 259 * None. |
227 **/ | 260 **/ |
228 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, const char* face, int
charset); | 261 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, |
| 262 const char* face, |
| 263 int charset); |
229 | 264 |
230 /** | 265 /** |
231 * Function: FPDF_SetSystemFontInfo | 266 * Function: FPDF_SetSystemFontInfo |
232 * Set the system font info interface into Foxit SDK | 267 * Set the system font info interface into Foxit SDK |
233 * Comments: | 268 * Comments: |
234 * Platform support implementation should implement required methods of
FFDF_SYSFONTINFO interface, | 269 * Platform support implementation should implement required methods of |
| 270 *FFDF_SYSFONTINFO interface, |
235 * then call this function during SDK initialization process. | 271 * then call this function during SDK initialization process. |
236 * Parameters: | 272 * Parameters: |
237 * pFontInfo - Pointer to a FPDF_SYSFONTINFO structure | 273 * pFontInfo - Pointer to a FPDF_SYSFONTINFO structure |
238 * Return Value: | 274 * Return Value: |
239 * None | 275 * None |
240 **/ | 276 **/ |
241 DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); | 277 DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); |
242 | 278 |
243 /** | 279 /** |
244 * Function: FPDF_GetDefaultSystemFontInfo | 280 * Function: FPDF_GetDefaultSystemFontInfo |
245 * Get default system font info interface for current platform | 281 * Get default system font info interface for current platform |
246 * Comments: | 282 * Comments: |
247 * For some platforms Foxit SDK implement a default version of system f
ont info interface. | 283 * For some platforms Foxit SDK implement a default version of system |
248 * The default implementation can be used in FPDF_SetSystemFontInfo fun
ction. | 284 *font info interface. |
| 285 * The default implementation can be used in FPDF_SetSystemFontInfo |
| 286 *function. |
249 * Parameters: | 287 * Parameters: |
250 * None | 288 * None |
251 * Return Value: | 289 * Return Value: |
252 * Pointer to a FPDF_SYSFONTINFO structure describing the default inter
face. | 290 * Pointer to a FPDF_SYSFONTINFO structure describing the default |
| 291 *interface. |
253 * Or NULL if the platform doesn't have a default interface. | 292 * Or NULL if the platform doesn't have a default interface. |
254 * Application should call FPDF_FreeMemory to free the returned pointer
. | 293 * Application should call FPDF_FreeMemory to free the returned |
| 294 *pointer. |
255 **/ | 295 **/ |
256 DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo(); | 296 DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo(); |
257 | 297 |
258 #ifdef __cplusplus | 298 #ifdef __cplusplus |
259 } | 299 } |
260 #endif | 300 #endif |
261 | 301 |
262 #endif // PUBLIC_FPDF_SYSFONTINFO_H_ | 302 #endif // PUBLIC_FPDF_SYSFONTINFO_H_ |
OLD | NEW |