-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibatures.h
112 lines (100 loc) · 3.1 KB
/
libatures.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/** \file libatures.h
*/
#pragma once
#ifdef BUILDING_LIBATURES
#if defined _WIN32 || defined __CYGWIN__
#define LIBATURES_PUBLIC __declspec(dllexport)
#else
#define LIBATURES_PUBLIC __attribute__ ((visibility ("default")))
#endif
#else
#define LIBATURES_PUBLIC
#endif
#include <stdint.h>
#include <stddef.h>
typedef struct LBT_ChainCreator LBT_ChainCreator;
typedef struct LBT_Chain LBT_Chain;
typedef uint16_t LBT_Glyph;
typedef const unsigned char (LBT_tag)[4];
#if !defined(NO_FREETYPE)
#include <ft2build.h>
#include FT_FREETYPE_H
/**
* \brief Create an LBT_ChainCreator from a FreeType font face.
*
* \param[in] face
*/
LBT_ChainCreator LIBATURES_PUBLIC *LBT_new(FT_Face face);
#endif
/**
* \brief Create an LBT_ChainCreator from a given GSUB table.
*
* The tables passed to this function will be fully managed by `libatures`, and
* will be freed by ::LBT_destroy.
*
* \see ::LBT_new
*
* \param[in] GSUB_table
*/
LBT_ChainCreator LIBATURES_PUBLIC *LBT_new_from_tables(uint8_t *GSUB_table);
/**
* \brief Destroy an LBT_ChainCreator
*
* Call this only after every LBT_Chain generated from the specified
* LBT_ChainCreator is destroyed.
*
* \param[in,out] cc
*/
void LIBATURES_PUBLIC LBT_destroy(LBT_ChainCreator* cc);
/**
* \brief Generate a chain of glyph substitutions.
*
* No feature is enabled by default, so you must specify all of them.
*
* The feature order doesn't have any effect on the output as Lookups are
* executed in Lookup order.
*
* To use the required feature, if any, use the feature tag \c{' ', 'R', 'Q', 'D'}\c.
*
* Needs to be destroyed by ::LBT_destroy_chain.
*
* \param[in] cc
* \param[in] script Set to `NULL` to use the default script
* \param[in] lang Set to `NULL` to use the default language
* \param[in] features
* \param[in] n_features
*/
LBT_Chain LIBATURES_PUBLIC *LBT_generate_chain(const LBT_ChainCreator *cc,
LBT_tag *script,
LBT_tag *lang,
LBT_tag *features,
size_t n_features);
/**
* \brief Apply chain to an `LBT_Glyph` array.
*
* This function is not thread-safe. Create multiple chains to execute them in
* parallel.
*
* \param[in] chain
* \param[in] glyph_array Array of glyphs to "ligate".
* \param[in] n_input_glyphs Number of glyphs in `glyph_array`.
* \param[out] n_output_glyphs Number of glyphs returned.
* \return Array of "ligated" glyphs.
*/
LBT_Glyph LIBATURES_PUBLIC *LBT_apply_chain(const LBT_Chain *chain,
const LBT_Glyph* glyph_array,
size_t n_input_glyphs,
size_t *n_output_glyphs);
/**
* \brief Destroy a Chain.
*
* This will not free the relative FreeType tables.
* The generated `GlyphArray`s are still usable.
*
* \param[in,out] chain
*/
void LIBATURES_PUBLIC LBT_destroy_chain(LBT_Chain *chain);
/**
* \brief Make a tag from a string.
*/
#define LBT_make_tag(str) { (str)[0], (str)[1], (str)[2], (str)[3] }