blob: 5c044c1c4fd960f050fc911ebd1b95e126e747d2 [file] [log] [blame]
Behdad Esfahbod90364842014-03-24 14:26:36 -07001/*
2 * Copyright © 2011,2014 Google, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Google Author(s): Behdad Esfahbod, Roozbeh Pournader
25 */
26
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070027#include "hb.hh"
Behdad Esfahbod90364842014-03-24 14:26:36 -070028
Behdad Esfahbod1432df12019-06-19 18:32:40 -070029#ifndef HB_NO_OT_FONT
30
Behdad Esfahbod90364842014-03-24 14:26:36 -070031#include "hb-ot.h"
32
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070033#include "hb-font.hh"
34#include "hb-machinery.hh"
Behdad Esfahbod1c48a7e2018-08-25 23:54:06 -070035#include "hb-ot-face.hh"
Behdad Esfahbod90364842014-03-24 14:26:36 -070036
Behdad Esfahbod41ca1fb2014-05-09 15:35:56 -040037#include "hb-ot-cmap-table.hh"
Behdad Esfahbod3a0b3a22018-08-26 15:11:24 -070038#include "hb-ot-glyf-table.hh"
Michiharu Ariza8af96902018-08-29 13:26:17 -070039#include "hb-ot-cff1-table.hh"
40#include "hb-ot-cff2-table.hh"
Behdad Esfahbod3a0b3a22018-08-26 15:11:24 -070041#include "hb-ot-hmtx-table.hh"
Ebrahim Byagowi7867c2b2018-11-14 22:13:50 +033042#include "hb-ot-os2-table.hh"
Behdad Esfahbod3a0b3a22018-08-26 15:11:24 -070043#include "hb-ot-post-table.hh"
Ebrahim Byagowi7867c2b2018-11-14 22:13:50 +033044#include "hb-ot-stat-table.hh" // Just so we compile it; unused otherwise.
Behdad Esfahbod48ed5982018-10-23 02:19:32 -070045#include "hb-ot-vorg-table.hh"
Ebrahim Byagowi0ef6ab22018-03-04 02:47:26 +033046#include "hb-ot-color-cbdt-table.hh"
Ebrahim Byagowi38706a02018-10-28 23:19:04 +033047#include "hb-ot-color-sbix-table.hh"
Behdad Esfahbod3a0b3a22018-08-26 15:11:24 -070048
Behdad Esfahbod90364842014-03-24 14:26:36 -070049
Behdad Esfahbod80d9a422018-10-27 04:58:32 -070050/**
51 * SECTION:hb-ot-font
52 * @title: hb-ot-font
53 * @short_description: OpenType font implementation
54 * @include: hb-ot.h
55 *
Evgeniy Reiznerd29c8422019-02-19 18:35:00 +020056 * Functions for using OpenType fonts with hb_shape(). Note that fonts returned
Behdad Esfahbodd6d6f3b2018-10-28 11:41:33 -070057 * by hb_font_create() default to using these functions, so most clients would
58 * never need to call these functions directly.
Behdad Esfahbod80d9a422018-10-27 04:58:32 -070059 **/
Behdad Esfahbod90364842014-03-24 14:26:36 -070060
Behdad Esfahbod90364842014-03-24 14:26:36 -070061
Behdad Esfahbod90364842014-03-24 14:26:36 -070062static hb_bool_t
Behdad Esfahbod8b5bc142016-02-24 19:05:23 +090063hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED,
64 void *font_data,
65 hb_codepoint_t unicode,
66 hb_codepoint_t *glyph,
67 void *user_data HB_UNUSED)
Behdad Esfahbod90364842014-03-24 14:26:36 -070068{
Behdad Esfahbod914b5952018-11-05 22:39:50 -050069 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
Behdad Esfahbod03348ce2018-11-05 12:59:32 -050070 return ot_face->cmap->get_nominal_glyph (unicode, glyph);
Behdad Esfahbod8b5bc142016-02-24 19:05:23 +090071}
72
Behdad Esfahbodec844602018-10-09 15:07:04 -040073static unsigned int
74hb_ot_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
75 void *font_data,
76 unsigned int count,
77 const hb_codepoint_t *first_unicode,
78 unsigned int unicode_stride,
79 hb_codepoint_t *first_glyph,
80 unsigned int glyph_stride,
81 void *user_data HB_UNUSED)
82{
Behdad Esfahbod914b5952018-11-05 22:39:50 -050083 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
Behdad Esfahbod56ba9982018-11-05 19:49:54 -050084 return ot_face->cmap->get_nominal_glyphs (count,
85 first_unicode, unicode_stride,
86 first_glyph, glyph_stride);
Behdad Esfahbod8b5bc142016-02-24 19:05:23 +090087}
88
89static hb_bool_t
90hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED,
91 void *font_data,
92 hb_codepoint_t unicode,
93 hb_codepoint_t variation_selector,
94 hb_codepoint_t *glyph,
95 void *user_data HB_UNUSED)
96{
Behdad Esfahbod914b5952018-11-05 22:39:50 -050097 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
Behdad Esfahbod03348ce2018-11-05 12:59:32 -050098 return ot_face->cmap->get_variation_glyph (unicode, variation_selector, glyph);
Behdad Esfahbod90364842014-03-24 14:26:36 -070099}
100
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200101static void
102hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data,
103 unsigned count,
Behdad Esfahbodbee93e22018-10-09 08:01:49 -0400104 const hb_codepoint_t *first_glyph,
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200105 unsigned glyph_stride,
106 hb_position_t *first_advance,
107 unsigned advance_stride,
108 void *user_data HB_UNUSED)
109{
Behdad Esfahbod914b5952018-11-05 22:39:50 -0500110 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
Behdad Esfahbod03348ce2018-11-05 12:59:32 -0500111 const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx;
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200112
113 for (unsigned int i = 0; i < count; i++)
114 {
115 *first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font));
Behdad Esfahbod447323b2019-01-22 12:45:40 +0100116 first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
117 first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200118 }
Behdad Esfahbod90364842014-03-24 14:26:36 -0700119}
120
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200121static void
122hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data,
123 unsigned count,
Behdad Esfahbodbee93e22018-10-09 08:01:49 -0400124 const hb_codepoint_t *first_glyph,
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200125 unsigned glyph_stride,
126 hb_position_t *first_advance,
127 unsigned advance_stride,
128 void *user_data HB_UNUSED)
129{
Behdad Esfahbod914b5952018-11-05 22:39:50 -0500130 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
Behdad Esfahbod03348ce2018-11-05 12:59:32 -0500131 const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200132
133 for (unsigned int i = 0; i < count; i++)
134 {
135 *first_advance = font->em_scale_y (-(int) vmtx.get_advance (*first_glyph, font));
Behdad Esfahbod447323b2019-01-22 12:45:40 +0100136 first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
137 first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200138 }
Behdad Esfahbod90364842014-03-24 14:26:36 -0700139}
140
141static hb_bool_t
Behdad Esfahbod8dc62962018-10-15 01:09:05 -0700142hb_ot_get_glyph_v_origin (hb_font_t *font,
143 void *font_data,
144 hb_codepoint_t glyph,
145 hb_position_t *x,
146 hb_position_t *y,
147 void *user_data HB_UNUSED)
148{
Behdad Esfahbod914b5952018-11-05 22:39:50 -0500149 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
Behdad Esfahbod8dc62962018-10-15 01:09:05 -0700150
151 *x = font->get_glyph_h_advance (glyph) / 2;
152
Behdad Esfahbodd7e27cd2019-06-18 14:38:05 -0700153#ifndef HB_NO_OT_FONT_CFF
Behdad Esfahbod03348ce2018-11-05 12:59:32 -0500154 const OT::VORG &VORG = *ot_face->VORG;
Behdad Esfahbod48ed5982018-10-23 02:19:32 -0700155 if (VORG.has_data ())
156 {
157 *y = font->em_scale_y (VORG.get_y_origin (glyph));
158 return true;
159 }
Behdad Esfahbodd7e27cd2019-06-18 14:38:05 -0700160#endif
Behdad Esfahbod48ed5982018-10-23 02:19:32 -0700161
Behdad Esfahbod8dc62962018-10-15 01:09:05 -0700162 hb_glyph_extents_t extents = {0};
Michiharu Arizab9ff43c2019-10-01 16:13:40 +0330163 if (ot_face->glyf->get_extents (font, glyph, &extents))
Behdad Esfahbod8dc62962018-10-15 01:09:05 -0700164 {
Behdad Esfahbod03348ce2018-11-05 12:59:32 -0500165 const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
Ebrahim Byagowi79ec65a2019-10-03 14:27:51 +0330166 hb_position_t tsb = vmtx.get_side_bearing (font, glyph);
Ebrahim Byagowid73cdcf2019-10-06 18:09:14 +0330167 *y = extents.y_bearing + font->em_scale_y (tsb);
Behdad Esfahbod8dc62962018-10-15 01:09:05 -0700168 return true;
169 }
170
171 hb_font_extents_t font_extents;
172 font->get_h_extents_with_fallback (&font_extents);
173 *y = font_extents.ascender;
174
175 return true;
176}
177
178static hb_bool_t
Ebrahim Byagowi24b8b9b2018-04-23 19:03:57 +0430179hb_ot_get_glyph_extents (hb_font_t *font,
Behdad Esfahbod90364842014-03-24 14:26:36 -0700180 void *font_data,
181 hb_codepoint_t glyph,
182 hb_glyph_extents_t *extents,
183 void *user_data HB_UNUSED)
184{
Behdad Esfahbod914b5952018-11-05 22:39:50 -0500185 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
Behdad Esfahbod32d3c062019-05-11 11:59:18 -0700186
187#if !defined(HB_NO_OT_FONT_BITMAP) && !defined(HB_NO_COLOR)
blueshade782545c52019-11-26 10:24:32 -0800188 if (ot_face->sbix->get_extents (font, glyph, extents)) return true;
Behdad Esfahbod32d3c062019-05-11 11:59:18 -0700189#endif
blueshade782545c52019-11-26 10:24:32 -0800190 if (ot_face->glyf->get_extents (font, glyph, extents)) return true;
Behdad Esfahbod227d85e2019-05-10 23:15:58 -0700191#ifndef HB_NO_OT_FONT_CFF
blueshade782545c52019-11-26 10:24:32 -0800192 if (ot_face->cff1->get_extents (font, glyph, extents)) return true;
193 if (ot_face->cff2->get_extents (font, glyph, extents)) return true;
Behdad Esfahbod160c4d82019-04-12 14:57:49 -0400194#endif
Behdad Esfahbod32d3c062019-05-11 11:59:18 -0700195#if !defined(HB_NO_OT_FONT_BITMAP) && !defined(HB_NO_COLOR)
blueshade782545c52019-11-26 10:24:32 -0800196 if (ot_face->CBDT->get_extents (font, glyph, extents)) return true;
Behdad Esfahbod60a58aa2019-04-12 14:58:53 -0400197#endif
Behdad Esfahbod32d3c062019-05-11 11:59:18 -0700198
Behdad Esfahbod79e8e272017-01-23 17:55:31 -0800199 // TODO Hook up side-bearings variations.
blueshade782545c52019-11-26 10:24:32 -0800200 return false;
Behdad Esfahbod90364842014-03-24 14:26:36 -0700201}
202
Behdad Esfahbod230adf22019-06-19 18:49:52 -0700203#ifndef HB_NO_OT_FONT_GLYPH_NAMES
Simon Cozens6f2e6de2015-10-26 16:23:22 +0900204static hb_bool_t
Khaled Hosny9d4d2fb2017-10-16 10:05:42 +0200205hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED,
Ebrahim Byagowia0b4ac42019-08-24 17:57:14 +0430206 void *font_data,
207 hb_codepoint_t glyph,
208 char *name, unsigned int size,
209 void *user_data HB_UNUSED)
Khaled Hosny9d4d2fb2017-10-16 10:05:42 +0200210{
Behdad Esfahbod914b5952018-11-05 22:39:50 -0500211 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
blueshade72e7c1232019-11-26 09:57:53 -0800212 if (ot_face->post->get_glyph_name (glyph, name, size)) return true;
blueshade77b490422019-11-16 18:20:16 -0800213#ifndef HB_NO_OT_FONT_CFF
blueshade72e7c1232019-11-26 09:57:53 -0800214 if (ot_face->cff1->get_glyph_name (glyph, name, size)) return true;
blueshade77b490422019-11-16 18:20:16 -0800215#endif
blueshade72e7c1232019-11-26 09:57:53 -0800216 return false;
Khaled Hosny9d4d2fb2017-10-16 10:05:42 +0200217}
Khaled Hosny9d4d2fb2017-10-16 10:05:42 +0200218static hb_bool_t
Khaled Hosnyd9e166f2017-10-18 20:49:16 +0200219hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED,
Ebrahim Byagowia0b4ac42019-08-24 17:57:14 +0430220 void *font_data,
221 const char *name, int len,
222 hb_codepoint_t *glyph,
223 void *user_data HB_UNUSED)
Khaled Hosnyd9e166f2017-10-18 20:49:16 +0200224{
Behdad Esfahbod914b5952018-11-05 22:39:50 -0500225 const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
blueshade782545c52019-11-26 10:24:32 -0800226 if (ot_face->post->get_glyph_from_name (name, len, glyph)) return true;
blueshade7ff874652019-11-19 16:18:33 -0800227#ifndef HB_NO_OT_FONT_CFF
blueshade782545c52019-11-26 10:24:32 -0800228 if (ot_face->cff1->get_glyph_from_name (name, len, glyph)) return true;
blueshade7ff874652019-11-19 16:18:33 -0800229#endif
blueshade782545c52019-11-26 10:24:32 -0800230 return false;
Khaled Hosnyd9e166f2017-10-18 20:49:16 +0200231}
Behdad Esfahbod230adf22019-06-19 18:49:52 -0700232#endif
Khaled Hosnyd9e166f2017-10-18 20:49:16 +0200233
234static hb_bool_t
Ebrahim Byagowi24b8b9b2018-04-23 19:03:57 +0430235hb_ot_get_font_h_extents (hb_font_t *font,
Ebrahim Byagowi29444d72019-07-20 13:52:21 +0430236 void *font_data HB_UNUSED,
Simon Cozens6f2e6de2015-10-26 16:23:22 +0900237 hb_font_extents_t *metrics,
238 void *user_data HB_UNUSED)
239{
Ebrahim Byagowi20072a22019-07-30 03:43:15 +0430240 return _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER, &metrics->ascender) &&
241 _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_HORIZONTAL_DESCENDER, &metrics->descender) &&
242 _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_HORIZONTAL_LINE_GAP, &metrics->line_gap);
Simon Cozens6f2e6de2015-10-26 16:23:22 +0900243}
244
245static hb_bool_t
Ebrahim Byagowi24b8b9b2018-04-23 19:03:57 +0430246hb_ot_get_font_v_extents (hb_font_t *font,
Ebrahim Byagowi29444d72019-07-20 13:52:21 +0430247 void *font_data HB_UNUSED,
Simon Cozens6f2e6de2015-10-26 16:23:22 +0900248 hb_font_extents_t *metrics,
249 void *user_data HB_UNUSED)
250{
Ebrahim Byagowi20072a22019-07-30 03:43:15 +0430251 return _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_VERTICAL_ASCENDER, &metrics->ascender) &&
252 _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_VERTICAL_DESCENDER, &metrics->descender) &&
253 _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_VERTICAL_LINE_GAP, &metrics->line_gap);
Simon Cozens6f2e6de2015-10-26 16:23:22 +0900254}
Behdad Esfahbod90364842014-03-24 14:26:36 -0700255
Behdad Esfahboded116322021-09-14 07:09:54 -0400256static inline void free_static_ot_funcs ();
Behdad Esfahbod75ea2da2015-11-04 20:43:59 -0800257
Behdad Esfahbod856db4c2018-10-07 18:21:15 +0200258static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot_font_funcs_lazy_loader_t>
Behdad Esfahbod90364842014-03-24 14:26:36 -0700259{
Ebrahim Byagowie4120082018-12-17 21:31:01 +0330260 static hb_font_funcs_t *create ()
Behdad Esfahbod75ea2da2015-11-04 20:43:59 -0800261 {
Behdad Esfahbodc7ca30a2018-08-12 13:46:53 -0700262 hb_font_funcs_t *funcs = hb_font_funcs_create ();
Behdad Esfahbod90364842014-03-24 14:26:36 -0700263
Behdad Esfahboddbdbfe32017-10-15 12:11:08 +0200264 hb_font_funcs_set_font_h_extents_func (funcs, hb_ot_get_font_h_extents, nullptr, nullptr);
265 hb_font_funcs_set_font_v_extents_func (funcs, hb_ot_get_font_v_extents, nullptr, nullptr);
266 hb_font_funcs_set_nominal_glyph_func (funcs, hb_ot_get_nominal_glyph, nullptr, nullptr);
Behdad Esfahbodec844602018-10-09 15:07:04 -0400267 hb_font_funcs_set_nominal_glyphs_func (funcs, hb_ot_get_nominal_glyphs, nullptr, nullptr);
Behdad Esfahboddbdbfe32017-10-15 12:11:08 +0200268 hb_font_funcs_set_variation_glyph_func (funcs, hb_ot_get_variation_glyph, nullptr, nullptr);
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200269 hb_font_funcs_set_glyph_h_advances_func (funcs, hb_ot_get_glyph_h_advances, nullptr, nullptr);
Behdad Esfahbodd8a67da2018-09-11 12:55:54 +0200270 hb_font_funcs_set_glyph_v_advances_func (funcs, hb_ot_get_glyph_v_advances, nullptr, nullptr);
Behdad Esfahboddbdbfe32017-10-15 12:11:08 +0200271 //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ot_get_glyph_h_origin, nullptr, nullptr);
Behdad Esfahbod8dc62962018-10-15 01:09:05 -0700272 hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, nullptr, nullptr);
Behdad Esfahboddbdbfe32017-10-15 12:11:08 +0200273 hb_font_funcs_set_glyph_extents_func (funcs, hb_ot_get_glyph_extents, nullptr, nullptr);
Behdad Esfahbod7b408762017-11-14 20:22:05 -0800274 //hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ot_get_glyph_contour_point, nullptr, nullptr);
Behdad Esfahbod230adf22019-06-19 18:49:52 -0700275#ifndef HB_NO_OT_FONT_GLYPH_NAMES
Khaled Hosny9d4d2fb2017-10-16 10:05:42 +0200276 hb_font_funcs_set_glyph_name_func (funcs, hb_ot_get_glyph_name, nullptr, nullptr);
Khaled Hosnyd9e166f2017-10-18 20:49:16 +0200277 hb_font_funcs_set_glyph_from_name_func (funcs, hb_ot_get_glyph_from_name, nullptr, nullptr);
Behdad Esfahbod230adf22019-06-19 18:49:52 -0700278#endif
Behdad Esfahbod75ea2da2015-11-04 20:43:59 -0800279
280 hb_font_funcs_make_immutable (funcs);
281
Behdad Esfahboded116322021-09-14 07:09:54 -0400282 hb_atexit (free_static_ot_funcs);
Behdad Esfahbodc7ca30a2018-08-12 13:46:53 -0700283
284 return funcs;
285 }
286} static_ot_funcs;
Behdad Esfahbod75ea2da2015-11-04 20:43:59 -0800287
Behdad Esfahboded116322021-09-14 07:09:54 -0400288static inline
Ebrahim Byagowie4120082018-12-17 21:31:01 +0330289void free_static_ot_funcs ()
Behdad Esfahbodc7ca30a2018-08-12 13:46:53 -0700290{
Behdad Esfahbod7bd508a2018-08-12 17:19:55 -0700291 static_ot_funcs.free_instance ();
Behdad Esfahbodc7ca30a2018-08-12 13:46:53 -0700292}
Behdad Esfahbod90364842014-03-24 14:26:36 -0700293
Behdad Esfahbodc7ca30a2018-08-12 13:46:53 -0700294static hb_font_funcs_t *
Ebrahim Byagowie4120082018-12-17 21:31:01 +0330295_hb_ot_get_font_funcs ()
Behdad Esfahbodc7ca30a2018-08-12 13:46:53 -0700296{
Behdad Esfahbod53442be2018-08-12 16:20:11 -0700297 return static_ot_funcs.get_unconst ();
Behdad Esfahbod90364842014-03-24 14:26:36 -0700298}
299
300
Sascha Brawer01c3a882015-06-01 13:22:01 +0200301/**
Behdad Esfahbod35d18582015-11-26 19:30:37 -0500302 * hb_ot_font_set_funcs:
Nathan Williseb10ef42019-04-22 19:22:24 +0100303 * @font: #hb_font_t to work upon
304 *
305 * Sets the font functions to use when working with @font.
Behdad Esfahbod35d18582015-11-26 19:30:37 -0500306 *
Sascha Brawer01c3a882015-06-01 13:22:01 +0200307 * Since: 0.9.28
308 **/
Behdad Esfahbod90364842014-03-24 14:26:36 -0700309void
310hb_ot_font_set_funcs (hb_font_t *font)
311{
Behdad Esfahbod90364842014-03-24 14:26:36 -0700312 hb_font_set_funcs (font,
313 _hb_ot_get_font_funcs (),
Behdad Esfahbod0fe7a742018-11-05 23:08:33 -0500314 &font->face->table,
Behdad Esfahbod1c48a7e2018-08-25 23:54:06 -0700315 nullptr);
Behdad Esfahbod90364842014-03-24 14:26:36 -0700316}
Behdad Esfahbod1432df12019-06-19 18:32:40 -0700317
Ebrahim Byagowi57528632019-10-05 23:51:50 +0330318#ifndef HB_NO_VAR
Ebrahim Byagowiee761012019-10-03 15:59:45 +0330319int
Ebrahim Byagowib068e252019-10-08 16:29:15 +0330320_glyf_get_side_bearing_var (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical)
Ebrahim Byagowiee761012019-10-03 15:59:45 +0330321{
Ebrahim Byagowid73cdcf2019-10-06 18:09:14 +0330322 return font->face->table.glyf->get_side_bearing_var (font, glyph, is_vertical);
Ebrahim Byagowiee761012019-10-03 15:59:45 +0330323}
324
325unsigned
Ebrahim Byagowib068e252019-10-08 16:29:15 +0330326_glyf_get_advance_var (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical)
Ebrahim Byagowiee761012019-10-03 15:59:45 +0330327{
Ebrahim Byagowid73cdcf2019-10-06 18:09:14 +0330328 return font->face->table.glyf->get_advance_var (font, glyph, is_vertical);
Ebrahim Byagowiee761012019-10-03 15:59:45 +0330329}
Ebrahim Byagowi57528632019-10-05 23:51:50 +0330330#endif
Ebrahim Byagowiee761012019-10-03 15:59:45 +0330331
Behdad Esfahbod1432df12019-06-19 18:32:40 -0700332
333#endif