jpayne@69
|
1 /* GRAPHITE2 LICENSING
|
jpayne@69
|
2
|
jpayne@69
|
3 Copyright 2010, SIL International
|
jpayne@69
|
4 All rights reserved.
|
jpayne@69
|
5
|
jpayne@69
|
6 This library is free software; you can redistribute it and/or modify
|
jpayne@69
|
7 it under the terms of the GNU Lesser General Public License as published
|
jpayne@69
|
8 by the Free Software Foundation; either version 2.1 of License, or
|
jpayne@69
|
9 (at your option) any later version.
|
jpayne@69
|
10
|
jpayne@69
|
11 This program is distributed in the hope that it will be useful,
|
jpayne@69
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jpayne@69
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
jpayne@69
|
14 Lesser General Public License for more details.
|
jpayne@69
|
15
|
jpayne@69
|
16 You should also have received a copy of the GNU Lesser General Public
|
jpayne@69
|
17 License along with this library in the file named "LICENSE".
|
jpayne@69
|
18 If not, write to the Free Software Foundation, 51 Franklin Street,
|
jpayne@69
|
19 Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
|
jpayne@69
|
20 internet at http://www.fsf.org/licenses/lgpl.html.
|
jpayne@69
|
21
|
jpayne@69
|
22 Alternatively, the contents of this file may be used under the terms
|
jpayne@69
|
23 of the Mozilla Public License (http://mozilla.org/MPL) or the GNU
|
jpayne@69
|
24 General Public License, as published by the Free Software Foundation,
|
jpayne@69
|
25 either version 2 of the License or (at your option) any later version.
|
jpayne@69
|
26 */
|
jpayne@69
|
27 #pragma once
|
jpayne@69
|
28
|
jpayne@69
|
29 #include "graphite2/Types.h"
|
jpayne@69
|
30 #include "graphite2/Font.h"
|
jpayne@69
|
31
|
jpayne@69
|
32 #ifdef __cplusplus
|
jpayne@69
|
33 extern "C"
|
jpayne@69
|
34 {
|
jpayne@69
|
35 #endif
|
jpayne@69
|
36
|
jpayne@69
|
37 enum gr_break_weight {
|
jpayne@69
|
38 gr_breakNone = 0,
|
jpayne@69
|
39 /* after break weights */
|
jpayne@69
|
40 gr_breakWhitespace = 10,
|
jpayne@69
|
41 gr_breakWord = 15,
|
jpayne@69
|
42 gr_breakIntra = 20,
|
jpayne@69
|
43 gr_breakLetter = 30,
|
jpayne@69
|
44 gr_breakClip = 40,
|
jpayne@69
|
45 /* before break weights */
|
jpayne@69
|
46 gr_breakBeforeWhitespace = -10,
|
jpayne@69
|
47 gr_breakBeforeWord = -15,
|
jpayne@69
|
48 gr_breakBeforeIntra = -20,
|
jpayne@69
|
49 gr_breakBeforeLetter = -30,
|
jpayne@69
|
50 gr_breakBeforeClip = -40
|
jpayne@69
|
51 };
|
jpayne@69
|
52
|
jpayne@69
|
53 enum gr_justFlags {
|
jpayne@69
|
54 /// Indicates that this segment is a complete line
|
jpayne@69
|
55 gr_justCompleteLine = 0,
|
jpayne@69
|
56 /// Indicates that the start of the slot list is not at the start of a line
|
jpayne@69
|
57 gr_justStartInline = 1,
|
jpayne@69
|
58 /// Indicates that the end of the slot list is not at the end of a line
|
jpayne@69
|
59 gr_justEndInline = 2
|
jpayne@69
|
60 };
|
jpayne@69
|
61
|
jpayne@69
|
62 /** Used for looking up slot attributes. Most are already available in other functions **/
|
jpayne@69
|
63 enum gr_attrCode {
|
jpayne@69
|
64 /// adjusted glyph advance in x direction in design units
|
jpayne@69
|
65 gr_slatAdvX = 0,
|
jpayne@69
|
66 /// adjusted glyph advance in y direction (usually 0) in design units
|
jpayne@69
|
67 gr_slatAdvY,
|
jpayne@69
|
68 /// returns 0. Deprecated.
|
jpayne@69
|
69 gr_slatAttTo,
|
jpayne@69
|
70 /// This slot attaches to its parent at the given design units in the x direction
|
jpayne@69
|
71 gr_slatAttX,
|
jpayne@69
|
72 /// This slot attaches to its parent at the given design units in the y direction
|
jpayne@69
|
73 gr_slatAttY,
|
jpayne@69
|
74 /// This slot attaches to its parent at the given glyph point (not implemented)
|
jpayne@69
|
75 gr_slatAttGpt,
|
jpayne@69
|
76 /// x-direction adjustment from the given glyph point (not implemented)
|
jpayne@69
|
77 gr_slatAttXOff,
|
jpayne@69
|
78 /// y-direction adjustment from the given glyph point (not implemented)
|
jpayne@69
|
79 gr_slatAttYOff,
|
jpayne@69
|
80 /// Where on this glyph should align with the attachment point on the parent glyph in the x-direction.
|
jpayne@69
|
81 gr_slatAttWithX,
|
jpayne@69
|
82 /// Where on this glyph should align with the attachment point on the parent glyph in the y-direction
|
jpayne@69
|
83 gr_slatAttWithY,
|
jpayne@69
|
84 /// Which glyph point on this glyph should align with the attachment point on the parent glyph (not implemented).
|
jpayne@69
|
85 gr_slatWithGpt,
|
jpayne@69
|
86 /// Adjustment to gr_slatWithGpt in x-direction (not implemented)
|
jpayne@69
|
87 gr_slatAttWithXOff,
|
jpayne@69
|
88 /// Adjustment to gr_slatWithGpt in y-direction (not implemented)
|
jpayne@69
|
89 gr_slatAttWithYOff,
|
jpayne@69
|
90 /// Attach at given nesting level (not implemented)
|
jpayne@69
|
91 gr_slatAttLevel,
|
jpayne@69
|
92 /// Line break breakweight for this glyph
|
jpayne@69
|
93 gr_slatBreak,
|
jpayne@69
|
94 /// Ligature component reference (not implemented)
|
jpayne@69
|
95 gr_slatCompRef,
|
jpayne@69
|
96 /// bidi directionality of this glyph (not implemented)
|
jpayne@69
|
97 gr_slatDir,
|
jpayne@69
|
98 /// Whether insertion is allowed before this glyph
|
jpayne@69
|
99 gr_slatInsert,
|
jpayne@69
|
100 /// Final positioned position of this glyph relative to its parent in x-direction in pixels
|
jpayne@69
|
101 gr_slatPosX,
|
jpayne@69
|
102 /// Final positioned position of this glyph relative to its parent in y-direction in pixels
|
jpayne@69
|
103 gr_slatPosY,
|
jpayne@69
|
104 /// Amount to shift glyph by in x-direction design units
|
jpayne@69
|
105 gr_slatShiftX,
|
jpayne@69
|
106 /// Amount to shift glyph by in y-direction design units
|
jpayne@69
|
107 gr_slatShiftY,
|
jpayne@69
|
108 /// attribute user1
|
jpayne@69
|
109 gr_slatUserDefnV1,
|
jpayne@69
|
110 /// not implemented
|
jpayne@69
|
111 gr_slatMeasureSol,
|
jpayne@69
|
112 /// not implemented
|
jpayne@69
|
113 gr_slatMeasureEol,
|
jpayne@69
|
114 /// Amount this slot can stretch (not implemented)
|
jpayne@69
|
115 gr_slatJStretch,
|
jpayne@69
|
116 /// Amount this slot can shrink (not implemented)
|
jpayne@69
|
117 gr_slatJShrink,
|
jpayne@69
|
118 /// Granularity by which this slot can stretch or shrink (not implemented)
|
jpayne@69
|
119 gr_slatJStep,
|
jpayne@69
|
120 /// Justification weight for this glyph (not implemented)
|
jpayne@69
|
121 gr_slatJWeight,
|
jpayne@69
|
122 /// Amount this slot mush shrink or stretch in design units
|
jpayne@69
|
123 gr_slatJWidth = 29,
|
jpayne@69
|
124 /// SubSegment split point
|
jpayne@69
|
125 gr_slatSegSplit = gr_slatJStretch + 29,
|
jpayne@69
|
126 /// User defined attribute, see subattr for user attr number
|
jpayne@69
|
127 gr_slatUserDefn,
|
jpayne@69
|
128 /// Bidi level
|
jpayne@69
|
129 gr_slatBidiLevel = 56,
|
jpayne@69
|
130 /// Collision flags
|
jpayne@69
|
131 gr_slatColFlags,
|
jpayne@69
|
132 /// Collision constraint rectangle left (bl.x)
|
jpayne@69
|
133 gr_slatColLimitblx,
|
jpayne@69
|
134 /// Collision constraint rectangle lower (bl.y)
|
jpayne@69
|
135 gr_slatColLimitbly,
|
jpayne@69
|
136 /// Collision constraint rectangle right (tr.x)
|
jpayne@69
|
137 gr_slatColLimittrx,
|
jpayne@69
|
138 /// Collision constraint rectangle upper (tr.y)
|
jpayne@69
|
139 gr_slatColLimittry,
|
jpayne@69
|
140 /// Collision shift x
|
jpayne@69
|
141 gr_slatColShiftx,
|
jpayne@69
|
142 /// Collision shift y
|
jpayne@69
|
143 gr_slatColShifty,
|
jpayne@69
|
144 /// Collision margin
|
jpayne@69
|
145 gr_slatColMargin,
|
jpayne@69
|
146 /// Margin cost weight
|
jpayne@69
|
147 gr_slatColMarginWt,
|
jpayne@69
|
148 // Additional glyph that excludes movement near this one:
|
jpayne@69
|
149 gr_slatColExclGlyph,
|
jpayne@69
|
150 gr_slatColExclOffx,
|
jpayne@69
|
151 gr_slatColExclOffy,
|
jpayne@69
|
152 // Collision sequence enforcing attributes:
|
jpayne@69
|
153 gr_slatSeqClass,
|
jpayne@69
|
154 gr_slatSeqProxClass,
|
jpayne@69
|
155 gr_slatSeqOrder,
|
jpayne@69
|
156 gr_slatSeqAboveXoff,
|
jpayne@69
|
157 gr_slatSeqAboveWt,
|
jpayne@69
|
158 gr_slatSeqBelowXlim,
|
jpayne@69
|
159 gr_slatSeqBelowWt,
|
jpayne@69
|
160 gr_slatSeqValignHt,
|
jpayne@69
|
161 gr_slatSeqValignWt,
|
jpayne@69
|
162
|
jpayne@69
|
163 /// not implemented
|
jpayne@69
|
164 gr_slatMax,
|
jpayne@69
|
165 /// not implemented
|
jpayne@69
|
166 gr_slatNoEffect = gr_slatMax + 1
|
jpayne@69
|
167 };
|
jpayne@69
|
168
|
jpayne@69
|
169 enum gr_bidirtl {
|
jpayne@69
|
170 /// Underlying paragraph direction is RTL
|
jpayne@69
|
171 gr_rtl = 1,
|
jpayne@69
|
172 /// Set this to not run the bidi pass internally, even if the font asks for it.
|
jpayne@69
|
173 /// This presumes that the segment is in a single direction. Most of the time
|
jpayne@69
|
174 /// this bit should be set unless you know you are passing full paragraphs of text.
|
jpayne@69
|
175 gr_nobidi = 2,
|
jpayne@69
|
176 /// Disable auto mirroring for rtl text
|
jpayne@69
|
177 gr_nomirror = 4
|
jpayne@69
|
178 };
|
jpayne@69
|
179
|
jpayne@69
|
180 typedef struct gr_char_info gr_char_info;
|
jpayne@69
|
181 typedef struct gr_segment gr_segment;
|
jpayne@69
|
182 typedef struct gr_slot gr_slot;
|
jpayne@69
|
183
|
jpayne@69
|
184 /** Returns Unicode character for a charinfo.
|
jpayne@69
|
185 *
|
jpayne@69
|
186 * @param p Pointer to charinfo to return information on.
|
jpayne@69
|
187 */
|
jpayne@69
|
188 GR2_API unsigned int gr_cinfo_unicode_char(const gr_char_info* p/*not NULL*/);
|
jpayne@69
|
189
|
jpayne@69
|
190 /** Returns breakweight for a charinfo.
|
jpayne@69
|
191 *
|
jpayne@69
|
192 * @return Breakweight is a number between -50 and 50 indicating the cost of a
|
jpayne@69
|
193 * break before or after this character. If the value < 0, the absolute value
|
jpayne@69
|
194 * is this character's contribution to the overall breakweight before it. If the value
|
jpayne@69
|
195 * > 0, then the value is this character's contribution to the overall breakweight after it.
|
jpayne@69
|
196 * The overall breakweight between two characters is the maximum of the breakweight
|
jpayne@69
|
197 * contributions from the characters either side of it. If a character makes no
|
jpayne@69
|
198 * contribution to the breakweight on one side of it, the contribution is considered
|
jpayne@69
|
199 * to be 0.
|
jpayne@69
|
200 * @param p Pointer to charinfo to return information on.
|
jpayne@69
|
201 */
|
jpayne@69
|
202 GR2_API int gr_cinfo_break_weight(const gr_char_info* p/*not NULL*/);
|
jpayne@69
|
203
|
jpayne@69
|
204 /** Returns the slot index that after this character is after in the slot stream
|
jpayne@69
|
205 *
|
jpayne@69
|
206 * In effect each character is associated with a set of slots and this returns
|
jpayne@69
|
207 * the index of the last slot in the segment this character is associated with.
|
jpayne@69
|
208 *
|
jpayne@69
|
209 * @return after slot index between 0 and gr_seg_n_slots()
|
jpayne@69
|
210 * @param p Pointer to charinfo to return information on.
|
jpayne@69
|
211 */
|
jpayne@69
|
212 GR2_API int gr_cinfo_after(const gr_char_info* p/*not NULL*/);
|
jpayne@69
|
213
|
jpayne@69
|
214 /** Returns the slot index that before this character is before in the slot stream
|
jpayne@69
|
215 *
|
jpayne@69
|
216 * In effect each character is associated with a set of slots and this returns
|
jpayne@69
|
217 * the index of the first slot in the segment this character is associated with.
|
jpayne@69
|
218 *
|
jpayne@69
|
219 * @return before slot index between 0 and gr_seg_n_slots()
|
jpayne@69
|
220 * @param p Pointer to charinfo to return information on.
|
jpayne@69
|
221 */
|
jpayne@69
|
222 GR2_API int gr_cinfo_before(const gr_char_info* p/*not NULL*/);
|
jpayne@69
|
223
|
jpayne@69
|
224 /** Returns the code unit index of this character in the input string
|
jpayne@69
|
225 *
|
jpayne@69
|
226 * @return code unit index between 0 and the end of the string
|
jpayne@69
|
227 * @param p Pointer to charinfo to return information on.
|
jpayne@69
|
228 */
|
jpayne@69
|
229 GR2_API size_t gr_cinfo_base(const gr_char_info* p/*not NULL*/);
|
jpayne@69
|
230
|
jpayne@69
|
231 /** Returns the number of unicode characters in a string.
|
jpayne@69
|
232 *
|
jpayne@69
|
233 * @return number of characters in the string
|
jpayne@69
|
234 * @param enc Specifies the type of data in the string: utf8, utf16, utf32
|
jpayne@69
|
235 * @param buffer_begin The start of the string
|
jpayne@69
|
236 * @param buffer_end Measure up to the first nul or when end is reached, whichever is earliest.
|
jpayne@69
|
237 * This parameter may be NULL.
|
jpayne@69
|
238 * @param pError If there is a structural fault in the string, the location is returned
|
jpayne@69
|
239 * in this variable. If no error occurs, pError will contain NULL. NULL
|
jpayne@69
|
240 * may be passed for pError if no such information is required.
|
jpayne@69
|
241 */
|
jpayne@69
|
242 GR2_API size_t gr_count_unicode_characters(enum gr_encform enc, const void* buffer_begin, const void* buffer_end, const void** pError);
|
jpayne@69
|
243
|
jpayne@69
|
244 /** Creates and returns a segment.
|
jpayne@69
|
245 *
|
jpayne@69
|
246 * @return a segment that needs seg_destroy called on it. May return NULL if bad problems
|
jpayne@69
|
247 * in segment processing.
|
jpayne@69
|
248 * @param font Gives the size of the font in pixels per em for final positioning. If
|
jpayne@69
|
249 * NULL, positions are returned in design units, i.e. at a ppm of the upem
|
jpayne@69
|
250 * of the face.
|
jpayne@69
|
251 * @param face The face containing all the non-size dependent information.
|
jpayne@69
|
252 * @param script This is a tag containing a script identifier that is used to choose
|
jpayne@69
|
253 * which graphite table within the font to use. Maybe 0. Tag may be 4 chars
|
jpayne@69
|
254 * NULL padded in LSBs or space padded in LSBs.
|
jpayne@69
|
255 * @param pFeats Pointer to a feature values to be used for the segment. Only one
|
jpayne@69
|
256 * feature values may be used for a segment. If NULL the default features
|
jpayne@69
|
257 * for the font will be used.
|
jpayne@69
|
258 * @param enc Specifies what encoding form the string is in (utf8, utf16, utf32)
|
jpayne@69
|
259 * @param pStart Start of the string
|
jpayne@69
|
260 * @param nChars Number of unicode characters to process in the string. The string will
|
jpayne@69
|
261 * be processed either up to the first NULL or until nChars have been
|
jpayne@69
|
262 * processed. nChars is also used to initialise the internal memory
|
jpayne@69
|
263 * allocations of the segment. So it is wise not to make nChars too much
|
jpayne@69
|
264 * greater than the actual number of characters being processed.
|
jpayne@69
|
265 * @param dir Specifies whether the segment is processed right to left (1) or left to
|
jpayne@69
|
266 * right (0) and whether to run the internal bidi pass, if a font requests it.
|
jpayne@69
|
267 * See enum gr_bidirtl for details.
|
jpayne@69
|
268 */
|
jpayne@69
|
269 GR2_API gr_segment* gr_make_seg(const gr_font* font, const gr_face* face, gr_uint32 script, const gr_feature_val* pFeats, enum gr_encform enc, const void* pStart, size_t nChars, int dir);
|
jpayne@69
|
270
|
jpayne@69
|
271 /** Destroys a segment, freeing the memory.
|
jpayne@69
|
272 *
|
jpayne@69
|
273 * @param p The segment to destroy
|
jpayne@69
|
274 */
|
jpayne@69
|
275 GR2_API void gr_seg_destroy(gr_segment* p);
|
jpayne@69
|
276
|
jpayne@69
|
277 /** Returns the advance for the whole segment.
|
jpayne@69
|
278 *
|
jpayne@69
|
279 * Returns the width of the segment up to the next glyph origin after the segment
|
jpayne@69
|
280 */
|
jpayne@69
|
281 GR2_API float gr_seg_advance_X(const gr_segment* pSeg/*not NULL*/);
|
jpayne@69
|
282
|
jpayne@69
|
283 /** Returns the height advance for the segment. **/
|
jpayne@69
|
284 GR2_API float gr_seg_advance_Y(const gr_segment* pSeg/*not NULL*/);
|
jpayne@69
|
285
|
jpayne@69
|
286 /** Returns the number of gr_char_infos in the segment. **/
|
jpayne@69
|
287 GR2_API unsigned int gr_seg_n_cinfo(const gr_segment* pSeg/*not NULL*/);
|
jpayne@69
|
288
|
jpayne@69
|
289 /** Returns a gr_char_info at a given index in the segment. **/
|
jpayne@69
|
290 GR2_API const gr_char_info* gr_seg_cinfo(const gr_segment* pSeg/*not NULL*/, unsigned int index/*must be <number_of_CharInfo*/);
|
jpayne@69
|
291
|
jpayne@69
|
292 /** Returns the number of glyph gr_slots in the segment. **/
|
jpayne@69
|
293 GR2_API unsigned int gr_seg_n_slots(const gr_segment* pSeg/*not NULL*/); //one slot per glyph
|
jpayne@69
|
294
|
jpayne@69
|
295 /** Returns the first gr_slot in the segment.
|
jpayne@69
|
296 *
|
jpayne@69
|
297 * The first slot in a segment has a gr_slot_prev_in_segment() of NULL. Slots are owned
|
jpayne@69
|
298 * by their segment and are destroyed along with the segment.
|
jpayne@69
|
299 */
|
jpayne@69
|
300 GR2_API const gr_slot* gr_seg_first_slot(gr_segment* pSeg/*not NULL*/); //may give a base slot or a slot which is attached to another
|
jpayne@69
|
301
|
jpayne@69
|
302 /** Returns the last gr_slot in the segment.
|
jpayne@69
|
303 *
|
jpayne@69
|
304 * The last slot in a segment has a gr_slot_next_in_segment() of NULL
|
jpayne@69
|
305 */
|
jpayne@69
|
306 GR2_API const gr_slot* gr_seg_last_slot(gr_segment* pSeg/*not NULL*/); //may give a base slot or a slot which is attached to another
|
jpayne@69
|
307
|
jpayne@69
|
308 /** Justifies a linked list of slots for a line to a given width
|
jpayne@69
|
309 *
|
jpayne@69
|
310 * Passed a pointer to the start of a linked list of slots corresponding to a line, as
|
jpayne@69
|
311 * set up by gr_slot_linebreak_before, this function will position the glyphs in the line
|
jpayne@69
|
312 * to take up the given width. It is possible to specify a subrange within the line to process.
|
jpayne@69
|
313 * This allows skipping of line initial or final whitespace, for example. While this will ensure
|
jpayne@69
|
314 * that the subrange fits width, the line will still be positioned with the first glyph of the
|
jpayne@69
|
315 * line at 0. So the resulting positions may be beyond width.
|
jpayne@69
|
316 *
|
jpayne@69
|
317 * @return float The resulting width of the range of slots justified.
|
jpayne@69
|
318 * @param pSeg Pointer to the segment
|
jpayne@69
|
319 * @param pStart Pointer to the start of the line linked list (including skipped characters)
|
jpayne@69
|
320 * @param pFont Font to use for positioning
|
jpayne@69
|
321 * @param width Width in pixels in which to fit the line. If < 0. don't adjust natural width, just run justification passes
|
jpayne@69
|
322 * to handle line end contextuals, if there are any.
|
jpayne@69
|
323 * @param flags Indicates line ending types. Default is linked list is a full line
|
jpayne@69
|
324 * @param pFirst If not NULL, the first slot in the list to be considered part of the line (so can skip)
|
jpayne@69
|
325 * @param pLast If not NULL, the last slot to process in the line (allow say trailing whitespace to be skipped)
|
jpayne@69
|
326 */
|
jpayne@69
|
327 GR2_API float gr_seg_justify(gr_segment* pSeg/*not NULL*/, const gr_slot* pStart/*not NULL*/, const gr_font *pFont, double width, enum gr_justFlags flags, const gr_slot* pFirst, const gr_slot* pLast);
|
jpayne@69
|
328
|
jpayne@69
|
329 /** Returns the next slot along in the segment.
|
jpayne@69
|
330 *
|
jpayne@69
|
331 * Slots are held in a linked list. This returns the next in the linked list. The slot
|
jpayne@69
|
332 * may or may not be attached to another slot. Returns NULL at the end of the segment.
|
jpayne@69
|
333 */
|
jpayne@69
|
334 GR2_API const gr_slot* gr_slot_next_in_segment(const gr_slot* p);
|
jpayne@69
|
335
|
jpayne@69
|
336 /** Returns the previous slot along in the segment.
|
jpayne@69
|
337 *
|
jpayne@69
|
338 * Slots are held in a doubly linked list. This returns the previos slot in the linked
|
jpayne@69
|
339 * list. This slot may or may not be attached to it. Returns NULL at the start of the
|
jpayne@69
|
340 * segment.
|
jpayne@69
|
341 */
|
jpayne@69
|
342 GR2_API const gr_slot* gr_slot_prev_in_segment(const gr_slot* p);
|
jpayne@69
|
343
|
jpayne@69
|
344 /** Returns the attachment parent slot of this slot.
|
jpayne@69
|
345 *
|
jpayne@69
|
346 * Attached slots form a tree. This returns the parent of this slot in that tree. A
|
jpayne@69
|
347 * base glyph which is not attached to another glyph, always returns NULL.
|
jpayne@69
|
348 */
|
jpayne@69
|
349 GR2_API const gr_slot* gr_slot_attached_to(const gr_slot* p);
|
jpayne@69
|
350
|
jpayne@69
|
351 /** Returns the first slot attached to this slot.
|
jpayne@69
|
352 *
|
jpayne@69
|
353 * Attached slots form a singly linked list from the parent. This returns the first
|
jpayne@69
|
354 * slot in that list. Note that this is a reference to another slot that is also in
|
jpayne@69
|
355 * the main segment doubly linked list.
|
jpayne@69
|
356 *
|
jpayne@69
|
357 * if gr_slot_first_attachment(p) != NULL then gr_slot_attached_to(gr_slot_first_attachment(p)) == p.
|
jpayne@69
|
358 */
|
jpayne@69
|
359 GR2_API const gr_slot* gr_slot_first_attachment(const gr_slot* p);
|
jpayne@69
|
360
|
jpayne@69
|
361 /** Returns the next slot attached to our attachment parent.
|
jpayne@69
|
362 *
|
jpayne@69
|
363 * This returns the next slot in the singly linked list of slots attached to this
|
jpayne@69
|
364 * slot's parent. If there are no more such slots, NULL is returned. If there is
|
jpayne@69
|
365 * no parent, i.e. the passed slot is a cluster base, then the next cluster base
|
jpayne@69
|
366 * in graphical order (ltr, even for rtl text) is returned.
|
jpayne@69
|
367 *
|
jpayne@69
|
368 * if gr_slot_next_sibling_attachment(p) != NULL then gr_slot_attached_to(gr_slot_next_sibling_attachment(p)) == gr_slot_attached_to(p).
|
jpayne@69
|
369 */
|
jpayne@69
|
370 GR2_API const gr_slot* gr_slot_next_sibling_attachment(const gr_slot* p);
|
jpayne@69
|
371
|
jpayne@69
|
372
|
jpayne@69
|
373 /** Returns glyph id of the slot
|
jpayne@69
|
374 *
|
jpayne@69
|
375 * Each slot has a glyphid which is rendered at the position given by the slot. This
|
jpayne@69
|
376 * glyphid is the real glyph to be rendered and never a pseudo glyph.
|
jpayne@69
|
377 */
|
jpayne@69
|
378 GR2_API unsigned short gr_slot_gid(const gr_slot* p);
|
jpayne@69
|
379
|
jpayne@69
|
380 /** Returns X offset of glyph from start of segment **/
|
jpayne@69
|
381 GR2_API float gr_slot_origin_X(const gr_slot* p);
|
jpayne@69
|
382
|
jpayne@69
|
383 /** Returns Y offset of glyph from start of segment **/
|
jpayne@69
|
384 GR2_API float gr_slot_origin_Y(const gr_slot* p);
|
jpayne@69
|
385
|
jpayne@69
|
386 /** Returns the glyph advance for this glyph as adjusted for kerning
|
jpayne@69
|
387 *
|
jpayne@69
|
388 * @param p Slot to give results for
|
jpayne@69
|
389 * @param face gr_face of the glyphs. May be NULL if unhinted advances used
|
jpayne@69
|
390 * @param font gr_font to scale for pixel results. If NULL returns design
|
jpayne@69
|
391 * units advance. If not NULL then returns pixel advance based
|
jpayne@69
|
392 * on hinted or scaled glyph advances in the font. face must be
|
jpayne@69
|
393 * passed for hinted advances to be used.
|
jpayne@69
|
394 */
|
jpayne@69
|
395 GR2_API float gr_slot_advance_X(const gr_slot* p, const gr_face* face, const gr_font *font);
|
jpayne@69
|
396
|
jpayne@69
|
397 /** Returns the vertical advance for the glyph in the slot adjusted for kerning
|
jpayne@69
|
398 *
|
jpayne@69
|
399 * Returns design units unless font is not NULL in which case the pixel value
|
jpayne@69
|
400 * is returned scaled for the given font
|
jpayne@69
|
401 */
|
jpayne@69
|
402 GR2_API float gr_slot_advance_Y(const gr_slot* p, const gr_face* face, const gr_font *font);
|
jpayne@69
|
403
|
jpayne@69
|
404 /** Returns the gr_char_info index before us
|
jpayne@69
|
405 *
|
jpayne@69
|
406 * Returns the index of the gr_char_info that a cursor before this slot, would put
|
jpayne@69
|
407 * an underlying cursor before. This may also be interpretted as each slot holding
|
jpayne@69
|
408 * a set of char_infos that it is associated with and this function returning the
|
jpayne@69
|
409 * index of the char_info with lowest index, from this set.
|
jpayne@69
|
410 */
|
jpayne@69
|
411 GR2_API int gr_slot_before(const gr_slot* p/*not NULL*/);
|
jpayne@69
|
412
|
jpayne@69
|
413 /** Returns the gr_char_info index after us
|
jpayne@69
|
414 *
|
jpayne@69
|
415 * Returns the index of the gr_char_info that a cursor after this slot would put an
|
jpayne@69
|
416 * underlying cursor after. This may also be interpretted as each slot holding a set
|
jpayne@69
|
417 * of char_infos that it is associated with and this function returning the index of
|
jpayne@69
|
418 * the char_info with the highest index, from this set.
|
jpayne@69
|
419 */
|
jpayne@69
|
420 GR2_API int gr_slot_after(const gr_slot* p/*not NULL*/);
|
jpayne@69
|
421
|
jpayne@69
|
422 /** Returns the index of this slot in the segment
|
jpayne@69
|
423 *
|
jpayne@69
|
424 * Returns the index given to this slot during final positioning. This corresponds
|
jpayne@69
|
425 * to the value returned br gr_cinfo_before() and gr_cinfo_after()
|
jpayne@69
|
426 */
|
jpayne@69
|
427 GR2_API unsigned int gr_slot_index(const gr_slot* p/*not NULL*/);
|
jpayne@69
|
428
|
jpayne@69
|
429 /** Return a slot attribute value
|
jpayne@69
|
430 *
|
jpayne@69
|
431 * Given a slot and an attribute along with a possible subattribute, return the
|
jpayne@69
|
432 * corresponding value in the slot. See enum gr_attrCode for details of each attribute.
|
jpayne@69
|
433 */
|
jpayne@69
|
434 GR2_API int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, enum gr_attrCode index, gr_uint8 subindex); //tbd - do we need to expose this?
|
jpayne@69
|
435
|
jpayne@69
|
436 /** Returns whether text may be inserted before this glyph.
|
jpayne@69
|
437 *
|
jpayne@69
|
438 * This indicates whether a cursor can be put before this slot. It applies to
|
jpayne@69
|
439 * base glyphs that have no parent as well as attached glyphs that have the
|
jpayne@69
|
440 * .insert attribute explicitly set to true. This is the primary mechanism
|
jpayne@69
|
441 * for identifying contiguous sequences of base plus diacritics.
|
jpayne@69
|
442 */
|
jpayne@69
|
443 GR2_API int gr_slot_can_insert_before(const gr_slot* p);
|
jpayne@69
|
444
|
jpayne@69
|
445 /** Returns the original gr_char_info index this slot refers to.
|
jpayne@69
|
446 *
|
jpayne@69
|
447 * Each Slot has a gr_char_info that it originates from. This is that gr_char_info.
|
jpayne@69
|
448 * The index is passed to gr_seg_cinfo(). This information is useful for testing.
|
jpayne@69
|
449 */
|
jpayne@69
|
450 GR2_API int gr_slot_original(const gr_slot* p/*not NULL*/);
|
jpayne@69
|
451
|
jpayne@69
|
452 /** Breaks a segment into lines.
|
jpayne@69
|
453 *
|
jpayne@69
|
454 * Breaks the slot linked list at the given point in the linked list. It is up
|
jpayne@69
|
455 * to the application to keep track of the first slot on each line.
|
jpayne@69
|
456 */
|
jpayne@69
|
457 GR2_API void gr_slot_linebreak_before(gr_slot *p/*not NULL*/);
|
jpayne@69
|
458
|
jpayne@69
|
459 #ifdef __cplusplus
|
jpayne@69
|
460 }
|
jpayne@69
|
461 #endif
|