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 _FPDF_SYSFONTINFO_H | 7 #ifndef PUBLIC_FPDF_SYSFONTINFO_H_ |
8 #define _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 m
apping | 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 interface is no longer used | 47 * Give implementation a chance to release any data after the inter
face is no longer used |
48 » * Interface Version: | 48 * Interface Version: |
49 » *» » » 1 | 49 * 1 |
50 » * Implementation Required: | 50 * Implementation Required: |
51 » *» » » No | 51 * No |
52 » * Comments: | 52 * Comments: |
53 » *» » » Called by Foxit SDK during the final cleanup pro
cess. | 53 * Called by Foxit SDK during the final cleanup process. |
54 » * Parameters: | 54 * Parameters: |
55 » *» » » pThis» » -» Pointer to the interface
structure itself | 55 * pThis - Pointer to the interface structure itself |
56 » * Return Value: | 56 * Return Value: |
57 » *» » » None | 57 * None |
58 » */ | 58 */ |
59 » void (*Release)(struct _FPDF_SYSFONTINFO* pThis); | 59 void (*Release)(struct _FPDF_SYSFONTINFO* pThis); |
60 » | |
61 » /** | |
62 » * Method: EnumFonts | |
63 » *» » » Enumerate all fonts installed on the system | |
64 » * Interface Version: | |
65 » *» » » 1 | |
66 » * Implementation Required: | |
67 » *» » » No | |
68 » * Comments: | |
69 » *» » » Implementation should call FPDF_AddIntalledFont(
) function for each font found. | |
70 » *» » » Only TrueType/OpenType and Type1 fonts are accep
ted by Foxit SDK. | |
71 » * Parameters: | |
72 » *» » » pThis» » -» Pointer to the interface
structure itself | |
73 » *» » » pMapper»» -» An opaque pointer to int
ernal font mapper, used when calling FPDF_AddInstalledFont | |
74 » * Return Value: | |
75 » *» » » None | |
76 » */ | |
77 » void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper); | |
78 | 60 |
79 » /** | 61 /** |
80 » * Method: MapFont | 62 * Method: EnumFonts |
81 » *» » » Use the system font mapper to get a font handle
from requested parameters | 63 * Enumerate all fonts installed on the system |
82 » * Interface Version: | 64 * Interface Version: |
83 » *» » » 1 | 65 * 1 |
84 » * Implementation Required: | 66 * Implementation Required: |
85 » *» » » Yes only if GetFont method is not implemented. | 67 * No |
86 » * Comments: | 68 * Comments: |
87 » *» » » If the system supports native font mapper (like
Windows), implementation can implement this method to get a font handle. | 69 * Implementation should call FPDF_AddIntalledFont() function for e
ach font found. |
88 » *» » » Otherwise, Foxit SDK will do the mapping and the
n call GetFont method. | 70 * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK
. |
89 » *» » » Only TrueType/OpenType and Type1 fonts are accep
ted by Foxit SDK. | 71 * Parameters: |
90 » * Parameters: | 72 * pThis - Pointer to the interface structure itself |
91 » *» » » pThis» » -» Pointer to the interface
structure itself | 73 * pMapper - An opaque pointer to internal font mapper, used
when calling FPDF_AddInstalledFont |
92 » *» » » weight» » -» Weight of the requested
font. 400 is normal and 700 is bold. | 74 * Return Value: |
93 » *» » » bItalic»» -» Italic option of the req
uested font, TRUE or FALSE. | 75 * None |
94 » *» » » charset»» -» Character set identifier
for the requested font. See above defined constants. | 76 */ |
95 » *» » » pitch_family -» A combination of flags. See abov
e defined constants. | 77 void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper); |
96 » *» » » face» » -» Typeface name. Currently
use system local encoding only. | |
97 » *» » » bExact» » -» Pointer to an boolean va
lue receiving the indicator whether mapper found the exact match. | |
98 » *» » » » » » » If mapper is not
sure whether it's exact match, ignore this paramter. | |
99 » * Return Value: | |
100 » *» » » An opaque pointer for font handle, or NULL if sy
stem mapping is not supported. | |
101 » **/ | |
102 » void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, int weight, int bItali
c, int charset, int pitch_family, | |
103 » » » » » » const char* face, int* bExact); | |
104 | 78 |
105 » /** | 79 /** |
106 » * Method: GetFont | 80 * Method: MapFont |
107 » *» » » Get a handle to a particular font by its interna
l ID | 81 * Use the system font mapper to get a font handle from requested p
arameters |
108 » * Interface Version: | 82 * Interface Version: |
109 » *» » » 1 | 83 * 1 |
110 » * Implementation Required: | 84 * Implementation Required: |
111 » *» » » Yes only if MapFont method is not implemented. | 85 * Yes only if GetFont method is not implemented. |
112 » * Comments: | 86 * Comments: |
113 » *» » » If the system mapping not supported, Foxit SDK w
ill do the font mapping and use this method to get a font handle. | 87 * If the system supports native font mapper (like Windows), implem
entation can implement this method to get a font handle. |
114 » * Parameters: | 88 * Otherwise, Foxit SDK will do the mapping and then call GetFont m
ethod. |
115 » *» » » pThis» » -» Pointer to the interface
structure itself | 89 * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK
. |
116 » *» » » face» » -» Typeface name. Currently
use system local encoding only. | 90 * Parameters: |
117 » * Return Value: | 91 * pThis - Pointer to the interface structure itself |
118 » *» » » An opaque pointer for font handle. | 92 * weight - Weight of the requested font. 400 is normal and
700 is bold. |
119 » **/ | 93 * bItalic - Italic option of the requested font, TRUE or FAL
SE. |
120 » void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face); | 94 * charset - Character set identifier for the requested font.
See above defined constants. |
| 95 * pitch_family - A combination of flags. See above defined consta
nts. |
| 96 * face - Typeface name. Currently use system local encodi
ng only. |
| 97 * bExact - Pointer to an boolean value receiving the indica
tor whether mapper found the exact match. |
| 98 * If mapper is not sure whether it's exact match,
ignore this paramter. |
| 99 * Return Value: |
| 100 * An opaque pointer for font handle, or NULL if system mapping is
not supported. |
| 101 **/ |
| 102 void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, int weight, int bItalic, i
nt charset, int pitch_family, |
| 103 const char* face, int* bExact); |
121 | 104 |
122 » /** | 105 /** |
123 » * Method: GetFontData | 106 * Method: GetFont |
124 » *» » » Get font data from a font | 107 * Get a handle to a particular font by its internal ID |
125 » * Interface Version: | 108 * Interface Version: |
126 » *» » » 1 | 109 * 1 |
127 » * Implementation Required: | 110 * Implementation Required: |
128 » *» » » Yes | 111 * Yes only if MapFont method is not implemented. |
129 » * Comments: | 112 * Comments: |
130 » *» » » Can read either full font file, or a particular
TrueType/OpenType table | 113 * If the system mapping not supported, Foxit SDK will do the font
mapping and use this method to get a font handle. |
131 » * Parameters: | 114 * Parameters: |
132 » *» » » pThis» » -» Pointer to the interface
structure itself | 115 * pThis - Pointer to the interface structure itself |
133 » *» » » hFont» » -» Font handle returned by
MapFont or GetFont method | 116 * face - Typeface name. Currently use system local encodi
ng only. |
134 » *» » » table» » -» TrueType/OpenType table
identifier (refer to TrueType specification). | 117 * Return Value: |
135 » *» » » » » » » 0 for the whole
font file. | 118 * An opaque pointer for font handle. |
136 » *» » » buffer» » -» The buffer receiving the
font data. Can be NULL if not provided | 119 **/ |
137 » *» » » buf_size» -» Buffer size, can be zero
if not provided | 120 void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face); |
138 » * Return Value: | |
139 » *» » » Number of bytes needed, if buffer not provided o
r not large enough, | |
140 » *» » » or number of bytes written into buffer otherwise
. | |
141 » **/ | |
142 » unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis, void* hFon
t, | |
143 » » » unsigned int table, unsigned char* buffer, unsigned long
buf_size); | |
144 | 121 |
145 » /** | 122 /** |
146 » * Method: GetFaceName | 123 * Method: GetFontData |
147 » *» » » Get face name from a font handle | 124 * Get font data from a font |
148 » * Interface Version: | 125 * Interface Version: |
149 » *» » » 1 | 126 * 1 |
150 » * Implementation Required: | 127 * Implementation Required: |
151 » *» » » No | 128 * Yes |
152 » * Parameters: | 129 * Comments: |
153 » *» » » pThis» » -» Pointer to the interface
structure itself | 130 * Can read either full font file, or a particular TrueType/OpenTyp
e table |
154 » *» » » hFont» » -» Font handle returned by
MapFont or GetFont method | 131 * Parameters: |
155 » *» » » buffer» » -» The buffer receiving the
face name. Can be NULL if not provided | 132 * pThis - Pointer to the interface structure itself |
156 » *» » » buf_size» -» Buffer size, can be zero
if not provided | 133 * hFont - Font handle returned by MapFont or GetFont metho
d |
157 » * Return Value: | 134 * table - TrueType/OpenType table identifier (refer to Tru
eType specification). |
158 » *» » » Number of bytes needed, if buffer not provided o
r not large enough, | 135 * 0 for the whole font file. |
159 » *» » » or number of bytes written into buffer otherwise
. | 136 * buffer - The buffer receiving the font data. Can be NULL
if not provided |
160 » **/ | 137 * buf_size - Buffer size, can be zero if not provided |
161 » unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis, void* hFon
t, char* buffer, unsigned long buf_size); | 138 * Return Value: |
162 » » » | 139 * Number of bytes needed, if buffer not provided or not large enou
gh, |
163 » /** | 140 * or number of bytes written into buffer otherwise. |
164 » * Method: GetFontCharset | 141 **/ |
165 » *» » » Get character set information for a font handle | 142 unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, |
166 » * Interface Version: | 143 unsigned int table, unsigned char* buffer, unsigned long buf_size); |
167 » *» » » 1 | |
168 » * Implementation Required: | |
169 » *» » » No | |
170 » * Parameters: | |
171 » *» » » pThis» » -» Pointer to the interface
structure itself | |
172 » *» » » hFont» » -» Font handle returned by
MapFont or GetFont method | |
173 » * Return Value: | |
174 » *» » » Character set identifier. See defined constants
above. | |
175 » **/ | |
176 » int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); | |
177 | 144 |
178 » /** | 145 /** |
179 » * Method: DeleteFont | 146 * Method: GetFaceName |
180 » *» » » Delete a font handle | 147 * Get face name from a font handle |
181 » * Interface Version: | 148 * Interface Version: |
182 » *» » » 1 | 149 * 1 |
183 » * Implementation Required: | 150 * Implementation Required: |
184 » *» » » Yes | 151 * No |
185 » * Parameters: | 152 * Parameters: |
186 » *» » » pThis» » -» Pointer to the interface
structure itself | 153 * pThis - Pointer to the interface structure itself |
187 » *» » » hFont» » -» Font handle returned by
MapFont or GetFont method | 154 * hFont - Font handle returned by MapFont or GetFont metho
d |
188 » * Return Value: | 155 * buffer - The buffer receiving the face name. Can be NULL
if not provided |
189 » *» » » None | 156 * buf_size - Buffer size, can be zero if not provided |
190 » **/ | 157 * Return Value: |
191 » void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); | 158 * Number of bytes needed, if buffer not provided or not large enou
gh, |
| 159 * or number of bytes written into buffer otherwise. |
| 160 **/ |
| 161 unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, c
har* buffer, unsigned long buf_size); |
| 162 |
| 163 /** |
| 164 * Method: GetFontCharset |
| 165 * Get character set information for a font handle |
| 166 * Interface Version: |
| 167 * 1 |
| 168 * Implementation Required: |
| 169 * No |
| 170 * Parameters: |
| 171 * pThis - Pointer to the interface structure itself |
| 172 * hFont - Font handle returned by MapFont or GetFont metho
d |
| 173 * Return Value: |
| 174 * Character set identifier. See defined constants above. |
| 175 **/ |
| 176 int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); |
| 177 |
| 178 /** |
| 179 * Method: DeleteFont |
| 180 * Delete a font handle |
| 181 * Interface Version: |
| 182 * 1 |
| 183 * Implementation Required: |
| 184 * Yes |
| 185 * Parameters: |
| 186 * pThis - Pointer to the interface structure itself |
| 187 * hFont - Font handle returned by MapFont or GetFont metho
d |
| 188 * Return Value: |
| 189 * None |
| 190 **/ |
| 191 void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); |
192 } FPDF_SYSFONTINFO; | 192 } FPDF_SYSFONTINFO; |
193 | 193 |
194 /** | 194 /** |
195 * Struct: FPDF_CharsetFontMap | 195 * Struct: FPDF_CharsetFontMap |
196 * Provides the name of a font to use for a given charset value. | 196 * Provides the name of a font to use for a given charset value. |
197 **/ | 197 **/ |
198 typedef struct FPDF_CharsetFontMap_ | 198 typedef struct FPDF_CharsetFontMap_ |
199 { | 199 { |
200 int charset; // Character Set Enum value, see FXFONT_*_CHARSET above. | 200 int charset; // Character Set Enum value, see FXFONT_*_CHARSET above. |
201 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; | 202 } FPDF_CharsetFontMap; |
203 | 203 |
204 /** | 204 /** |
205 * Function: FPDF_GetDefaultTTFMap | 205 * Function: FPDF_GetDefaultTTFMap |
206 * Returns a pointer to the default character set to TT Font name map. The | 206 * 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 | 207 * map is an array of FPDF_CharsetFontMap structs, with its end indicated |
208 * by a { -1, NULL } entry. | 208 * by a { -1, NULL } entry. |
209 * Parameters: | 209 * Parameters: |
210 * None. | 210 * None. |
211 * Return Value: | 211 * Return Value: |
212 * Pointer to the Charset Font Map. | 212 * Pointer to the Charset Font Map. |
213 **/ | 213 **/ |
214 DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap(); | 214 DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap(); |
215 | 215 |
216 /** | 216 /** |
217 * Function: FPDF_AddInstalledFont | 217 * Function: FPDF_AddInstalledFont |
218 *» » » Add a system font to the list in Foxit SDK. | 218 * Add a system font to the list in Foxit SDK. |
219 * Comments: | 219 * Comments: |
220 *» » » This function is only called during the system font list
building process. | 220 * This function is only called during the system font list building pr
ocess. |
221 * Parameters: | 221 * Parameters: |
222 *» » » mapper» » » -» Opaque pointer to Foxit
font mapper | 222 * mapper - Opaque pointer to Foxit font mapper |
223 *» » » face» » » -» The font face name | 223 * face - The font face name |
224 *» » » charset»» » -» Font character set. See
above defined constants. | 224 * charset - Font character set. See above defined constants. |
225 * Return Value: | 225 * Return Value: |
226 *» » » None. | 226 * None. |
227 **/ | 227 **/ |
228 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, const char* face, int
charset); | 228 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, const char* face, int
charset); |
229 | 229 |
230 /** | 230 /** |
231 * Function: FPDF_SetSystemFontInfo | 231 * Function: FPDF_SetSystemFontInfo |
232 *» » » Set the system font info interface into Foxit SDK | 232 * Set the system font info interface into Foxit SDK |
233 * Comments: | 233 * Comments: |
234 *» » » Platform support implementation should implement require
d methods of FFDF_SYSFONTINFO interface, | 234 * Platform support implementation should implement required methods of
FFDF_SYSFONTINFO interface, |
235 *» » » then call this function during SDK initialization proces
s. | 235 * then call this function during SDK initialization process. |
236 * Parameters: | 236 * Parameters: |
237 *» » » pFontInfo» » -» Pointer to a FPDF_SYSFON
TINFO structure | 237 * pFontInfo - Pointer to a FPDF_SYSFONTINFO structure |
238 * Return Value: | 238 * Return Value: |
239 *» » » None | 239 * None |
240 **/ | 240 **/ |
241 DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); | 241 DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); |
242 | 242 |
243 /** | 243 /** |
244 * Function: FPDF_GetDefaultSystemFontInfo | 244 * Function: FPDF_GetDefaultSystemFontInfo |
245 *» » » Get default system font info interface for current platf
orm | 245 * Get default system font info interface for current platform |
246 * Comments: | 246 * Comments: |
247 *» » » For some platforms Foxit SDK implement a default version
of system font info interface. | 247 * For some platforms Foxit SDK implement a default version of system f
ont info interface. |
248 *» » » The default implementation can be used in FPDF_SetSystem
FontInfo function. | 248 * The default implementation can be used in FPDF_SetSystemFontInfo fun
ction. |
249 * Parameters: | 249 * Parameters: |
250 *» » » None | 250 * None |
251 * Return Value: | 251 * Return Value: |
252 *» » » Pointer to a FPDF_SYSFONTINFO structure describing the d
efault interface. | 252 * Pointer to a FPDF_SYSFONTINFO structure describing the default inter
face. |
253 *» » » Or NULL if the platform doesn't have a default interface
. | 253 * Or NULL if the platform doesn't have a default interface. |
254 *» » » Application should call FPDF_FreeMemory to free the retu
rned pointer. | 254 * Application should call FPDF_FreeMemory to free the returned pointer
. |
255 **/ | 255 **/ |
256 DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo(); | 256 DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo(); |
257 | 257 |
258 #ifdef __cplusplus | 258 #ifdef __cplusplus |
259 }; | 259 } |
260 #endif | 260 #endif |
261 | 261 |
262 #endif // _FPDF_SYSFONTINFO_H | 262 #endif // PUBLIC_FPDF_SYSFONTINFO_H_ |
OLD | NEW |