tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

hb-ft.h (4839B)


      1 /*
      2 * Copyright © 2009  Red Hat, Inc.
      3 * Copyright © 2015  Google, Inc.
      4 *
      5 *  This is part of HarfBuzz, a text shaping library.
      6 *
      7 * Permission is hereby granted, without written agreement and without
      8 * license or royalty fees, to use, copy, modify, and distribute this
      9 * software and its documentation for any purpose, provided that the
     10 * above copyright notice and the following two paragraphs appear in
     11 * all copies of this software.
     12 *
     13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
     14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
     15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
     16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
     17 * DAMAGE.
     18 *
     19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
     20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
     21 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
     22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
     23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
     24 *
     25 * Red Hat Author(s): Behdad Esfahbod
     26 * Google Author(s): Behdad Esfahbod
     27 */
     28 
     29 #ifndef HB_FT_H
     30 #define HB_FT_H
     31 
     32 #include "hb.h"
     33 
     34 #include <ft2build.h>
     35 #include FT_FREETYPE_H
     36 
     37 HB_BEGIN_DECLS
     38 
     39 /*
     40 * Note: FreeType is not thread-safe.
     41 * Hence, these functions are not either.
     42 */
     43 
     44 /*
     45 * hb-face from ft-face.
     46 */
     47 
     48 /* This one creates a new hb-face for given ft-face.
     49 * When the returned hb-face is destroyed, the destroy
     50 * callback is called (if not NULL), with the ft-face passed
     51 * to it.
     52 *
     53 * The client is responsible to make sure that ft-face is
     54 * destroyed after hb-face is destroyed.
     55 *
     56 * Most often you don't want this function.  You should use either
     57 * hb_ft_face_create_cached(), or hb_ft_face_create_referenced().
     58 * In particular, if you are going to pass NULL as destroy, you
     59 * probably should use (the more recent) hb_ft_face_create_referenced()
     60 * instead.
     61 */
     62 HB_EXTERN hb_face_t *
     63 hb_ft_face_create (FT_Face           ft_face,
     64 	   hb_destroy_func_t destroy);
     65 
     66 /* This version is like hb_ft_face_create(), except that it caches
     67 * the hb-face using the generic pointer of the ft-face.  This means
     68 * that subsequent calls to this function with the same ft-face will
     69 * return the same hb-face (correctly referenced).
     70 *
     71 * Client is still responsible for making sure that ft-face is destroyed
     72 * after hb-face is.
     73 */
     74 HB_EXTERN hb_face_t *
     75 hb_ft_face_create_cached (FT_Face ft_face);
     76 
     77 /* This version is like hb_ft_face_create(), except that it calls
     78 * FT_Reference_Face() on ft-face, as such keeping ft-face alive
     79 * as long as the hb-face is.
     80 *
     81 * This is the most convenient version to use.  Use it unless you have
     82 * very good reasons not to.
     83 */
     84 HB_EXTERN hb_face_t *
     85 hb_ft_face_create_referenced (FT_Face ft_face);
     86 
     87 HB_EXTERN hb_face_t *
     88 hb_ft_face_create_from_file_or_fail (const char   *file_name,
     89 			     unsigned int  index);
     90 
     91 HB_EXTERN hb_face_t *
     92 hb_ft_face_create_from_blob_or_fail (hb_blob_t    *blob,
     93 			     unsigned int  index);
     94 
     95 /*
     96 * hb-font from ft-face.
     97 */
     98 
     99 /*
    100 * Note:
    101 *
    102 * Set face size on ft-face before creating hb-font from it.
    103 * Otherwise hb-ft would NOT pick up the font size correctly.
    104 */
    105 
    106 /* See notes on hb_ft_face_create().  Same issues re lifecycle-management
    107 * apply here.  Use hb_ft_font_create_referenced() if you can. */
    108 HB_EXTERN hb_font_t *
    109 hb_ft_font_create (FT_Face           ft_face,
    110 	   hb_destroy_func_t destroy);
    111 
    112 /* See notes on hb_ft_face_create_referenced() re lifecycle-management
    113 * issues. */
    114 HB_EXTERN hb_font_t *
    115 hb_ft_font_create_referenced (FT_Face ft_face);
    116 
    117 HB_EXTERN FT_Face
    118 hb_ft_font_get_ft_face (hb_font_t *font);
    119 
    120 HB_EXTERN FT_Face
    121 hb_ft_font_lock_face (hb_font_t *font);
    122 
    123 HB_EXTERN void
    124 hb_ft_font_unlock_face (hb_font_t *font);
    125 
    126 HB_EXTERN void
    127 hb_ft_font_set_load_flags (hb_font_t *font, int load_flags);
    128 
    129 HB_EXTERN int
    130 hb_ft_font_get_load_flags (hb_font_t *font);
    131 
    132 /* Call when size or variations settings on underlying FT_Face changed,
    133 * and you want to update the hb_font_t from it. */
    134 HB_EXTERN void
    135 hb_ft_font_changed (hb_font_t *font);
    136 
    137 /* Call when size or variations settings on underlying hb_font_t may have
    138 * changed, and you want to update the FT_Face from it.  This call is fast
    139 * if nothing changed on hb_font_t. Returns true if changed. */
    140 HB_EXTERN hb_bool_t
    141 hb_ft_hb_font_changed (hb_font_t *font);
    142 
    143 /* Makes an hb_font_t use FreeType internally to implement font functions.
    144 * Note: this internally creates an FT_Face.  Use it when you create your
    145 * hb_face_t using hb_face_create(). */
    146 HB_EXTERN void
    147 hb_ft_font_set_funcs (hb_font_t *font);
    148 
    149 #ifndef HB_DISABLE_DEPRECATED
    150 
    151 HB_DEPRECATED_FOR (hb_ft_font_get_ft_face)
    152 HB_EXTERN FT_Face
    153 hb_ft_font_get_face (hb_font_t *font);
    154 
    155 #endif
    156 
    157 HB_END_DECLS
    158 
    159 #endif /* HB_FT_H */