hb-ft.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright © 2009 Red Hat, Inc.
  3. * Copyright © 2015 Google, Inc.
  4. *
  5. * This is part of HarfBuzz, a text shaping library.
  6. *
  7. * Permission is hereby granted, without written agreement and without
  8. * license or royalty fees, to use, copy, modify, and distribute this
  9. * software and its documentation for any purpose, provided that the
  10. * above copyright notice and the following two paragraphs appear in
  11. * all copies of this software.
  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. #ifndef HB_FT_H
  29. #define HB_FT_H
  30. #include "hb.h"
  31. #include <ft2build.h>
  32. #include FT_FREETYPE_H
  33. HB_BEGIN_DECLS
  34. /*
  35. * Note: FreeType is not thread-safe.
  36. * Hence, these functions are not either.
  37. */
  38. /*
  39. * hb-face from ft-face.
  40. */
  41. /* This one creates a new hb-face for given ft-face.
  42. * When the returned hb-face is destroyed, the destroy
  43. * callback is called (if not NULL), with the ft-face passed
  44. * to it.
  45. *
  46. * The client is responsible to make sure that ft-face is
  47. * destroyed after hb-face is destroyed.
  48. *
  49. * Most often you don't want this function. You should use either
  50. * hb_ft_face_create_cached(), or hb_ft_face_create_referenced().
  51. * In particular, if you are going to pass NULL as destroy, you
  52. * probably should use (the more recent) hb_ft_face_create_referenced()
  53. * instead.
  54. */
  55. HB_EXTERN hb_face_t *
  56. hb_ft_face_create (FT_Face ft_face,
  57. hb_destroy_func_t destroy);
  58. /* This version is like hb_ft_face_create(), except that it caches
  59. * the hb-face using the generic pointer of the ft-face. This means
  60. * that subsequent calls to this function with the same ft-face will
  61. * return the same hb-face (correctly referenced).
  62. *
  63. * Client is still responsible for making sure that ft-face is destroyed
  64. * after hb-face is.
  65. */
  66. HB_EXTERN hb_face_t *
  67. hb_ft_face_create_cached (FT_Face ft_face);
  68. /* This version is like hb_ft_face_create(), except that it calls
  69. * FT_Reference_Face() on ft-face, as such keeping ft-face alive
  70. * as long as the hb-face is.
  71. *
  72. * This is the most convenient version to use. Use it unless you have
  73. * very good reasons not to.
  74. */
  75. HB_EXTERN hb_face_t *
  76. hb_ft_face_create_referenced (FT_Face ft_face);
  77. /*
  78. * hb-font from ft-face.
  79. */
  80. /*
  81. * Note:
  82. *
  83. * Set face size on ft-face before creating hb-font from it.
  84. * Otherwise hb-ft would NOT pick up the font size correctly.
  85. */
  86. /* See notes on hb_ft_face_create(). Same issues re lifecycle-management
  87. * apply here. Use hb_ft_font_create_referenced() if you can. */
  88. HB_EXTERN hb_font_t *
  89. hb_ft_font_create (FT_Face ft_face,
  90. hb_destroy_func_t destroy);
  91. /* See notes on hb_ft_face_create_referenced() re lifecycle-management
  92. * issues. */
  93. HB_EXTERN hb_font_t *
  94. hb_ft_font_create_referenced (FT_Face ft_face);
  95. HB_EXTERN FT_Face
  96. hb_ft_font_get_face (hb_font_t *font);
  97. HB_EXTERN void
  98. hb_ft_font_set_load_flags (hb_font_t *font, int load_flags);
  99. HB_EXTERN int
  100. hb_ft_font_get_load_flags (hb_font_t *font);
  101. /* Call when size or variations settings on underlying FT_Face change. */
  102. HB_EXTERN void
  103. hb_ft_font_changed (hb_font_t *font);
  104. /* Makes an hb_font_t use FreeType internally to implement font functions.
  105. * Note: this internally creates an FT_Face. Use it when you create your
  106. * hb_face_t using hb_face_create(). */
  107. HB_EXTERN void
  108. hb_ft_font_set_funcs (hb_font_t *font);
  109. HB_END_DECLS
  110. #endif /* HB_FT_H */