Go to the source code of this file.
Typedefs | |
typedef struct gr_char_info | gr_char_info |
typedef struct gr_segment | gr_segment |
typedef struct gr_slot | gr_slot |
Functions | |
GR2_API unsigned int | gr_cinfo_unicode_char (const gr_char_info *p) |
Returns Unicode character for a charinfo. | |
GR2_API int | gr_cinfo_break_weight (const gr_char_info *p) |
Returns breakweight for a charinfo. | |
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 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 size_t | gr_cinfo_base (const gr_char_info *p) |
Returns the code unit index of this character in the input string. | |
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. | |
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 void | gr_seg_destroy (gr_segment *p) |
Destroys a segment, freeing the memory. | |
GR2_API float | gr_seg_advance_X (const gr_segment *pSeg) |
Returns the advance for the whole segment. | |
GR2_API float | gr_seg_advance_Y (const gr_segment *pSeg) |
Returns the height advance for 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 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 unsigned int | gr_seg_n_slots (const gr_segment *pSeg) |
Returns the number of glyph gr_slots 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 const gr_slot * | gr_seg_last_slot (gr_segment *pSeg) |
Returns the last gr_slot in the 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 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_slot_prev_in_segment (const gr_slot *p) |
Returns the previous slot along in the segment. | |
GR2_API const gr_slot * | gr_slot_attached_to (const gr_slot *p) |
Returns the attachment parent slot of this slot. | |
GR2_API const gr_slot * | gr_slot_first_attachment (const gr_slot *p) |
Returns the first slot attached to this slot. | |
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 unsigned short | gr_slot_gid (const gr_slot *p) |
Returns glyph id of the slot. | |
GR2_API float | gr_slot_origin_X (const gr_slot *p) |
Returns X offset of glyph from start of segment. | |
GR2_API float | gr_slot_origin_Y (const gr_slot *p) |
Returns Y offset of glyph from start of segment. | |
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 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_before (const gr_slot *p) |
Returns the gr_char_info index before us. | |
GR2_API int | gr_slot_after (const gr_slot *p) |
Returns the gr_char_info index after us. | |
GR2_API unsigned int | gr_slot_index (const gr_slot *p) |
Returns the index of this slot 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 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 void | gr_slot_linebreak_before (gr_slot *p) |
Breaks a segment into lines. |
typedef struct gr_char_info gr_char_info |
typedef struct gr_segment gr_segment |
enum gr_attrCode |
Used for looking up slot attributes.
Most are already available in other functions
enum gr_bidirtl |
enum gr_break_weight |
enum gr_justFlags |
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.
In effect each character is associated with a set of slots and this returns the index of the last slot in the segment this character is associated with.
p | Pointer to charinfo to return information on. |
GR2_API size_t gr_cinfo_base | ( | const gr_char_info * | p | ) |
Returns the code unit index of this character in the input string.
p | Pointer to charinfo to return information on. |
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.
In effect each character is associated with a set of slots and this returns the index of the first slot in the segment this character is associated with.
p | Pointer to charinfo to return information on. |
GR2_API int gr_cinfo_break_weight | ( | const gr_char_info * | p | ) |
Returns breakweight for a charinfo.
The overall breakweight between two characters is the maximum of the breakweight contributions from the characters either side of it. If a character makes no contribution to the breakweight on one side of it, the contribution is considered to be 0.0, then the value is this character's contribution to the overall breakweight after it.
p | Pointer to charinfo to return information on. |
GR2_API unsigned int gr_cinfo_unicode_char | ( | const gr_char_info * | p | ) |
Returns Unicode character for a charinfo.
p | Pointer to charinfo to return information on. |
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.
enc | Specifies the type of data in the string: utf8, utf16, utf32 |
buffer_begin | The start of the string |
buffer_end | Measure up to the first nul or when end is reached, whichever is earliest. This parameter may be NULL. |
pError | If there is a structural fault in the string, the location is returned in this variable. If no error occurs, pError will contain NULL. NULL may be passed for pError if no such information is required. |
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.
font | Gives the size of the font in pixels per em for final positioning. If NULL, positions are returned in design units, i.e. at a ppm of the upem of the face. |
face | The face containing all the non-size dependent information. |
script | This is a tag containing a script identifier that is used to choose which graphite table within the font to use. Maybe 0. Tag may be 4 chars NULL padded in LSBs or space padded in LSBs. |
pFeats | Pointer to a feature values to be used for the segment. Only one feature values may be used for a segment. If NULL the default features for the font will be used. |
enc | Specifies what encoding form the string is in (utf8, utf16, utf32) |
pStart | Start of the string |
nChars | Number of unicode characters to process in the string. The string will be processed either up to the first NULL or until nChars have been processed. nChars is also used to initialise the internal memory allocations of the segment. So it is wise not to make nChars too much greater than the actual number of characters being processed. |
dir | Specifies whether the segment is processed right to left (1) or left to right (0) and whether to run the internal bidi pass, if a font requests it. See enum gr_bidirtl for details. |
GR2_API float gr_seg_advance_X | ( | const gr_segment * | pSeg | ) |
Returns the advance for the whole segment.
Returns the width of the segment up to the next glyph origin after the segment
GR2_API float gr_seg_advance_Y | ( | const gr_segment * | pSeg | ) |
Returns the height advance for the segment.
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 void gr_seg_destroy | ( | gr_segment * | p | ) |
Destroys a segment, freeing the memory.
p | The segment to destroy |
GR2_API const gr_slot* gr_seg_first_slot | ( | gr_segment * | pSeg | ) |
Returns the first gr_slot in the segment.
The first slot in a segment has a gr_slot_prev_in_segment() of NULL. Slots are owned by their segment and are destroyed along with the 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.
Passed a pointer to the start of a linked list of slots corresponding to a line, as set up by gr_slot_linebreak_before, this function will position the glyphs in the line to take up the given width. It is possible to specify a subrange within the line to process. This allows skipping of line initial or final whitespace, for example. While this will ensure that the subrange fits width, the line will still be positioned with the first glyph of the line at 0. So the resulting positions may be beyond width.
pSeg | Pointer to the segment |
pStart | Pointer to the start of the line linked list (including skipped characters) |
pFont | Font to use for positioning |
width | Width in pixels in which to fit the line. If < 0. don't adjust natural width, just run justification passes to handle line end contextuals, if there are any. |
flags | Indicates line ending types. Default is linked list is a full line |
pFirst | If not NULL, the first slot in the list to be considered part of the line (so can skip) |
pLast | If not NULL, the last slot to process in the line (allow say trailing whitespace to be skipped) |
GR2_API const gr_slot* gr_seg_last_slot | ( | gr_segment * | pSeg | ) |
Returns the last gr_slot in the segment.
The last slot in a segment has a gr_slot_next_in_segment() of NULL
GR2_API unsigned int gr_seg_n_cinfo | ( | const gr_segment * | pSeg | ) |
Returns the number of gr_char_infos in the segment.
GR2_API unsigned int gr_seg_n_slots | ( | const gr_segment * | pSeg | ) |
Returns the number of glyph gr_slots in the segment.
Returns the glyph advance for this glyph as adjusted for kerning.
p | Slot to give results for |
face | gr_face of the glyphs. May be NULL if unhinted advances used |
font | gr_font to scale for pixel results. If NULL returns design units advance. If not NULL then returns pixel advance based on hinted or scaled glyph advances in the font. face must be passed for hinted advances to be used. |
Returns the vertical advance for the glyph in the slot adjusted for kerning.
Returns design units unless font is not NULL in which case the pixel value is returned scaled for the given font
Returns the gr_char_info index after us.
Returns the index of the gr_char_info that a cursor after this slot would put an underlying cursor after. This may also be interpretted as each slot holding a set of char_infos that it is associated with and this function returning the index of the char_info with the highest index, from this set.
Returns the attachment parent slot of this slot.
Attached slots form a tree. This returns the parent of this slot in that tree. A base glyph which is not attached to another glyph, always returns NULL.
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.
Given a slot and an attribute along with a possible subattribute, return the corresponding value in the slot. See enum gr_attrCode for details of each attribute.
Returns the gr_char_info index before us.
Returns the index of the gr_char_info that a cursor before this slot, would put an underlying cursor before. This may also be interpretted as each slot holding a set of char_infos that it is associated with and this function returning the index of the char_info with lowest index, from this set.
Returns whether text may be inserted before this glyph.
This indicates whether a cursor can be put before this slot. It applies to base glyphs that have no parent as well as attached glyphs that have the .insert attribute explicitly set to true. This is the primary mechanism for identifying contiguous sequences of base plus diacritics.
Returns the first slot attached to this slot.
Attached slots form a singly linked list from the parent. This returns the first slot in that list. Note that this is a reference to another slot that is also in the main segment doubly linked list.
if gr_slot_first_attachment(p) != NULL then gr_slot_attached_to(gr_slot_first_attachment(p)) == p.
Returns glyph id of the slot.
Each slot has a glyphid which is rendered at the position given by the slot. This glyphid is the real glyph to be rendered and never a pseudo glyph.
Returns the index of this slot in the segment.
Returns the index given to this slot during final positioning. This corresponds to the value returned br gr_cinfo_before() and gr_cinfo_after()
Breaks a segment into lines.
Breaks the slot linked list at the given point in the linked list. It is up to the application to keep track of the first slot on each line.
Returns the next slot along in the segment.
Slots are held in a linked list. This returns the next in the linked list. The slot may or may not be attached to another slot. Returns NULL at the end of the segment.
Returns the next slot attached to our attachment parent.
This returns the next slot in the singly linked list of slots attached to this slot's parent. If there are no more such slots, NULL is returned. If there is no parent, i.e. the passed slot is a cluster base, then the next cluster base in graphical order (ltr, even for rtl text) is returned.
if gr_slot_next_sibling_attachment(p) != NULL then gr_slot_attached_to(gr_slot_next_sibling_attachment(p)) == gr_slot_attached_to(p).
Returns X offset of glyph from start of segment.
Returns Y offset of glyph from start of segment.
Returns the original gr_char_info index this slot refers to.
Each Slot has a gr_char_info that it originates from. This is that gr_char_info. The index is passed to gr_seg_cinfo(). This information is useful for testing.