< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-font.cc

Print this page




   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.
  12  *
  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
  17  * DAMAGE.
  18  *
  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.
  24  *
  25  * Red Hat Author(s): Behdad Esfahbod
  26  * Google Author(s): Behdad Esfahbod
  27  */
  28 
  29 #include "hb-private.hh"
  30 
  31 #include "hb-font-private.hh"
















  32 
  33 
  34 /*
  35  * hb_font_funcs_t
  36  */
  37 
  38 static hb_bool_t
  39 hb_font_get_font_h_extents_nil (hb_font_t *font HB_UNUSED,
  40                                 void *font_data HB_UNUSED,
  41                                 hb_font_extents_t *metrics,
  42                                 void *user_data HB_UNUSED)
  43 {
  44   memset (metrics, 0, sizeof (*metrics));
  45   return false;
  46 }
  47 static hb_bool_t
  48 hb_font_get_font_h_extents_parent (hb_font_t *font,
  49                                    void *font_data HB_UNUSED,
  50                                    hb_font_extents_t *metrics,
  51                                    void *user_data HB_UNUSED)
  52 {
  53   hb_bool_t ret = font->parent->get_font_h_extents (metrics);
  54   if (ret) {
  55     metrics->ascender = font->parent_scale_y_distance (metrics->ascender);
  56     metrics->descender = font->parent_scale_y_distance (metrics->descender);
  57     metrics->line_gap = font->parent_scale_y_distance (metrics->line_gap);
  58   }
  59   return ret;
  60 }
  61 
  62 static hb_bool_t
  63 hb_font_get_font_v_extents_nil (hb_font_t *font HB_UNUSED,
  64                                 void *font_data HB_UNUSED,
  65                                 hb_font_extents_t *metrics,
  66                                 void *user_data HB_UNUSED)
  67 {
  68   memset (metrics, 0, sizeof (*metrics));
  69   return false;
  70 }
  71 static hb_bool_t
  72 hb_font_get_font_v_extents_parent (hb_font_t *font,
  73                                    void *font_data HB_UNUSED,
  74                                    hb_font_extents_t *metrics,
  75                                    void *user_data HB_UNUSED)
  76 {
  77   hb_bool_t ret = font->parent->get_font_v_extents (metrics);
  78   if (ret) {
  79     metrics->ascender = font->parent_scale_x_distance (metrics->ascender);
  80     metrics->descender = font->parent_scale_x_distance (metrics->descender);
  81     metrics->line_gap = font->parent_scale_x_distance (metrics->line_gap);
  82   }
  83   return ret;
  84 }
  85 
  86 static hb_bool_t
  87 hb_font_get_nominal_glyph_nil (hb_font_t *font HB_UNUSED,
  88                                void *font_data HB_UNUSED,
  89                                hb_codepoint_t unicode,
  90                                hb_codepoint_t *glyph,
  91                                void *user_data HB_UNUSED)
  92 {
  93   *glyph = 0;
  94   return false;
  95 }
  96 static hb_bool_t
  97 hb_font_get_nominal_glyph_parent (hb_font_t *font,
  98                                   void *font_data HB_UNUSED,
  99                                   hb_codepoint_t unicode,
 100                                   hb_codepoint_t *glyph,
 101                                   void *user_data HB_UNUSED)
 102 {




 103   return font->parent->get_nominal_glyph (unicode, glyph);
 104 }
 105 





























 106 static hb_bool_t
 107 hb_font_get_variation_glyph_nil (hb_font_t *font HB_UNUSED,
 108                                  void *font_data HB_UNUSED,
 109                                  hb_codepoint_t unicode,
 110                                  hb_codepoint_t variation_selector,
 111                                  hb_codepoint_t *glyph,
 112                                  void *user_data HB_UNUSED)
 113 {
 114   *glyph = 0;
 115   return false;
 116 }
 117 static hb_bool_t
 118 hb_font_get_variation_glyph_parent (hb_font_t *font,
 119                                     void *font_data HB_UNUSED,
 120                                     hb_codepoint_t unicode,
 121                                     hb_codepoint_t variation_selector,
 122                                     hb_codepoint_t *glyph,
 123                                     void *user_data HB_UNUSED)
 124 {
 125   return font->parent->get_variation_glyph (unicode, variation_selector, glyph);
 126 }
 127 
 128 
 129 static hb_position_t
 130 hb_font_get_glyph_h_advance_nil (hb_font_t *font,
 131                                  void *font_data HB_UNUSED,
 132                                  hb_codepoint_t glyph,
 133                                  void *user_data HB_UNUSED)
 134 {
 135   return font->x_scale;
 136 }
 137 static hb_position_t
 138 hb_font_get_glyph_h_advance_parent (hb_font_t *font,
 139                                     void *font_data HB_UNUSED,
 140                                     hb_codepoint_t glyph,
 141                                     void *user_data HB_UNUSED)
 142 {






 143   return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph));
 144 }
 145 
 146 static hb_position_t
 147 hb_font_get_glyph_v_advance_nil (hb_font_t *font,
 148                                  void *font_data HB_UNUSED,
 149                                  hb_codepoint_t glyph,
 150                                  void *user_data HB_UNUSED)
 151 {
 152   /* TODO use font_extents.ascender+descender */
 153   return font->y_scale;
 154 }
 155 static hb_position_t
 156 hb_font_get_glyph_v_advance_parent (hb_font_t *font,
 157                                     void *font_data HB_UNUSED,
 158                                     hb_codepoint_t glyph,
 159                                     void *user_data HB_UNUSED)
 160 {






 161   return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph));
 162 }
 163 
































































 164 static hb_bool_t
 165 hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
 166                                 void *font_data HB_UNUSED,
 167                                 hb_codepoint_t glyph,
 168                                 hb_position_t *x,
 169                                 hb_position_t *y,
 170                                 void *user_data HB_UNUSED)
 171 {
 172   *x = *y = 0;
 173   return true;
 174 }
 175 static hb_bool_t
 176 hb_font_get_glyph_h_origin_parent (hb_font_t *font,
 177                                    void *font_data HB_UNUSED,
 178                                    hb_codepoint_t glyph,
 179                                    hb_position_t *x,
 180                                    hb_position_t *y,
 181                                    void *user_data HB_UNUSED)
 182 {
 183   hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y);
 184   if (ret)
 185     font->parent_scale_position (x, y);
 186   return ret;
 187 }
 188 
 189 static hb_bool_t
 190 hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
 191                                 void *font_data HB_UNUSED,
 192                                 hb_codepoint_t glyph,
 193                                 hb_position_t *x,
 194                                 hb_position_t *y,
 195                                 void *user_data HB_UNUSED)
 196 {
 197   *x = *y = 0;
 198   return false;
 199 }
 200 static hb_bool_t
 201 hb_font_get_glyph_v_origin_parent (hb_font_t *font,
 202                                    void *font_data HB_UNUSED,
 203                                    hb_codepoint_t glyph,
 204                                    hb_position_t *x,
 205                                    hb_position_t *y,
 206                                    void *user_data HB_UNUSED)
 207 {
 208   hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y);
 209   if (ret)
 210     font->parent_scale_position (x, y);
 211   return ret;
 212 }
 213 
 214 static hb_position_t
 215 hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
 216                                  void *font_data HB_UNUSED,
 217                                  hb_codepoint_t left_glyph,
 218                                  hb_codepoint_t right_glyph,
 219                                  void *user_data HB_UNUSED)
 220 {
 221   return 0;
 222 }
 223 static hb_position_t
 224 hb_font_get_glyph_h_kerning_parent (hb_font_t *font,
 225                                     void *font_data HB_UNUSED,
 226                                     hb_codepoint_t left_glyph,
 227                                     hb_codepoint_t right_glyph,
 228                                     void *user_data HB_UNUSED)
 229 {
 230   return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph));
 231 }
 232 
 233 static hb_position_t
 234 hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
 235                                  void *font_data HB_UNUSED,
 236                                  hb_codepoint_t top_glyph,
 237                                  hb_codepoint_t bottom_glyph,
 238                                  void *user_data HB_UNUSED)
 239 {
 240   return 0;
 241 }
 242 static hb_position_t
 243 hb_font_get_glyph_v_kerning_parent (hb_font_t *font,
 244                                     void *font_data HB_UNUSED,
 245                                     hb_codepoint_t top_glyph,
 246                                     hb_codepoint_t bottom_glyph,
 247                                     void *user_data HB_UNUSED)
 248 {
 249   return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph));
 250 }
 251 
 252 static hb_bool_t
 253 hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
 254                                void *font_data HB_UNUSED,
 255                                hb_codepoint_t glyph,
 256                                hb_glyph_extents_t *extents,
 257                                void *user_data HB_UNUSED)
 258 {
 259   memset (extents, 0, sizeof (*extents));
 260   return false;
 261 }
 262 static hb_bool_t
 263 hb_font_get_glyph_extents_parent (hb_font_t *font,
 264                                   void *font_data HB_UNUSED,
 265                                   hb_codepoint_t glyph,
 266                                   hb_glyph_extents_t *extents,
 267                                   void *user_data HB_UNUSED)
 268 {
 269   hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents);
 270   if (ret) {
 271     font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
 272     font->parent_scale_distance (&extents->width, &extents->height);
 273   }
 274   return ret;
 275 }
 276 
 277 static hb_bool_t
 278 hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED,
 279                                      void *font_data HB_UNUSED,
 280                                      hb_codepoint_t glyph,
 281                                      unsigned int point_index,
 282                                      hb_position_t *x,
 283                                      hb_position_t *y,
 284                                      void *user_data HB_UNUSED)
 285 {
 286   *x = *y = 0;
 287   return false;
 288 }
 289 static hb_bool_t
 290 hb_font_get_glyph_contour_point_parent (hb_font_t *font,
 291                                         void *font_data HB_UNUSED,
 292                                         hb_codepoint_t glyph,
 293                                         unsigned int point_index,
 294                                         hb_position_t *x,
 295                                         hb_position_t *y,
 296                                         void *user_data HB_UNUSED)
 297 {
 298   hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y);
 299   if (ret)
 300     font->parent_scale_position (x, y);
 301   return ret;
 302 }
 303 
 304 static hb_bool_t
 305 hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED,
 306                             void *font_data HB_UNUSED,
 307                             hb_codepoint_t glyph,
 308                             char *name, unsigned int size,
 309                             void *user_data HB_UNUSED)
 310 {
 311   if (size) *name = '\0';
 312   return false;
 313 }
 314 static hb_bool_t
 315 hb_font_get_glyph_name_parent (hb_font_t *font,
 316                                void *font_data HB_UNUSED,
 317                                hb_codepoint_t glyph,
 318                                char *name, unsigned int size,
 319                                void *user_data HB_UNUSED)
 320 {
 321   return font->parent->get_glyph_name (glyph, name, size);
 322 }
 323 
 324 static hb_bool_t
 325 hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED,
 326                                  void *font_data HB_UNUSED,
 327                                  const char *name, int len, /* -1 means nul-terminated */

 328                                  hb_codepoint_t *glyph,
 329                                  void *user_data HB_UNUSED)
 330 {
 331   *glyph = 0;
 332   return false;
 333 }
 334 static hb_bool_t
 335 hb_font_get_glyph_from_name_parent (hb_font_t *font,
 336                                     void *font_data HB_UNUSED,
 337                                     const char *name, int len, /* -1 means nul-terminated */
 338                                     hb_codepoint_t *glyph,
 339                                     void *user_data HB_UNUSED)
 340 {
 341   return font->parent->get_glyph_from_name (name, len, glyph);
 342 }
 343 
 344 static const hb_font_funcs_t _hb_font_funcs_nil = {

 345   HB_OBJECT_HEADER_STATIC,
 346 
 347   true, /* immutable */
 348 
 349   {
 350 #define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
 351     HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 352 #undef HB_FONT_FUNC_IMPLEMENT
 353   },
 354   {
 355 #define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
 356     HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 357 #undef HB_FONT_FUNC_IMPLEMENT
 358   },
 359   {
 360     {
 361 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil,
 362       HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 363 #undef HB_FONT_FUNC_IMPLEMENT
 364     }
 365   }
 366 };
 367 static const hb_font_funcs_t _hb_font_funcs_parent = {
 368   HB_OBJECT_HEADER_STATIC,
 369 
 370   true, /* immutable */

 371 
 372   {
 373 #define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
 374     HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 375 #undef HB_FONT_FUNC_IMPLEMENT
 376   },
 377   {
 378 #define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
 379     HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 380 #undef HB_FONT_FUNC_IMPLEMENT
 381   },
 382   {
 383     {
 384 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_parent,
 385       HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 386 #undef HB_FONT_FUNC_IMPLEMENT
 387     }
 388   }
 389 };
 390 
 391 
 392 /**
 393  * hb_font_funcs_create: (Xconstructor)
 394  *
 395  *
 396  *
 397  * Return value: (transfer full):
 398  *
 399  * Since: 0.9.2
 400  **/
 401 hb_font_funcs_t *
 402 hb_font_funcs_create (void)
 403 {
 404   hb_font_funcs_t *ffuncs;
 405 
 406   if (!(ffuncs = hb_object_create<hb_font_funcs_t> ()))
 407     return hb_font_funcs_get_empty ();
 408 
 409   ffuncs->get = _hb_font_funcs_parent.get;
 410 
 411   return ffuncs;
 412 }
 413 
 414 /**
 415  * hb_font_funcs_get_empty:
 416  *
 417  *
 418  *
 419  * Return value: (transfer full):
 420  *
 421  * Since: 0.9.2
 422  **/
 423 hb_font_funcs_t *
 424 hb_font_funcs_get_empty (void)
 425 {
 426   return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_parent);
 427 }
 428 
 429 /**
 430  * hb_font_funcs_reference: (skip)
 431  * @ffuncs: font functions.
 432  *
 433  *
 434  *
 435  * Return value:
 436  *
 437  * Since: 0.9.2
 438  **/
 439 hb_font_funcs_t *
 440 hb_font_funcs_reference (hb_font_funcs_t *ffuncs)
 441 {
 442   return hb_object_reference (ffuncs);
 443 }
 444 
 445 /**
 446  * hb_font_funcs_destroy: (skip)


 500  **/
 501 void *
 502 hb_font_funcs_get_user_data (hb_font_funcs_t    *ffuncs,
 503                              hb_user_data_key_t *key)
 504 {
 505   return hb_object_get_user_data (ffuncs, key);
 506 }
 507 
 508 
 509 /**
 510  * hb_font_funcs_make_immutable:
 511  * @ffuncs: font functions.
 512  *
 513  *
 514  *
 515  * Since: 0.9.2
 516  **/
 517 void
 518 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs)
 519 {
 520   if (unlikely (hb_object_is_inert (ffuncs)))
 521     return;
 522 
 523   ffuncs->immutable = true;
 524 }
 525 
 526 /**
 527  * hb_font_funcs_is_immutable:
 528  * @ffuncs: font functions.
 529  *
 530  *
 531  *
 532  * Return value:
 533  *
 534  * Since: 0.9.2
 535  **/
 536 hb_bool_t
 537 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs)
 538 {
 539   return ffuncs->immutable;
 540 }
 541 
 542 
 543 #define HB_FONT_FUNC_IMPLEMENT(name) \
 544                                                                          \
 545 void                                                                     \
 546 hb_font_funcs_set_##name##_func (hb_font_funcs_t             *ffuncs,    \
 547                                  hb_font_get_##name##_func_t  func,      \
 548                                  void                        *user_data, \
 549                                  hb_destroy_func_t            destroy)   \
 550 {                                                                        \
 551   if (ffuncs->immutable) {                                               \
 552     if (destroy)                                                         \
 553       destroy (user_data);                                               \
 554     return;                                                              \
 555   }                                                                      \
 556                                                                          \
 557   if (ffuncs->destroy.name)                                              \
 558     ffuncs->destroy.name (ffuncs->user_data.name);                       \
 559                                                                          \
 560   if (func) {                                                            \
 561     ffuncs->get.f.name = func;                                           \
 562     ffuncs->user_data.name = user_data;                                  \
 563     ffuncs->destroy.name = destroy;                                      \
 564   } else {                                                               \
 565     ffuncs->get.f.name = hb_font_get_##name##_parent;                    \
 566     ffuncs->user_data.name = nullptr;                                       \
 567     ffuncs->destroy.name = nullptr;                                         \
 568   }                                                                      \
 569 }
 570 
 571 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 572 #undef HB_FONT_FUNC_IMPLEMENT
 573 
 574 bool






 575 hb_font_t::has_func (unsigned int i)
 576 {
 577   if (parent && parent != hb_font_get_empty () && parent->has_func (i))
 578     return true;
 579   return this->klass->get.array[i] != _hb_font_funcs_parent.get.array[i];
 580 }
 581 
 582 /* Public getters */
 583 
 584 /**
 585  * hb_font_get_h_extents:
 586  * @font: a font.
 587  * @extents: (out):
 588  *
 589  *
 590  *
 591  * Return value:
 592  *
 593  * Since: 1.1.3
 594  **/
 595 hb_bool_t
 596 hb_font_get_h_extents (hb_font_t *font,
 597                        hb_font_extents_t *extents)
 598 {
 599   return font->get_font_h_extents (extents);


 701 
 702 /**
 703  * hb_font_get_glyph_v_advance:
 704  * @font: a font.
 705  * @glyph:
 706  *
 707  *
 708  *
 709  * Return value:
 710  *
 711  * Since: 0.9.2
 712  **/
 713 hb_position_t
 714 hb_font_get_glyph_v_advance (hb_font_t *font,
 715                              hb_codepoint_t glyph)
 716 {
 717   return font->get_glyph_v_advance (glyph);
 718 }
 719 
 720 /**





































 721  * hb_font_get_glyph_h_origin:
 722  * @font: a font.
 723  * @glyph:
 724  * @x: (out):
 725  * @y: (out):
 726  *
 727  *
 728  *
 729  * Return value:
 730  *
 731  * Since: 0.9.2
 732  **/
 733 hb_bool_t
 734 hb_font_get_glyph_h_origin (hb_font_t *font,
 735                             hb_codepoint_t glyph,
 736                             hb_position_t *x, hb_position_t *y)
 737 {
 738   return font->get_glyph_h_origin (glyph, x, y);
 739 }
 740 


 753  **/
 754 hb_bool_t
 755 hb_font_get_glyph_v_origin (hb_font_t *font,
 756                             hb_codepoint_t glyph,
 757                             hb_position_t *x, hb_position_t *y)
 758 {
 759   return font->get_glyph_v_origin (glyph, x, y);
 760 }
 761 
 762 /**
 763  * hb_font_get_glyph_h_kerning:
 764  * @font: a font.
 765  * @left_glyph:
 766  * @right_glyph:
 767  *
 768  *
 769  *
 770  * Return value:
 771  *
 772  * Since: 0.9.2

 773  **/
 774 hb_position_t
 775 hb_font_get_glyph_h_kerning (hb_font_t *font,
 776                              hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
 777 {
 778   return font->get_glyph_h_kerning (left_glyph, right_glyph);
 779 }
 780 
 781 /**
 782  * hb_font_get_glyph_v_kerning:
 783  * @font: a font.
 784  * @top_glyph:
 785  * @bottom_glyph:
 786  *
 787  *
 788  *
 789  * Return value:
 790  *
 791  * Since: 0.9.2

 792  **/
 793 hb_position_t
 794 hb_font_get_glyph_v_kerning (hb_font_t *font,
 795                              hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph)
 796 {
 797   return font->get_glyph_v_kerning (top_glyph, bottom_glyph);
 798 }
 799 
 800 /**
 801  * hb_font_get_glyph_extents:
 802  * @font: a font.
 803  * @glyph:
 804  * @extents: (out):
 805  *
 806  *
 807  *
 808  * Return value:
 809  *
 810  * Since: 0.9.2
 811  **/


 871  *
 872  * Return value:
 873  *
 874  * Since: 0.9.2
 875  **/
 876 hb_bool_t
 877 hb_font_get_glyph_from_name (hb_font_t *font,
 878                              const char *name, int len, /* -1 means nul-terminated */
 879                              hb_codepoint_t *glyph)
 880 {
 881   return font->get_glyph_from_name (name, len, glyph);
 882 }
 883 
 884 
 885 /* A bit higher-level, and with fallback */
 886 
 887 /**
 888  * hb_font_get_extents_for_direction:
 889  * @font: a font.
 890  * @direction:
 891  * @extents:
 892  *
 893  *
 894  *
 895  * Since: 1.1.3
 896  **/
 897 void
 898 hb_font_get_extents_for_direction (hb_font_t *font,
 899                                    hb_direction_t direction,
 900                                    hb_font_extents_t *extents)
 901 {
 902   return font->get_extents_for_direction (direction, extents);
 903 }
 904 /**
 905  * hb_font_get_glyph_advance_for_direction:
 906  * @font: a font.
 907  * @glyph:
 908  * @direction:
 909  * @x: (out):
 910  * @y: (out):
 911  *
 912  *
 913  *
 914  * Since: 0.9.2
 915  **/
 916 void
 917 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
 918                                          hb_codepoint_t glyph,
 919                                          hb_direction_t direction,
 920                                          hb_position_t *x, hb_position_t *y)
 921 {
 922   return font->get_glyph_advance_for_direction (glyph, direction, x, y);
 923 }




















 924 
 925 /**
 926  * hb_font_get_glyph_origin_for_direction:
 927  * @font: a font.
 928  * @glyph:
 929  * @direction:
 930  * @x: (out):
 931  * @y: (out):
 932  *
 933  *
 934  *
 935  * Since: 0.9.2
 936  **/
 937 void
 938 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
 939                                         hb_codepoint_t glyph,
 940                                         hb_direction_t direction,
 941                                         hb_position_t *x, hb_position_t *y)
 942 {
 943   return font->get_glyph_origin_for_direction (glyph, direction, x, y);


 980 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
 981                                              hb_codepoint_t glyph,
 982                                              hb_direction_t direction,
 983                                              hb_position_t *x, hb_position_t *y)
 984 {
 985   return font->subtract_glyph_origin_for_direction (glyph, direction, x, y);
 986 }
 987 
 988 /**
 989  * hb_font_get_glyph_kerning_for_direction:
 990  * @font: a font.
 991  * @first_glyph:
 992  * @second_glyph:
 993  * @direction:
 994  * @x: (out):
 995  * @y: (out):
 996  *
 997  *
 998  *
 999  * Since: 0.9.2

1000  **/
1001 void
1002 hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
1003                                          hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
1004                                          hb_direction_t direction,
1005                                          hb_position_t *x, hb_position_t *y)
1006 {
1007   return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direction, x, y);
1008 }
1009 
1010 /**
1011  * hb_font_get_glyph_extents_for_origin:
1012  * @font: a font.
1013  * @glyph:
1014  * @direction:
1015  * @extents: (out):
1016  *
1017  *
1018  *
1019  * Return value:


1083  *
1084  *
1085  *
1086  * Return value:
1087  *
1088  * Since: 0.9.2
1089  **/
1090 hb_bool_t
1091 hb_font_glyph_from_string (hb_font_t *font,
1092                            const char *s, int len, /* -1 means nul-terminated */
1093                            hb_codepoint_t *glyph)
1094 {
1095   return font->glyph_from_string (s, len, glyph);
1096 }
1097 
1098 
1099 /*
1100  * hb_font_t
1101  */
1102 











































1103 /**
1104  * hb_font_create: (Xconstructor)
1105  * @face: a face.
1106  *
1107  *
1108  *
1109  * Return value: (transfer full):
1110  *
1111  * Since: 0.9.2
1112  **/
1113 hb_font_t *
1114 hb_font_create (hb_face_t *face)
1115 {
1116   hb_font_t *font;
1117 
1118   if (unlikely (!face))
1119     face = hb_face_get_empty ();
1120   if (!(font = hb_object_create<hb_font_t> ()))
1121     return hb_font_get_empty ();
1122 
1123   hb_face_make_immutable (face);
1124   font->parent = hb_font_get_empty ();
1125   font->face = hb_face_reference (face);
1126   font->klass = hb_font_funcs_get_empty ();
1127 
1128   font->x_scale = font->y_scale = hb_face_get_upem (face);
1129 
1130   return font;
1131 }
1132 
1133 /**
1134  * hb_font_create_sub_font:
1135  * @parent: parent font.
1136  *
1137  *
1138  *
1139  * Return value: (transfer full):
1140  *
1141  * Since: 0.9.2
1142  **/
1143 hb_font_t *
1144 hb_font_create_sub_font (hb_font_t *parent)
1145 {
1146   if (unlikely (!parent))
1147     parent = hb_font_get_empty ();
1148 
1149   hb_font_t *font = hb_font_create (parent->face);
1150 
1151   if (unlikely (hb_object_is_inert (font)))
1152     return font;
1153 
1154   font->parent = hb_font_reference (parent);
1155 
1156   font->x_scale = parent->x_scale;
1157   font->y_scale = parent->y_scale;
1158   font->x_ppem = parent->x_ppem;
1159   font->y_ppem = parent->y_ppem;
1160   font->ptem = parent->ptem;
1161 
1162   font->num_coords = parent->num_coords;
1163   if (!font->num_coords)
1164     font->coords = nullptr;
1165   else
1166   {
1167     unsigned int size = parent->num_coords * sizeof (parent->coords[0]);
1168     font->coords = (int *) malloc (size);
1169     if (unlikely (!font->coords))
1170       font->num_coords = 0;
1171     else
1172       memcpy (font->coords, parent->coords, size);
1173   }
1174 
1175   return font;
1176 }
1177 
1178 /**
1179  * hb_font_get_empty:
1180  *
1181  *
1182  *
1183  * Return value: (transfer full)
1184  *
1185  * Since: 0.9.2
1186  **/
1187 hb_font_t *
1188 hb_font_get_empty (void)
1189 {
1190   static const hb_font_t _hb_font_nil = {
1191     HB_OBJECT_HEADER_STATIC,
1192 
1193     true, /* immutable */
1194 
1195     nullptr, /* parent */
1196     const_cast<hb_face_t *> (&_hb_face_nil),
1197 
1198     1000, /* x_scale */
1199     1000, /* y_scale */
1200 
1201     0, /* x_ppem */
1202     0, /* y_ppem */
1203     0, /* ptem */
1204 
1205     0, /* num_coords */
1206     nullptr, /* coords */
1207 
1208     const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */
1209     nullptr, /* user_data */
1210     nullptr, /* destroy */
1211 
1212     {
1213 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
1214 #include "hb-shaper-list.hh"
1215 #undef HB_SHAPER_IMPLEMENT
1216     }
1217   };
1218 
1219   return const_cast<hb_font_t *> (&_hb_font_nil);
1220 }
1221 
1222 /**
1223  * hb_font_reference: (skip)
1224  * @font: a font.
1225  *
1226  *
1227  *
1228  * Return value: (transfer full):
1229  *
1230  * Since: 0.9.2
1231  **/
1232 hb_font_t *
1233 hb_font_reference (hb_font_t *font)
1234 {
1235   return hb_object_reference (font);
1236 }
1237 
1238 /**
1239  * hb_font_destroy: (skip)
1240  * @font: a font.
1241  *
1242  *
1243  *
1244  * Since: 0.9.2
1245  **/
1246 void
1247 hb_font_destroy (hb_font_t *font)
1248 {
1249   if (!hb_object_destroy (font)) return;
1250 
1251 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, font);
1252 #include "hb-shaper-list.hh"
1253 #undef HB_SHAPER_IMPLEMENT
1254 
1255   if (font->destroy)
1256     font->destroy (font->user_data);
1257 
1258   hb_font_destroy (font->parent);
1259   hb_face_destroy (font->face);
1260   hb_font_funcs_destroy (font->klass);
1261 
1262   free (font->coords);
1263 
1264   free (font);
1265 }
1266 
1267 /**
1268  * hb_font_set_user_data: (skip)
1269  * @font: a font.
1270  * @key:
1271  * @data:
1272  * @destroy:
1273  * @replace:


1300  * Since: 0.9.2
1301  **/
1302 void *
1303 hb_font_get_user_data (hb_font_t          *font,
1304                        hb_user_data_key_t *key)
1305 {
1306   return hb_object_get_user_data (font, key);
1307 }
1308 
1309 /**
1310  * hb_font_make_immutable:
1311  * @font: a font.
1312  *
1313  *
1314  *
1315  * Since: 0.9.2
1316  **/
1317 void
1318 hb_font_make_immutable (hb_font_t *font)
1319 {
1320   if (unlikely (hb_object_is_inert (font)))
1321     return;
1322 
1323   if (font->parent)
1324     hb_font_make_immutable (font->parent);
1325 
1326   font->immutable = true;
1327 }
1328 
1329 /**
1330  * hb_font_is_immutable:
1331  * @font: a font.
1332  *
1333  *
1334  *
1335  * Return value:
1336  *
1337  * Since: 0.9.2
1338  **/
1339 hb_bool_t
1340 hb_font_is_immutable (hb_font_t *font)
1341 {
1342   return font->immutable;
1343 }
1344 
1345 /**
1346  * hb_font_set_parent:
1347  * @font: a font.
1348  * @parent: new parent.
1349  *
1350  * Sets parent font of @font.
1351  *
1352  * Since: 1.0.5
1353  **/
1354 void
1355 hb_font_set_parent (hb_font_t *font,
1356                     hb_font_t *parent)
1357 {
1358   if (font->immutable)
1359     return;
1360 
1361   if (!parent)
1362     parent = hb_font_get_empty ();
1363 
1364   hb_font_t *old = font->parent;
1365 
1366   font->parent = hb_font_reference (parent);
1367 
1368   hb_font_destroy (old);
1369 }
1370 
1371 /**
1372  * hb_font_get_parent:
1373  * @font: a font.
1374  *
1375  *
1376  *
1377  * Return value: (transfer none):
1378  *


1380  **/
1381 hb_font_t *
1382 hb_font_get_parent (hb_font_t *font)
1383 {
1384   return font->parent;
1385 }
1386 
1387 /**
1388  * hb_font_set_face:
1389  * @font: a font.
1390  * @face: new face.
1391  *
1392  * Sets font-face of @font.
1393  *
1394  * Since: 1.4.3
1395  **/
1396 void
1397 hb_font_set_face (hb_font_t *font,
1398                   hb_face_t *face)
1399 {
1400   if (font->immutable)
1401     return;
1402 
1403   if (unlikely (!face))
1404     face = hb_face_get_empty ();
1405 
1406   hb_face_t *old = font->face;
1407 
1408   font->face = hb_face_reference (face);
1409 
1410   hb_face_destroy (old);
1411 }
1412 
1413 /**
1414  * hb_font_get_face:
1415  * @font: a font.
1416  *
1417  *
1418  *
1419  * Return value: (transfer none):
1420  *


1427 }
1428 
1429 
1430 /**
1431  * hb_font_set_funcs:
1432  * @font: a font.
1433  * @klass: (closure font_data) (destroy destroy) (scope notified):
1434  * @font_data:
1435  * @destroy:
1436  *
1437  *
1438  *
1439  * Since: 0.9.2
1440  **/
1441 void
1442 hb_font_set_funcs (hb_font_t         *font,
1443                    hb_font_funcs_t   *klass,
1444                    void              *font_data,
1445                    hb_destroy_func_t  destroy)
1446 {
1447   if (font->immutable) {

1448     if (destroy)
1449       destroy (font_data);
1450     return;
1451   }
1452 
1453   if (font->destroy)
1454     font->destroy (font->user_data);
1455 
1456   if (!klass)
1457     klass = hb_font_funcs_get_empty ();
1458 
1459   hb_font_funcs_reference (klass);
1460   hb_font_funcs_destroy (font->klass);
1461   font->klass = klass;
1462   font->user_data = font_data;
1463   font->destroy = destroy;
1464 }
1465 
1466 /**
1467  * hb_font_set_funcs_data:
1468  * @font: a font.
1469  * @font_data: (destroy destroy) (scope notified):
1470  * @destroy:
1471  *
1472  *
1473  *
1474  * Since: 0.9.2
1475  **/
1476 void
1477 hb_font_set_funcs_data (hb_font_t         *font,
1478                         void              *font_data,
1479                         hb_destroy_func_t  destroy)
1480 {
1481   /* Destroy user_data? */
1482   if (font->immutable) {

1483     if (destroy)
1484       destroy (font_data);
1485     return;
1486   }
1487 
1488   if (font->destroy)
1489     font->destroy (font->user_data);
1490 
1491   font->user_data = font_data;
1492   font->destroy = destroy;
1493 }
1494 
1495 
1496 /**
1497  * hb_font_set_scale:
1498  * @font: a font.
1499  * @x_scale:
1500  * @y_scale:
1501  *
1502  *
1503  *
1504  * Since: 0.9.2
1505  **/
1506 void
1507 hb_font_set_scale (hb_font_t *font,
1508                    int x_scale,
1509                    int y_scale)
1510 {
1511   if (font->immutable)
1512     return;
1513 
1514   font->x_scale = x_scale;
1515   font->y_scale = y_scale;
1516 }
1517 
1518 /**
1519  * hb_font_get_scale:
1520  * @font: a font.
1521  * @x_scale: (out):
1522  * @y_scale: (out):
1523  *
1524  *
1525  *
1526  * Since: 0.9.2
1527  **/
1528 void
1529 hb_font_get_scale (hb_font_t *font,
1530                    int *x_scale,
1531                    int *y_scale)
1532 {
1533   if (x_scale) *x_scale = font->x_scale;
1534   if (y_scale) *y_scale = font->y_scale;
1535 }
1536 
1537 /**
1538  * hb_font_set_ppem:
1539  * @font: a font.
1540  * @x_ppem:
1541  * @y_ppem:
1542  *
1543  *
1544  *
1545  * Since: 0.9.2
1546  **/
1547 void
1548 hb_font_set_ppem (hb_font_t *font,
1549                   unsigned int x_ppem,
1550                   unsigned int y_ppem)
1551 {
1552   if (font->immutable)
1553     return;
1554 
1555   font->x_ppem = x_ppem;
1556   font->y_ppem = y_ppem;
1557 }
1558 
1559 /**
1560  * hb_font_get_ppem:
1561  * @font: a font.
1562  * @x_ppem: (out):
1563  * @y_ppem: (out):
1564  *
1565  *
1566  *
1567  * Since: 0.9.2
1568  **/
1569 void
1570 hb_font_get_ppem (hb_font_t *font,
1571                   unsigned int *x_ppem,
1572                   unsigned int *y_ppem)
1573 {
1574   if (x_ppem) *x_ppem = font->x_ppem;
1575   if (y_ppem) *y_ppem = font->y_ppem;
1576 }
1577 
1578 /**
1579  * hb_font_set_ptem:
1580  * @font: a font.
1581  * @ptem:


1582  *
1583  * Sets "point size" of the font.
1584  *
1585  * Since: 1.6.0
1586  **/
1587 void
1588 hb_font_set_ptem (hb_font_t *font, float ptem)
1589 {
1590   if (font->immutable)
1591     return;
1592 
1593   font->ptem = ptem;
1594 }
1595 
1596 /**
1597  * hb_font_get_ptem:
1598  * @font: a font.
1599  *
1600  * Gets the "point size" of the font.  A value of 0 means unset.
1601  *
1602  * Return value: Point size.
1603  *
1604  * Since: 0.9.2
1605  **/
1606 float
1607 hb_font_get_ptem (hb_font_t *font)
1608 {
1609   return font->ptem;
1610 }


1617 _hb_font_adopt_var_coords_normalized (hb_font_t *font,
1618                                       int *coords, /* 2.14 normalized */
1619                                       unsigned int coords_length)
1620 {
1621   free (font->coords);
1622 
1623   font->coords = coords;
1624   font->num_coords = coords_length;
1625 }
1626 
1627 /**
1628  * hb_font_set_variations:
1629  *
1630  * Since: 1.4.2
1631  */
1632 void
1633 hb_font_set_variations (hb_font_t *font,
1634                         const hb_variation_t *variations,
1635                         unsigned int variations_length)
1636 {
1637   if (font->immutable)
1638     return;
1639 
1640   if (!variations_length)
1641   {
1642     hb_font_set_var_coords_normalized (font, nullptr, 0);
1643     return;
1644   }
1645 
1646   unsigned int coords_length = hb_ot_var_get_axis_count (font->face);
1647 
1648   int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr;
1649   if (unlikely (coords_length && !normalized))
1650     return;
1651 
1652   hb_ot_var_normalize_variations (font->face,
1653                                   variations, variations_length,
1654                                   normalized, coords_length);
1655   _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
1656 }
1657 
1658 /**
1659  * hb_font_set_var_coords_design:
1660  *
1661  * Since: 1.4.2
1662  */
1663 void
1664 hb_font_set_var_coords_design (hb_font_t *font,
1665                                const float *coords,
1666                                unsigned int coords_length)
1667 {
1668   if (font->immutable)
1669     return;
1670 
1671   int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr;
1672   if (unlikely (coords_length && !normalized))
1673     return;
1674 
1675   hb_ot_var_normalize_coords (font->face, coords_length, coords, normalized);
1676   _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
1677 }
1678 
1679 /**
1680  * hb_font_set_var_coords_normalized:
1681  *
1682  * Since: 1.4.2
1683  */
1684 void
1685 hb_font_set_var_coords_normalized (hb_font_t *font,
1686                                    const int *coords, /* 2.14 normalized */
1687                                    unsigned int coords_length)
1688 {
1689   if (font->immutable)
1690     return;
1691 
1692   int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : nullptr;
1693   if (unlikely (coords_length && !copy))
1694     return;
1695 
1696   if (coords_length)
1697     memcpy (copy, coords, coords_length * sizeof (coords[0]));
1698 
1699   _hb_font_adopt_var_coords_normalized (font, copy, coords_length);
1700 }
1701 
1702 /**
1703  * hb_font_get_var_coords_normalized:
1704  *
1705  * Return value is valid as long as variation coordinates of the font
1706  * are not modified.
1707  *
1708  * Since: 1.4.2
1709  */
1710 const int *
1711 hb_font_get_var_coords_normalized (hb_font_t *font,
1712                                    unsigned int *length)
1713 {
1714   if (length)
1715     *length = font->num_coords;
1716 
1717   return font->coords;
1718 }
1719 
1720 
1721 #ifndef HB_DISABLE_DEPRECATED
1722 
1723 /*
1724  * Deprecated get_glyph_func():
1725  */
1726 
1727 struct hb_trampoline_closure_t
1728 {
1729   void *user_data;
1730   hb_destroy_func_t destroy;
1731   unsigned int ref_count;
1732 };
1733 
1734 template <typename FuncType>
1735 struct hb_trampoline_t
1736 {
1737   hb_trampoline_closure_t closure; /* Must be first. */
1738   FuncType func;
1739 };
1740 
1741 template <typename FuncType>
1742 static hb_trampoline_t<FuncType> *


1789 {
1790   hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t *) user_data;
1791   return trampoline->func (font, font_data, unicode, 0, glyph, trampoline->closure.user_data);
1792 }
1793 
1794 static hb_bool_t
1795 hb_font_get_variation_glyph_trampoline (hb_font_t *font,
1796                                         void *font_data,
1797                                         hb_codepoint_t unicode,
1798                                         hb_codepoint_t variation_selector,
1799                                         hb_codepoint_t *glyph,
1800                                         void *user_data)
1801 {
1802   hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t *) user_data;
1803   return trampoline->func (font, font_data, unicode, variation_selector, glyph, trampoline->closure.user_data);
1804 }
1805 
1806 /**
1807  * hb_font_funcs_set_glyph_func:
1808  * @ffuncs: font functions.
1809  * @func: (closure user_data) (destroy destroy) (scope notified):
1810  * @user_data:
1811  * @destroy:
1812  *
1813  * Deprecated.  Use hb_font_funcs_set_nominal_glyph_func() and
1814  * hb_font_funcs_set_variation_glyph_func() instead.
1815  *
1816  * Since: 0.9.2
1817  * Deprecated: 1.2.3
1818  **/
1819 void
1820 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
1821                               hb_font_get_glyph_func_t func,
1822                               void *user_data, hb_destroy_func_t destroy)
1823 {
1824   hb_font_get_glyph_trampoline_t *trampoline;
1825 
1826   trampoline = trampoline_create (func, user_data, destroy);
1827   if (unlikely (!trampoline))
1828   {
1829     if (destroy)
1830       destroy (user_data);
1831     return;
1832   }
1833 
1834   hb_font_funcs_set_nominal_glyph_func (ffuncs,
1835                                         hb_font_get_nominal_glyph_trampoline,
1836                                         trampoline,
1837                                         trampoline_destroy);
1838 
1839   trampoline_reference (&trampoline->closure);
1840   hb_font_funcs_set_variation_glyph_func (ffuncs,
1841                                           hb_font_get_variation_glyph_trampoline,
1842                                           trampoline,
1843                                           trampoline_destroy);
1844 }
1845 
1846 #endif /* HB_DISABLE_DEPRECATED */


   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.
  12  *
  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
  17  * DAMAGE.
  18  *
  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.
  24  *
  25  * Red Hat Author(s): Behdad Esfahbod
  26  * Google Author(s): Behdad Esfahbod
  27  */
  28 
  29 #include "hb.hh"
  30 
  31 #include "hb-font.hh"
  32 #include "hb-machinery.hh"
  33 
  34 #include "hb-ot.h"
  35 
  36 
  37 /**
  38  * SECTION:hb-font
  39  * @title: hb-font
  40  * @short_description: Font objects
  41  * @include: hb.h
  42  *
  43  * Font objects represent a font face at a certain size and other
  44  * parameters (pixels per EM, points per EM, variation settings.)
  45  * Fonts are created from font faces, and are used as input to
  46  * hb_shape() among other things.
  47  **/
  48 
  49 
  50 /*
  51  * hb_font_funcs_t
  52  */
  53 
  54 static hb_bool_t
  55 hb_font_get_font_h_extents_nil (hb_font_t *font HB_UNUSED,
  56                                 void *font_data HB_UNUSED,
  57                                 hb_font_extents_t *extents,
  58                                 void *user_data HB_UNUSED)
  59 {
  60   memset (extents, 0, sizeof (*extents));
  61   return false;
  62 }
  63 static hb_bool_t
  64 hb_font_get_font_h_extents_default (hb_font_t *font,
  65                                     void *font_data HB_UNUSED,
  66                                     hb_font_extents_t *extents,
  67                                     void *user_data HB_UNUSED)
  68 {
  69   hb_bool_t ret = font->parent->get_font_h_extents (extents);
  70   if (ret) {
  71     extents->ascender = font->parent_scale_y_distance (extents->ascender);
  72     extents->descender = font->parent_scale_y_distance (extents->descender);
  73     extents->line_gap = font->parent_scale_y_distance (extents->line_gap);
  74   }
  75   return ret;
  76 }
  77 
  78 static hb_bool_t
  79 hb_font_get_font_v_extents_nil (hb_font_t *font HB_UNUSED,
  80                                 void *font_data HB_UNUSED,
  81                                 hb_font_extents_t *extents,
  82                                 void *user_data HB_UNUSED)
  83 {
  84   memset (extents, 0, sizeof (*extents));
  85   return false;
  86 }
  87 static hb_bool_t
  88 hb_font_get_font_v_extents_default (hb_font_t *font,
  89                                     void *font_data HB_UNUSED,
  90                                     hb_font_extents_t *extents,
  91                                     void *user_data HB_UNUSED)
  92 {
  93   hb_bool_t ret = font->parent->get_font_v_extents (extents);
  94   if (ret) {
  95     extents->ascender = font->parent_scale_x_distance (extents->ascender);
  96     extents->descender = font->parent_scale_x_distance (extents->descender);
  97     extents->line_gap = font->parent_scale_x_distance (extents->line_gap);
  98   }
  99   return ret;
 100 }
 101 
 102 static hb_bool_t
 103 hb_font_get_nominal_glyph_nil (hb_font_t *font HB_UNUSED,
 104                                void *font_data HB_UNUSED,
 105                                hb_codepoint_t unicode HB_UNUSED,
 106                                hb_codepoint_t *glyph,
 107                                void *user_data HB_UNUSED)
 108 {
 109   *glyph = 0;
 110   return false;
 111 }
 112 static hb_bool_t
 113 hb_font_get_nominal_glyph_default (hb_font_t *font,
 114                                    void *font_data HB_UNUSED,
 115                                    hb_codepoint_t unicode,
 116                                    hb_codepoint_t *glyph,
 117                                    void *user_data HB_UNUSED)
 118 {
 119   if (font->has_nominal_glyphs_func_set ())
 120   {
 121     return font->get_nominal_glyphs (1, &unicode, 0, glyph, 0);
 122   }
 123   return font->parent->get_nominal_glyph (unicode, glyph);
 124 }
 125 
 126 #define hb_font_get_nominal_glyphs_nil hb_font_get_nominal_glyphs_default
 127 static unsigned int
 128 hb_font_get_nominal_glyphs_default (hb_font_t *font,
 129                                     void *font_data HB_UNUSED,
 130                                     unsigned int count,
 131                                     const hb_codepoint_t *first_unicode,
 132                                     unsigned int unicode_stride,
 133                                     hb_codepoint_t *first_glyph,
 134                                     unsigned int glyph_stride,
 135                                     void *user_data HB_UNUSED)
 136 {
 137   if (font->has_nominal_glyph_func_set ())
 138   {
 139     for (unsigned int i = 0; i < count; i++)
 140     {
 141       if (!font->get_nominal_glyph (*first_unicode, first_glyph))
 142         return i;
 143 
 144       first_unicode = &StructAtOffsetUnaligned<hb_codepoint_t> (first_unicode, unicode_stride);
 145       first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
 146     }
 147     return count;
 148   }
 149 
 150   return font->parent->get_nominal_glyphs (count,
 151                                            first_unicode, unicode_stride,
 152                                            first_glyph, glyph_stride);
 153 }
 154 
 155 static hb_bool_t
 156 hb_font_get_variation_glyph_nil (hb_font_t *font HB_UNUSED,
 157                                  void *font_data HB_UNUSED,
 158                                  hb_codepoint_t unicode HB_UNUSED,
 159                                  hb_codepoint_t variation_selector HB_UNUSED,
 160                                  hb_codepoint_t *glyph,
 161                                  void *user_data HB_UNUSED)
 162 {
 163   *glyph = 0;
 164   return false;
 165 }
 166 static hb_bool_t
 167 hb_font_get_variation_glyph_default (hb_font_t *font,
 168                                      void *font_data HB_UNUSED,
 169                                      hb_codepoint_t unicode,
 170                                      hb_codepoint_t variation_selector,
 171                                      hb_codepoint_t *glyph,
 172                                      void *user_data HB_UNUSED)
 173 {
 174   return font->parent->get_variation_glyph (unicode, variation_selector, glyph);
 175 }
 176 
 177 
 178 static hb_position_t
 179 hb_font_get_glyph_h_advance_nil (hb_font_t *font,
 180                                  void *font_data HB_UNUSED,
 181                                  hb_codepoint_t glyph HB_UNUSED,
 182                                  void *user_data HB_UNUSED)
 183 {
 184   return font->x_scale;
 185 }
 186 static hb_position_t
 187 hb_font_get_glyph_h_advance_default (hb_font_t *font,
 188                                      void *font_data HB_UNUSED,
 189                                      hb_codepoint_t glyph,
 190                                      void *user_data HB_UNUSED)
 191 {
 192   if (font->has_glyph_h_advances_func_set ())
 193   {
 194     hb_position_t ret;
 195     font->get_glyph_h_advances (1, &glyph, 0, &ret, 0);
 196     return ret;
 197   }
 198   return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph));
 199 }
 200 
 201 static hb_position_t
 202 hb_font_get_glyph_v_advance_nil (hb_font_t *font,
 203                                  void *font_data HB_UNUSED,
 204                                  hb_codepoint_t glyph HB_UNUSED,
 205                                  void *user_data HB_UNUSED)
 206 {
 207   /* TODO use font_extents.ascender+descender */
 208   return font->y_scale;
 209 }
 210 static hb_position_t
 211 hb_font_get_glyph_v_advance_default (hb_font_t *font,
 212                                      void *font_data HB_UNUSED,
 213                                      hb_codepoint_t glyph,
 214                                      void *user_data HB_UNUSED)
 215 {
 216   if (font->has_glyph_v_advances_func_set ())
 217   {
 218     hb_position_t ret;
 219     font->get_glyph_v_advances (1, &glyph, 0, &ret, 0);
 220     return ret;
 221   }
 222   return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph));
 223 }
 224 
 225 #define hb_font_get_glyph_h_advances_nil hb_font_get_glyph_h_advances_default
 226 static void
 227 hb_font_get_glyph_h_advances_default (hb_font_t* font,
 228                                       void* font_data HB_UNUSED,
 229                                       unsigned int count,
 230                                       const hb_codepoint_t *first_glyph,
 231                                       unsigned int glyph_stride,
 232                                       hb_position_t *first_advance,
 233                                       unsigned int advance_stride,
 234                                       void *user_data HB_UNUSED)
 235 {
 236   if (font->has_glyph_h_advance_func_set ())
 237   {
 238     for (unsigned int i = 0; i < count; i++)
 239     {
 240       *first_advance = font->get_glyph_h_advance (*first_glyph);
 241       first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
 242       first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
 243     }
 244     return;
 245   }
 246 
 247   font->parent->get_glyph_h_advances (count,
 248                                       first_glyph, glyph_stride,
 249                                       first_advance, advance_stride);
 250   for (unsigned int i = 0; i < count; i++)
 251   {
 252     *first_advance = font->parent_scale_x_distance (*first_advance);
 253     first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
 254   }
 255 }
 256 
 257 #define hb_font_get_glyph_v_advances_nil hb_font_get_glyph_v_advances_default
 258 static void
 259 hb_font_get_glyph_v_advances_default (hb_font_t* font,
 260                                       void* font_data HB_UNUSED,
 261                                       unsigned int count,
 262                                       const hb_codepoint_t *first_glyph,
 263                                       unsigned int glyph_stride,
 264                                       hb_position_t *first_advance,
 265                                       unsigned int advance_stride,
 266                                       void *user_data HB_UNUSED)
 267 {
 268   if (font->has_glyph_v_advance_func_set ())
 269   {
 270     for (unsigned int i = 0; i < count; i++)
 271     {
 272       *first_advance = font->get_glyph_v_advance (*first_glyph);
 273       first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
 274       first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
 275     }
 276     return;
 277   }
 278 
 279   font->parent->get_glyph_v_advances (count,
 280                                       first_glyph, glyph_stride,
 281                                       first_advance, advance_stride);
 282   for (unsigned int i = 0; i < count; i++)
 283   {
 284     *first_advance = font->parent_scale_y_distance (*first_advance);
 285     first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
 286   }
 287 }
 288 
 289 static hb_bool_t
 290 hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
 291                                 void *font_data HB_UNUSED,
 292                                 hb_codepoint_t glyph HB_UNUSED,
 293                                 hb_position_t *x,
 294                                 hb_position_t *y,
 295                                 void *user_data HB_UNUSED)
 296 {
 297   *x = *y = 0;
 298   return true;
 299 }
 300 static hb_bool_t
 301 hb_font_get_glyph_h_origin_default (hb_font_t *font,
 302                                     void *font_data HB_UNUSED,
 303                                     hb_codepoint_t glyph,
 304                                     hb_position_t *x,
 305                                     hb_position_t *y,
 306                                     void *user_data HB_UNUSED)
 307 {
 308   hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y);
 309   if (ret)
 310     font->parent_scale_position (x, y);
 311   return ret;
 312 }
 313 
 314 static hb_bool_t
 315 hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
 316                                 void *font_data HB_UNUSED,
 317                                 hb_codepoint_t glyph HB_UNUSED,
 318                                 hb_position_t *x,
 319                                 hb_position_t *y,
 320                                 void *user_data HB_UNUSED)
 321 {
 322   *x = *y = 0;
 323   return false;
 324 }
 325 static hb_bool_t
 326 hb_font_get_glyph_v_origin_default (hb_font_t *font,
 327                                     void *font_data HB_UNUSED,
 328                                     hb_codepoint_t glyph,
 329                                     hb_position_t *x,
 330                                     hb_position_t *y,
 331                                     void *user_data HB_UNUSED)
 332 {
 333   hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y);
 334   if (ret)
 335     font->parent_scale_position (x, y);
 336   return ret;
 337 }
 338 
 339 static hb_position_t
 340 hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
 341                                  void *font_data HB_UNUSED,
 342                                  hb_codepoint_t left_glyph HB_UNUSED,
 343                                  hb_codepoint_t right_glyph HB_UNUSED,
 344                                  void *user_data HB_UNUSED)
 345 {
 346   return 0;
 347 }
 348 static hb_position_t
 349 hb_font_get_glyph_h_kerning_default (hb_font_t *font,
 350                                      void *font_data HB_UNUSED,
 351                                      hb_codepoint_t left_glyph,
 352                                      hb_codepoint_t right_glyph,
 353                                      void *user_data HB_UNUSED)
 354 {
 355   return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph));
 356 }
 357 
 358 static hb_position_t
 359 hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
 360                                  void *font_data HB_UNUSED,
 361                                  hb_codepoint_t top_glyph HB_UNUSED,
 362                                  hb_codepoint_t bottom_glyph HB_UNUSED,
 363                                  void *user_data HB_UNUSED)
 364 {
 365   return 0;
 366 }
 367 static hb_position_t
 368 hb_font_get_glyph_v_kerning_default (hb_font_t *font,
 369                                      void *font_data HB_UNUSED,
 370                                      hb_codepoint_t top_glyph,
 371                                      hb_codepoint_t bottom_glyph,
 372                                      void *user_data HB_UNUSED)
 373 {
 374   return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph));
 375 }
 376 
 377 static hb_bool_t
 378 hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
 379                                void *font_data HB_UNUSED,
 380                                hb_codepoint_t glyph HB_UNUSED,
 381                                hb_glyph_extents_t *extents,
 382                                void *user_data HB_UNUSED)
 383 {
 384   memset (extents, 0, sizeof (*extents));
 385   return false;
 386 }
 387 static hb_bool_t
 388 hb_font_get_glyph_extents_default (hb_font_t *font,
 389                                    void *font_data HB_UNUSED,
 390                                    hb_codepoint_t glyph,
 391                                    hb_glyph_extents_t *extents,
 392                                    void *user_data HB_UNUSED)
 393 {
 394   hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents);
 395   if (ret) {
 396     font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
 397     font->parent_scale_distance (&extents->width, &extents->height);
 398   }
 399   return ret;
 400 }
 401 
 402 static hb_bool_t
 403 hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED,
 404                                      void *font_data HB_UNUSED,
 405                                      hb_codepoint_t glyph HB_UNUSED,
 406                                      unsigned int point_index HB_UNUSED,
 407                                      hb_position_t *x,
 408                                      hb_position_t *y,
 409                                      void *user_data HB_UNUSED)
 410 {
 411   *x = *y = 0;
 412   return false;
 413 }
 414 static hb_bool_t
 415 hb_font_get_glyph_contour_point_default (hb_font_t *font,
 416                                          void *font_data HB_UNUSED,
 417                                          hb_codepoint_t glyph,
 418                                          unsigned int point_index,
 419                                          hb_position_t *x,
 420                                          hb_position_t *y,
 421                                          void *user_data HB_UNUSED)
 422 {
 423   hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y);
 424   if (ret)
 425     font->parent_scale_position (x, y);
 426   return ret;
 427 }
 428 
 429 static hb_bool_t
 430 hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED,
 431                             void *font_data HB_UNUSED,
 432                             hb_codepoint_t glyph HB_UNUSED,
 433                             char *name, unsigned int size,
 434                             void *user_data HB_UNUSED)
 435 {
 436   if (size) *name = '\0';
 437   return false;
 438 }
 439 static hb_bool_t
 440 hb_font_get_glyph_name_default (hb_font_t *font,
 441                                 void *font_data HB_UNUSED,
 442                                 hb_codepoint_t glyph,
 443                                 char *name, unsigned int size,
 444                                 void *user_data HB_UNUSED)
 445 {
 446   return font->parent->get_glyph_name (glyph, name, size);
 447 }
 448 
 449 static hb_bool_t
 450 hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED,
 451                                  void *font_data HB_UNUSED,
 452                                  const char *name HB_UNUSED,
 453                                  int len HB_UNUSED, /* -1 means nul-terminated */
 454                                  hb_codepoint_t *glyph,
 455                                  void *user_data HB_UNUSED)
 456 {
 457   *glyph = 0;
 458   return false;
 459 }
 460 static hb_bool_t
 461 hb_font_get_glyph_from_name_default (hb_font_t *font,
 462                                      void *font_data HB_UNUSED,
 463                                      const char *name, int len, /* -1 means nul-terminated */
 464                                      hb_codepoint_t *glyph,
 465                                      void *user_data HB_UNUSED)
 466 {
 467   return font->parent->get_glyph_from_name (name, len, glyph);
 468 }
 469 
 470 DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
 471 {
 472   HB_OBJECT_HEADER_STATIC,
 473 


 474   {
 475 #define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
 476     HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 477 #undef HB_FONT_FUNC_IMPLEMENT
 478   },
 479   {
 480 #define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
 481     HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 482 #undef HB_FONT_FUNC_IMPLEMENT
 483   },
 484   {
 485     {
 486 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil,
 487       HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 488 #undef HB_FONT_FUNC_IMPLEMENT
 489     }
 490   }
 491 };


 492 
 493 static const hb_font_funcs_t _hb_font_funcs_default = {
 494   HB_OBJECT_HEADER_STATIC,
 495 
 496   {
 497 #define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
 498     HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 499 #undef HB_FONT_FUNC_IMPLEMENT
 500   },
 501   {
 502 #define HB_FONT_FUNC_IMPLEMENT(name) nullptr,
 503     HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 504 #undef HB_FONT_FUNC_IMPLEMENT
 505   },
 506   {
 507     {
 508 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_default,
 509       HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 510 #undef HB_FONT_FUNC_IMPLEMENT
 511     }
 512   }
 513 };
 514 
 515 
 516 /**
 517  * hb_font_funcs_create: (Xconstructor)
 518  *
 519  *
 520  *
 521  * Return value: (transfer full):
 522  *
 523  * Since: 0.9.2
 524  **/
 525 hb_font_funcs_t *
 526 hb_font_funcs_create ()
 527 {
 528   hb_font_funcs_t *ffuncs;
 529 
 530   if (!(ffuncs = hb_object_create<hb_font_funcs_t> ()))
 531     return hb_font_funcs_get_empty ();
 532 
 533   ffuncs->get = _hb_font_funcs_default.get;
 534 
 535   return ffuncs;
 536 }
 537 
 538 /**
 539  * hb_font_funcs_get_empty:
 540  *
 541  *
 542  *
 543  * Return value: (transfer full):
 544  *
 545  * Since: 0.9.2
 546  **/
 547 hb_font_funcs_t *
 548 hb_font_funcs_get_empty ()
 549 {
 550   return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_default);
 551 }
 552 
 553 /**
 554  * hb_font_funcs_reference: (skip)
 555  * @ffuncs: font functions.
 556  *
 557  *
 558  *
 559  * Return value:
 560  *
 561  * Since: 0.9.2
 562  **/
 563 hb_font_funcs_t *
 564 hb_font_funcs_reference (hb_font_funcs_t *ffuncs)
 565 {
 566   return hb_object_reference (ffuncs);
 567 }
 568 
 569 /**
 570  * hb_font_funcs_destroy: (skip)


 624  **/
 625 void *
 626 hb_font_funcs_get_user_data (hb_font_funcs_t    *ffuncs,
 627                              hb_user_data_key_t *key)
 628 {
 629   return hb_object_get_user_data (ffuncs, key);
 630 }
 631 
 632 
 633 /**
 634  * hb_font_funcs_make_immutable:
 635  * @ffuncs: font functions.
 636  *
 637  *
 638  *
 639  * Since: 0.9.2
 640  **/
 641 void
 642 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs)
 643 {
 644   if (hb_object_is_immutable (ffuncs))
 645     return;
 646 
 647   hb_object_make_immutable (ffuncs);
 648 }
 649 
 650 /**
 651  * hb_font_funcs_is_immutable:
 652  * @ffuncs: font functions.
 653  *
 654  *
 655  *
 656  * Return value:
 657  *
 658  * Since: 0.9.2
 659  **/
 660 hb_bool_t
 661 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs)
 662 {
 663   return hb_object_is_immutable (ffuncs);
 664 }
 665 
 666 
 667 #define HB_FONT_FUNC_IMPLEMENT(name) \
 668                                                                          \
 669 void                                                                     \
 670 hb_font_funcs_set_##name##_func (hb_font_funcs_t             *ffuncs,    \
 671                                  hb_font_get_##name##_func_t  func,      \
 672                                  void                        *user_data, \
 673                                  hb_destroy_func_t            destroy)   \
 674 {                                                                        \
 675   if (hb_object_is_immutable (ffuncs)) {                                 \
 676     if (destroy)                                                         \
 677       destroy (user_data);                                               \
 678     return;                                                              \
 679   }                                                                      \
 680                                                                          \
 681   if (ffuncs->destroy.name)                                              \
 682     ffuncs->destroy.name (ffuncs->user_data.name);                       \
 683                                                                          \
 684   if (func) {                                                            \
 685     ffuncs->get.f.name = func;                                           \
 686     ffuncs->user_data.name = user_data;                                  \
 687     ffuncs->destroy.name = destroy;                                      \
 688   } else {                                                               \
 689     ffuncs->get.f.name = hb_font_get_##name##_default;                   \
 690     ffuncs->user_data.name = nullptr;                                    \
 691     ffuncs->destroy.name = nullptr;                                      \
 692   }                                                                      \
 693 }
 694 
 695 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
 696 #undef HB_FONT_FUNC_IMPLEMENT
 697 
 698 bool
 699 hb_font_t::has_func_set (unsigned int i)
 700 {
 701   return this->klass->get.array[i] != _hb_font_funcs_default.get.array[i];
 702 }
 703 
 704 bool
 705 hb_font_t::has_func (unsigned int i)
 706 {
 707   return has_func_set (i) ||
 708          (parent && parent != &_hb_Null_hb_font_t && parent->has_func (i));

 709 }
 710 
 711 /* Public getters */
 712 
 713 /**
 714  * hb_font_get_h_extents:
 715  * @font: a font.
 716  * @extents: (out):
 717  *
 718  *
 719  *
 720  * Return value:
 721  *
 722  * Since: 1.1.3
 723  **/
 724 hb_bool_t
 725 hb_font_get_h_extents (hb_font_t *font,
 726                        hb_font_extents_t *extents)
 727 {
 728   return font->get_font_h_extents (extents);


 830 
 831 /**
 832  * hb_font_get_glyph_v_advance:
 833  * @font: a font.
 834  * @glyph:
 835  *
 836  *
 837  *
 838  * Return value:
 839  *
 840  * Since: 0.9.2
 841  **/
 842 hb_position_t
 843 hb_font_get_glyph_v_advance (hb_font_t *font,
 844                              hb_codepoint_t glyph)
 845 {
 846   return font->get_glyph_v_advance (glyph);
 847 }
 848 
 849 /**
 850  * hb_font_get_glyph_h_advances:
 851  * @font: a font.
 852  *
 853  *
 854  *
 855  * Since: 1.8.6
 856  **/
 857 void
 858 hb_font_get_glyph_h_advances (hb_font_t* font,
 859                               unsigned int count,
 860                               const hb_codepoint_t *first_glyph,
 861                               unsigned glyph_stride,
 862                               hb_position_t *first_advance,
 863                               unsigned advance_stride)
 864 {
 865   font->get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride);
 866 }
 867 /**
 868  * hb_font_get_glyph_v_advances:
 869  * @font: a font.
 870  *
 871  *
 872  *
 873  * Since: 1.8.6
 874  **/
 875 void
 876 hb_font_get_glyph_v_advances (hb_font_t* font,
 877                               unsigned int count,
 878                               const hb_codepoint_t *first_glyph,
 879                               unsigned glyph_stride,
 880                               hb_position_t *first_advance,
 881                               unsigned advance_stride)
 882 {
 883   font->get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride);
 884 }
 885 
 886 /**
 887  * hb_font_get_glyph_h_origin:
 888  * @font: a font.
 889  * @glyph:
 890  * @x: (out):
 891  * @y: (out):
 892  *
 893  *
 894  *
 895  * Return value:
 896  *
 897  * Since: 0.9.2
 898  **/
 899 hb_bool_t
 900 hb_font_get_glyph_h_origin (hb_font_t *font,
 901                             hb_codepoint_t glyph,
 902                             hb_position_t *x, hb_position_t *y)
 903 {
 904   return font->get_glyph_h_origin (glyph, x, y);
 905 }
 906 


 919  **/
 920 hb_bool_t
 921 hb_font_get_glyph_v_origin (hb_font_t *font,
 922                             hb_codepoint_t glyph,
 923                             hb_position_t *x, hb_position_t *y)
 924 {
 925   return font->get_glyph_v_origin (glyph, x, y);
 926 }
 927 
 928 /**
 929  * hb_font_get_glyph_h_kerning:
 930  * @font: a font.
 931  * @left_glyph:
 932  * @right_glyph:
 933  *
 934  *
 935  *
 936  * Return value:
 937  *
 938  * Since: 0.9.2
 939  * Deprecated: 2.0.0
 940  **/
 941 hb_position_t
 942 hb_font_get_glyph_h_kerning (hb_font_t *font,
 943                              hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
 944 {
 945   return font->get_glyph_h_kerning (left_glyph, right_glyph);
 946 }
 947 
 948 /**
 949  * hb_font_get_glyph_v_kerning:
 950  * @font: a font.
 951  * @top_glyph:
 952  * @bottom_glyph:
 953  *
 954  *
 955  *
 956  * Return value:
 957  *
 958  * Since: 0.9.2
 959  * Deprecated: 2.0.0
 960  **/
 961 hb_position_t
 962 hb_font_get_glyph_v_kerning (hb_font_t *font,
 963                              hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph)
 964 {
 965   return font->get_glyph_v_kerning (top_glyph, bottom_glyph);
 966 }
 967 
 968 /**
 969  * hb_font_get_glyph_extents:
 970  * @font: a font.
 971  * @glyph:
 972  * @extents: (out):
 973  *
 974  *
 975  *
 976  * Return value:
 977  *
 978  * Since: 0.9.2
 979  **/


1039  *
1040  * Return value:
1041  *
1042  * Since: 0.9.2
1043  **/
1044 hb_bool_t
1045 hb_font_get_glyph_from_name (hb_font_t *font,
1046                              const char *name, int len, /* -1 means nul-terminated */
1047                              hb_codepoint_t *glyph)
1048 {
1049   return font->get_glyph_from_name (name, len, glyph);
1050 }
1051 
1052 
1053 /* A bit higher-level, and with fallback */
1054 
1055 /**
1056  * hb_font_get_extents_for_direction:
1057  * @font: a font.
1058  * @direction:
1059  * @extents: (out):
1060  *
1061  *
1062  *
1063  * Since: 1.1.3
1064  **/
1065 void
1066 hb_font_get_extents_for_direction (hb_font_t *font,
1067                                    hb_direction_t direction,
1068                                    hb_font_extents_t *extents)
1069 {
1070   return font->get_extents_for_direction (direction, extents);
1071 }
1072 /**
1073  * hb_font_get_glyph_advance_for_direction:
1074  * @font: a font.
1075  * @glyph:
1076  * @direction:
1077  * @x: (out):
1078  * @y: (out):
1079  *
1080  *
1081  *
1082  * Since: 0.9.2
1083  **/
1084 void
1085 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
1086                                          hb_codepoint_t glyph,
1087                                          hb_direction_t direction,
1088                                          hb_position_t *x, hb_position_t *y)
1089 {
1090   return font->get_glyph_advance_for_direction (glyph, direction, x, y);
1091 }
1092 /**
1093  * hb_font_get_glyph_advances_for_direction:
1094  * @font: a font.
1095  * @direction:
1096  *
1097  *
1098  *
1099  * Since: 1.8.6
1100  **/
1101 HB_EXTERN void
1102 hb_font_get_glyph_advances_for_direction (hb_font_t* font,
1103                                           hb_direction_t direction,
1104                                           unsigned int count,
1105                                           const hb_codepoint_t *first_glyph,
1106                                           unsigned glyph_stride,
1107                                           hb_position_t *first_advance,
1108                                           unsigned advance_stride)
1109 {
1110   font->get_glyph_advances_for_direction (direction, count, first_glyph, glyph_stride, first_advance, advance_stride);
1111 }
1112 
1113 /**
1114  * hb_font_get_glyph_origin_for_direction:
1115  * @font: a font.
1116  * @glyph:
1117  * @direction:
1118  * @x: (out):
1119  * @y: (out):
1120  *
1121  *
1122  *
1123  * Since: 0.9.2
1124  **/
1125 void
1126 hb_font_get_glyph_origin_for_direction (hb_font_t *font,
1127                                         hb_codepoint_t glyph,
1128                                         hb_direction_t direction,
1129                                         hb_position_t *x, hb_position_t *y)
1130 {
1131   return font->get_glyph_origin_for_direction (glyph, direction, x, y);


1168 hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
1169                                              hb_codepoint_t glyph,
1170                                              hb_direction_t direction,
1171                                              hb_position_t *x, hb_position_t *y)
1172 {
1173   return font->subtract_glyph_origin_for_direction (glyph, direction, x, y);
1174 }
1175 
1176 /**
1177  * hb_font_get_glyph_kerning_for_direction:
1178  * @font: a font.
1179  * @first_glyph:
1180  * @second_glyph:
1181  * @direction:
1182  * @x: (out):
1183  * @y: (out):
1184  *
1185  *
1186  *
1187  * Since: 0.9.2
1188  * Deprecated: 2.0.0
1189  **/
1190 void
1191 hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
1192                                          hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
1193                                          hb_direction_t direction,
1194                                          hb_position_t *x, hb_position_t *y)
1195 {
1196   return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direction, x, y);
1197 }
1198 
1199 /**
1200  * hb_font_get_glyph_extents_for_origin:
1201  * @font: a font.
1202  * @glyph:
1203  * @direction:
1204  * @extents: (out):
1205  *
1206  *
1207  *
1208  * Return value:


1272  *
1273  *
1274  *
1275  * Return value:
1276  *
1277  * Since: 0.9.2
1278  **/
1279 hb_bool_t
1280 hb_font_glyph_from_string (hb_font_t *font,
1281                            const char *s, int len, /* -1 means nul-terminated */
1282                            hb_codepoint_t *glyph)
1283 {
1284   return font->glyph_from_string (s, len, glyph);
1285 }
1286 
1287 
1288 /*
1289  * hb_font_t
1290  */
1291 
1292 DEFINE_NULL_INSTANCE (hb_font_t) =
1293 {
1294   HB_OBJECT_HEADER_STATIC,
1295 
1296   nullptr, /* parent */
1297   const_cast<hb_face_t *> (&_hb_Null_hb_face_t),
1298 
1299   1000, /* x_scale */
1300   1000, /* y_scale */
1301 
1302   0, /* x_ppem */
1303   0, /* y_ppem */
1304   0, /* ptem */
1305 
1306   0, /* num_coords */
1307   nullptr, /* coords */
1308 
1309   const_cast<hb_font_funcs_t *> (&_hb_Null_hb_font_funcs_t),
1310 
1311   /* Zero for the rest is fine. */
1312 };
1313 
1314 
1315 static hb_font_t *
1316 _hb_font_create (hb_face_t *face)
1317 {
1318   hb_font_t *font;
1319 
1320   if (unlikely (!face))
1321     face = hb_face_get_empty ();
1322   if (!(font = hb_object_create<hb_font_t> ()))
1323     return hb_font_get_empty ();
1324 
1325   hb_face_make_immutable (face);
1326   font->parent = hb_font_get_empty ();
1327   font->face = hb_face_reference (face);
1328   font->klass = hb_font_funcs_get_empty ();
1329   font->data.init0 (font);
1330   font->x_scale = font->y_scale = hb_face_get_upem (face);
1331 
1332   return font;
1333 }
1334 
1335 /**
1336  * hb_font_create: (Xconstructor)
1337  * @face: a face.
1338  *
1339  *
1340  *
1341  * Return value: (transfer full):
1342  *
1343  * Since: 0.9.2
1344  **/
1345 hb_font_t *
1346 hb_font_create (hb_face_t *face)
1347 {
1348   hb_font_t *font = _hb_font_create (face);
1349 
1350   /* Install our in-house, very lightweight, funcs. */
1351   hb_ot_font_set_funcs (font);









1352 
1353   return font;
1354 }
1355 
1356 /**
1357  * hb_font_create_sub_font:
1358  * @parent: parent font.
1359  *
1360  *
1361  *
1362  * Return value: (transfer full):
1363  *
1364  * Since: 0.9.2
1365  **/
1366 hb_font_t *
1367 hb_font_create_sub_font (hb_font_t *parent)
1368 {
1369   if (unlikely (!parent))
1370     parent = hb_font_get_empty ();
1371 
1372   hb_font_t *font = _hb_font_create (parent->face);
1373 
1374   if (unlikely (hb_object_is_immutable (font)))
1375     return font;
1376 
1377   font->parent = hb_font_reference (parent);
1378 
1379   font->x_scale = parent->x_scale;
1380   font->y_scale = parent->y_scale;
1381   font->x_ppem = parent->x_ppem;
1382   font->y_ppem = parent->y_ppem;
1383   font->ptem = parent->ptem;
1384 
1385   font->num_coords = parent->num_coords;
1386   if (!font->num_coords)
1387     font->coords = nullptr;
1388   else
1389   {
1390     unsigned int size = parent->num_coords * sizeof (parent->coords[0]);
1391     font->coords = (int *) malloc (size);
1392     if (unlikely (!font->coords))
1393       font->num_coords = 0;
1394     else
1395       memcpy (font->coords, parent->coords, size);
1396   }
1397 
1398   return font;
1399 }
1400 
1401 /**
1402  * hb_font_get_empty:
1403  *
1404  *
1405  *
1406  * Return value: (transfer full)
1407  *
1408  * Since: 0.9.2
1409  **/
1410 hb_font_t *
1411 hb_font_get_empty ()
1412 {
1413   return const_cast<hb_font_t *> (&Null(hb_font_t));





























1414 }
1415 
1416 /**
1417  * hb_font_reference: (skip)
1418  * @font: a font.
1419  *
1420  *
1421  *
1422  * Return value: (transfer full):
1423  *
1424  * Since: 0.9.2
1425  **/
1426 hb_font_t *
1427 hb_font_reference (hb_font_t *font)
1428 {
1429   return hb_object_reference (font);
1430 }
1431 
1432 /**
1433  * hb_font_destroy: (skip)
1434  * @font: a font.
1435  *
1436  *
1437  *
1438  * Since: 0.9.2
1439  **/
1440 void
1441 hb_font_destroy (hb_font_t *font)
1442 {
1443   if (!hb_object_destroy (font)) return;
1444 
1445   font->data.fini ();


1446 
1447   if (font->destroy)
1448     font->destroy (font->user_data);
1449 
1450   hb_font_destroy (font->parent);
1451   hb_face_destroy (font->face);
1452   hb_font_funcs_destroy (font->klass);
1453 
1454   free (font->coords);
1455 
1456   free (font);
1457 }
1458 
1459 /**
1460  * hb_font_set_user_data: (skip)
1461  * @font: a font.
1462  * @key:
1463  * @data:
1464  * @destroy:
1465  * @replace:


1492  * Since: 0.9.2
1493  **/
1494 void *
1495 hb_font_get_user_data (hb_font_t          *font,
1496                        hb_user_data_key_t *key)
1497 {
1498   return hb_object_get_user_data (font, key);
1499 }
1500 
1501 /**
1502  * hb_font_make_immutable:
1503  * @font: a font.
1504  *
1505  *
1506  *
1507  * Since: 0.9.2
1508  **/
1509 void
1510 hb_font_make_immutable (hb_font_t *font)
1511 {
1512   if (hb_object_is_immutable (font))
1513     return;
1514 
1515   if (font->parent)
1516     hb_font_make_immutable (font->parent);
1517 
1518   hb_object_make_immutable (font);
1519 }
1520 
1521 /**
1522  * hb_font_is_immutable:
1523  * @font: a font.
1524  *
1525  *
1526  *
1527  * Return value:
1528  *
1529  * Since: 0.9.2
1530  **/
1531 hb_bool_t
1532 hb_font_is_immutable (hb_font_t *font)
1533 {
1534   return hb_object_is_immutable (font);
1535 }
1536 
1537 /**
1538  * hb_font_set_parent:
1539  * @font: a font.
1540  * @parent: new parent.
1541  *
1542  * Sets parent font of @font.
1543  *
1544  * Since: 1.0.5
1545  **/
1546 void
1547 hb_font_set_parent (hb_font_t *font,
1548                     hb_font_t *parent)
1549 {
1550   if (hb_object_is_immutable (font))
1551     return;
1552 
1553   if (!parent)
1554     parent = hb_font_get_empty ();
1555 
1556   hb_font_t *old = font->parent;
1557 
1558   font->parent = hb_font_reference (parent);
1559 
1560   hb_font_destroy (old);
1561 }
1562 
1563 /**
1564  * hb_font_get_parent:
1565  * @font: a font.
1566  *
1567  *
1568  *
1569  * Return value: (transfer none):
1570  *


1572  **/
1573 hb_font_t *
1574 hb_font_get_parent (hb_font_t *font)
1575 {
1576   return font->parent;
1577 }
1578 
1579 /**
1580  * hb_font_set_face:
1581  * @font: a font.
1582  * @face: new face.
1583  *
1584  * Sets font-face of @font.
1585  *
1586  * Since: 1.4.3
1587  **/
1588 void
1589 hb_font_set_face (hb_font_t *font,
1590                   hb_face_t *face)
1591 {
1592   if (hb_object_is_immutable (font))
1593     return;
1594 
1595   if (unlikely (!face))
1596     face = hb_face_get_empty ();
1597 
1598   hb_face_t *old = font->face;
1599 
1600   font->face = hb_face_reference (face);
1601 
1602   hb_face_destroy (old);
1603 }
1604 
1605 /**
1606  * hb_font_get_face:
1607  * @font: a font.
1608  *
1609  *
1610  *
1611  * Return value: (transfer none):
1612  *


1619 }
1620 
1621 
1622 /**
1623  * hb_font_set_funcs:
1624  * @font: a font.
1625  * @klass: (closure font_data) (destroy destroy) (scope notified):
1626  * @font_data:
1627  * @destroy:
1628  *
1629  *
1630  *
1631  * Since: 0.9.2
1632  **/
1633 void
1634 hb_font_set_funcs (hb_font_t         *font,
1635                    hb_font_funcs_t   *klass,
1636                    void              *font_data,
1637                    hb_destroy_func_t  destroy)
1638 {
1639   if (hb_object_is_immutable (font))
1640   {
1641     if (destroy)
1642       destroy (font_data);
1643     return;
1644   }
1645 
1646   if (font->destroy)
1647     font->destroy (font->user_data);
1648 
1649   if (!klass)
1650     klass = hb_font_funcs_get_empty ();
1651 
1652   hb_font_funcs_reference (klass);
1653   hb_font_funcs_destroy (font->klass);
1654   font->klass = klass;
1655   font->user_data = font_data;
1656   font->destroy = destroy;
1657 }
1658 
1659 /**
1660  * hb_font_set_funcs_data:
1661  * @font: a font.
1662  * @font_data: (destroy destroy) (scope notified):
1663  * @destroy:
1664  *
1665  *
1666  *
1667  * Since: 0.9.2
1668  **/
1669 void
1670 hb_font_set_funcs_data (hb_font_t         *font,
1671                         void              *font_data,
1672                         hb_destroy_func_t  destroy)
1673 {
1674   /* Destroy user_data? */
1675   if (hb_object_is_immutable (font))
1676   {
1677     if (destroy)
1678       destroy (font_data);
1679     return;
1680   }
1681 
1682   if (font->destroy)
1683     font->destroy (font->user_data);
1684 
1685   font->user_data = font_data;
1686   font->destroy = destroy;
1687 }
1688 
1689 
1690 /**
1691  * hb_font_set_scale:
1692  * @font: a font.
1693  * @x_scale:
1694  * @y_scale:
1695  *
1696  *
1697  *
1698  * Since: 0.9.2
1699  **/
1700 void
1701 hb_font_set_scale (hb_font_t *font,
1702                    int x_scale,
1703                    int y_scale)
1704 {
1705   if (hb_object_is_immutable (font))
1706     return;
1707 
1708   font->x_scale = x_scale;
1709   font->y_scale = y_scale;
1710 }
1711 
1712 /**
1713  * hb_font_get_scale:
1714  * @font: a font.
1715  * @x_scale: (out):
1716  * @y_scale: (out):
1717  *
1718  *
1719  *
1720  * Since: 0.9.2
1721  **/
1722 void
1723 hb_font_get_scale (hb_font_t *font,
1724                    int *x_scale,
1725                    int *y_scale)
1726 {
1727   if (x_scale) *x_scale = font->x_scale;
1728   if (y_scale) *y_scale = font->y_scale;
1729 }
1730 
1731 /**
1732  * hb_font_set_ppem:
1733  * @font: a font.
1734  * @x_ppem:
1735  * @y_ppem:
1736  *
1737  *
1738  *
1739  * Since: 0.9.2
1740  **/
1741 void
1742 hb_font_set_ppem (hb_font_t *font,
1743                   unsigned int x_ppem,
1744                   unsigned int y_ppem)
1745 {
1746   if (hb_object_is_immutable (font))
1747     return;
1748 
1749   font->x_ppem = x_ppem;
1750   font->y_ppem = y_ppem;
1751 }
1752 
1753 /**
1754  * hb_font_get_ppem:
1755  * @font: a font.
1756  * @x_ppem: (out):
1757  * @y_ppem: (out):
1758  *
1759  *
1760  *
1761  * Since: 0.9.2
1762  **/
1763 void
1764 hb_font_get_ppem (hb_font_t *font,
1765                   unsigned int *x_ppem,
1766                   unsigned int *y_ppem)
1767 {
1768   if (x_ppem) *x_ppem = font->x_ppem;
1769   if (y_ppem) *y_ppem = font->y_ppem;
1770 }
1771 
1772 /**
1773  * hb_font_set_ptem:
1774  * @font: a font.
1775  * @ptem: font size in points.
1776  *
1777  * Sets "point size" of the font.  Set to 0 to unset.
1778  *
1779  * There are 72 points in an inch.
1780  *
1781  * Since: 1.6.0
1782  **/
1783 void
1784 hb_font_set_ptem (hb_font_t *font, float ptem)
1785 {
1786   if (hb_object_is_immutable (font))
1787     return;
1788 
1789   font->ptem = ptem;
1790 }
1791 
1792 /**
1793  * hb_font_get_ptem:
1794  * @font: a font.
1795  *
1796  * Gets the "point size" of the font.  A value of 0 means unset.
1797  *
1798  * Return value: Point size.
1799  *
1800  * Since: 0.9.2
1801  **/
1802 float
1803 hb_font_get_ptem (hb_font_t *font)
1804 {
1805   return font->ptem;
1806 }


1813 _hb_font_adopt_var_coords_normalized (hb_font_t *font,
1814                                       int *coords, /* 2.14 normalized */
1815                                       unsigned int coords_length)
1816 {
1817   free (font->coords);
1818 
1819   font->coords = coords;
1820   font->num_coords = coords_length;
1821 }
1822 
1823 /**
1824  * hb_font_set_variations:
1825  *
1826  * Since: 1.4.2
1827  */
1828 void
1829 hb_font_set_variations (hb_font_t *font,
1830                         const hb_variation_t *variations,
1831                         unsigned int variations_length)
1832 {
1833   if (hb_object_is_immutable (font))
1834     return;
1835 
1836   if (!variations_length)
1837   {
1838     hb_font_set_var_coords_normalized (font, nullptr, 0);
1839     return;
1840   }
1841 
1842   unsigned int coords_length = hb_ot_var_get_axis_count (font->face);
1843 
1844   int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr;
1845   if (unlikely (coords_length && !normalized))
1846     return;
1847 
1848   hb_ot_var_normalize_variations (font->face,
1849                                   variations, variations_length,
1850                                   normalized, coords_length);
1851   _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
1852 }
1853 
1854 /**
1855  * hb_font_set_var_coords_design:
1856  *
1857  * Since: 1.4.2
1858  */
1859 void
1860 hb_font_set_var_coords_design (hb_font_t *font,
1861                                const float *coords,
1862                                unsigned int coords_length)
1863 {
1864   if (hb_object_is_immutable (font))
1865     return;
1866 
1867   int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : nullptr;
1868   if (unlikely (coords_length && !normalized))
1869     return;
1870 
1871   hb_ot_var_normalize_coords (font->face, coords_length, coords, normalized);
1872   _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
1873 }
1874 
1875 /**
1876  * hb_font_set_var_coords_normalized:
1877  *
1878  * Since: 1.4.2
1879  */
1880 void
1881 hb_font_set_var_coords_normalized (hb_font_t *font,
1882                                    const int *coords, /* 2.14 normalized */
1883                                    unsigned int coords_length)
1884 {
1885   if (hb_object_is_immutable (font))
1886     return;
1887 
1888   int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : nullptr;
1889   if (unlikely (coords_length && !copy))
1890     return;
1891 
1892   if (coords_length)
1893     memcpy (copy, coords, coords_length * sizeof (coords[0]));
1894 
1895   _hb_font_adopt_var_coords_normalized (font, copy, coords_length);
1896 }
1897 
1898 /**
1899  * hb_font_get_var_coords_normalized:
1900  *
1901  * Return value is valid as long as variation coordinates of the font
1902  * are not modified.
1903  *
1904  * Since: 1.4.2
1905  */
1906 const int *
1907 hb_font_get_var_coords_normalized (hb_font_t *font,
1908                                    unsigned int *length)
1909 {
1910   if (length)
1911     *length = font->num_coords;
1912 
1913   return font->coords;
1914 }
1915 
1916 


1917 /*
1918  * Deprecated get_glyph_func():
1919  */
1920 
1921 struct hb_trampoline_closure_t
1922 {
1923   void *user_data;
1924   hb_destroy_func_t destroy;
1925   unsigned int ref_count;
1926 };
1927 
1928 template <typename FuncType>
1929 struct hb_trampoline_t
1930 {
1931   hb_trampoline_closure_t closure; /* Must be first. */
1932   FuncType func;
1933 };
1934 
1935 template <typename FuncType>
1936 static hb_trampoline_t<FuncType> *


1983 {
1984   hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t *) user_data;
1985   return trampoline->func (font, font_data, unicode, 0, glyph, trampoline->closure.user_data);
1986 }
1987 
1988 static hb_bool_t
1989 hb_font_get_variation_glyph_trampoline (hb_font_t *font,
1990                                         void *font_data,
1991                                         hb_codepoint_t unicode,
1992                                         hb_codepoint_t variation_selector,
1993                                         hb_codepoint_t *glyph,
1994                                         void *user_data)
1995 {
1996   hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t *) user_data;
1997   return trampoline->func (font, font_data, unicode, variation_selector, glyph, trampoline->closure.user_data);
1998 }
1999 
2000 /**
2001  * hb_font_funcs_set_glyph_func:
2002  * @ffuncs: font functions.
2003  * @func: (closure user_data) (destroy destroy) (scope notified): callback function.
2004  * @user_data: data to pass to @func.
2005  * @destroy: function to call when @user_data is not needed anymore.
2006  *
2007  * Deprecated.  Use hb_font_funcs_set_nominal_glyph_func() and
2008  * hb_font_funcs_set_variation_glyph_func() instead.
2009  *
2010  * Since: 0.9.2
2011  * Deprecated: 1.2.3
2012  **/
2013 void
2014 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
2015                               hb_font_get_glyph_func_t func,
2016                               void *user_data, hb_destroy_func_t destroy)
2017 {
2018   hb_font_get_glyph_trampoline_t *trampoline;
2019 
2020   trampoline = trampoline_create (func, user_data, destroy);
2021   if (unlikely (!trampoline))
2022   {
2023     if (destroy)
2024       destroy (user_data);
2025     return;
2026   }
2027 
2028   hb_font_funcs_set_nominal_glyph_func (ffuncs,
2029                                         hb_font_get_nominal_glyph_trampoline,
2030                                         trampoline,
2031                                         trampoline_destroy);
2032 
2033   trampoline_reference (&trampoline->closure);
2034   hb_font_funcs_set_variation_glyph_func (ffuncs,
2035                                           hb_font_get_variation_glyph_trampoline,
2036                                           trampoline,
2037                                           trampoline_destroy);
2038 }


< prev index next >