jpayne@69: /* jpayne@69: * Copyright © 2009 Red Hat, Inc. jpayne@69: * Copyright © 2015 Google, Inc. jpayne@69: * jpayne@69: * This is part of HarfBuzz, a text shaping library. jpayne@69: * jpayne@69: * Permission is hereby granted, without written agreement and without jpayne@69: * license or royalty fees, to use, copy, modify, and distribute this jpayne@69: * software and its documentation for any purpose, provided that the jpayne@69: * above copyright notice and the following two paragraphs appear in jpayne@69: * all copies of this software. jpayne@69: * jpayne@69: * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR jpayne@69: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES jpayne@69: * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN jpayne@69: * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH jpayne@69: * DAMAGE. jpayne@69: * jpayne@69: * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, jpayne@69: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND jpayne@69: * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS jpayne@69: * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO jpayne@69: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. jpayne@69: * jpayne@69: * Red Hat Author(s): Behdad Esfahbod jpayne@69: * Google Author(s): Behdad Esfahbod jpayne@69: */ jpayne@69: jpayne@69: #ifndef HB_FT_H jpayne@69: #define HB_FT_H jpayne@69: jpayne@69: #include "hb.h" jpayne@69: jpayne@69: #include jpayne@69: #include FT_FREETYPE_H jpayne@69: jpayne@69: HB_BEGIN_DECLS jpayne@69: jpayne@69: /* jpayne@69: * Note: FreeType is not thread-safe. jpayne@69: * Hence, these functions are not either. jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * hb-face from ft-face. jpayne@69: */ jpayne@69: jpayne@69: /* This one creates a new hb-face for given ft-face. jpayne@69: * When the returned hb-face is destroyed, the destroy jpayne@69: * callback is called (if not NULL), with the ft-face passed jpayne@69: * to it. jpayne@69: * jpayne@69: * The client is responsible to make sure that ft-face is jpayne@69: * destroyed after hb-face is destroyed. jpayne@69: * jpayne@69: * Most often you don't want this function. You should use either jpayne@69: * hb_ft_face_create_cached(), or hb_ft_face_create_referenced(). jpayne@69: * In particular, if you are going to pass NULL as destroy, you jpayne@69: * probably should use (the more recent) hb_ft_face_create_referenced() jpayne@69: * instead. jpayne@69: */ jpayne@69: HB_EXTERN hb_face_t * jpayne@69: hb_ft_face_create (FT_Face ft_face, jpayne@69: hb_destroy_func_t destroy); jpayne@69: jpayne@69: /* This version is like hb_ft_face_create(), except that it caches jpayne@69: * the hb-face using the generic pointer of the ft-face. This means jpayne@69: * that subsequent calls to this function with the same ft-face will jpayne@69: * return the same hb-face (correctly referenced). jpayne@69: * jpayne@69: * Client is still responsible for making sure that ft-face is destroyed jpayne@69: * after hb-face is. jpayne@69: */ jpayne@69: HB_EXTERN hb_face_t * jpayne@69: hb_ft_face_create_cached (FT_Face ft_face); jpayne@69: jpayne@69: /* This version is like hb_ft_face_create(), except that it calls jpayne@69: * FT_Reference_Face() on ft-face, as such keeping ft-face alive jpayne@69: * as long as the hb-face is. jpayne@69: * jpayne@69: * This is the most convenient version to use. Use it unless you have jpayne@69: * very good reasons not to. jpayne@69: */ jpayne@69: HB_EXTERN hb_face_t * jpayne@69: hb_ft_face_create_referenced (FT_Face ft_face); jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * hb-font from ft-face. jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * Note: jpayne@69: * jpayne@69: * Set face size on ft-face before creating hb-font from it. jpayne@69: * Otherwise hb-ft would NOT pick up the font size correctly. jpayne@69: */ jpayne@69: jpayne@69: /* See notes on hb_ft_face_create(). Same issues re lifecycle-management jpayne@69: * apply here. Use hb_ft_font_create_referenced() if you can. */ jpayne@69: HB_EXTERN hb_font_t * jpayne@69: hb_ft_font_create (FT_Face ft_face, jpayne@69: hb_destroy_func_t destroy); jpayne@69: jpayne@69: /* See notes on hb_ft_face_create_referenced() re lifecycle-management jpayne@69: * issues. */ jpayne@69: HB_EXTERN hb_font_t * jpayne@69: hb_ft_font_create_referenced (FT_Face ft_face); jpayne@69: jpayne@69: HB_EXTERN FT_Face jpayne@69: hb_ft_font_get_face (hb_font_t *font); jpayne@69: jpayne@69: HB_EXTERN FT_Face jpayne@69: hb_ft_font_lock_face (hb_font_t *font); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_ft_font_unlock_face (hb_font_t *font); jpayne@69: jpayne@69: HB_EXTERN void jpayne@69: hb_ft_font_set_load_flags (hb_font_t *font, int load_flags); jpayne@69: jpayne@69: HB_EXTERN int jpayne@69: hb_ft_font_get_load_flags (hb_font_t *font); jpayne@69: jpayne@69: /* Call when size or variations settings on underlying FT_Face change. */ jpayne@69: HB_EXTERN void jpayne@69: hb_ft_font_changed (hb_font_t *font); jpayne@69: jpayne@69: /* Makes an hb_font_t use FreeType internally to implement font functions. jpayne@69: * Note: this internally creates an FT_Face. Use it when you create your jpayne@69: * hb_face_t using hb_face_create(). */ jpayne@69: HB_EXTERN void jpayne@69: hb_ft_font_set_funcs (hb_font_t *font); jpayne@69: jpayne@69: jpayne@69: HB_END_DECLS jpayne@69: jpayne@69: #endif /* HB_FT_H */