hb-font.h 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  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. #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
  27. #error "Include <hb.h> instead."
  28. #endif
  29. #ifndef HB_FONT_H
  30. #define HB_FONT_H
  31. #include "hb-common.h"
  32. #include "hb-face.h"
  33. #include "hb-draw.h"
  34. HB_BEGIN_DECLS
  35. /**
  36. * hb_font_t:
  37. *
  38. * Data type for holding fonts.
  39. *
  40. */
  41. typedef struct hb_font_t hb_font_t;
  42. /*
  43. * hb_font_funcs_t
  44. */
  45. /**
  46. * hb_font_funcs_t:
  47. *
  48. * Data type containing a set of virtual methods used for
  49. * working on #hb_font_t font objects.
  50. *
  51. * HarfBuzz provides a lightweight default function for each of
  52. * the methods in #hb_font_funcs_t. Client programs can implement
  53. * their own replacements for the individual font functions, as
  54. * needed, and replace the default by calling the setter for a
  55. * method.
  56. *
  57. **/
  58. typedef struct hb_font_funcs_t hb_font_funcs_t;
  59. HB_EXTERN hb_font_funcs_t *
  60. hb_font_funcs_create (void);
  61. HB_EXTERN hb_font_funcs_t *
  62. hb_font_funcs_get_empty (void);
  63. HB_EXTERN hb_font_funcs_t *
  64. hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
  65. HB_EXTERN void
  66. hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
  67. HB_EXTERN hb_bool_t
  68. hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
  69. hb_user_data_key_t *key,
  70. void * data,
  71. hb_destroy_func_t destroy,
  72. hb_bool_t replace);
  73. HB_EXTERN void *
  74. hb_font_funcs_get_user_data (const hb_font_funcs_t *ffuncs,
  75. hb_user_data_key_t *key);
  76. HB_EXTERN void
  77. hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
  78. HB_EXTERN hb_bool_t
  79. hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
  80. /* font and glyph extents */
  81. /**
  82. * hb_font_extents_t:
  83. * @ascender: The height of typographic ascenders.
  84. * @descender: The depth of typographic descenders.
  85. * @line_gap: The suggested line-spacing gap.
  86. *
  87. * Font-wide extent values, measured in font units.
  88. *
  89. * Note that typically @ascender is positive and @descender
  90. * negative, in coordinate systems that grow up.
  91. **/
  92. typedef struct hb_font_extents_t {
  93. hb_position_t ascender;
  94. hb_position_t descender;
  95. hb_position_t line_gap;
  96. /*< private >*/
  97. hb_position_t reserved9;
  98. hb_position_t reserved8;
  99. hb_position_t reserved7;
  100. hb_position_t reserved6;
  101. hb_position_t reserved5;
  102. hb_position_t reserved4;
  103. hb_position_t reserved3;
  104. hb_position_t reserved2;
  105. hb_position_t reserved1;
  106. } hb_font_extents_t;
  107. /**
  108. * hb_glyph_extents_t:
  109. * @x_bearing: Distance from the x-origin to the left extremum of the glyph.
  110. * @y_bearing: Distance from the top extremum of the glyph to the y-origin.
  111. * @width: Distance from the left extremum of the glyph to the right extremum.
  112. * @height: Distance from the top extremum of the glyph to the bottom extremum.
  113. *
  114. * Glyph extent values, measured in font units.
  115. *
  116. * Note that @height is negative, in coordinate systems that grow up.
  117. **/
  118. typedef struct hb_glyph_extents_t {
  119. hb_position_t x_bearing;
  120. hb_position_t y_bearing;
  121. hb_position_t width;
  122. hb_position_t height;
  123. } hb_glyph_extents_t;
  124. /* func types */
  125. /**
  126. * hb_font_get_font_extents_func_t:
  127. * @font: #hb_font_t to work upon
  128. * @font_data: @font user data pointer
  129. * @extents: (out): The font extents retrieved
  130. * @user_data: User data pointer passed by the caller
  131. *
  132. * This method should retrieve the extents for a font.
  133. *
  134. **/
  135. typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *font_data,
  136. hb_font_extents_t *extents,
  137. void *user_data);
  138. /**
  139. * hb_font_get_font_h_extents_func_t:
  140. *
  141. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  142. *
  143. * This method should retrieve the extents for a font, for horizontal-direction
  144. * text segments. Extents must be returned in an #hb_glyph_extents output
  145. * parameter.
  146. *
  147. **/
  148. typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t;
  149. /**
  150. * hb_font_get_font_v_extents_func_t:
  151. *
  152. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  153. *
  154. * This method should retrieve the extents for a font, for vertical-direction
  155. * text segments. Extents must be returned in an #hb_glyph_extents output
  156. * parameter.
  157. *
  158. **/
  159. typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t;
  160. /**
  161. * hb_font_get_nominal_glyph_func_t:
  162. * @font: #hb_font_t to work upon
  163. * @font_data: @font user data pointer
  164. * @unicode: The Unicode code point to query
  165. * @glyph: (out): The glyph ID retrieved
  166. * @user_data: User data pointer passed by the caller
  167. *
  168. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  169. *
  170. * This method should retrieve the nominal glyph ID for a specified Unicode code
  171. * point. Glyph IDs must be returned in a #hb_codepoint_t output parameter.
  172. *
  173. * Return value: `true` if data found, `false` otherwise
  174. *
  175. **/
  176. typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *font_data,
  177. hb_codepoint_t unicode,
  178. hb_codepoint_t *glyph,
  179. void *user_data);
  180. /**
  181. * hb_font_get_variation_glyph_func_t:
  182. * @font: #hb_font_t to work upon
  183. * @font_data: @font user data pointer
  184. * @unicode: The Unicode code point to query
  185. * @variation_selector: The variation-selector code point to query
  186. * @glyph: (out): The glyph ID retrieved
  187. * @user_data: User data pointer passed by the caller
  188. *
  189. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  190. *
  191. * This method should retrieve the glyph ID for a specified Unicode code point
  192. * followed by a specified Variation Selector code point. Glyph IDs must be
  193. * returned in a #hb_codepoint_t output parameter.
  194. *
  195. * Return value: `true` if data found, `false` otherwise
  196. *
  197. **/
  198. typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void *font_data,
  199. hb_codepoint_t unicode, hb_codepoint_t variation_selector,
  200. hb_codepoint_t *glyph,
  201. void *user_data);
  202. /**
  203. * hb_font_get_nominal_glyphs_func_t:
  204. * @font: #hb_font_t to work upon
  205. * @font_data: @font user data pointer
  206. * @count: number of code points to query
  207. * @first_unicode: The first Unicode code point to query
  208. * @unicode_stride: The stride between successive code points
  209. * @first_glyph: (out): The first glyph ID retrieved
  210. * @glyph_stride: The stride between successive glyph IDs
  211. * @user_data: User data pointer passed by the caller
  212. *
  213. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  214. *
  215. * This method should retrieve the nominal glyph IDs for a sequence of
  216. * Unicode code points. Glyph IDs must be returned in a #hb_codepoint_t
  217. * output parameter.
  218. *
  219. * Return value: the number of code points processed
  220. *
  221. **/
  222. typedef unsigned int (*hb_font_get_nominal_glyphs_func_t) (hb_font_t *font, void *font_data,
  223. unsigned int count,
  224. const hb_codepoint_t *first_unicode,
  225. unsigned int unicode_stride,
  226. hb_codepoint_t *first_glyph,
  227. unsigned int glyph_stride,
  228. void *user_data);
  229. /**
  230. * hb_font_get_glyph_advance_func_t:
  231. * @font: #hb_font_t to work upon
  232. * @font_data: @font user data pointer
  233. * @glyph: The glyph ID to query
  234. * @user_data: User data pointer passed by the caller
  235. *
  236. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  237. *
  238. * This method should retrieve the advance for a specified glyph. The
  239. * method must return an #hb_position_t.
  240. *
  241. * Return value: The advance of @glyph within @font
  242. *
  243. **/
  244. typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data,
  245. hb_codepoint_t glyph,
  246. void *user_data);
  247. /**
  248. * hb_font_get_glyph_h_advance_func_t:
  249. *
  250. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  251. *
  252. * This method should retrieve the advance for a specified glyph, in
  253. * horizontal-direction text segments. Advances must be returned in
  254. * an #hb_position_t output parameter.
  255. *
  256. **/
  257. typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t;
  258. /**
  259. * hb_font_get_glyph_v_advance_func_t:
  260. *
  261. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  262. *
  263. * This method should retrieve the advance for a specified glyph, in
  264. * vertical-direction text segments. Advances must be returned in
  265. * an #hb_position_t output parameter.
  266. *
  267. **/
  268. typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t;
  269. /**
  270. * hb_font_get_glyph_advances_func_t:
  271. * @font: #hb_font_t to work upon
  272. * @font_data: @font user data pointer
  273. * @count: The number of glyph IDs in the sequence queried
  274. * @first_glyph: The first glyph ID to query
  275. * @glyph_stride: The stride between successive glyph IDs
  276. * @first_advance: (out): The first advance retrieved
  277. * @advance_stride: The stride between successive advances
  278. * @user_data: User data pointer passed by the caller
  279. *
  280. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  281. *
  282. * This method should retrieve the advances for a sequence of glyphs.
  283. *
  284. **/
  285. typedef void (*hb_font_get_glyph_advances_func_t) (hb_font_t* font, void* font_data,
  286. unsigned int count,
  287. const hb_codepoint_t *first_glyph,
  288. unsigned glyph_stride,
  289. hb_position_t *first_advance,
  290. unsigned advance_stride,
  291. void *user_data);
  292. /**
  293. * hb_font_get_glyph_h_advances_func_t:
  294. *
  295. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  296. *
  297. * This method should retrieve the advances for a sequence of glyphs, in
  298. * horizontal-direction text segments.
  299. *
  300. **/
  301. typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_h_advances_func_t;
  302. /**
  303. * hb_font_get_glyph_v_advances_func_t:
  304. *
  305. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  306. *
  307. * This method should retrieve the advances for a sequence of glyphs, in
  308. * vertical-direction text segments.
  309. *
  310. **/
  311. typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t;
  312. /**
  313. * hb_font_get_glyph_origin_func_t:
  314. * @font: #hb_font_t to work upon
  315. * @font_data: @font user data pointer
  316. * @glyph: The glyph ID to query
  317. * @x: (out): The X coordinate of the origin
  318. * @y: (out): The Y coordinate of the origin
  319. * @user_data: User data pointer passed by the caller
  320. *
  321. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  322. *
  323. * This method should retrieve the (X,Y) coordinates (in font units) of the
  324. * origin for a glyph. Each coordinate must be returned in an #hb_position_t
  325. * output parameter.
  326. *
  327. * Return value: `true` if data found, `false` otherwise
  328. *
  329. **/
  330. typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data,
  331. hb_codepoint_t glyph,
  332. hb_position_t *x, hb_position_t *y,
  333. void *user_data);
  334. /**
  335. * hb_font_get_glyph_h_origin_func_t:
  336. *
  337. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  338. *
  339. * This method should retrieve the (X,Y) coordinates (in font units) of the
  340. * origin for a glyph, for horizontal-direction text segments. Each
  341. * coordinate must be returned in an #hb_position_t output parameter.
  342. *
  343. **/
  344. typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
  345. /**
  346. * hb_font_get_glyph_v_origin_func_t:
  347. *
  348. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  349. *
  350. * This method should retrieve the (X,Y) coordinates (in font units) of the
  351. * origin for a glyph, for vertical-direction text segments. Each coordinate
  352. * must be returned in an #hb_position_t output parameter.
  353. *
  354. **/
  355. typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
  356. /**
  357. * hb_font_get_glyph_kerning_func_t:
  358. * @font: #hb_font_t to work upon
  359. * @font_data: @font user data pointer
  360. * @first_glyph: The glyph ID of the first glyph in the glyph pair
  361. * @second_glyph: The glyph ID of the second glyph in the glyph pair
  362. * @user_data: User data pointer passed by the caller
  363. *
  364. * This method should retrieve the kerning-adjustment value for a glyph-pair in
  365. * the specified font, for horizontal text segments.
  366. *
  367. **/
  368. typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data,
  369. hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
  370. void *user_data);
  371. /**
  372. * hb_font_get_glyph_h_kerning_func_t:
  373. *
  374. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  375. *
  376. * This method should retrieve the kerning-adjustment value for a glyph-pair in
  377. * the specified font, for horizontal text segments.
  378. *
  379. **/
  380. typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t;
  381. /**
  382. * hb_font_get_glyph_extents_func_t:
  383. * @font: #hb_font_t to work upon
  384. * @font_data: @font user data pointer
  385. * @glyph: The glyph ID to query
  386. * @extents: (out): The #hb_glyph_extents_t retrieved
  387. * @user_data: User data pointer passed by the caller
  388. *
  389. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  390. *
  391. * This method should retrieve the extents for a specified glyph. Extents must be
  392. * returned in an #hb_glyph_extents output parameter.
  393. *
  394. * Return value: `true` if data found, `false` otherwise
  395. *
  396. **/
  397. typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data,
  398. hb_codepoint_t glyph,
  399. hb_glyph_extents_t *extents,
  400. void *user_data);
  401. /**
  402. * hb_font_get_glyph_contour_point_func_t:
  403. * @font: #hb_font_t to work upon
  404. * @font_data: @font user data pointer
  405. * @glyph: The glyph ID to query
  406. * @point_index: The contour-point index to query
  407. * @x: (out): The X value retrieved for the contour point
  408. * @y: (out): The Y value retrieved for the contour point
  409. * @user_data: User data pointer passed by the caller
  410. *
  411. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  412. *
  413. * This method should retrieve the (X,Y) coordinates (in font units) for a
  414. * specified contour point in a glyph. Each coordinate must be returned as
  415. * an #hb_position_t output parameter.
  416. *
  417. * Return value: `true` if data found, `false` otherwise
  418. *
  419. **/
  420. typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data,
  421. hb_codepoint_t glyph, unsigned int point_index,
  422. hb_position_t *x, hb_position_t *y,
  423. void *user_data);
  424. /**
  425. * hb_font_get_glyph_name_func_t:
  426. * @font: #hb_font_t to work upon
  427. * @font_data: @font user data pointer
  428. * @glyph: The glyph ID to query
  429. * @name: (out) (array length=size): Name string retrieved for the glyph ID
  430. * @size: Length of the glyph-name string retrieved
  431. * @user_data: User data pointer passed by the caller
  432. *
  433. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  434. *
  435. * This method should retrieve the glyph name that corresponds to a
  436. * glyph ID. The name should be returned in a string output parameter.
  437. *
  438. * Return value: `true` if data found, `false` otherwise
  439. *
  440. **/
  441. typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data,
  442. hb_codepoint_t glyph,
  443. char *name, unsigned int size,
  444. void *user_data);
  445. /**
  446. * hb_font_get_glyph_from_name_func_t:
  447. * @font: #hb_font_t to work upon
  448. * @font_data: @font user data pointer
  449. * @name: (array length=len): The name string to query
  450. * @len: The length of the name queried
  451. * @glyph: (out): The glyph ID retrieved
  452. * @user_data: User data pointer passed by the caller
  453. *
  454. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  455. *
  456. * This method should retrieve the glyph ID that corresponds to a glyph-name
  457. * string.
  458. *
  459. * Return value: `true` if data found, `false` otherwise
  460. *
  461. **/
  462. typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data,
  463. const char *name, int len, /* -1 means nul-terminated */
  464. hb_codepoint_t *glyph,
  465. void *user_data);
  466. /**
  467. * hb_font_get_glyph_shape_func_t:
  468. * @font: #hb_font_t to work upon
  469. * @font_data: @font user data pointer
  470. * @glyph: The glyph ID to query
  471. * @draw_funcs: The draw functions to send the shape data to
  472. * @draw_data: The data accompanying the draw functions
  473. * @user_data: User data pointer passed by the caller
  474. *
  475. * A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
  476. *
  477. * Since: 4.0.0
  478. *
  479. **/
  480. typedef void (*hb_font_get_glyph_shape_func_t) (hb_font_t *font, void *font_data,
  481. hb_codepoint_t glyph,
  482. hb_draw_funcs_t *draw_funcs, void *draw_data,
  483. void *user_data);
  484. /* func setters */
  485. /**
  486. * hb_font_funcs_set_font_h_extents_func:
  487. * @ffuncs: A font-function structure
  488. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  489. * @user_data: Data to pass to @func
  490. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  491. *
  492. * Sets the implementation function for #hb_font_get_font_h_extents_func_t.
  493. *
  494. * Since: 1.1.2
  495. **/
  496. HB_EXTERN void
  497. hb_font_funcs_set_font_h_extents_func (hb_font_funcs_t *ffuncs,
  498. hb_font_get_font_h_extents_func_t func,
  499. void *user_data, hb_destroy_func_t destroy);
  500. /**
  501. * hb_font_funcs_set_font_v_extents_func:
  502. * @ffuncs: A font-function structure
  503. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  504. * @user_data: Data to pass to @func
  505. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  506. *
  507. * Sets the implementation function for #hb_font_get_font_v_extents_func_t.
  508. *
  509. * Since: 1.1.2
  510. **/
  511. HB_EXTERN void
  512. hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs,
  513. hb_font_get_font_v_extents_func_t func,
  514. void *user_data, hb_destroy_func_t destroy);
  515. /**
  516. * hb_font_funcs_set_nominal_glyph_func:
  517. * @ffuncs: A font-function structure
  518. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  519. * @user_data: Data to pass to @func
  520. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  521. *
  522. * Sets the implementation function for #hb_font_get_nominal_glyph_func_t.
  523. *
  524. * Since: 1.2.3
  525. **/
  526. HB_EXTERN void
  527. hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs,
  528. hb_font_get_nominal_glyph_func_t func,
  529. void *user_data, hb_destroy_func_t destroy);
  530. /**
  531. * hb_font_funcs_set_nominal_glyphs_func:
  532. * @ffuncs: A font-function structure
  533. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  534. * @user_data: Data to pass to @func
  535. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  536. *
  537. * Sets the implementation function for #hb_font_get_nominal_glyphs_func_t.
  538. *
  539. * Since: 2.0.0
  540. **/
  541. HB_EXTERN void
  542. hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs,
  543. hb_font_get_nominal_glyphs_func_t func,
  544. void *user_data, hb_destroy_func_t destroy);
  545. /**
  546. * hb_font_funcs_set_variation_glyph_func:
  547. * @ffuncs: A font-function structure
  548. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  549. * @user_data: Data to pass to @func
  550. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  551. *
  552. * Sets the implementation function for #hb_font_get_variation_glyph_func_t.
  553. *
  554. * Since: 1.2.3
  555. **/
  556. HB_EXTERN void
  557. hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t *ffuncs,
  558. hb_font_get_variation_glyph_func_t func,
  559. void *user_data, hb_destroy_func_t destroy);
  560. /**
  561. * hb_font_funcs_set_glyph_h_advance_func:
  562. * @ffuncs: A font-function structure
  563. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  564. * @user_data: Data to pass to @func
  565. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  566. *
  567. * Sets the implementation function for #hb_font_get_glyph_h_advance_func_t.
  568. *
  569. * Since: 0.9.2
  570. **/
  571. HB_EXTERN void
  572. hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs,
  573. hb_font_get_glyph_h_advance_func_t func,
  574. void *user_data, hb_destroy_func_t destroy);
  575. /**
  576. * hb_font_funcs_set_glyph_v_advance_func:
  577. * @ffuncs: A font-function structure
  578. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  579. * @user_data: Data to pass to @func
  580. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  581. *
  582. * Sets the implementation function for #hb_font_get_glyph_v_advance_func_t.
  583. *
  584. * Since: 0.9.2
  585. **/
  586. HB_EXTERN void
  587. hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs,
  588. hb_font_get_glyph_v_advance_func_t func,
  589. void *user_data, hb_destroy_func_t destroy);
  590. /**
  591. * hb_font_funcs_set_glyph_h_advances_func:
  592. * @ffuncs: A font-function structure
  593. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  594. * @user_data: Data to pass to @func
  595. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  596. *
  597. * Sets the implementation function for #hb_font_get_glyph_h_advances_func_t.
  598. *
  599. * Since: 1.8.6
  600. **/
  601. HB_EXTERN void
  602. hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs,
  603. hb_font_get_glyph_h_advances_func_t func,
  604. void *user_data, hb_destroy_func_t destroy);
  605. /**
  606. * hb_font_funcs_set_glyph_v_advances_func:
  607. * @ffuncs: A font-function structure
  608. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  609. * @user_data: Data to pass to @func
  610. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  611. *
  612. * Sets the implementation function for #hb_font_get_glyph_v_advances_func_t.
  613. *
  614. * Since: 1.8.6
  615. **/
  616. HB_EXTERN void
  617. hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs,
  618. hb_font_get_glyph_v_advances_func_t func,
  619. void *user_data, hb_destroy_func_t destroy);
  620. /**
  621. * hb_font_funcs_set_glyph_h_origin_func:
  622. * @ffuncs: A font-function structure
  623. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  624. * @user_data: Data to pass to @func
  625. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  626. *
  627. * Sets the implementation function for #hb_font_get_glyph_h_origin_func_t.
  628. *
  629. * Since: 0.9.2
  630. **/
  631. HB_EXTERN void
  632. hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs,
  633. hb_font_get_glyph_h_origin_func_t func,
  634. void *user_data, hb_destroy_func_t destroy);
  635. /**
  636. * hb_font_funcs_set_glyph_v_origin_func:
  637. * @ffuncs: A font-function structure
  638. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  639. * @user_data: Data to pass to @func
  640. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  641. *
  642. * Sets the implementation function for #hb_font_get_glyph_v_origin_func_t.
  643. *
  644. * Since: 0.9.2
  645. **/
  646. HB_EXTERN void
  647. hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
  648. hb_font_get_glyph_v_origin_func_t func,
  649. void *user_data, hb_destroy_func_t destroy);
  650. /**
  651. * hb_font_funcs_set_glyph_h_kerning_func:
  652. * @ffuncs: A font-function structure
  653. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  654. * @user_data: Data to pass to @func
  655. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  656. *
  657. * Sets the implementation function for #hb_font_get_glyph_h_kerning_func_t.
  658. *
  659. * Since: 0.9.2
  660. **/
  661. HB_EXTERN void
  662. hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs,
  663. hb_font_get_glyph_h_kerning_func_t func,
  664. void *user_data, hb_destroy_func_t destroy);
  665. /**
  666. * hb_font_funcs_set_glyph_extents_func:
  667. * @ffuncs: A font-function structure
  668. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  669. * @user_data: Data to pass to @func
  670. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  671. *
  672. * Sets the implementation function for #hb_font_get_glyph_extents_func_t.
  673. *
  674. * Since: 0.9.2
  675. **/
  676. HB_EXTERN void
  677. hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
  678. hb_font_get_glyph_extents_func_t func,
  679. void *user_data, hb_destroy_func_t destroy);
  680. /**
  681. * hb_font_funcs_set_glyph_contour_point_func:
  682. * @ffuncs: A font-function structure
  683. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  684. * @user_data: Data to pass to @func
  685. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  686. *
  687. * Sets the implementation function for #hb_font_get_glyph_contour_point_func_t.
  688. *
  689. * Since: 0.9.2
  690. **/
  691. HB_EXTERN void
  692. hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs,
  693. hb_font_get_glyph_contour_point_func_t func,
  694. void *user_data, hb_destroy_func_t destroy);
  695. /**
  696. * hb_font_funcs_set_glyph_name_func:
  697. * @ffuncs: A font-function structure
  698. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  699. * @user_data: Data to pass to @func
  700. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  701. *
  702. * Sets the implementation function for #hb_font_get_glyph_name_func_t.
  703. *
  704. * Since: 0.9.2
  705. **/
  706. HB_EXTERN void
  707. hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs,
  708. hb_font_get_glyph_name_func_t func,
  709. void *user_data, hb_destroy_func_t destroy);
  710. /**
  711. * hb_font_funcs_set_glyph_from_name_func:
  712. * @ffuncs: A font-function structure
  713. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  714. * @user_data: Data to pass to @func
  715. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  716. *
  717. * Sets the implementation function for #hb_font_get_glyph_from_name_func_t.
  718. *
  719. * Since: 0.9.2
  720. **/
  721. HB_EXTERN void
  722. hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
  723. hb_font_get_glyph_from_name_func_t func,
  724. void *user_data, hb_destroy_func_t destroy);
  725. /**
  726. * hb_font_funcs_set_glyph_shape_func:
  727. * @ffuncs: A font-function structure
  728. * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
  729. * @user_data: Data to pass to @func
  730. * @destroy: (nullable): The function to call when @user_data is not needed anymore
  731. *
  732. * Sets the implementation function for #hb_font_get_glyph_shape_func_t.
  733. *
  734. * Since: 4.0.0
  735. **/
  736. HB_EXTERN void
  737. hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs,
  738. hb_font_get_glyph_shape_func_t func,
  739. void *user_data, hb_destroy_func_t destroy);
  740. /* func dispatch */
  741. HB_EXTERN hb_bool_t
  742. hb_font_get_h_extents (hb_font_t *font,
  743. hb_font_extents_t *extents);
  744. HB_EXTERN hb_bool_t
  745. hb_font_get_v_extents (hb_font_t *font,
  746. hb_font_extents_t *extents);
  747. HB_EXTERN hb_bool_t
  748. hb_font_get_nominal_glyph (hb_font_t *font,
  749. hb_codepoint_t unicode,
  750. hb_codepoint_t *glyph);
  751. HB_EXTERN hb_bool_t
  752. hb_font_get_variation_glyph (hb_font_t *font,
  753. hb_codepoint_t unicode, hb_codepoint_t variation_selector,
  754. hb_codepoint_t *glyph);
  755. HB_EXTERN unsigned int
  756. hb_font_get_nominal_glyphs (hb_font_t *font,
  757. unsigned int count,
  758. const hb_codepoint_t *first_unicode,
  759. unsigned int unicode_stride,
  760. hb_codepoint_t *first_glyph,
  761. unsigned int glyph_stride);
  762. HB_EXTERN hb_position_t
  763. hb_font_get_glyph_h_advance (hb_font_t *font,
  764. hb_codepoint_t glyph);
  765. HB_EXTERN hb_position_t
  766. hb_font_get_glyph_v_advance (hb_font_t *font,
  767. hb_codepoint_t glyph);
  768. HB_EXTERN void
  769. hb_font_get_glyph_h_advances (hb_font_t* font,
  770. unsigned int count,
  771. const hb_codepoint_t *first_glyph,
  772. unsigned glyph_stride,
  773. hb_position_t *first_advance,
  774. unsigned advance_stride);
  775. HB_EXTERN void
  776. hb_font_get_glyph_v_advances (hb_font_t* font,
  777. unsigned int count,
  778. const hb_codepoint_t *first_glyph,
  779. unsigned glyph_stride,
  780. hb_position_t *first_advance,
  781. unsigned advance_stride);
  782. HB_EXTERN hb_bool_t
  783. hb_font_get_glyph_h_origin (hb_font_t *font,
  784. hb_codepoint_t glyph,
  785. hb_position_t *x, hb_position_t *y);
  786. HB_EXTERN hb_bool_t
  787. hb_font_get_glyph_v_origin (hb_font_t *font,
  788. hb_codepoint_t glyph,
  789. hb_position_t *x, hb_position_t *y);
  790. HB_EXTERN hb_position_t
  791. hb_font_get_glyph_h_kerning (hb_font_t *font,
  792. hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
  793. HB_EXTERN hb_bool_t
  794. hb_font_get_glyph_extents (hb_font_t *font,
  795. hb_codepoint_t glyph,
  796. hb_glyph_extents_t *extents);
  797. HB_EXTERN hb_bool_t
  798. hb_font_get_glyph_contour_point (hb_font_t *font,
  799. hb_codepoint_t glyph, unsigned int point_index,
  800. hb_position_t *x, hb_position_t *y);
  801. HB_EXTERN hb_bool_t
  802. hb_font_get_glyph_name (hb_font_t *font,
  803. hb_codepoint_t glyph,
  804. char *name, unsigned int size);
  805. HB_EXTERN hb_bool_t
  806. hb_font_get_glyph_from_name (hb_font_t *font,
  807. const char *name, int len, /* -1 means nul-terminated */
  808. hb_codepoint_t *glyph);
  809. HB_EXTERN void
  810. hb_font_get_glyph_shape (hb_font_t *font,
  811. hb_codepoint_t glyph,
  812. hb_draw_funcs_t *dfuncs, void *draw_data);
  813. /* high-level funcs, with fallback */
  814. /* Calls either hb_font_get_nominal_glyph() if variation_selector is 0,
  815. * otherwise calls hb_font_get_variation_glyph(). */
  816. HB_EXTERN hb_bool_t
  817. hb_font_get_glyph (hb_font_t *font,
  818. hb_codepoint_t unicode, hb_codepoint_t variation_selector,
  819. hb_codepoint_t *glyph);
  820. HB_EXTERN void
  821. hb_font_get_extents_for_direction (hb_font_t *font,
  822. hb_direction_t direction,
  823. hb_font_extents_t *extents);
  824. HB_EXTERN void
  825. hb_font_get_glyph_advance_for_direction (hb_font_t *font,
  826. hb_codepoint_t glyph,
  827. hb_direction_t direction,
  828. hb_position_t *x, hb_position_t *y);
  829. HB_EXTERN void
  830. hb_font_get_glyph_advances_for_direction (hb_font_t* font,
  831. hb_direction_t direction,
  832. unsigned int count,
  833. const hb_codepoint_t *first_glyph,
  834. unsigned glyph_stride,
  835. hb_position_t *first_advance,
  836. unsigned advance_stride);
  837. HB_EXTERN void
  838. hb_font_get_glyph_origin_for_direction (hb_font_t *font,
  839. hb_codepoint_t glyph,
  840. hb_direction_t direction,
  841. hb_position_t *x, hb_position_t *y);
  842. HB_EXTERN void
  843. hb_font_add_glyph_origin_for_direction (hb_font_t *font,
  844. hb_codepoint_t glyph,
  845. hb_direction_t direction,
  846. hb_position_t *x, hb_position_t *y);
  847. HB_EXTERN void
  848. hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
  849. hb_codepoint_t glyph,
  850. hb_direction_t direction,
  851. hb_position_t *x, hb_position_t *y);
  852. HB_EXTERN void
  853. hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
  854. hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
  855. hb_direction_t direction,
  856. hb_position_t *x, hb_position_t *y);
  857. HB_EXTERN hb_bool_t
  858. hb_font_get_glyph_extents_for_origin (hb_font_t *font,
  859. hb_codepoint_t glyph,
  860. hb_direction_t direction,
  861. hb_glyph_extents_t *extents);
  862. HB_EXTERN hb_bool_t
  863. hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
  864. hb_codepoint_t glyph, unsigned int point_index,
  865. hb_direction_t direction,
  866. hb_position_t *x, hb_position_t *y);
  867. /* Generates gidDDD if glyph has no name. */
  868. HB_EXTERN void
  869. hb_font_glyph_to_string (hb_font_t *font,
  870. hb_codepoint_t glyph,
  871. char *s, unsigned int size);
  872. /* Parses gidDDD and uniUUUU strings automatically. */
  873. HB_EXTERN hb_bool_t
  874. hb_font_glyph_from_string (hb_font_t *font,
  875. const char *s, int len, /* -1 means nul-terminated */
  876. hb_codepoint_t *glyph);
  877. /*
  878. * hb_font_t
  879. */
  880. /* Fonts are very light-weight objects */
  881. HB_EXTERN hb_font_t *
  882. hb_font_create (hb_face_t *face);
  883. HB_EXTERN hb_font_t *
  884. hb_font_create_sub_font (hb_font_t *parent);
  885. HB_EXTERN hb_font_t *
  886. hb_font_get_empty (void);
  887. HB_EXTERN hb_font_t *
  888. hb_font_reference (hb_font_t *font);
  889. HB_EXTERN void
  890. hb_font_destroy (hb_font_t *font);
  891. HB_EXTERN hb_bool_t
  892. hb_font_set_user_data (hb_font_t *font,
  893. hb_user_data_key_t *key,
  894. void * data,
  895. hb_destroy_func_t destroy,
  896. hb_bool_t replace);
  897. HB_EXTERN void *
  898. hb_font_get_user_data (const hb_font_t *font,
  899. hb_user_data_key_t *key);
  900. HB_EXTERN void
  901. hb_font_make_immutable (hb_font_t *font);
  902. HB_EXTERN hb_bool_t
  903. hb_font_is_immutable (hb_font_t *font);
  904. HB_EXTERN unsigned int
  905. hb_font_get_serial (hb_font_t *font);
  906. HB_EXTERN void
  907. hb_font_changed (hb_font_t *font);
  908. HB_EXTERN void
  909. hb_font_set_parent (hb_font_t *font,
  910. hb_font_t *parent);
  911. HB_EXTERN hb_font_t *
  912. hb_font_get_parent (hb_font_t *font);
  913. HB_EXTERN void
  914. hb_font_set_face (hb_font_t *font,
  915. hb_face_t *face);
  916. HB_EXTERN hb_face_t *
  917. hb_font_get_face (hb_font_t *font);
  918. HB_EXTERN void
  919. hb_font_set_funcs (hb_font_t *font,
  920. hb_font_funcs_t *klass,
  921. void *font_data,
  922. hb_destroy_func_t destroy);
  923. /* Be *very* careful with this function! */
  924. HB_EXTERN void
  925. hb_font_set_funcs_data (hb_font_t *font,
  926. void *font_data,
  927. hb_destroy_func_t destroy);
  928. HB_EXTERN void
  929. hb_font_set_scale (hb_font_t *font,
  930. int x_scale,
  931. int y_scale);
  932. HB_EXTERN void
  933. hb_font_get_scale (hb_font_t *font,
  934. int *x_scale,
  935. int *y_scale);
  936. /*
  937. * A zero value means "no hinting in that direction"
  938. */
  939. HB_EXTERN void
  940. hb_font_set_ppem (hb_font_t *font,
  941. unsigned int x_ppem,
  942. unsigned int y_ppem);
  943. HB_EXTERN void
  944. hb_font_get_ppem (hb_font_t *font,
  945. unsigned int *x_ppem,
  946. unsigned int *y_ppem);
  947. /*
  948. * Point size per EM. Used for optical-sizing in CoreText.
  949. * A value of zero means "not set".
  950. */
  951. HB_EXTERN void
  952. hb_font_set_ptem (hb_font_t *font, float ptem);
  953. HB_EXTERN float
  954. hb_font_get_ptem (hb_font_t *font);
  955. HB_EXTERN void
  956. hb_font_set_synthetic_slant (hb_font_t *font, float slant);
  957. HB_EXTERN float
  958. hb_font_get_synthetic_slant (hb_font_t *font);
  959. HB_EXTERN void
  960. hb_font_set_variations (hb_font_t *font,
  961. const hb_variation_t *variations,
  962. unsigned int variations_length);
  963. HB_EXTERN void
  964. hb_font_set_var_coords_design (hb_font_t *font,
  965. const float *coords,
  966. unsigned int coords_length);
  967. HB_EXTERN const float *
  968. hb_font_get_var_coords_design (hb_font_t *font,
  969. unsigned int *length);
  970. HB_EXTERN void
  971. hb_font_set_var_coords_normalized (hb_font_t *font,
  972. const int *coords, /* 2.14 normalized */
  973. unsigned int coords_length);
  974. HB_EXTERN const int *
  975. hb_font_get_var_coords_normalized (hb_font_t *font,
  976. unsigned int *length);
  977. HB_EXTERN void
  978. hb_font_set_var_named_instance (hb_font_t *font,
  979. unsigned instance_index);
  980. HB_END_DECLS
  981. #endif /* HB_FONT_H */