Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* cairo - a vector graphics library with display and print output
  2.  *
  3.  * Copyright © 2006 Red Hat, Inc
  4.  *
  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.
  12.  *
  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
  18.  *
  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/
  23.  *
  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.
  27.  *
  28.  * The Original Code is the cairo graphics library.
  29.  *
  30.  * The Initial Developer of the Original Code is University of Southern
  31.  * California.
  32.  *
  33.  * Contributor(s):
  34.  *      Carl D. Worth <cworth@cworth.org>
  35.  */
  36.  
  37. #ifndef CAIRO_SCALED_FONT_SUBSETS_PRIVATE_H
  38. #define CAIRO_SCALED_FONT_SUBSETS_PRIVATE_H
  39.  
  40. #include "cairoint.h"
  41.  
  42. #if CAIRO_HAS_FONT_SUBSET
  43.  
  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.     double       x_advance;
  51.     double       y_advance;
  52.     cairo_bool_t utf8_is_mapped;
  53.     uint32_t     unicode;
  54. } cairo_scaled_font_subsets_glyph_t;
  55.  
  56. /**
  57.  * _cairo_scaled_font_subsets_create_scaled:
  58.  *
  59.  * Create a new #cairo_scaled_font_subsets_t object which can be used
  60.  * to create subsets of any number of #cairo_scaled_font_t
  61.  * objects. This allows the (arbitrarily large and sparse) glyph
  62.  * indices of a #cairo_scaled_font_t to be mapped to one or more font
  63.  * subsets with glyph indices packed into the range
  64.  * [0 .. max_glyphs_per_subset).
  65.  *
  66.  * Return value: a pointer to the newly creates font subsets. The
  67.  * caller owns this object and should call
  68.  * _cairo_scaled_font_subsets_destroy() when done with it.
  69.  **/
  70. cairo_private cairo_scaled_font_subsets_t *
  71. _cairo_scaled_font_subsets_create_scaled (void);
  72.  
  73. /**
  74.  * _cairo_scaled_font_subsets_create_simple:
  75.  *
  76.  * Create a new #cairo_scaled_font_subsets_t object which can be used
  77.  * to create font subsets suitable for embedding as Postscript or PDF
  78.  * simple fonts.
  79.  *
  80.  * Glyphs with an outline path available will be mapped to one font
  81.  * subset for each font face. Glyphs from bitmap fonts will mapped to
  82.  * separate font subsets for each #cairo_scaled_font_t object.
  83.  *
  84.  * The maximum number of glyphs per subset is 256. Each subset
  85.  * reserves the first glyph for the .notdef glyph.
  86.  *
  87.  * Return value: a pointer to the newly creates font subsets. The
  88.  * caller owns this object and should call
  89.  * _cairo_scaled_font_subsets_destroy() when done with it.
  90.  **/
  91. cairo_private cairo_scaled_font_subsets_t *
  92. _cairo_scaled_font_subsets_create_simple (void);
  93.  
  94. /**
  95.  * _cairo_scaled_font_subsets_create_composite:
  96.  *
  97.  * Create a new #cairo_scaled_font_subsets_t object which can be used
  98.  * to create font subsets suitable for embedding as Postscript or PDF
  99.  * composite fonts.
  100.  *
  101.  * Glyphs with an outline path available will be mapped to one font
  102.  * subset for each font face. Each unscaled subset has a maximum of
  103.  * 65536 glyphs except for Type1 fonts which have a maximum of 256 glyphs.
  104.  *
  105.  * Glyphs from bitmap fonts will mapped to separate font subsets for
  106.  * each #cairo_scaled_font_t object. Each unscaled subset has a maximum
  107.  * of 256 glyphs.
  108.  *
  109.  * Each subset reserves the first glyph for the .notdef glyph.
  110.  *
  111.  * Return value: a pointer to the newly creates font subsets. The
  112.  * caller owns this object and should call
  113.  * _cairo_scaled_font_subsets_destroy() when done with it.
  114.  **/
  115. cairo_private cairo_scaled_font_subsets_t *
  116. _cairo_scaled_font_subsets_create_composite (void);
  117.  
  118. /**
  119.  * _cairo_scaled_font_subsets_destroy:
  120.  * @font_subsets: a #cairo_scaled_font_subsets_t object to be destroyed
  121.  *
  122.  * Destroys @font_subsets and all resources associated with it.
  123.  **/
  124. cairo_private void
  125. _cairo_scaled_font_subsets_destroy (cairo_scaled_font_subsets_t *font_subsets);
  126.  
  127. /**
  128.  * _cairo_scaled_font_subsets_map_glyph:
  129.  * @font_subsets: a #cairo_scaled_font_subsets_t
  130.  * @scaled_font: the font of the glyph to be mapped
  131.  * @scaled_font_glyph_index: the index of the glyph to be mapped
  132.  * @utf8: a string of text encoded in UTF-8
  133.  * @utf8_len: length of @utf8 in bytes
  134.  * @subset_glyph_ret: return structure containing subset font and glyph id
  135.  *
  136.  * Map a glyph from a #cairo_scaled_font to a new index within a
  137.  * subset of that font. The mapping performed is from the tuple:
  138.  *
  139.  *      (scaled_font, scaled_font_glyph_index)
  140.  *
  141.  * to the tuple:
  142.  *
  143.  *      (font_id, subset_id, subset_glyph_index)
  144.  *
  145.  * This mapping is 1:1. If the input tuple has previously mapped, the
  146.  * the output tuple previously returned will be returned again.
  147.  *
  148.  * Otherwise, the return tuple will be constructed as follows:
  149.  *
  150.  * 1) There is a 1:1 correspondence between the input scaled_font
  151.  *    value and the output font_id value. If no mapping has been
  152.  *    previously performed with the scaled_font value then the
  153.  *    smallest unused font_id value will be returned.
  154.  *
  155.  * 2) Within the set of output tuples of the same font_id value the
  156.  *    smallest value of subset_id will be returned such that
  157.  *    subset_glyph_index does not exceed max_glyphs_per_subset (as
  158.  *    passed to _cairo_scaled_font_subsets_create()) and that the
  159.  *    resulting tuple is unique.
  160.  *
  161.  * 3) The smallest value of subset_glyph_index is returned such that
  162.  *    the resulting tuple is unique.
  163.  *
  164.  * The net result is that any #cairo_scaled_font_t will be represented
  165.  * by one or more font subsets. Each subset is effectively a tuple of
  166.  * (scaled_font, font_id, subset_id) and within each subset there
  167.  * exists a mapping of scaled_glyph_font_index to subset_glyph_index.
  168.  *
  169.  * This final description of a font subset is the same representation
  170.  * used by #cairo_scaled_font_subset_t as provided by
  171.  * _cairo_scaled_font_subsets_foreach.
  172.  *
  173.  * @utf8 and @utf8_len specify a string of unicode characters that the
  174.  * glyph @scaled_font_glyph_index maps to. If @utf8_is_mapped in
  175.  * @subset_glyph_ret is %TRUE, the font subsetting will (where index to
  176.  * unicode mapping is supported) ensure that @scaled_font_glyph_index
  177.  * maps to @utf8. If @utf8_is_mapped is %FALSE,
  178.  * @scaled_font_glyph_index has already been mapped to a different
  179.  * unicode string.
  180.  *
  181.  * The returned values in the #cairo_scaled_font_subsets_glyph_t struct are:
  182.  *
  183.  * @font_id: The font ID of the mapped glyph
  184.  * @subset_id : The subset ID of the mapped glyph within the @font_id
  185.  * @subset_glyph_index: The index of the mapped glyph within the @subset_id subset
  186.  * @is_scaled: If true, the mapped glyph is from a bitmap font, and separate font
  187.  * subset is created for each font scale used. If false, the outline of the mapped glyph
  188.  * is available. One font subset for each font face is created.
  189.  * @x_advance, @y_advance: When @is_scaled is true, @x_advance and @y_advance contain
  190.  * the x and y advance for the mapped glyph in device space.
  191.  * When @is_scaled is false, @x_advance and @y_advance contain the x and y advance for
  192.  * the the mapped glyph from an unhinted 1 point font.
  193.  * @utf8_is_mapped: If true the utf8 string provided to _cairo_scaled_font_subsets_map_glyph()
  194.  * is (or already was) the utf8 string mapped to this glyph. If false the glyph is already
  195.  * mapped to a different utf8 string.
  196.  * @unicode: the unicode character mapped to this glyph by the font backend.
  197.  *
  198.  * Return value: %CAIRO_STATUS_SUCCESS if successful, or a non-zero
  199.  * value indicating an error. Possible errors include
  200.  * %CAIRO_STATUS_NO_MEMORY.
  201.  **/
  202. cairo_private cairo_status_t
  203. _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t       *font_subsets,
  204.                                       cairo_scaled_font_t               *scaled_font,
  205.                                       unsigned long                      scaled_font_glyph_index,
  206.                                       const char *                       utf8,
  207.                                       int                                utf8_len,
  208.                                       cairo_scaled_font_subsets_glyph_t *subset_glyph_ret);
  209.  
  210. typedef cairo_status_t
  211. (*cairo_scaled_font_subset_callback_func_t) (cairo_scaled_font_subset_t *font_subset,
  212.                                              void                       *closure);
  213.  
  214. /**
  215.  * _cairo_scaled_font_subsets_foreach:
  216.  * @font_subsets: a #cairo_scaled_font_subsets_t
  217.  * @font_subset_callback: a function to be called for each font subset
  218.  * @closure: closure data for the callback function
  219.  *
  220.  * Iterate over each unique scaled font subset as created by calls to
  221.  * _cairo_scaled_font_subsets_map_glyph(). A subset is determined by
  222.  * unique pairs of (font_id, subset_id) as returned by
  223.  * _cairo_scaled_font_subsets_map_glyph().
  224.  *
  225.  * For each subset, @font_subset_callback will be called and will be
  226.  * provided with both a #cairo_scaled_font_subset_t object containing
  227.  * all the glyphs in the subset as well as the value of @closure.
  228.  *
  229.  * The #cairo_scaled_font_subset_t object contains the scaled_font,
  230.  * the font_id, and the subset_id corresponding to all glyphs
  231.  * belonging to the subset. In addition, it contains an array providing
  232.  * a mapping between subset glyph indices and the original scaled font
  233.  * glyph indices.
  234.  *
  235.  * The index of the array corresponds to subset_glyph_index values
  236.  * returned by _cairo_scaled_font_subsets_map_glyph() while the
  237.  * values of the array correspond to the scaled_font_glyph_index
  238.  * values passed as input to the same function.
  239.  *
  240.  * Return value: %CAIRO_STATUS_SUCCESS if successful, or a non-zero
  241.  * value indicating an error. Possible errors include
  242.  * %CAIRO_STATUS_NO_MEMORY.
  243.  **/
  244. cairo_private cairo_status_t
  245. _cairo_scaled_font_subsets_foreach_scaled (cairo_scaled_font_subsets_t              *font_subsets,
  246.                                            cairo_scaled_font_subset_callback_func_t  font_subset_callback,
  247.                                            void                                     *closure);
  248.  
  249. /**
  250.  * _cairo_scaled_font_subsets_foreach_unscaled:
  251.  * @font_subsets: a #cairo_scaled_font_subsets_t
  252.  * @font_subset_callback: a function to be called for each font subset
  253.  * @closure: closure data for the callback function
  254.  *
  255.  * Iterate over each unique unscaled font subset as created by calls to
  256.  * _cairo_scaled_font_subsets_map_glyph(). A subset is determined by
  257.  * unique pairs of (font_id, subset_id) as returned by
  258.  * _cairo_scaled_font_subsets_map_glyph().
  259.  *
  260.  * For each subset, @font_subset_callback will be called and will be
  261.  * provided with both a #cairo_scaled_font_subset_t object containing
  262.  * all the glyphs in the subset as well as the value of @closure.
  263.  *
  264.  * The #cairo_scaled_font_subset_t object contains the scaled_font,
  265.  * the font_id, and the subset_id corresponding to all glyphs
  266.  * belonging to the subset. In addition, it contains an array providing
  267.  * a mapping between subset glyph indices and the original scaled font
  268.  * glyph indices.
  269.  *
  270.  * The index of the array corresponds to subset_glyph_index values
  271.  * returned by _cairo_scaled_font_subsets_map_glyph() while the
  272.  * values of the array correspond to the scaled_font_glyph_index
  273.  * values passed as input to the same function.
  274.  *
  275.  * Return value: %CAIRO_STATUS_SUCCESS if successful, or a non-zero
  276.  * value indicating an error. Possible errors include
  277.  * %CAIRO_STATUS_NO_MEMORY.
  278.  **/
  279. cairo_private cairo_status_t
  280. _cairo_scaled_font_subsets_foreach_unscaled (cairo_scaled_font_subsets_t              *font_subsets,
  281.                                              cairo_scaled_font_subset_callback_func_t  font_subset_callback,
  282.                                              void                                     *closure);
  283.  
  284. /**
  285.  * _cairo_scaled_font_subsets_foreach_user:
  286.  * @font_subsets: a #cairo_scaled_font_subsets_t
  287.  * @font_subset_callback: a function to be called for each font subset
  288.  * @closure: closure data for the callback function
  289.  *
  290.  * Iterate over each unique scaled font subset as created by calls to
  291.  * _cairo_scaled_font_subsets_map_glyph(). A subset is determined by
  292.  * unique pairs of (font_id, subset_id) as returned by
  293.  * _cairo_scaled_font_subsets_map_glyph().
  294.  *
  295.  * For each subset, @font_subset_callback will be called and will be
  296.  * provided with both a #cairo_scaled_font_subset_t object containing
  297.  * all the glyphs in the subset as well as the value of @closure.
  298.  *
  299.  * The #cairo_scaled_font_subset_t object contains the scaled_font,
  300.  * the font_id, and the subset_id corresponding to all glyphs
  301.  * belonging to the subset. In addition, it contains an array providing
  302.  * a mapping between subset glyph indices and the original scaled font
  303.  * glyph indices.
  304.  *
  305.  * The index of the array corresponds to subset_glyph_index values
  306.  * returned by _cairo_scaled_font_subsets_map_glyph() while the
  307.  * values of the array correspond to the scaled_font_glyph_index
  308.  * values passed as input to the same function.
  309.  *
  310.  * Return value: %CAIRO_STATUS_SUCCESS if successful, or a non-zero
  311.  * value indicating an error. Possible errors include
  312.  * %CAIRO_STATUS_NO_MEMORY.
  313.  **/
  314. cairo_private cairo_status_t
  315. _cairo_scaled_font_subsets_foreach_user (cairo_scaled_font_subsets_t              *font_subsets,
  316.                                          cairo_scaled_font_subset_callback_func_t  font_subset_callback,
  317.                                          void                                     *closure);
  318.  
  319. /**
  320.  * _cairo_scaled_font_subset_create_glyph_names:
  321.  * @font_subsets: a #cairo_scaled_font_subsets_t
  322.  *
  323.  * Create an array of strings containing the glyph name for each glyph
  324.  * in @font_subsets. The array as store in font_subsets->glyph_names.
  325.  *
  326.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  327.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font backend does not support
  328.  * mapping the glyph indices to unicode characters. Possible errors
  329.  * include %CAIRO_STATUS_NO_MEMORY.
  330.  **/
  331. cairo_private cairo_int_status_t
  332. _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset);
  333.  
  334. typedef struct _cairo_cff_subset {
  335.     char *font_name;
  336.     char *ps_name;
  337.     double *widths;
  338.     double x_min, y_min, x_max, y_max;
  339.     double ascent, descent;
  340.     char *data;
  341.     unsigned long data_length;
  342. } cairo_cff_subset_t;
  343.  
  344. /**
  345.  * _cairo_cff_subset_init:
  346.  * @cff_subset: a #cairo_cff_subset_t to initialize
  347.  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  348.  *
  349.  * If possible (depending on the format of the underlying
  350.  * #cairo_scaled_font_t and the font backend in use) generate a
  351.  * cff file corresponding to @font_subset and initialize
  352.  * @cff_subset with information about the subset and the cff
  353.  * data.
  354.  *
  355.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  356.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a
  357.  * cff file, or an non-zero value indicating an error.  Possible
  358.  * errors include %CAIRO_STATUS_NO_MEMORY.
  359.  **/
  360. cairo_private cairo_status_t
  361. _cairo_cff_subset_init (cairo_cff_subset_t          *cff_subset,
  362.                         const char                  *name,
  363.                         cairo_scaled_font_subset_t  *font_subset);
  364.  
  365. /**
  366.  * _cairo_cff_subset_fini:
  367.  * @cff_subset: a #cairo_cff_subset_t
  368.  *
  369.  * Free all resources associated with @cff_subset.  After this
  370.  * call, @cff_subset should not be used again without a
  371.  * subsequent call to _cairo_cff_subset_init() again first.
  372.  **/
  373. cairo_private void
  374. _cairo_cff_subset_fini (cairo_cff_subset_t *cff_subset);
  375.  
  376. /**
  377.  * _cairo_cff_fallback_init:
  378.  * @cff_subset: a #cairo_cff_subset_t to initialize
  379.  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  380.  *
  381.  * If possible (depending on the format of the underlying
  382.  * #cairo_scaled_font_t and the font backend in use) generate a cff
  383.  * file corresponding to @font_subset and initialize @cff_subset
  384.  * with information about the subset and the cff data.
  385.  *
  386.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  387.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a
  388.  * cff file, or an non-zero value indicating an error.  Possible
  389.  * errors include %CAIRO_STATUS_NO_MEMORY.
  390.  **/
  391. cairo_private cairo_status_t
  392. _cairo_cff_fallback_init (cairo_cff_subset_t          *cff_subset,
  393.                           const char                  *name,
  394.                           cairo_scaled_font_subset_t  *font_subset);
  395.  
  396. /**
  397.  * _cairo_cff_fallback_fini:
  398.  * @cff_subset: a #cairo_cff_subset_t
  399.  *
  400.  * Free all resources associated with @cff_subset.  After this
  401.  * call, @cff_subset should not be used again without a
  402.  * subsequent call to _cairo_cff_subset_init() again first.
  403.  **/
  404. cairo_private void
  405. _cairo_cff_fallback_fini (cairo_cff_subset_t *cff_subset);
  406.  
  407. typedef struct _cairo_truetype_subset {
  408.     char *font_name;
  409.     char *ps_name;
  410.     double *widths;
  411.     double x_min, y_min, x_max, y_max;
  412.     double ascent, descent;
  413.     unsigned char *data;
  414.     unsigned long data_length;
  415.     unsigned long *string_offsets;
  416.     unsigned long num_string_offsets;
  417. } cairo_truetype_subset_t;
  418.  
  419. /**
  420.  * _cairo_truetype_subset_init:
  421.  * @truetype_subset: a #cairo_truetype_subset_t to initialize
  422.  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  423.  *
  424.  * If possible (depending on the format of the underlying
  425.  * #cairo_scaled_font_t and the font backend in use) generate a
  426.  * truetype file corresponding to @font_subset and initialize
  427.  * @truetype_subset with information about the subset and the truetype
  428.  * data.
  429.  *
  430.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  431.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a
  432.  * truetype file, or an non-zero value indicating an error.  Possible
  433.  * errors include %CAIRO_STATUS_NO_MEMORY.
  434.  **/
  435. cairo_private cairo_status_t
  436. _cairo_truetype_subset_init (cairo_truetype_subset_t    *truetype_subset,
  437.                              cairo_scaled_font_subset_t *font_subset);
  438.  
  439. /**
  440.  * _cairo_truetype_subset_fini:
  441.  * @truetype_subset: a #cairo_truetype_subset_t
  442.  *
  443.  * Free all resources associated with @truetype_subset.  After this
  444.  * call, @truetype_subset should not be used again without a
  445.  * subsequent call to _cairo_truetype_subset_init() again first.
  446.  **/
  447. cairo_private void
  448. _cairo_truetype_subset_fini (cairo_truetype_subset_t *truetype_subset);
  449.  
  450.  
  451.  
  452. typedef struct _cairo_type1_subset {
  453.     char *base_font;
  454.     double *widths;
  455.     double x_min, y_min, x_max, y_max;
  456.     double ascent, descent;
  457.     char *data;
  458.     unsigned long header_length;
  459.     unsigned long data_length;
  460.     unsigned long trailer_length;
  461. } cairo_type1_subset_t;
  462.  
  463.  
  464. #if CAIRO_HAS_FT_FONT
  465.  
  466. /**
  467.  * _cairo_type1_subset_init:
  468.  * @type1_subset: a #cairo_type1_subset_t to initialize
  469.  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  470.  * @hex_encode: if true the encrypted portion of the font is hex encoded
  471.  *
  472.  * If possible (depending on the format of the underlying
  473.  * #cairo_scaled_font_t and the font backend in use) generate a type1
  474.  * file corresponding to @font_subset and initialize @type1_subset
  475.  * with information about the subset and the type1 data.
  476.  *
  477.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  478.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type1
  479.  * file, or an non-zero value indicating an error.  Possible errors
  480.  * include %CAIRO_STATUS_NO_MEMORY.
  481.  **/
  482. cairo_private cairo_status_t
  483. _cairo_type1_subset_init (cairo_type1_subset_t          *type_subset,
  484.                           const char                    *name,
  485.                           cairo_scaled_font_subset_t    *font_subset,
  486.                           cairo_bool_t                   hex_encode);
  487.  
  488. /**
  489.  * _cairo_type1_subset_fini:
  490.  * @type1_subset: a #cairo_type1_subset_t
  491.  *
  492.  * Free all resources associated with @type1_subset.  After this call,
  493.  * @type1_subset should not be used again without a subsequent call to
  494.  * _cairo_truetype_type1_init() again first.
  495.  **/
  496. cairo_private void
  497. _cairo_type1_subset_fini (cairo_type1_subset_t *subset);
  498.  
  499. #endif /* CAIRO_HAS_FT_FONT */
  500.  
  501.  
  502. /**
  503.  * _cairo_type1_scaled_font_is_type1:
  504.  * @scaled_font: a #cairo_scaled_font_t
  505.  *
  506.  * Return %TRUE if @scaled_font is a Type 1 font, otherwise return %FALSE.
  507.  **/
  508. cairo_private cairo_bool_t
  509. _cairo_type1_scaled_font_is_type1 (cairo_scaled_font_t  *scaled_font);
  510.  
  511. /**
  512.  * _cairo_type1_fallback_init_binary:
  513.  * @type1_subset: a #cairo_type1_subset_t to initialize
  514.  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  515.  *
  516.  * If possible (depending on the format of the underlying
  517.  * #cairo_scaled_font_t and the font backend in use) generate a type1
  518.  * file corresponding to @font_subset and initialize @type1_subset
  519.  * with information about the subset and the type1 data.  The encrypted
  520.  * part of the font is binary encoded.
  521.  *
  522.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  523.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type1
  524.  * file, or an non-zero value indicating an error.  Possible errors
  525.  * include %CAIRO_STATUS_NO_MEMORY.
  526.  **/
  527. cairo_private cairo_status_t
  528. _cairo_type1_fallback_init_binary (cairo_type1_subset_t       *type_subset,
  529.                                    const char                 *name,
  530.                                    cairo_scaled_font_subset_t *font_subset);
  531.  
  532. /**
  533.  * _cairo_type1_fallback_init_hexencode:
  534.  * @type1_subset: a #cairo_type1_subset_t to initialize
  535.  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  536.  *
  537.  * If possible (depending on the format of the underlying
  538.  * #cairo_scaled_font_t and the font backend in use) generate a type1
  539.  * file corresponding to @font_subset and initialize @type1_subset
  540.  * with information about the subset and the type1 data. The encrypted
  541.  * part of the font is hex encoded.
  542.  *
  543.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  544.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type1
  545.  * file, or an non-zero value indicating an error.  Possible errors
  546.  * include %CAIRO_STATUS_NO_MEMORY.
  547.  **/
  548. cairo_private cairo_status_t
  549. _cairo_type1_fallback_init_hex (cairo_type1_subset_t       *type_subset,
  550.                                 const char                 *name,
  551.                                 cairo_scaled_font_subset_t *font_subset);
  552.  
  553. /**
  554.  * _cairo_type1_fallback_fini:
  555.  * @type1_subset: a #cairo_type1_subset_t
  556.  *
  557.  * Free all resources associated with @type1_subset.  After this call,
  558.  * @type1_subset should not be used again without a subsequent call to
  559.  * _cairo_truetype_type1_init() again first.
  560.  **/
  561. cairo_private void
  562. _cairo_type1_fallback_fini (cairo_type1_subset_t *subset);
  563.  
  564. typedef struct _cairo_type2_charstrings {
  565.     int *widths;
  566.     long x_min, y_min, x_max, y_max;
  567.     long ascent, descent;
  568.     cairo_array_t charstrings;
  569. } cairo_type2_charstrings_t;
  570.  
  571. /**
  572.  * _cairo_type2_charstrings_init:
  573.  * @type2_subset: a #cairo_type2_subset_t to initialize
  574.  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  575.  *
  576.  * If possible (depending on the format of the underlying
  577.  * #cairo_scaled_font_t and the font backend in use) generate type2
  578.  * charstrings to @font_subset and initialize @type2_subset
  579.  * with information about the subset.
  580.  *
  581.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  582.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type2
  583.  * charstrings, or an non-zero value indicating an error.  Possible errors
  584.  * include %CAIRO_STATUS_NO_MEMORY.
  585.  **/
  586. cairo_private cairo_status_t
  587. _cairo_type2_charstrings_init (cairo_type2_charstrings_t   *charstrings,
  588.                                cairo_scaled_font_subset_t  *font_subset);
  589.  
  590. /**
  591.  * _cairo_type2_charstrings_fini:
  592.  * @subset: a #cairo_type2_charstrings_t
  593.  *
  594.  * Free all resources associated with @type2_charstring.  After this call,
  595.  * @type2_charstring should not be used again without a subsequent call to
  596.  * _cairo_type2_charstring_init() again first.
  597.  **/
  598. cairo_private void
  599. _cairo_type2_charstrings_fini (cairo_type2_charstrings_t *charstrings);
  600.  
  601. /**
  602.  * _cairo_truetype_create_glyph_to_unicode_map:
  603.  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  604.  *
  605.  * If possible (depending on the format of the underlying
  606.  * #cairo_scaled_font_t and the font backend in use) assign
  607.  * the unicode character of each glyph in font_subset to
  608.  * fontsubset->to_unicode.
  609.  *
  610.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  611.  * %CAIRO_INT_STATUS_UNSUPPORTED if the unicode encoding of
  612.  * the glyphs is not available.  Possible  errors include
  613.  * %CAIRO_STATUS_NO_MEMORY.
  614.  **/
  615. cairo_private cairo_int_status_t
  616. _cairo_truetype_create_glyph_to_unicode_map (cairo_scaled_font_subset_t *font_subset);
  617.  
  618. /**
  619.  * _cairo_truetype_index_to_ucs4:
  620.  * @scaled_font: the #cairo_scaled_font_t
  621.  * @index: the glyph index
  622.  * @ucs4: return value for the unicode value of the glyph
  623.  *
  624.  * If possible (depending on the format of the underlying
  625.  * #cairo_scaled_font_t and the font backend in use) assign
  626.  * the unicode character of the glyph to @ucs4.
  627.  *
  628.  * If mapping glyph indices to unicode is supported but the unicode
  629.  * value of the specified glyph is not available, @ucs4 is set to -1.
  630.  *
  631.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  632.  * %CAIRO_INT_STATUS_UNSUPPORTED if mapping glyph indices to unicode
  633.  * is not supported.  Possible errors include %CAIRO_STATUS_NO_MEMORY.
  634.  **/
  635. cairo_private cairo_int_status_t
  636. _cairo_truetype_index_to_ucs4 (cairo_scaled_font_t *scaled_font,
  637.                                unsigned long        index,
  638.                                uint32_t            *ucs4);
  639.  
  640. /**
  641.  * _cairo_truetype_read_font_name:
  642.  * @scaled_font: the #cairo_scaled_font_t
  643.  * @ps_name: returns the PostScript name of the font
  644.  *           or %NULL if the name could not be found.
  645.  * @font_name: returns the font name or %NULL if the name could not be found.
  646.  *
  647.  * If possible (depending on the format of the underlying
  648.  * #cairo_scaled_font_t and the font backend in use) read the
  649.  * PostScript and Font names from a TrueType/OpenType font.
  650.  *
  651.  * The font name is the full name of the font eg "DejaVu Sans Bold".
  652.  * The PostScript name is a shortened name with spaces removed
  653.  * suitable for use as the font name in a PS or PDF file eg
  654.  * "DejaVuSans-Bold".
  655.  *
  656.  * Return value: %CAIRO_STATUS_SUCCESS if successful,
  657.  * %CAIRO_INT_STATUS_UNSUPPORTED if the font is not TrueType/OpenType
  658.  * or the name table is not present.  Possible errors include
  659.  * %CAIRO_STATUS_NO_MEMORY.
  660.  **/
  661. cairo_private cairo_int_status_t
  662. _cairo_truetype_read_font_name (cairo_scaled_font_t   *scaled_font,
  663.                                 char                 **ps_name,
  664.                                 char                 **font_name);
  665.  
  666. #endif /* CAIRO_HAS_FONT_SUBSET */
  667.  
  668. #endif /* CAIRO_SCALED_FONT_SUBSETS_PRIVATE_H */
  669.