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