Loading...
Searching...
No Matches
Segment.h
Go to the documentation of this file.
/* GRAPHITE2 LICENSING
Copyright 2010, SIL International
All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should also have received a copy of the GNU Lesser General Public
License along with this library in the file named "LICENSE".
If not, write to the Free Software Foundation, 51 Franklin Street,
Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
internet at http://www.fsf.org/licenses/lgpl.html.
Alternatively, the contents of this file may be used under the terms
of the Mozilla Public License (http://mozilla.org/MPL) or the GNU
General Public License, as published by the Free Software Foundation,
either version 2 of the License or (at your option) any later version.
*/
#pragma once
#include "graphite2/Types.h"
#include "graphite2/Font.h"
#ifdef __cplusplus
extern "C"
{
#endif
enum gr_break_weight {
gr_breakNone = 0,
/* after break weights */
gr_breakWhitespace = 10,
gr_breakWord = 15,
gr_breakIntra = 20,
gr_breakLetter = 30,
gr_breakClip = 40,
/* before break weights */
gr_breakBeforeWhitespace = -10,
gr_breakBeforeWord = -15,
gr_breakBeforeIntra = -20,
gr_breakBeforeLetter = -30,
gr_breakBeforeClip = -40
};
enum gr_justFlags {
gr_justCompleteLine = 0,
gr_justStartInline = 1,
gr_justEndInline = 2
};
enum gr_attrCode {
gr_slatAdvX = 0,
gr_slatAdvY,
gr_slatAttTo,
gr_slatAttX,
gr_slatAttY,
gr_slatAttGpt,
gr_slatAttXOff,
gr_slatAttYOff,
gr_slatAttWithX,
gr_slatAttWithY,
gr_slatWithGpt,
gr_slatAttWithXOff,
gr_slatAttWithYOff,
gr_slatAttLevel,
gr_slatBreak,
gr_slatCompRef,
gr_slatDir,
gr_slatInsert,
gr_slatPosX,
gr_slatPosY,
gr_slatShiftX,
gr_slatShiftY,
gr_slatUserDefnV1,
gr_slatMeasureSol,
gr_slatMeasureEol,
gr_slatJStretch,
gr_slatJShrink,
gr_slatJStep,
gr_slatJWeight,
gr_slatJWidth = 29,
gr_slatSegSplit = gr_slatJStretch + 29,
gr_slatUserDefn,
gr_slatBidiLevel = 56,
gr_slatColFlags,
gr_slatColLimitblx,
gr_slatColLimitbly,
gr_slatColLimittrx,
gr_slatColLimittry,
gr_slatColShiftx,
gr_slatColShifty,
gr_slatColMargin,
gr_slatColMarginWt,
// Additional glyph that excludes movement near this one:
gr_slatColExclGlyph,
gr_slatColExclOffx,
gr_slatColExclOffy,
// Collision sequence enforcing attributes:
gr_slatSeqClass,
gr_slatSeqProxClass,
gr_slatSeqOrder,
gr_slatSeqAboveXoff,
gr_slatSeqAboveWt,
gr_slatSeqBelowXlim,
gr_slatSeqBelowWt,
gr_slatSeqValignHt,
gr_slatSeqValignWt,
gr_slatMax,
gr_slatNoEffect = gr_slatMax + 1
};
enum gr_bidirtl {
gr_rtl = 1,
gr_nobidi = 2,
gr_nomirror = 4
};
typedef struct gr_char_info gr_char_info;
typedef struct gr_segment gr_segment;
typedef struct gr_slot gr_slot;
GR2_API unsigned int gr_cinfo_unicode_char(const gr_char_info* p/*not NULL*/);
GR2_API int gr_cinfo_break_weight(const gr_char_info* p/*not NULL*/);
GR2_API int gr_cinfo_after(const gr_char_info* p/*not NULL*/);
GR2_API int gr_cinfo_before(const gr_char_info* p/*not NULL*/);
GR2_API size_t gr_cinfo_base(const gr_char_info* p/*not NULL*/);
GR2_API size_t gr_count_unicode_characters(enum gr_encform enc, const void* buffer_begin, const void* buffer_end, const void** pError);
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);
GR2_API void gr_seg_destroy(gr_segment* p);
GR2_API float gr_seg_advance_X(const gr_segment* pSeg/*not NULL*/);
GR2_API float gr_seg_advance_Y(const gr_segment* pSeg/*not NULL*/);
GR2_API unsigned int gr_seg_n_cinfo(const gr_segment* pSeg/*not NULL*/);
GR2_API const gr_char_info* gr_seg_cinfo(const gr_segment* pSeg/*not NULL*/, unsigned int index/*must be <number_of_CharInfo*/);
GR2_API unsigned int gr_seg_n_slots(const gr_segment* pSeg/*not NULL*/); //one slot per glyph
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
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
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);
GR2_API const gr_slot* gr_slot_next_in_segment(const gr_slot* p);
GR2_API const gr_slot* gr_slot_prev_in_segment(const gr_slot* p);
GR2_API const gr_slot* gr_slot_attached_to(const gr_slot* p);
GR2_API const gr_slot* gr_slot_first_attachment(const gr_slot* p);
GR2_API const gr_slot* gr_slot_next_sibling_attachment(const gr_slot* p);
GR2_API unsigned short gr_slot_gid(const gr_slot* p);
GR2_API float gr_slot_origin_X(const gr_slot* p);
GR2_API float gr_slot_origin_Y(const gr_slot* p);
GR2_API float gr_slot_advance_X(const gr_slot* p, const gr_face* face, const gr_font *font);
GR2_API float gr_slot_advance_Y(const gr_slot* p, const gr_face* face, const gr_font *font);
GR2_API int gr_slot_before(const gr_slot* p/*not NULL*/);
GR2_API int gr_slot_after(const gr_slot* p/*not NULL*/);
GR2_API unsigned int gr_slot_index(const gr_slot* p/*not NULL*/);
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?
GR2_API int gr_slot_can_insert_before(const gr_slot* p);
GR2_API int gr_slot_original(const gr_slot* p/*not NULL*/);
GR2_API void gr_slot_linebreak_before(gr_slot *p/*not NULL*/);
#ifdef __cplusplus
}
#endif
Font.h
gr_feature_val
struct gr_feature_val gr_feature_val
Definition Font.h:43
gr_face
struct gr_face gr_face
Definition Font.h:40
gr_font
struct gr_font gr_font
Definition Font.h:41
gr_slot_advance_X
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.
gr_cinfo_before
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.
gr_slot_advance_Y
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.
gr_slot_after
GR2_API int gr_slot_after(const gr_slot *p)
Returns the gr_char_info index after us.
gr_seg_cinfo
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.
gr_slot_next_sibling_attachment
GR2_API const gr_slot * gr_slot_next_sibling_attachment(const gr_slot *p)
Returns the next slot attached to our attachment parent.
gr_seg_advance_X
GR2_API float gr_seg_advance_X(const gr_segment *pSeg)
Returns the advance for the whole segment.
gr_slot_prev_in_segment
GR2_API const gr_slot * gr_slot_prev_in_segment(const gr_slot *p)
Returns the previous slot along in the segment.
gr_segment
struct gr_segment gr_segment
Definition Segment.h:181
gr_slot_gid
GR2_API unsigned short gr_slot_gid(const gr_slot *p)
Returns glyph id of the slot.
gr_slot_can_insert_before
GR2_API int gr_slot_can_insert_before(const gr_slot *p)
Returns whether text may be inserted before this glyph.
gr_slot_original
GR2_API int gr_slot_original(const gr_slot *p)
Returns the original gr_char_info index this slot refers to.
gr_make_seg
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.
gr_slot_origin_Y
GR2_API float gr_slot_origin_Y(const gr_slot *p)
Returns Y offset of glyph from start of segment.
gr_bidirtl
gr_bidirtl
Definition Segment.h:169
gr_rtl
@ gr_rtl
Underlying paragraph direction is RTL.
Definition Segment.h:171
gr_nomirror
@ gr_nomirror
Disable auto mirroring for rtl text.
Definition Segment.h:177
gr_nobidi
@ 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
gr_break_weight
Definition Segment.h:37
gr_breakWord
@ gr_breakWord
Definition Segment.h:41
gr_breakBeforeWord
@ gr_breakBeforeWord
Definition Segment.h:47
gr_breakBeforeWhitespace
@ gr_breakBeforeWhitespace
Definition Segment.h:46
gr_breakIntra
@ gr_breakIntra
Definition Segment.h:42
gr_breakLetter
@ gr_breakLetter
Definition Segment.h:43
gr_breakNone
@ gr_breakNone
Definition Segment.h:38
gr_breakWhitespace
@ gr_breakWhitespace
Definition Segment.h:40
gr_breakBeforeClip
@ gr_breakBeforeClip
Definition Segment.h:50
gr_breakClip
@ gr_breakClip
Definition Segment.h:44
gr_breakBeforeLetter
@ gr_breakBeforeLetter
Definition Segment.h:49
gr_breakBeforeIntra
@ gr_breakBeforeIntra
Definition Segment.h:48
gr_cinfo_unicode_char
GR2_API unsigned int gr_cinfo_unicode_char(const gr_char_info *p)
Returns Unicode character for a charinfo.
gr_attrCode
gr_attrCode
Used for looking up slot attributes.
Definition Segment.h:63
gr_slatMax
@ gr_slatMax
not implemented
Definition Segment.h:164
gr_slatShiftX
@ gr_slatShiftX
Amount to shift glyph by in x-direction design units.
Definition Segment.h:105
gr_slatPosX
@ gr_slatPosX
Final positioned position of this glyph relative to its parent in x-direction in pixels.
Definition Segment.h:101
gr_slatSegSplit
@ gr_slatSegSplit
SubSegment split point.
Definition Segment.h:125
gr_slatSeqClass
@ gr_slatSeqClass
Definition Segment.h:153
gr_slatColMargin
@ gr_slatColMargin
Collision margin.
Definition Segment.h:145
gr_slatColMarginWt
@ gr_slatColMarginWt
Margin cost weight.
Definition Segment.h:147
gr_slatAttWithX
@ 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
@ gr_slatAttX
This slot attaches to its parent at the given design units in the x direction.
Definition Segment.h:71
gr_slatUserDefnV1
@ gr_slatUserDefnV1
attribute user1
Definition Segment.h:109
gr_slatMeasureEol
@ gr_slatMeasureEol
not implemented
Definition Segment.h:113
gr_slatAttWithXOff
@ gr_slatAttWithXOff
Adjustment to gr_slatWithGpt in x-direction (not implemented)
Definition Segment.h:87
gr_slatAdvY
@ gr_slatAdvY
adjusted glyph advance in y direction (usually 0) in design units
Definition Segment.h:67
gr_slatColShiftx
@ gr_slatColShiftx
Collision shift x.
Definition Segment.h:141
gr_slatWithGpt
@ 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
@ gr_slatJWidth
Amount this slot mush shrink or stretch in design units.
Definition Segment.h:123
gr_slatColLimitblx
@ gr_slatColLimitblx
Collision constraint rectangle left (bl.x)
Definition Segment.h:133
gr_slatSeqBelowXlim
@ gr_slatSeqBelowXlim
Definition Segment.h:158
gr_slatCompRef
@ gr_slatCompRef
Ligature component reference (not implemented)
Definition Segment.h:95
gr_slatColExclOffy
@ gr_slatColExclOffy
Definition Segment.h:151
gr_slatColLimitbly
@ gr_slatColLimitbly
Collision constraint rectangle lower (bl.y)
Definition Segment.h:135
gr_slatJWeight
@ gr_slatJWeight
Justification weight for this glyph (not implemented)
Definition Segment.h:121
gr_slatColExclOffx
@ gr_slatColExclOffx
Definition Segment.h:150
gr_slatInsert
@ gr_slatInsert
Whether insertion is allowed before this glyph.
Definition Segment.h:99
gr_slatJStep
@ gr_slatJStep
Granularity by which this slot can stretch or shrink (not implemented)
Definition Segment.h:119
gr_slatSeqProxClass
@ gr_slatSeqProxClass
Definition Segment.h:154
gr_slatMeasureSol
@ gr_slatMeasureSol
not implemented
Definition Segment.h:111
gr_slatAttGpt
@ gr_slatAttGpt
This slot attaches to its parent at the given glyph point (not implemented)
Definition Segment.h:75
gr_slatAttXOff
@ gr_slatAttXOff
x-direction adjustment from the given glyph point (not implemented)
Definition Segment.h:77
gr_slatJStretch
@ gr_slatJStretch
Amount this slot can stretch (not implemented)
Definition Segment.h:115
gr_slatColFlags
@ gr_slatColFlags
Collision flags.
Definition Segment.h:131
gr_slatColLimittrx
@ gr_slatColLimittrx
Collision constraint rectangle right (tr.x)
Definition Segment.h:137
gr_slatNoEffect
@ gr_slatNoEffect
not implemented
Definition Segment.h:166
gr_slatSeqOrder
@ gr_slatSeqOrder
Definition Segment.h:155
gr_slatAttYOff
@ gr_slatAttYOff
y-direction adjustment from the given glyph point (not implemented)
Definition Segment.h:79
gr_slatBidiLevel
@ gr_slatBidiLevel
Bidi level.
Definition Segment.h:129
gr_slatAttWithY
@ 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
@ gr_slatPosY
Final positioned position of this glyph relative to its parent in y-direction in pixels.
Definition Segment.h:103
gr_slatShiftY
@ gr_slatShiftY
Amount to shift glyph by in y-direction design units.
Definition Segment.h:107
gr_slatJShrink
@ gr_slatJShrink
Amount this slot can shrink (not implemented)
Definition Segment.h:117
gr_slatColLimittry
@ gr_slatColLimittry
Collision constraint rectangle upper (tr.y)
Definition Segment.h:139
gr_slatAttTo
@ gr_slatAttTo
returns 0. Deprecated.
Definition Segment.h:69
gr_slatUserDefn
@ gr_slatUserDefn
User defined attribute, see subattr for user attr number.
Definition Segment.h:127
gr_slatAdvX
@ gr_slatAdvX
adjusted glyph advance in x direction in design units
Definition Segment.h:65
gr_slatBreak
@ gr_slatBreak
Line break breakweight for this glyph.
Definition Segment.h:93
gr_slatSeqValignWt
@ gr_slatSeqValignWt
Definition Segment.h:161
gr_slatAttLevel
@ gr_slatAttLevel
Attach at given nesting level (not implemented)
Definition Segment.h:91
gr_slatAttWithYOff
@ gr_slatAttWithYOff
Adjustment to gr_slatWithGpt in y-direction (not implemented)
Definition Segment.h:89
gr_slatSeqBelowWt
@ gr_slatSeqBelowWt
Definition Segment.h:159
gr_slatDir
@ gr_slatDir
bidi directionality of this glyph (not implemented)
Definition Segment.h:97
gr_slatSeqAboveWt
@ gr_slatSeqAboveWt
Definition Segment.h:157
gr_slatColExclGlyph
@ gr_slatColExclGlyph
Definition Segment.h:149
gr_slatColShifty
@ gr_slatColShifty
Collision shift y.
Definition Segment.h:143
gr_slatSeqValignHt
@ gr_slatSeqValignHt
Definition Segment.h:160
gr_slatAttY
@ gr_slatAttY
This slot attaches to its parent at the given design units in the y direction.
Definition Segment.h:73
gr_slatSeqAboveXoff
@ gr_slatSeqAboveXoff
Definition Segment.h:156
gr_slot_next_in_segment
GR2_API const gr_slot * gr_slot_next_in_segment(const gr_slot *p)
Returns the next slot along in the segment.
gr_seg_first_slot
GR2_API const gr_slot * gr_seg_first_slot(gr_segment *pSeg)
Returns the first gr_slot in the segment.
gr_slot_before
GR2_API int gr_slot_before(const gr_slot *p)
Returns the gr_char_info index before us.
gr_slot_attached_to
GR2_API const gr_slot * gr_slot_attached_to(const gr_slot *p)
Returns the attachment parent slot of this slot.
gr_cinfo_base
GR2_API size_t gr_cinfo_base(const gr_char_info *p)
Returns the code unit index of this character in the input string.
gr_seg_advance_Y
GR2_API float gr_seg_advance_Y(const gr_segment *pSeg)
Returns the height advance for the segment.
gr_slot_origin_X
GR2_API float gr_slot_origin_X(const gr_slot *p)
Returns X offset of glyph from start of segment.
gr_seg_justify
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.
gr_cinfo_break_weight
GR2_API int gr_cinfo_break_weight(const gr_char_info *p)
Returns breakweight for a charinfo.
gr_seg_last_slot
GR2_API const gr_slot * gr_seg_last_slot(gr_segment *pSeg)
Returns the last gr_slot in the segment.
gr_seg_n_cinfo
GR2_API unsigned int gr_seg_n_cinfo(const gr_segment *pSeg)
Returns the number of gr_char_infos in the segment.
gr_slot_linebreak_before
GR2_API void gr_slot_linebreak_before(gr_slot *p)
Breaks a segment into lines.
gr_cinfo_after
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.
gr_seg_n_slots
GR2_API unsigned int gr_seg_n_slots(const gr_segment *pSeg)
Returns the number of glyph gr_slots in the segment.
gr_slot_attr
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.
gr_slot_first_attachment
GR2_API const gr_slot * gr_slot_first_attachment(const gr_slot *p)
Returns the first slot attached to this slot.
gr_justFlags
gr_justFlags
Definition Segment.h:53
gr_justEndInline
@ gr_justEndInline
Indicates that the end of the slot list is not at the end of a line.
Definition Segment.h:59
gr_justStartInline
@ gr_justStartInline
Indicates that the start of the slot list is not at the start of a line.
Definition Segment.h:57
gr_justCompleteLine
@ gr_justCompleteLine
Indicates that this segment is a complete line.
Definition Segment.h:55
gr_count_unicode_characters
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.
gr_char_info
struct gr_char_info gr_char_info
Definition Segment.h:180
gr_slot
struct gr_slot gr_slot
Definition Segment.h:182
gr_slot_index
GR2_API unsigned int gr_slot_index(const gr_slot *p)
Returns the index of this slot in the segment.
gr_seg_destroy
GR2_API void gr_seg_destroy(gr_segment *p)
Destroys a segment, freeing the memory.
Types.h
gr_encform
gr_encform
Definition Types.h:39
gr_uint32
unsigned int gr_uint32
Definition Types.h:36
gr_uint8
unsigned char gr_uint8
Definition Types.h:31
GR2_API
#define GR2_API
Definition Types.h:77