2 * Copyright © 2009 Red Hat, Inc.
3 * Copyright © 2011 Google, Inc.
5 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
25 * Red Hat Author(s): Behdad Esfahbod
26 * Google Author(s): Behdad Esfahbod
29 #ifndef HB_FONT_PRIVATE_HH
30 #define HB_FONT_PRIVATE_HH
32 #include "hb-private.hh"
35 #include "hb-object-private.hh"
43 #define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \
44 HB_FONT_FUNC_IMPLEMENT (glyph) \
45 HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \
46 HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \
47 HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \
48 HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \
49 HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \
50 HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \
51 HB_FONT_FUNC_IMPLEMENT (glyph_extents) \
52 HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \
53 HB_FONT_FUNC_IMPLEMENT (glyph_name) \
54 HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \
55 /* ^--- Add new callbacks here */
57 struct _hb_font_funcs_t {
58 hb_object_header_t header;
63 /* Don't access these directly. Call hb_font_get_*() instead. */
66 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name;
67 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
68 #undef HB_FONT_FUNC_IMPLEMENT
72 #define HB_FONT_FUNC_IMPLEMENT(name) void *name;
73 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
74 #undef HB_FONT_FUNC_IMPLEMENT
78 #define HB_FONT_FUNC_IMPLEMENT(name) hb_destroy_func_t name;
79 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
80 #undef HB_FONT_FUNC_IMPLEMENT
90 hb_object_header_t header;
95 hb_reference_table_func_t reference_table;
97 hb_destroy_func_t destroy;
99 struct hb_ot_layout_t *ot_layout;
111 hb_object_header_t header;
125 hb_font_funcs_t *klass;
127 hb_destroy_func_t destroy;
130 /* Convert from font-space to user-space */
131 inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); }
132 inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, this->y_scale); }
134 /* Convert from parent-font user-space to our user-space */
135 inline hb_position_t parent_scale_x_distance (hb_position_t v) {
136 if (unlikely (parent && parent->x_scale != x_scale))
137 return v * (int64_t) this->x_scale / this->parent->x_scale;
140 inline hb_position_t parent_scale_y_distance (hb_position_t v) {
141 if (unlikely (parent && parent->y_scale != y_scale))
142 return v * (int64_t) this->y_scale / this->parent->y_scale;
145 inline hb_position_t parent_scale_x_position (hb_position_t v) {
146 return parent_scale_x_distance (v);
148 inline hb_position_t parent_scale_y_position (hb_position_t v) {
149 return parent_scale_y_distance (v);
152 inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) {
153 *x = parent_scale_x_distance (*x);
154 *y = parent_scale_y_distance (*y);
156 inline void parent_scale_position (hb_position_t *x, hb_position_t *y) {
157 *x = parent_scale_x_position (*x);
158 *y = parent_scale_y_position (*y);
163 inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / hb_face_get_upem (this->face); }
168 #endif /* HB_FONT_PRIVATE_HH */