hb-ft.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright © 2009 Red Hat, Inc.
  3. *
  4. * This is part of HarfBuzz, a text shaping library.
  5. *
  6. * Permission is hereby granted, without written agreement and without
  7. * license or royalty fees, to use, copy, modify, and distribute this
  8. * software and its documentation for any purpose, provided that the
  9. * above copyright notice and the following two paragraphs appear in
  10. * all copies of this software.
  11. *
  12. * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
  13. * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  14. * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  15. * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  16. * DAMAGE.
  17. *
  18. * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  19. * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  20. * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
  21. * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  22. * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  23. *
  24. * Red Hat Author(s): Behdad Esfahbod
  25. */
  26. #ifndef HB_FT_H
  27. #define HB_FT_H
  28. #include "hb.h"
  29. #include <ft2build.h>
  30. #include FT_FREETYPE_H
  31. HB_BEGIN_DECLS
  32. /*
  33. * Note: FreeType is not thread-safe.
  34. * Hence, these functions are not either.
  35. */
  36. /*
  37. * hb-face from ft-face.
  38. */
  39. /* This one creates a new hb-face for given ft-face.
  40. * When the returned hb-face is destroyed, the destroy
  41. * callback is called (if not NULL), with the ft-face passed
  42. * to it.
  43. *
  44. * The client is responsible to make sure that ft-face is
  45. * destroyed after hb-face is destroyed.
  46. *
  47. * Most often you don't want this function. You should use either
  48. * hb_ft_face_create_cached(), or hb_ft_face_create_referenced().
  49. * In particular, if you are going to pass NULL as destroy, you
  50. * probably should use (the more recent) hb_ft_face_create_referenced()
  51. * instead.
  52. */
  53. hb_face_t *
  54. hb_ft_face_create (FT_Face ft_face,
  55. hb_destroy_func_t destroy);
  56. /* This version is like hb_ft_face_create(), except that it caches
  57. * the hb-face using the generic pointer of the ft-face. This means
  58. * that subsequent calls to this function with the same ft-face will
  59. * return the same hb-face (correctly referenced).
  60. *
  61. * Client is still responsible for making sure that ft-face is destroyed
  62. * after hb-face is.
  63. */
  64. hb_face_t *
  65. hb_ft_face_create_cached (FT_Face ft_face);
  66. /* This version is like hb_ft_face_create(), except that it calls
  67. * FT_Reference_Face() on ft-face, as such keeping ft-face alive
  68. * as long as the hb-face is.
  69. *
  70. * This is the most convenient version to use. Use it unless you have
  71. * very good reasons not to.
  72. */
  73. hb_face_t *
  74. hb_ft_face_create_referenced (FT_Face ft_face);
  75. /*
  76. * hb-font from ft-face.
  77. */
  78. /*
  79. * Note:
  80. *
  81. * Set face size on ft-face before creating hb-font from it.
  82. * Otherwise hb-ft would NOT pick up the font size correctly.
  83. */
  84. /* See notes on hb_ft_face_create(). Same issues re lifecycle-management
  85. * apply here. Use hb_ft_font_create_referenced() if you can. */
  86. hb_font_t *
  87. hb_ft_font_create (FT_Face ft_face,
  88. hb_destroy_func_t destroy);
  89. /* See notes on hb_ft_face_create_referenced() re lifecycle-management
  90. * issues. */
  91. hb_font_t *
  92. hb_ft_font_create_referenced (FT_Face ft_face);
  93. /* Makes an hb_font_t use FreeType internally to implement font functions. */
  94. void
  95. hb_ft_font_set_funcs (hb_font_t *font);
  96. FT_Face
  97. hb_ft_font_get_face (hb_font_t *font);
  98. HB_END_DECLS
  99. #endif /* HB_FT_H */