< prev index next >

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

Print this page




  16  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  17  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  18  * DAMAGE.
  19  *
  20  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  21  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  22  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  23  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  24  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  25  *
  26  * Red Hat Author(s): Behdad Esfahbod
  27  * Google Author(s): Behdad Esfahbod
  28  */
  29 
  30 #include "hb-private.hh"
  31 
  32 #include "hb-ft.h"
  33 
  34 #include "hb-font-private.hh"
  35 


  36 #include FT_ADVANCES_H

  37 #include FT_TRUETYPE_TABLES_H
  38 
  39 
  40 
  41 #ifndef HB_DEBUG_FT
  42 #define HB_DEBUG_FT (HB_DEBUG+0)
  43 #endif
  44 
  45 
  46 /* TODO:
  47  *
  48  * In general, this file does a fine job of what it's supposed to do.
  49  * There are, however, things that need more work:
  50  *
  51  *   - I remember seeing FT_Get_Advance() without the NO_HINTING flag to be buggy.
  52  *     Have not investigated.
  53  *
  54  *   - FreeType works in 26.6 mode.  Clients can decide to use that mode, and everything
  55  *     would work fine.  However, we also abuse this API for performing in font-space,
  56  *     but don't pass the correct flags to FreeType.  We just abuse the no-hinting mode


 589  * @ft_face: (destroy destroy) (scope notified):
 590  * @destroy:
 591  *
 592  *
 593  *
 594  * Return value: (transfer full):
 595  * Since: 0.9.2
 596  **/
 597 hb_font_t *
 598 hb_ft_font_create (FT_Face           ft_face,
 599                    hb_destroy_func_t destroy)
 600 {
 601   hb_font_t *font;
 602   hb_face_t *face;
 603 
 604   face = hb_ft_face_create (ft_face, destroy);
 605   font = hb_font_create (face);
 606   hb_face_destroy (face);
 607   _hb_ft_font_set_funcs (font, ft_face, false);
 608   hb_font_set_scale (font,
 609                      (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16),
 610                      (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16));
 611 #if 0 /* hb-ft works in no-hinting model */
 612   hb_font_set_ppem (font,
 613                     ft_face->size->metrics.x_ppem,
 614                     ft_face->size->metrics.y_ppem);
 615 #endif
 616 

















 617   return font;
 618 }
 619 
 620 /**
 621  * hb_ft_font_create_referenced:
 622  * @ft_face:
 623  *
 624  *
 625  *
 626  * Return value: (transfer full):
 627  * Since: 0.9.38
 628  **/
 629 hb_font_t *
 630 hb_ft_font_create_referenced (FT_Face ft_face)
 631 {
 632   FT_Reference_Face (ft_face);
 633   return hb_ft_font_create (ft_face, (hb_destroy_func_t) _hb_ft_face_destroy);
 634 }
 635 
 636 




  16  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  17  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  18  * DAMAGE.
  19  *
  20  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  21  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  22  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  23  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  24  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  25  *
  26  * Red Hat Author(s): Behdad Esfahbod
  27  * Google Author(s): Behdad Esfahbod
  28  */
  29 
  30 #include "hb-private.hh"
  31 
  32 #include "hb-ft.h"
  33 
  34 #include "hb-font-private.hh"
  35 
  36 #include "hb-cache-private.hh" // Maybe use in the future?
  37 
  38 #include FT_ADVANCES_H
  39 #include FT_MULTIPLE_MASTERS_H
  40 #include FT_TRUETYPE_TABLES_H
  41 
  42 
  43 
  44 #ifndef HB_DEBUG_FT
  45 #define HB_DEBUG_FT (HB_DEBUG+0)
  46 #endif
  47 
  48 
  49 /* TODO:
  50  *
  51  * In general, this file does a fine job of what it's supposed to do.
  52  * There are, however, things that need more work:
  53  *
  54  *   - I remember seeing FT_Get_Advance() without the NO_HINTING flag to be buggy.
  55  *     Have not investigated.
  56  *
  57  *   - FreeType works in 26.6 mode.  Clients can decide to use that mode, and everything
  58  *     would work fine.  However, we also abuse this API for performing in font-space,
  59  *     but don't pass the correct flags to FreeType.  We just abuse the no-hinting mode


 592  * @ft_face: (destroy destroy) (scope notified): 
 593  * @destroy:
 594  *
 595  * 
 596  *
 597  * Return value: (transfer full): 
 598  * Since: 0.9.2
 599  **/
 600 hb_font_t *
 601 hb_ft_font_create (FT_Face           ft_face,
 602                    hb_destroy_func_t destroy)
 603 {
 604   hb_font_t *font;
 605   hb_face_t *face;
 606 
 607   face = hb_ft_face_create (ft_face, destroy);
 608   font = hb_font_create (face);
 609   hb_face_destroy (face);
 610   _hb_ft_font_set_funcs (font, ft_face, false);
 611   hb_font_set_scale (font,
 612                      (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16),
 613                      (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1u<<15)) >> 16));
 614 #if 0 /* hb-ft works in no-hinting model */
 615   hb_font_set_ppem (font,
 616                     ft_face->size->metrics.x_ppem,
 617                     ft_face->size->metrics.y_ppem);
 618 #endif
 619 
 620 #ifdef HAVE_FT_GET_VAR_BLEND_COORDINATES
 621   FT_MM_Var *mm_var = NULL;
 622   if (!FT_Get_MM_Var (ft_face, &mm_var))
 623   {
 624     FT_Fixed coords[mm_var->num_axis];
 625     int hbCoords[mm_var->num_axis];
 626     if (!FT_Get_Var_Blend_Coordinates (ft_face, mm_var->num_axis, coords))
 627     {
 628       for (int i = 0; i < mm_var->num_axis; ++i)
 629         hbCoords[i] = coords[i] >> 2;
 630 
 631       hb_font_set_var_coords_normalized (font, hbCoords, mm_var->num_axis);
 632     }
 633   }
 634   free (mm_var);
 635 #endif
 636 
 637   return font;
 638 }
 639 
 640 /**
 641  * hb_ft_font_create_referenced:
 642  * @ft_face:
 643  *
 644  * 
 645  *
 646  * Return value: (transfer full): 
 647  * Since: 0.9.38
 648  **/
 649 hb_font_t *
 650 hb_ft_font_create_referenced (FT_Face ft_face)
 651 {
 652   FT_Reference_Face (ft_face);
 653   return hb_ft_font_create (ft_face, (hb_destroy_func_t) _hb_ft_face_destroy);
 654 }
 655 
 656 


< prev index next >