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"
44 #define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \
45 HB_FONT_FUNC_IMPLEMENT (glyph) \
46 HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \
47 HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \
48 HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \
49 HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \
50 HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \
51 HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \
52 HB_FONT_FUNC_IMPLEMENT (glyph_extents) \
53 HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \
54 /* ^--- Add new callbacks here */
56 struct _hb_font_funcs_t {
57 hb_object_header_t header;
61 /* Don't access these directly. Call hb_font_get_*() instead. */
64 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name;
65 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
66 #undef HB_FONT_FUNC_IMPLEMENT
70 #define HB_FONT_FUNC_IMPLEMENT(name) void *name;
71 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
72 #undef HB_FONT_FUNC_IMPLEMENT
76 #define HB_FONT_FUNC_IMPLEMENT(name) hb_destroy_func_t name;
77 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
78 #undef HB_FONT_FUNC_IMPLEMENT
88 hb_object_header_t header;
92 hb_get_table_func_t get_table;
94 hb_destroy_func_t destroy;
96 struct hb_ot_layout_t *ot_layout;
107 hb_object_header_t header;
120 hb_font_funcs_t *klass;
122 hb_destroy_func_t destroy;
125 /* Convert from font-space to user-space */
126 inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); }
127 inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, this->y_scale); }
129 /* Convert from parent-font user-space to our user-space */
130 inline hb_position_t parent_scale_x_distance (hb_position_t v) {
131 if (unlikely (parent && parent->x_scale != x_scale))
132 return v * (int64_t) this->x_scale / this->parent->x_scale;
135 inline hb_position_t parent_scale_y_distance (hb_position_t v) {
136 if (unlikely (parent && parent->y_scale != y_scale))
137 return v * (int64_t) this->y_scale / this->parent->y_scale;
140 inline hb_position_t parent_scale_x_position (hb_position_t v) {
141 return parent_scale_x_distance (v);
143 inline hb_position_t parent_scale_y_position (hb_position_t v) {
144 return parent_scale_y_distance (v);
147 inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) {
148 *x = parent_scale_x_distance (*x);
149 *y = parent_scale_y_distance (*y);
151 inline void parent_scale_position (hb_position_t *x, hb_position_t *y) {
152 *x = parent_scale_x_position (*x);
153 *y = parent_scale_y_position (*y);
158 inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / this->face->upem; }
164 #endif /* HB_FONT_PRIVATE_HH */