aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pillow/py2/libImaging/raqm.h
blob: 92c6368b6ae5124e5bab821b4f321ea38b6fe233 (plain) (blame)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
 * Copyright © 2015 Information Technology Authority (ITA) <foss@ita.gov.om>
 * Copyright © 2016 Khaled Hosny <khaledhosny@eglug.org>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 *
 */

#ifndef _RAQM_H_
#define _RAQM_H_

#ifdef HAVE_CONFIG_H
#error #include "config.h"
#endif

#ifndef bool
typedef int bool;
#endif
#ifndef uint32_t
typedef UINT32 uint32_t;
#endif
#include <ft2build.h>
#include FT_FREETYPE_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * raqm_t:
 *
 * This is the main object holding all state of the currently processed text as
 * well as its output.
 *
 * Since: 0.1
 */
typedef struct _raqm raqm_t;

/**
 * raqm_direction_t:
 * @RAQM_DIRECTION_DEFAULT: Detect paragraph direction automatically.
 * @RAQM_DIRECTION_RTL: Paragraph is mainly right-to-left text.
 * @RAQM_DIRECTION_LTR: Paragraph is mainly left-to-right text.
 * @RAQM_DIRECTION_TTB: Paragraph is mainly vertical top-to-bottom text.
 *
 * Base paragraph direction, see raqm_set_par_direction().
 *
 * Since: 0.1
 */
typedef enum
{
    RAQM_DIRECTION_DEFAULT,
    RAQM_DIRECTION_RTL,
    RAQM_DIRECTION_LTR,
    RAQM_DIRECTION_TTB
} raqm_direction_t;

/**
 * raqm_glyph_t:
 * @index: the index of the glyph in the font file.
 * @x_advance: the glyph advance width in horizontal text.
 * @y_advance: the glyph advance width in vertical text.
 * @x_offset: the horizontal movement of the glyph from the current point.
 * @y_offset: the vertical movement of the glyph from the current point.
 * @cluster: the index of original character in input text.
 * @ftface: the @FT_Face of the glyph.
 *
 * The structure that holds information about output glyphs, returned from
 * raqm_get_glyphs().
 */
typedef struct raqm_glyph_t {
    unsigned int index;
    int x_advance;
    int y_advance;
    int x_offset;
    int y_offset;
    uint32_t cluster;
    FT_Face ftface;
} raqm_glyph_t;

/**
 * version 0.1 of the raqm_glyph_t structure
 */
typedef struct raqm_glyph_t_01 {
    unsigned int index;
    int x_advance;
    int y_advance;
    int x_offset;
    int y_offset;
    uint32_t cluster;
} raqm_glyph_t_01;


raqm_t *
raqm_create (void);

raqm_t *
raqm_reference (raqm_t *rq);

void
raqm_destroy (raqm_t *rq);

bool
raqm_set_text (raqm_t         *rq,
               const uint32_t *text,
               size_t          len);

bool
raqm_set_text_utf8 (raqm_t     *rq,
                    const char *text,
                    size_t      len);

bool
raqm_set_par_direction (raqm_t          *rq,
                        raqm_direction_t dir);

bool
raqm_set_language (raqm_t       *rq,
                   const char   *lang,
                   size_t        start,
                   size_t        len);

bool
raqm_add_font_feature  (raqm_t     *rq,
                        const char *feature,
                        int         len);

bool
raqm_set_freetype_face (raqm_t *rq,
                        FT_Face face);

bool
raqm_set_freetype_face_range (raqm_t *rq,
                              FT_Face face,
                              size_t  start,
                              size_t  len);

bool
raqm_set_freetype_load_flags (raqm_t *rq,
                              int flags);

bool
raqm_layout (raqm_t *rq);

raqm_glyph_t *
raqm_get_glyphs (raqm_t *rq,
                 size_t *length);

bool
raqm_index_to_position (raqm_t *rq,
                        size_t *index,
                        int *x,
                        int *y);

bool
raqm_position_to_index (raqm_t *rq,
                        int x,
                        int y,
                        size_t *index);

#ifdef __cplusplus
}
#endif
#endif /* _RAQM_H_ */