#ifndef HARFBUZZ_SHAPER_H
#define HARFBUZZ_SHAPER_H
#include "harfbuzz-global.h"
#include "harfbuzz-gdef.h"
#include "harfbuzz-gpos.h"
#include "harfbuzz-gsub.h"
#include "harfbuzz-external.h"
#include "harfbuzz-stream-private.h"
HB_BEGIN_HEADER
typedef enum {
HB_Script_Common,
HB_Script_Greek,
HB_Script_Cyrillic,
HB_Script_Armenian,
HB_Script_Hebrew,
HB_Script_Arabic,
HB_Script_Syriac,
HB_Script_Thaana,
HB_Script_Devanagari,
HB_Script_Bengali,
HB_Script_Gurmukhi,
HB_Script_Gujarati,
HB_Script_Oriya,
HB_Script_Tamil,
HB_Script_Telugu,
HB_Script_Kannada,
HB_Script_Malayalam,
HB_Script_Sinhala,
HB_Script_Thai,
HB_Script_Lao,
HB_Script_Tibetan,
HB_Script_Myanmar,
HB_Script_Georgian,
HB_Script_Hangul,
HB_Script_Ogham,
HB_Script_Runic,
HB_Script_Khmer,
HB_Script_Nko,
HB_Script_Inherited,
HB_ScriptCount = HB_Script_Inherited
} HB_Script;
typedef struct
{
hb_uint32 pos;
hb_uint32 length;
HB_Script script;
hb_uint8 bidiLevel;
} HB_ScriptItem;
typedef enum {
HB_NoBreak,
HB_SoftHyphen,
HB_Break,
HB_ForcedBreak
} HB_LineBreakType;
typedef struct {
unsigned lineBreakType :2;
unsigned whiteSpace :1;
unsigned charStop :1;
unsigned wordBoundary :1;
unsigned sentenceBoundary :1;
unsigned unused :2;
} HB_CharAttributes;
void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
const HB_ScriptItem *items, hb_uint32 numItems,
HB_CharAttributes *attributes);
void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
const HB_ScriptItem *items, hb_uint32 numItems,
HB_CharAttributes *attributes);
void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
const HB_ScriptItem *items, hb_uint32 numItems,
HB_CharAttributes *attributes);
typedef enum {
HB_LeftToRight = 0,
HB_RightToLeft = 1
} HB_StringToGlyphsFlags;
typedef enum {
HB_ShaperFlag_Default = 0,
HB_ShaperFlag_NoKerning = 1,
HB_ShaperFlag_UseDesignMetrics = 1 << 1,
HB_ShaperFlag_ForceMarksToZeroWidth = 1 << 2
} HB_ShaperFlag;
typedef enum {
HB_NoJustification= 0,
HB_Arabic_Space = 1,
HB_Character = 2,
HB_Space = 4,
HB_Arabic_Normal = 7,
HB_Arabic_Waw = 8,
HB_Arabic_BaRa = 9,
HB_Arabic_Alef = 10,
HB_Arabic_HaaDal = 11,
HB_Arabic_Seen = 12,
HB_Arabic_Kashida = 13
} HB_JustificationClass;
typedef struct {
unsigned justification :4;
unsigned clusterStart :1;
unsigned mark :1;
unsigned zeroWidth :1;
unsigned dontPrint :1;
unsigned combiningClass :8;
} HB_GlyphAttributes;
typedef struct HB_FaceRec_ {
HB_Bool isSymbolFont;
HB_GDEF gdef;
HB_GSUB gsub;
HB_GPOS gpos;
HB_Bool supported_scripts[HB_ScriptCount];
HB_Buffer buffer;
HB_Script current_script;
int current_flags;
HB_Bool has_opentype_kerning;
HB_Bool glyphs_substituted;
HB_GlyphAttributes *tmpAttributes;
unsigned int *tmpLogClusters;
int length;
int orig_nglyphs;
} HB_FaceRec;
typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);
HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc);
void HB_FreeFace(HB_Face face);
typedef struct {
HB_Fixed x, y;
HB_Fixed width, height;
HB_Fixed xOffset, yOffset;
} HB_GlyphMetrics;
typedef enum {
HB_FontAscent
} HB_FontMetric;
typedef struct {
HB_Bool (*convertStringToGlyphIndices)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);
void (*getGlyphAdvances)(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags );
HB_Bool (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);
HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags , hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);
void (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
HB_Fixed (*getFontMetric)(HB_Font font, HB_FontMetric metric);
} HB_FontClass;
typedef struct HB_Font_ {
const HB_FontClass *klass;
HB_UShort x_ppem, y_ppem;
HB_16Dot16 x_scale, y_scale;
void *userData;
} HB_FontRec;
typedef struct HB_ShaperItem_ HB_ShaperItem;
struct HB_ShaperItem_ {
const HB_UChar16 *string;
hb_uint32 stringLength;
HB_ScriptItem item;
HB_Font font;
HB_Face face;
int shaperFlags;
HB_Bool glyphIndicesPresent;
hb_uint32 initialGlyphCount;
hb_uint32 num_glyphs;
HB_Glyph *glyphs;
HB_GlyphAttributes *attributes;
HB_Fixed *advances;
HB_FixedPoint *offsets;
unsigned short *log_clusters;
HB_Bool kerning_applied;
};
HB_Bool HB_ShapeItem(HB_ShaperItem *item);
HB_END_HEADER
#endif