Graphiteng
Segment.h
Go to the documentation of this file.
1/* GRAPHITE2 LICENSING
2
3 Copyright 2010, SIL International
4 All rights reserved.
5
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2.1 of License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should also have received a copy of the GNU Lesser General Public
17 License along with this library in the file named "LICENSE".
18 If not, write to the Free Software Foundation, 51 Franklin Street,
19 Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
20 internet at http://www.fsf.org/licenses/lgpl.html.
21
22 Alternatively, the contents of this file may be used under the terms
23 of the Mozilla Public License (http://mozilla.org/MPL) or the GNU
24 General Public License, as published by the Free Software Foundation,
25 either version 2 of the License or (at your option) any later version.
26*/
27#pragma once
28
29#include "graphite2/Types.h"
30#include "graphite2/Font.h"
31
32#ifdef __cplusplus
33extern "C"
34{
35#endif
36
39 /* after break weights */
45 /* before break weights */
51};
52
60};
61
148 // Additional glyph that excludes movement near this one:
152 // Collision sequence enforcing attributes:
162
168
177 gr_nomirror = 4
179
181typedef struct gr_segment gr_segment;
182typedef struct gr_slot gr_slot;
183
188GR2_API unsigned int gr_cinfo_unicode_char(const gr_char_info* p/*not NULL*/);
189
203
212GR2_API int gr_cinfo_after(const gr_char_info* p/*not NULL*/);
213
222GR2_API int gr_cinfo_before(const gr_char_info* p/*not NULL*/);
223
229GR2_API size_t gr_cinfo_base(const gr_char_info* p/*not NULL*/);
230
242GR2_API size_t gr_count_unicode_characters(enum gr_encform enc, const void* buffer_begin, const void* buffer_end, const void** pError);
243
269GR2_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);
270
276
281GR2_API float gr_seg_advance_X(const gr_segment* pSeg/*not NULL*/);
282
284GR2_API float gr_seg_advance_Y(const gr_segment* pSeg/*not NULL*/);
285
287GR2_API unsigned int gr_seg_n_cinfo(const gr_segment* pSeg/*not NULL*/);
288
290GR2_API const gr_char_info* gr_seg_cinfo(const gr_segment* pSeg/*not NULL*/, unsigned int index/*must be <number_of_CharInfo*/);
291
293GR2_API unsigned int gr_seg_n_slots(const gr_segment* pSeg/*not NULL*/); //one slot per glyph
294
300GR2_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
301
306GR2_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
307
327GR2_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);
328
335
343
350
360
371
372
378GR2_API unsigned short gr_slot_gid(const gr_slot* p);
379
382
385
395GR2_API float gr_slot_advance_X(const gr_slot* p, const gr_face* face, const gr_font *font);
396
402GR2_API float gr_slot_advance_Y(const gr_slot* p, const gr_face* face, const gr_font *font);
403
411GR2_API int gr_slot_before(const gr_slot* p/*not NULL*/);
412
420GR2_API int gr_slot_after(const gr_slot* p/*not NULL*/);
421
427GR2_API unsigned int gr_slot_index(const gr_slot* p/*not NULL*/);
428
434GR2_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?
435
444
450GR2_API int gr_slot_original(const gr_slot* p/*not NULL*/);
451
458
459#ifdef __cplusplus
460}
461#endif
struct gr_feature_val gr_feature_val
Definition: Font.h:43
struct gr_face gr_face
Definition: Font.h:40
struct gr_font gr_font
Definition: Font.h:41
GR2_API float gr_slot_advance_X(const gr_slot *p, const gr_face *face, const gr_font *font)
Returns the glyph advance for this glyph as adjusted for kerning.
GR2_API int gr_cinfo_before(const gr_char_info *p)
Returns the slot index that before this character is before in the slot stream.
GR2_API float gr_slot_advance_Y(const gr_slot *p, const gr_face *face, const gr_font *font)
Returns the vertical advance for the glyph in the slot adjusted for kerning.
GR2_API int gr_slot_after(const gr_slot *p)
Returns the gr_char_info index after us.
GR2_API const gr_char_info * gr_seg_cinfo(const gr_segment *pSeg, unsigned int index)
Returns a gr_char_info at a given index in the segment.
GR2_API const gr_slot * gr_slot_next_sibling_attachment(const gr_slot *p)
Returns the next slot attached to our attachment parent.
GR2_API float gr_seg_advance_X(const gr_segment *pSeg)
Returns the advance for the whole segment.
GR2_API const gr_slot * gr_slot_prev_in_segment(const gr_slot *p)
Returns the previous slot along in the segment.
struct gr_segment gr_segment
Definition: Segment.h:181
GR2_API unsigned short gr_slot_gid(const gr_slot *p)
Returns glyph id of the slot.
GR2_API int gr_slot_can_insert_before(const gr_slot *p)
Returns whether text may be inserted before this glyph.
GR2_API int gr_slot_original(const gr_slot *p)
Returns the original gr_char_info index this slot refers to.
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)
Creates and returns a segment.
GR2_API float gr_slot_origin_Y(const gr_slot *p)
Returns Y offset of glyph from start of segment.
gr_bidirtl
Definition: Segment.h:169
@ gr_rtl
Underlying paragraph direction is RTL.
Definition: Segment.h:171
@ gr_nomirror
Disable auto mirroring for rtl text.
Definition: Segment.h:177
@ gr_nobidi
Set this to not run the bidi pass internally, even if the font asks for it.
Definition: Segment.h:175
gr_break_weight
Definition: Segment.h:37
@ gr_breakWord
Definition: Segment.h:41
@ gr_breakBeforeWord
Definition: Segment.h:47
@ gr_breakBeforeWhitespace
Definition: Segment.h:46
@ gr_breakIntra
Definition: Segment.h:42
@ gr_breakLetter
Definition: Segment.h:43
@ gr_breakNone
Definition: Segment.h:38
@ gr_breakWhitespace
Definition: Segment.h:40
@ gr_breakBeforeClip
Definition: Segment.h:50
@ gr_breakClip
Definition: Segment.h:44
@ gr_breakBeforeLetter
Definition: Segment.h:49
@ gr_breakBeforeIntra
Definition: Segment.h:48
GR2_API unsigned int gr_cinfo_unicode_char(const gr_char_info *p)
Returns Unicode character for a charinfo.
gr_attrCode
Used for looking up slot attributes.
Definition: Segment.h:63
@ gr_slatMax
not implemented
Definition: Segment.h:164
@ gr_slatShiftX
Amount to shift glyph by in x-direction design units.
Definition: Segment.h:105
@ gr_slatPosX
Final positioned position of this glyph relative to its parent in x-direction in pixels.
Definition: Segment.h:101
@ gr_slatSegSplit
SubSegment split point.
Definition: Segment.h:125
@ gr_slatSeqClass
Definition: Segment.h:153
@ gr_slatColMargin
Collision margin.
Definition: Segment.h:145
@ gr_slatColMarginWt
Margin cost weight.
Definition: Segment.h:147
@ gr_slatAttWithX
Where on this glyph should align with the attachment point on the parent glyph in the x-direction.
Definition: Segment.h:81
@ gr_slatAttX
This slot attaches to its parent at the given design units in the x direction.
Definition: Segment.h:71
@ gr_slatUserDefnV1
attribute user1
Definition: Segment.h:109
@ gr_slatMeasureEol
not implemented
Definition: Segment.h:113
@ gr_slatAttWithXOff
Adjustment to gr_slatWithGpt in x-direction (not implemented)
Definition: Segment.h:87
@ gr_slatAdvY
adjusted glyph advance in y direction (usually 0) in design units
Definition: Segment.h:67
@ gr_slatColShiftx
Collision shift x.
Definition: Segment.h:141
@ gr_slatWithGpt
Which glyph point on this glyph should align with the attachment point on the parent glyph (not imple...
Definition: Segment.h:85
@ gr_slatJWidth
Amount this slot mush shrink or stretch in design units.
Definition: Segment.h:123
@ gr_slatColLimitblx
Collision constraint rectangle left (bl.x)
Definition: Segment.h:133
@ gr_slatSeqBelowXlim
Definition: Segment.h:158
@ gr_slatCompRef
Ligature component reference (not implemented)
Definition: Segment.h:95
@ gr_slatColExclOffy
Definition: Segment.h:151
@ gr_slatColLimitbly
Collision constraint rectangle lower (bl.y)
Definition: Segment.h:135
@ gr_slatJWeight
Justification weight for this glyph (not implemented)
Definition: Segment.h:121
@ gr_slatColExclOffx
Definition: Segment.h:150
@ gr_slatInsert
Whether insertion is allowed before this glyph.
Definition: Segment.h:99
@ gr_slatJStep
Granularity by which this slot can stretch or shrink (not implemented)
Definition: Segment.h:119
@ gr_slatSeqProxClass
Definition: Segment.h:154
@ gr_slatMeasureSol
not implemented
Definition: Segment.h:111
@ gr_slatAttGpt
This slot attaches to its parent at the given glyph point (not implemented)
Definition: Segment.h:75
@ gr_slatAttXOff
x-direction adjustment from the given glyph point (not implemented)
Definition: Segment.h:77
@ gr_slatJStretch
Amount this slot can stretch (not implemented)
Definition: Segment.h:115
@ gr_slatColFlags
Collision flags.
Definition: Segment.h:131
@ gr_slatColLimittrx
Collision constraint rectangle right (tr.x)
Definition: Segment.h:137
@ gr_slatNoEffect
not implemented
Definition: Segment.h:166
@ gr_slatSeqOrder
Definition: Segment.h:155
@ gr_slatAttYOff
y-direction adjustment from the given glyph point (not implemented)
Definition: Segment.h:79
@ gr_slatBidiLevel
Bidi level.
Definition: Segment.h:129
@ gr_slatAttWithY
Where on this glyph should align with the attachment point on the parent glyph in the y-direction.
Definition: Segment.h:83
@ gr_slatPosY
Final positioned position of this glyph relative to its parent in y-direction in pixels.
Definition: Segment.h:103
@ gr_slatShiftY
Amount to shift glyph by in y-direction design units.
Definition: Segment.h:107
@ gr_slatJShrink
Amount this slot can shrink (not implemented)
Definition: Segment.h:117
@ gr_slatColLimittry
Collision constraint rectangle upper (tr.y)
Definition: Segment.h:139
@ gr_slatAttTo
returns 0. Deprecated.
Definition: Segment.h:69
@ gr_slatUserDefn
User defined attribute, see subattr for user attr number.
Definition: Segment.h:127
@ gr_slatAdvX
adjusted glyph advance in x direction in design units
Definition: Segment.h:65
@ gr_slatBreak
Line break breakweight for this glyph.
Definition: Segment.h:93
@ gr_slatSeqValignWt
Definition: Segment.h:161
@ gr_slatAttLevel
Attach at given nesting level (not implemented)
Definition: Segment.h:91
@ gr_slatAttWithYOff
Adjustment to gr_slatWithGpt in y-direction (not implemented)
Definition: Segment.h:89
@ gr_slatSeqBelowWt
Definition: Segment.h:159
@ gr_slatDir
bidi directionality of this glyph (not implemented)
Definition: Segment.h:97
@ gr_slatSeqAboveWt
Definition: Segment.h:157
@ gr_slatColExclGlyph
Definition: Segment.h:149
@ gr_slatColShifty
Collision shift y.
Definition: Segment.h:143
@ gr_slatSeqValignHt
Definition: Segment.h:160
@ gr_slatAttY
This slot attaches to its parent at the given design units in the y direction.
Definition: Segment.h:73
@ gr_slatSeqAboveXoff
Definition: Segment.h:156
GR2_API const gr_slot * gr_slot_next_in_segment(const gr_slot *p)
Returns the next slot along in the segment.
GR2_API const gr_slot * gr_seg_first_slot(gr_segment *pSeg)
Returns the first gr_slot in the segment.
GR2_API int gr_slot_before(const gr_slot *p)
Returns the gr_char_info index before us.
GR2_API const gr_slot * gr_slot_attached_to(const gr_slot *p)
Returns the attachment parent slot of this slot.
GR2_API size_t gr_cinfo_base(const gr_char_info *p)
Returns the code unit index of this character in the input string.
GR2_API float gr_seg_advance_Y(const gr_segment *pSeg)
Returns the height advance for the segment.
GR2_API float gr_slot_origin_X(const gr_slot *p)
Returns X offset of glyph from start of segment.
GR2_API float gr_seg_justify(gr_segment *pSeg, const gr_slot *pStart, const gr_font *pFont, double width, enum gr_justFlags flags, const gr_slot *pFirst, const gr_slot *pLast)
Justifies a linked list of slots for a line to a given width.
GR2_API int gr_cinfo_break_weight(const gr_char_info *p)
Returns breakweight for a charinfo.
GR2_API const gr_slot * gr_seg_last_slot(gr_segment *pSeg)
Returns the last gr_slot in the segment.
GR2_API unsigned int gr_seg_n_cinfo(const gr_segment *pSeg)
Returns the number of gr_char_infos in the segment.
GR2_API void gr_slot_linebreak_before(gr_slot *p)
Breaks a segment into lines.
GR2_API int gr_cinfo_after(const gr_char_info *p)
Returns the slot index that after this character is after in the slot stream.
GR2_API unsigned int gr_seg_n_slots(const gr_segment *pSeg)
Returns the number of glyph gr_slots in the segment.
GR2_API int gr_slot_attr(const gr_slot *p, const gr_segment *pSeg, enum gr_attrCode index, gr_uint8 subindex)
Return a slot attribute value.
GR2_API const gr_slot * gr_slot_first_attachment(const gr_slot *p)
Returns the first slot attached to this slot.
gr_justFlags
Definition: Segment.h:53
@ gr_justEndInline
Indicates that the end of the slot list is not at the end of a line.
Definition: Segment.h:59
@ gr_justStartInline
Indicates that the start of the slot list is not at the start of a line.
Definition: Segment.h:57
@ gr_justCompleteLine
Indicates that this segment is a complete line.
Definition: Segment.h:55
GR2_API size_t gr_count_unicode_characters(enum gr_encform enc, const void *buffer_begin, const void *buffer_end, const void **pError)
Returns the number of unicode characters in a string.
struct gr_char_info gr_char_info
Definition: Segment.h:180
struct gr_slot gr_slot
Definition: Segment.h:182
GR2_API unsigned int gr_slot_index(const gr_slot *p)
Returns the index of this slot in the segment.
GR2_API void gr_seg_destroy(gr_segment *p)
Destroys a segment, freeing the memory.
gr_encform
Definition: Types.h:39
unsigned int gr_uint32
Definition: Types.h:36
unsigned char gr_uint8
Definition: Types.h:31
#define GR2_API
Definition: Types.h:77