beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / cairo-scaled-font-subsets-private.h
blob866e63d7bca8dd6a7f1569700fc8c3e45ef7974d
1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2006 Red Hat, Inc
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is University of Southern
31 * California.
33 * Contributor(s):
34 * Carl D. Worth <cworth@cworth.org>
37 #ifndef CAIRO_SCALED_FONT_SUBSETS_PRIVATE_H
38 #define CAIRO_SCALED_FONT_SUBSETS_PRIVATE_H
40 #include "cairoint.h"
42 #if CAIRO_HAS_FONT_SUBSET
44 typedef struct _cairo_scaled_font_subsets_glyph {
45 unsigned int font_id;
46 unsigned int subset_id;
47 unsigned int subset_glyph_index;
48 cairo_bool_t is_scaled;
49 cairo_bool_t is_composite;
50 cairo_bool_t is_latin;
51 double x_advance;
52 double y_advance;
53 cairo_bool_t utf8_is_mapped;
54 uint32_t unicode;
55 } cairo_scaled_font_subsets_glyph_t;
57 /**
58 * _cairo_scaled_font_subsets_create_scaled:
60 * Create a new #cairo_scaled_font_subsets_t object which can be used
61 * to create subsets of any number of #cairo_scaled_font_t
62 * objects. This allows the (arbitrarily large and sparse) glyph
63 * indices of a #cairo_scaled_font_t to be mapped to one or more font
64 * subsets with glyph indices packed into the range
65 * [0 .. max_glyphs_per_subset).
67 * Return value: a pointer to the newly creates font subsets. The
68 * caller owns this object and should call
69 * _cairo_scaled_font_subsets_destroy() when done with it.
70 **/
71 cairo_private cairo_scaled_font_subsets_t *
72 _cairo_scaled_font_subsets_create_scaled (void);
74 /**
75 * _cairo_scaled_font_subsets_create_simple:
77 * Create a new #cairo_scaled_font_subsets_t object which can be used
78 * to create font subsets suitable for embedding as Postscript or PDF
79 * simple fonts.
81 * Glyphs with an outline path available will be mapped to one font
82 * subset for each font face. Glyphs from bitmap fonts will mapped to
83 * separate font subsets for each #cairo_scaled_font_t object.
85 * The maximum number of glyphs per subset is 256. Each subset
86 * reserves the first glyph for the .notdef glyph.
88 * Return value: a pointer to the newly creates font subsets. The
89 * caller owns this object and should call
90 * _cairo_scaled_font_subsets_destroy() when done with it.
91 **/
92 cairo_private cairo_scaled_font_subsets_t *
93 _cairo_scaled_font_subsets_create_simple (void);
95 /**
96 * _cairo_scaled_font_subsets_create_composite:
98 * Create a new #cairo_scaled_font_subsets_t object which can be used
99 * to create font subsets suitable for embedding as Postscript or PDF
100 * composite fonts.
102 * Glyphs with an outline path available will be mapped to one font
103 * subset for each font face. Each unscaled subset has a maximum of
104 * 65536 glyphs except for Type1 fonts which have a maximum of 256 glyphs.
106 * Glyphs from bitmap fonts will mapped to separate font subsets for
107 * each #cairo_scaled_font_t object. Each unscaled subset has a maximum
108 * of 256 glyphs.
110 * Each subset reserves the first glyph for the .notdef glyph.
112 * Return value: a pointer to the newly creates font subsets. The
113 * caller owns this object and should call
114 * _cairo_scaled_font_subsets_destroy() when done with it.
116 cairo_private cairo_scaled_font_subsets_t *
117 _cairo_scaled_font_subsets_create_composite (void);
120 * _cairo_scaled_font_subsets_destroy:
121 * @font_subsets: a #cairo_scaled_font_subsets_t object to be destroyed
123 * Destroys @font_subsets and all resources associated with it.
125 cairo_private void
126 _cairo_scaled_font_subsets_destroy (cairo_scaled_font_subsets_t *font_subsets);
129 * _cairo_scaled_font_subsets_enable_latin_subset:
130 * @font_subsets: a #cairo_scaled_font_subsets_t object to be destroyed
131 * @use_latin: a #cairo_bool_t indicating if a latin subset is to be used
133 * If enabled, all CP1252 characters will be placed in a separate
134 * 8-bit latin subset.
136 cairo_private void
137 _cairo_scaled_font_subsets_enable_latin_subset (cairo_scaled_font_subsets_t *font_subsets,
138 cairo_bool_t use_latin);
141 * _cairo_scaled_font_subsets_map_glyph:
142 * @font_subsets: a #cairo_scaled_font_subsets_t
143 * @scaled_font: the font of the glyph to be mapped
144 * @scaled_font_glyph_index: the index of the glyph to be mapped
145 * @utf8: a string of text encoded in UTF-8
146 * @utf8_len: length of @utf8 in bytes
147 * @subset_glyph_ret: return structure containing subset font and glyph id
149 * Map a glyph from a #cairo_scaled_font to a new index within a
150 * subset of that font. The mapping performed is from the tuple:
152 * (scaled_font, scaled_font_glyph_index)
154 * to the tuple:
156 * (font_id, subset_id, subset_glyph_index)
158 * This mapping is 1:1. If the input tuple has previously mapped, the
159 * the output tuple previously returned will be returned again.
161 * Otherwise, the return tuple will be constructed as follows:
163 * 1) There is a 1:1 correspondence between the input scaled_font
164 * value and the output font_id value. If no mapping has been
165 * previously performed with the scaled_font value then the
166 * smallest unused font_id value will be returned.
168 * 2) Within the set of output tuples of the same font_id value the
169 * smallest value of subset_id will be returned such that
170 * subset_glyph_index does not exceed max_glyphs_per_subset (as
171 * passed to _cairo_scaled_font_subsets_create()) and that the
172 * resulting tuple is unique.
174 * 3) The smallest value of subset_glyph_index is returned such that
175 * the resulting tuple is unique.
177 * The net result is that any #cairo_scaled_font_t will be represented
178 * by one or more font subsets. Each subset is effectively a tuple of
179 * (scaled_font, font_id, subset_id) and within each subset there
180 * exists a mapping of scaled_glyph_font_index to subset_glyph_index.
182 * This final description of a font subset is the same representation
183 * used by #cairo_scaled_font_subset_t as provided by
184 * _cairo_scaled_font_subsets_foreach.
186 * @utf8 and @utf8_len specify a string of unicode characters that the
187 * glyph @scaled_font_glyph_index maps to. If @utf8_is_mapped in
188 * @subset_glyph_ret is %TRUE, the font subsetting will (where index to
189 * unicode mapping is supported) ensure that @scaled_font_glyph_index
190 * maps to @utf8. If @utf8_is_mapped is %FALSE,
191 * @scaled_font_glyph_index has already been mapped to a different
192 * unicode string.
194 * The returned values in the #cairo_scaled_font_subsets_glyph_t struct are:
196 * @font_id: The font ID of the mapped glyph
197 * @subset_id : The subset ID of the mapped glyph within the @font_id
198 * @subset_glyph_index: The index of the mapped glyph within the @subset_id subset
199 * @is_scaled: If true, the mapped glyph is from a bitmap font, and separate font
200 * subset is created for each font scale used. If false, the outline of the mapped glyph
201 * is available. One font subset for each font face is created.
202 * @x_advance, @y_advance: When @is_scaled is true, @x_advance and @y_advance contain
203 * the x and y advance for the mapped glyph in device space.
204 * When @is_scaled is false, @x_advance and @y_advance contain the x and y advance for
205 * the the mapped glyph from an unhinted 1 point font.
206 * @utf8_is_mapped: If true the utf8 string provided to _cairo_scaled_font_subsets_map_glyph()
207 * is (or already was) the utf8 string mapped to this glyph. If false the glyph is already
208 * mapped to a different utf8 string.
209 * @unicode: the unicode character mapped to this glyph by the font backend.
211 * Return value: %CAIRO_STATUS_SUCCESS if successful, or a non-zero
212 * value indicating an error. Possible errors include
213 * %CAIRO_STATUS_NO_MEMORY.
215 cairo_private cairo_status_t
216 _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t *font_subsets,
217 cairo_scaled_font_t *scaled_font,
218 unsigned long scaled_font_glyph_index,
219 const char * utf8,
220 int utf8_len,
221 cairo_scaled_font_subsets_glyph_t *subset_glyph_ret);
223 typedef cairo_int_status_t
224 (*cairo_scaled_font_subset_callback_func_t) (cairo_scaled_font_subset_t *font_subset,
225 void *closure);
228 * _cairo_scaled_font_subsets_foreach_scaled:
229 * @font_subsets: a #cairo_scaled_font_subsets_t
230 * @font_subset_callback: a function to be called for each font subset
231 * @closure: closure data for the callback function
233 * Iterate over each unique scaled font subset as created by calls to
234 * _cairo_scaled_font_subsets_map_glyph(). A subset is determined by
235 * unique pairs of (font_id, subset_id) as returned by
236 * _cairo_scaled_font_subsets_map_glyph().
238 * For each subset, @font_subset_callback will be called and will be
239 * provided with both a #cairo_scaled_font_subset_t object containing
240 * all the glyphs in the subset as well as the value of @closure.
242 * The #cairo_scaled_font_subset_t object contains the scaled_font,
243 * the font_id, and the subset_id corresponding to all glyphs
244 * belonging to the subset. In addition, it contains an array providing
245 * a mapping between subset glyph indices and the original scaled font
246 * glyph indices.
248 * The index of the array corresponds to subset_glyph_index values
249 * returned by _cairo_scaled_font_subsets_map_glyph() while the
250 * values of the array correspond to the scaled_font_glyph_index
251 * values passed as input to the same function.
253 * Return value: %CAIRO_STATUS_SUCCESS if successful, or a non-zero
254 * value indicating an error. Possible errors include
255 * %CAIRO_STATUS_NO_MEMORY.
257 cairo_private cairo_status_t
258 _cairo_scaled_font_subsets_foreach_scaled (cairo_scaled_font_subsets_t *font_subsets,
259 cairo_scaled_font_subset_callback_func_t font_subset_callback,
260 void *closure);
263 * _cairo_scaled_font_subsets_foreach_unscaled:
264 * @font_subsets: a #cairo_scaled_font_subsets_t
265 * @font_subset_callback: a function to be called for each font subset
266 * @closure: closure data for the callback function
268 * Iterate over each unique unscaled font subset as created by calls to
269 * _cairo_scaled_font_subsets_map_glyph(). A subset is determined by
270 * unique pairs of (font_id, subset_id) as returned by
271 * _cairo_scaled_font_subsets_map_glyph().
273 * For each subset, @font_subset_callback will be called and will be
274 * provided with both a #cairo_scaled_font_subset_t object containing
275 * all the glyphs in the subset as well as the value of @closure.
277 * The #cairo_scaled_font_subset_t object contains the scaled_font,
278 * the font_id, and the subset_id corresponding to all glyphs
279 * belonging to the subset. In addition, it contains an array providing
280 * a mapping between subset glyph indices and the original scaled font
281 * glyph indices.
283 * The index of the array corresponds to subset_glyph_index values
284 * returned by _cairo_scaled_font_subsets_map_glyph() while the
285 * values of the array correspond to the scaled_font_glyph_index
286 * values passed as input to the same function.
288 * Return value: %CAIRO_STATUS_SUCCESS if successful, or a non-zero
289 * value indicating an error. Possible errors include
290 * %CAIRO_STATUS_NO_MEMORY.
292 cairo_private cairo_status_t
293 _cairo_scaled_font_subsets_foreach_unscaled (cairo_scaled_font_subsets_t *font_subsets,
294 cairo_scaled_font_subset_callback_func_t font_subset_callback,
295 void *closure);
298 * _cairo_scaled_font_subsets_foreach_user:
299 * @font_subsets: a #cairo_scaled_font_subsets_t
300 * @font_subset_callback: a function to be called for each font subset
301 * @closure: closure data for the callback function
303 * Iterate over each unique scaled font subset as created by calls to
304 * _cairo_scaled_font_subsets_map_glyph(). A subset is determined by
305 * unique pairs of (font_id, subset_id) as returned by
306 * _cairo_scaled_font_subsets_map_glyph().
308 * For each subset, @font_subset_callback will be called and will be
309 * provided with both a #cairo_scaled_font_subset_t object containing
310 * all the glyphs in the subset as well as the value of @closure.
312 * The #cairo_scaled_font_subset_t object contains the scaled_font,
313 * the font_id, and the subset_id corresponding to all glyphs
314 * belonging to the subset. In addition, it contains an array providing
315 * a mapping between subset glyph indices and the original scaled font
316 * glyph indices.
318 * The index of the array corresponds to subset_glyph_index values
319 * returned by _cairo_scaled_font_subsets_map_glyph() while the
320 * values of the array correspond to the scaled_font_glyph_index
321 * values passed as input to the same function.
323 * Return value: %CAIRO_STATUS_SUCCESS if successful, or a non-zero
324 * value indicating an error. Possible errors include
325 * %CAIRO_STATUS_NO_MEMORY.
327 cairo_private cairo_status_t
328 _cairo_scaled_font_subsets_foreach_user (cairo_scaled_font_subsets_t *font_subsets,
329 cairo_scaled_font_subset_callback_func_t font_subset_callback,
330 void *closure);
333 * _cairo_scaled_font_subset_create_glyph_names:
334 * @font_subsets: a #cairo_scaled_font_subsets_t
336 * Create an array of strings containing the glyph name for each glyph
337 * in @font_subsets. The array as store in font_subsets->glyph_names.
339 * Return value: %CAIRO_STATUS_SUCCESS if successful,
340 * %CAIRO_INT_STATUS_UNSUPPORTED if the font backend does not support
341 * mapping the glyph indices to unicode characters. Possible errors
342 * include %CAIRO_STATUS_NO_MEMORY.
344 cairo_private cairo_int_status_t
345 _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset);
347 typedef struct _cairo_cff_subset {
348 char *family_name_utf8;
349 char *ps_name;
350 double *widths;
351 double x_min, y_min, x_max, y_max;
352 double ascent, descent;
353 char *data;
354 unsigned long data_length;
355 } cairo_cff_subset_t;
358 * _cairo_cff_subset_init:
359 * @cff_subset: a #cairo_cff_subset_t to initialize
360 * @font_subset: the #cairo_scaled_font_subset_t to initialize from
362 * If possible (depending on the format of the underlying
363 * #cairo_scaled_font_t and the font backend in use) generate a
364 * cff file corresponding to @font_subset and initialize
365 * @cff_subset with information about the subset and the cff
366 * data.
368 * Return value: %CAIRO_STATUS_SUCCESS if successful,
369 * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a
370 * cff file, or an non-zero value indicating an error. Possible
371 * errors include %CAIRO_STATUS_NO_MEMORY.
373 cairo_private cairo_status_t
374 _cairo_cff_subset_init (cairo_cff_subset_t *cff_subset,
375 const char *name,
376 cairo_scaled_font_subset_t *font_subset);
379 * _cairo_cff_subset_fini:
380 * @cff_subset: a #cairo_cff_subset_t
382 * Free all resources associated with @cff_subset. After this
383 * call, @cff_subset should not be used again without a
384 * subsequent call to _cairo_cff_subset_init() again first.
386 cairo_private void
387 _cairo_cff_subset_fini (cairo_cff_subset_t *cff_subset);
390 * _cairo_cff_scaled_font_is_cid_cff:
391 * @scaled_font: a #cairo_scaled_font_t
393 * Return %TRUE if @scaled_font is a CID CFF font, otherwise return %FALSE.
395 cairo_private cairo_bool_t
396 _cairo_cff_scaled_font_is_cid_cff (cairo_scaled_font_t *scaled_font);
399 * _cairo_cff_fallback_init:
400 * @cff_subset: a #cairo_cff_subset_t to initialize
401 * @font_subset: the #cairo_scaled_font_subset_t to initialize from
403 * If possible (depending on the format of the underlying
404 * #cairo_scaled_font_t and the font backend in use) generate a cff
405 * file corresponding to @font_subset and initialize @cff_subset
406 * with information about the subset and the cff data.
408 * Return value: %CAIRO_STATUS_SUCCESS if successful,
409 * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a
410 * cff file, or an non-zero value indicating an error. Possible
411 * errors include %CAIRO_STATUS_NO_MEMORY.
413 cairo_private cairo_status_t
414 _cairo_cff_fallback_init (cairo_cff_subset_t *cff_subset,
415 const char *name,
416 cairo_scaled_font_subset_t *font_subset);
419 * _cairo_cff_fallback_fini:
420 * @cff_subset: a #cairo_cff_subset_t
422 * Free all resources associated with @cff_subset. After this
423 * call, @cff_subset should not be used again without a
424 * subsequent call to _cairo_cff_subset_init() again first.
426 cairo_private void
427 _cairo_cff_fallback_fini (cairo_cff_subset_t *cff_subset);
429 typedef struct _cairo_truetype_subset {
430 char *family_name_utf8;
431 char *ps_name;
432 double *widths;
433 double x_min, y_min, x_max, y_max;
434 double ascent, descent;
435 unsigned char *data;
436 unsigned long data_length;
437 unsigned long *string_offsets;
438 unsigned long num_string_offsets;
439 } cairo_truetype_subset_t;
442 * _cairo_truetype_subset_init_ps:
443 * @truetype_subset: a #cairo_truetype_subset_t to initialize
444 * @font_subset: the #cairo_scaled_font_subset_t to initialize from
446 * If possible (depending on the format of the underlying
447 * #cairo_scaled_font_t and the font backend in use) generate a
448 * truetype file corresponding to @font_subset and initialize
449 * @truetype_subset with information about the subset and the truetype
450 * data. The generated font will be suitable for embedding in
451 * PostScript.
453 * Return value: %CAIRO_STATUS_SUCCESS if successful,
454 * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a
455 * truetype file, or an non-zero value indicating an error. Possible
456 * errors include %CAIRO_STATUS_NO_MEMORY.
458 cairo_private cairo_status_t
459 _cairo_truetype_subset_init_ps (cairo_truetype_subset_t *truetype_subset,
460 cairo_scaled_font_subset_t *font_subset);
463 * _cairo_truetype_subset_init_pdf:
464 * @truetype_subset: a #cairo_truetype_subset_t to initialize
465 * @font_subset: the #cairo_scaled_font_subset_t to initialize from
467 * If possible (depending on the format of the underlying
468 * #cairo_scaled_font_t and the font backend in use) generate a
469 * truetype file corresponding to @font_subset and initialize
470 * @truetype_subset with information about the subset and the truetype
471 * data. The generated font will be suitable for embedding in
472 * PDF.
474 * Return value: %CAIRO_STATUS_SUCCESS if successful,
475 * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a
476 * truetype file, or an non-zero value indicating an error. Possible
477 * errors include %CAIRO_STATUS_NO_MEMORY.
479 cairo_private cairo_status_t
480 _cairo_truetype_subset_init_pdf (cairo_truetype_subset_t *truetype_subset,
481 cairo_scaled_font_subset_t *font_subset);
484 * _cairo_truetype_subset_fini:
485 * @truetype_subset: a #cairo_truetype_subset_t
487 * Free all resources associated with @truetype_subset. After this
488 * call, @truetype_subset should not be used again without a
489 * subsequent call to _cairo_truetype_subset_init() again first.
491 cairo_private void
492 _cairo_truetype_subset_fini (cairo_truetype_subset_t *truetype_subset);
494 cairo_private const char *
495 _cairo_ps_standard_encoding_to_glyphname (int glyph);
497 cairo_private int
498 _cairo_unicode_to_winansi (unsigned long unicode);
500 cairo_private const char *
501 _cairo_winansi_to_glyphname (int glyph);
503 typedef struct _cairo_type1_subset {
504 char *base_font;
505 double *widths;
506 double x_min, y_min, x_max, y_max;
507 double ascent, descent;
508 char *data;
509 unsigned long header_length;
510 unsigned long data_length;
511 unsigned long trailer_length;
512 } cairo_type1_subset_t;
516 * _cairo_type1_subset_init:
517 * @type1_subset: a #cairo_type1_subset_t to initialize
518 * @font_subset: the #cairo_scaled_font_subset_t to initialize from
519 * @hex_encode: if true the encrypted portion of the font is hex encoded
521 * If possible (depending on the format of the underlying
522 * #cairo_scaled_font_t and the font backend in use) generate a type1
523 * file corresponding to @font_subset and initialize @type1_subset
524 * with information about the subset and the type1 data.
526 * Return value: %CAIRO_STATUS_SUCCESS if successful,
527 * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type1
528 * file, or an non-zero value indicating an error. Possible errors
529 * include %CAIRO_STATUS_NO_MEMORY.
531 cairo_private cairo_status_t
532 _cairo_type1_subset_init (cairo_type1_subset_t *type_subset,
533 const char *name,
534 cairo_scaled_font_subset_t *font_subset,
535 cairo_bool_t hex_encode);
538 * _cairo_type1_subset_fini:
539 * @type1_subset: a #cairo_type1_subset_t
541 * Free all resources associated with @type1_subset. After this call,
542 * @type1_subset should not be used again without a subsequent call to
543 * _cairo_truetype_type1_init() again first.
545 cairo_private void
546 _cairo_type1_subset_fini (cairo_type1_subset_t *subset);
549 * _cairo_type1_scaled_font_is_type1:
550 * @scaled_font: a #cairo_scaled_font_t
552 * Return %TRUE if @scaled_font is a Type 1 font, otherwise return %FALSE.
554 cairo_private cairo_bool_t
555 _cairo_type1_scaled_font_is_type1 (cairo_scaled_font_t *scaled_font);
558 * _cairo_type1_fallback_init_binary:
559 * @type1_subset: a #cairo_type1_subset_t to initialize
560 * @font_subset: the #cairo_scaled_font_subset_t to initialize from
562 * If possible (depending on the format of the underlying
563 * #cairo_scaled_font_t and the font backend in use) generate a type1
564 * file corresponding to @font_subset and initialize @type1_subset
565 * with information about the subset and the type1 data. The encrypted
566 * part of the font is binary encoded.
568 * Return value: %CAIRO_STATUS_SUCCESS if successful,
569 * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type1
570 * file, or an non-zero value indicating an error. Possible errors
571 * include %CAIRO_STATUS_NO_MEMORY.
573 cairo_private cairo_status_t
574 _cairo_type1_fallback_init_binary (cairo_type1_subset_t *type_subset,
575 const char *name,
576 cairo_scaled_font_subset_t *font_subset);
579 * _cairo_type1_fallback_init_hex:
580 * @type1_subset: a #cairo_type1_subset_t to initialize
581 * @font_subset: the #cairo_scaled_font_subset_t to initialize from
583 * If possible (depending on the format of the underlying
584 * #cairo_scaled_font_t and the font backend in use) generate a type1
585 * file corresponding to @font_subset and initialize @type1_subset
586 * with information about the subset and the type1 data. The encrypted
587 * part of the font is hex encoded.
589 * Return value: %CAIRO_STATUS_SUCCESS if successful,
590 * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type1
591 * file, or an non-zero value indicating an error. Possible errors
592 * include %CAIRO_STATUS_NO_MEMORY.
594 cairo_private cairo_status_t
595 _cairo_type1_fallback_init_hex (cairo_type1_subset_t *type_subset,
596 const char *name,
597 cairo_scaled_font_subset_t *font_subset);
600 * _cairo_type1_fallback_fini:
601 * @type1_subset: a #cairo_type1_subset_t
603 * Free all resources associated with @type1_subset. After this call,
604 * @type1_subset should not be used again without a subsequent call to
605 * _cairo_truetype_type1_init() again first.
607 cairo_private void
608 _cairo_type1_fallback_fini (cairo_type1_subset_t *subset);
610 typedef struct _cairo_type2_charstrings {
611 int *widths;
612 long x_min, y_min, x_max, y_max;
613 long ascent, descent;
614 cairo_array_t charstrings;
615 } cairo_type2_charstrings_t;
618 * _cairo_type2_charstrings_init:
619 * @type2_subset: a #cairo_type2_subset_t to initialize
620 * @font_subset: the #cairo_scaled_font_subset_t to initialize from
622 * If possible (depending on the format of the underlying
623 * #cairo_scaled_font_t and the font backend in use) generate type2
624 * charstrings to @font_subset and initialize @type2_subset
625 * with information about the subset.
627 * Return value: %CAIRO_STATUS_SUCCESS if successful,
628 * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type2
629 * charstrings, or an non-zero value indicating an error. Possible errors
630 * include %CAIRO_STATUS_NO_MEMORY.
632 cairo_private cairo_status_t
633 _cairo_type2_charstrings_init (cairo_type2_charstrings_t *charstrings,
634 cairo_scaled_font_subset_t *font_subset);
637 * _cairo_type2_charstrings_fini:
638 * @subset: a #cairo_type2_charstrings_t
640 * Free all resources associated with @type2_charstring. After this call,
641 * @type2_charstring should not be used again without a subsequent call to
642 * _cairo_type2_charstring_init() again first.
644 cairo_private void
645 _cairo_type2_charstrings_fini (cairo_type2_charstrings_t *charstrings);
648 * _cairo_truetype_index_to_ucs4:
649 * @scaled_font: the #cairo_scaled_font_t
650 * @index: the glyph index
651 * @ucs4: return value for the unicode value of the glyph
653 * If possible (depending on the format of the underlying
654 * #cairo_scaled_font_t and the font backend in use) assign
655 * the unicode character of the glyph to @ucs4.
657 * If mapping glyph indices to unicode is supported but the unicode
658 * value of the specified glyph is not available, @ucs4 is set to -1.
660 * Return value: %CAIRO_STATUS_SUCCESS if successful,
661 * %CAIRO_INT_STATUS_UNSUPPORTED if mapping glyph indices to unicode
662 * is not supported. Possible errors include %CAIRO_STATUS_NO_MEMORY.
664 cairo_private cairo_int_status_t
665 _cairo_truetype_index_to_ucs4 (cairo_scaled_font_t *scaled_font,
666 unsigned long index,
667 uint32_t *ucs4);
670 * _cairo_truetype_read_font_name:
671 * @scaled_font: the #cairo_scaled_font_t
672 * @ps_name: returns the PostScript name of the font
673 * or %NULL if the name could not be found.
674 * @font_name: returns the font name or %NULL if the name could not be found.
676 * If possible (depending on the format of the underlying
677 * #cairo_scaled_font_t and the font backend in use) read the
678 * PostScript and Font names from a TrueType/OpenType font.
680 * The font name is the full name of the font eg "DejaVu Sans Bold".
681 * The PostScript name is a shortened name with spaces removed
682 * suitable for use as the font name in a PS or PDF file eg
683 * "DejaVuSans-Bold".
685 * Return value: %CAIRO_STATUS_SUCCESS if successful,
686 * %CAIRO_INT_STATUS_UNSUPPORTED if the font is not TrueType/OpenType
687 * or the name table is not present. Possible errors include
688 * %CAIRO_STATUS_NO_MEMORY.
690 cairo_private cairo_int_status_t
691 _cairo_truetype_read_font_name (cairo_scaled_font_t *scaled_font,
692 char **ps_name,
693 char **font_name);
696 * _cairo_truetype_get_style:
697 * @scaled_font: the #cairo_scaled_font_t
698 * @weight: returns the font weight from the OS/2 table
699 * @bold: returns true if font is bold
700 * @italic: returns true if font is italic
702 * If the font is a truetype/opentype font with an OS/2 table, get the
703 * weight, bold, and italic data from the OS/2 table. The weight
704 * values have the same meaning as the lfWeight field of the Windows
705 * LOGFONT structure. Refer to the TrueType Specification for
706 * definition of the weight values.
708 * Return value: %CAIRO_STATUS_SUCCESS if successful,
709 * %CAIRO_INT_STATUS_UNSUPPORTED if the font is not TrueType/OpenType
710 * or the OS/2 table is not present.
712 cairo_private cairo_int_status_t
713 _cairo_truetype_get_style (cairo_scaled_font_t *scaled_font,
714 int *weight,
715 cairo_bool_t *bold,
716 cairo_bool_t *italic);
719 * _cairo_escape_ps_name:
720 * @ps_name: returns the PostScript name with all invalid characters escaped
722 * Ensure that PostSript name is a valid PDF/PostSript name object.
723 * In PDF names are treated as UTF8 and non ASCII bytes, ' ',
724 * and '#' are encoded as '#' followed by 2 hex digits that
725 * encode the byte.
727 * Return value: %CAIRO_STATUS_SUCCESS if successful. Possible errors include
728 * %CAIRO_STATUS_NO_MEMORY.
730 cairo_private cairo_int_status_t
731 _cairo_escape_ps_name (char **ps_name);
733 #endif /* CAIRO_HAS_FONT_SUBSET */
735 #endif /* CAIRO_SCALED_FONT_SUBSETS_PRIVATE_H */