ftadvanc.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /****************************************************************************
  2. *
  3. * ftadvanc.h
  4. *
  5. * Quick computation of advance widths (specification only).
  6. *
  7. * Copyright (C) 2008-2023 by
  8. * David Turner, Robert Wilhelm, and Werner Lemberg.
  9. *
  10. * This file is part of the FreeType project, and may only be used,
  11. * modified, and distributed under the terms of the FreeType project
  12. * license, LICENSE.TXT. By continuing to use, modify, or distribute
  13. * this file you indicate that you have read the license and
  14. * understand and accept it fully.
  15. *
  16. */
  17. #ifndef FTADVANC_H_
  18. #define FTADVANC_H_
  19. #include <freetype/freetype.h>
  20. #ifdef FREETYPE_H
  21. #error "freetype.h of FreeType 1 has been loaded!"
  22. #error "Please fix the directory search order for header files"
  23. #error "so that freetype.h of FreeType 2 is found first."
  24. #endif
  25. FT_BEGIN_HEADER
  26. /**************************************************************************
  27. *
  28. * @section:
  29. * quick_advance
  30. *
  31. * @title:
  32. * Quick retrieval of advance values
  33. *
  34. * @abstract:
  35. * Retrieve horizontal and vertical advance values without processing
  36. * glyph outlines, if possible.
  37. *
  38. * @description:
  39. * This section contains functions to quickly extract advance values
  40. * without handling glyph outlines, if possible.
  41. *
  42. * @order:
  43. * FT_Get_Advance
  44. * FT_Get_Advances
  45. *
  46. */
  47. /**************************************************************************
  48. *
  49. * @enum:
  50. * FT_ADVANCE_FLAG_FAST_ONLY
  51. *
  52. * @description:
  53. * A bit-flag to be OR-ed with the `flags` parameter of the
  54. * @FT_Get_Advance and @FT_Get_Advances functions.
  55. *
  56. * If set, it indicates that you want these functions to fail if the
  57. * corresponding hinting mode or font driver doesn't allow for very quick
  58. * advance computation.
  59. *
  60. * Typically, glyphs that are either unscaled, unhinted, bitmapped, or
  61. * light-hinted can have their advance width computed very quickly.
  62. *
  63. * Normal and bytecode hinted modes that require loading, scaling, and
  64. * hinting of the glyph outline, are extremely slow by comparison.
  65. */
  66. #define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L
  67. /**************************************************************************
  68. *
  69. * @function:
  70. * FT_Get_Advance
  71. *
  72. * @description:
  73. * Retrieve the advance value of a given glyph outline in an @FT_Face.
  74. *
  75. * @input:
  76. * face ::
  77. * The source @FT_Face handle.
  78. *
  79. * gindex ::
  80. * The glyph index.
  81. *
  82. * load_flags ::
  83. * A set of bit flags similar to those used when calling
  84. * @FT_Load_Glyph, used to determine what kind of advances you need.
  85. *
  86. * @output:
  87. * padvance ::
  88. * The advance value. If scaling is performed (based on the value of
  89. * `load_flags`), the advance value is in 16.16 format. Otherwise, it
  90. * is in font units.
  91. *
  92. * If @FT_LOAD_VERTICAL_LAYOUT is set, this is the vertical advance
  93. * corresponding to a vertical layout. Otherwise, it is the horizontal
  94. * advance in a horizontal layout.
  95. *
  96. * @return:
  97. * FreeType error code. 0 means success.
  98. *
  99. * @note:
  100. * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if
  101. * the corresponding font backend doesn't have a quick way to retrieve
  102. * the advances.
  103. *
  104. * A scaled advance is returned in 16.16 format but isn't transformed by
  105. * the affine transformation specified by @FT_Set_Transform.
  106. */
  107. FT_EXPORT( FT_Error )
  108. FT_Get_Advance( FT_Face face,
  109. FT_UInt gindex,
  110. FT_Int32 load_flags,
  111. FT_Fixed *padvance );
  112. /**************************************************************************
  113. *
  114. * @function:
  115. * FT_Get_Advances
  116. *
  117. * @description:
  118. * Retrieve the advance values of several glyph outlines in an @FT_Face.
  119. *
  120. * @input:
  121. * face ::
  122. * The source @FT_Face handle.
  123. *
  124. * start ::
  125. * The first glyph index.
  126. *
  127. * count ::
  128. * The number of advance values you want to retrieve.
  129. *
  130. * load_flags ::
  131. * A set of bit flags similar to those used when calling
  132. * @FT_Load_Glyph.
  133. *
  134. * @output:
  135. * padvance ::
  136. * The advance values. This array, to be provided by the caller, must
  137. * contain at least `count` elements.
  138. *
  139. * If scaling is performed (based on the value of `load_flags`), the
  140. * advance values are in 16.16 format. Otherwise, they are in font
  141. * units.
  142. *
  143. * If @FT_LOAD_VERTICAL_LAYOUT is set, these are the vertical advances
  144. * corresponding to a vertical layout. Otherwise, they are the
  145. * horizontal advances in a horizontal layout.
  146. *
  147. * @return:
  148. * FreeType error code. 0 means success.
  149. *
  150. * @note:
  151. * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if
  152. * the corresponding font backend doesn't have a quick way to retrieve
  153. * the advances.
  154. *
  155. * Scaled advances are returned in 16.16 format but aren't transformed by
  156. * the affine transformation specified by @FT_Set_Transform.
  157. */
  158. FT_EXPORT( FT_Error )
  159. FT_Get_Advances( FT_Face face,
  160. FT_UInt start,
  161. FT_UInt count,
  162. FT_Int32 load_flags,
  163. FT_Fixed *padvances );
  164. /* */
  165. FT_END_HEADER
  166. #endif /* FTADVANC_H_ */
  167. /* END */