summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <shausman@rhea.troll.no>2007-02-19 14:57:49 +0100
committerSimon Hausmann <shausman@rhea.troll.no>2007-03-28 12:52:31 +0200
commit4ff365a55273abab4d9d2ad4194738aadb589d45 (patch)
tree14f2225a29bcacc4d8be7c02fe9e980347a2eb84 /src
parent11d29340b430242f749ff369602ed8549893a942 (diff)
Use HB_FontClass's getSFntTable callback instead of using FT_Load_SFnt_Table directly
Diffstat (limited to 'src')
-rw-r--r--src/harfbuzz-arabic.cpp2
-rw-r--r--src/harfbuzz-hangul.cpp2
-rw-r--r--src/harfbuzz-hebrew.cpp4
-rw-r--r--src/harfbuzz-indic.cpp6
-rw-r--r--src/harfbuzz-khmer.cpp2
-rw-r--r--src/harfbuzz-myanmar.cpp2
-rw-r--r--src/harfbuzz-shaper-private.h4
-rw-r--r--src/harfbuzz-shaper.cpp47
-rw-r--r--src/harfbuzz-shaper.h10
-rw-r--r--src/harfbuzz-tibetan.cpp2
10 files changed, 28 insertions, 53 deletions
diff --git a/src/harfbuzz-arabic.cpp b/src/harfbuzz-arabic.cpp
index c267d2c..1b08ed7 100644
--- a/src/harfbuzz-arabic.cpp
+++ b/src/harfbuzz-arabic.cpp
@@ -1036,7 +1036,7 @@ HB_Bool HB_ArabicShape(HB_ShaperItem *item)
item->item.bidiLevel % 2,
item->attributes, item->log_clusters);
- HB_Bool haveGlyphs = item->font->klass->stringToGlyphs(item->font,
+ HB_Bool haveGlyphs = item->face->font->klass->stringToGlyphs(item->face->font,
shapedChars, slen,
item->glyphs, &item->num_glyphs,
item->item.bidiLevel % 2);
diff --git a/src/harfbuzz-hangul.cpp b/src/harfbuzz-hangul.cpp
index 4ecee4f..1250eb7 100644
--- a/src/harfbuzz-hangul.cpp
+++ b/src/harfbuzz-hangul.cpp
@@ -157,7 +157,7 @@ static bool hangul_shape_syllable(HB_ShaperItem *item, HB_Bool openType)
#ifndef NO_OPENTYPE
const int availableGlyphs = item->num_glyphs;
#endif
- if (!item->font->klass->stringToGlyphs(item->font,
+ if (!item->face->font->klass->stringToGlyphs(item->face->font,
ch, len,
item->glyphs, &item->num_glyphs,
item->item.bidiLevel % 2))
diff --git a/src/harfbuzz-hebrew.cpp b/src/harfbuzz-hebrew.cpp
index 0d04728..cfbed79 100644
--- a/src/harfbuzz-hebrew.cpp
+++ b/src/harfbuzz-hebrew.cpp
@@ -123,7 +123,7 @@ HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item)
++slen;
}
if (shaped) {
- if (shaper_item->font->klass->canRender(shaper_item->font, (HB_UChar16 *)&shaped, 1)) {
+ if (shaper_item->face->font->klass->canRender(shaper_item->face->font, (HB_UChar16 *)&shaped, 1)) {
shapedChars[slen-1] = shaped;
} else
shaped = 0;
@@ -149,7 +149,7 @@ HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item)
logClusters[i] = cluster_start;
}
- HB_Bool haveGlyphs = shaper_item->font->klass->stringToGlyphs(shaper_item->font,
+ HB_Bool haveGlyphs = shaper_item->face->font->klass->stringToGlyphs(shaper_item->face->font,
shapedChars, slen,
shaper_item->glyphs, &shaper_item->num_glyphs,
shaper_item->item.bidiLevel % 2);
diff --git a/src/harfbuzz-indic.cpp b/src/harfbuzz-indic.cpp
index 8b15b37..dad3994 100644
--- a/src/harfbuzz-indic.cpp
+++ b/src/harfbuzz-indic.cpp
@@ -1481,7 +1481,7 @@ static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool inv
#ifndef NO_OPENTYPE
const int availableGlyphs = item->num_glyphs;
#endif
- if (!item->font->klass->stringToGlyphs(item->font,
+ if (!item->face->font->klass->stringToGlyphs(item->face->font,
reordered, len,
item->glyphs, &item->num_glyphs,
item->item.bidiLevel % 2))
@@ -1605,8 +1605,8 @@ static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool inv
item->log_clusters = clusters;
HB_OpenTypeShape(item, properties);
- int newLen = item->font->face->buffer->in_length;
- HB_GlyphItem otl_glyphs = item->font->face->buffer->in_string;
+ int newLen = item->face->buffer->in_length;
+ HB_GlyphItem otl_glyphs = item->face->buffer->in_string;
// move the left matra back to its correct position in malayalam and tamil
if ((script == HB_Script_Malayalam || script == HB_Script_Tamil) && (form(reordered[0]) == Matra)) {
diff --git a/src/harfbuzz-khmer.cpp b/src/harfbuzz-khmer.cpp
index 8f41a5c..b9dea75 100644
--- a/src/harfbuzz-khmer.cpp
+++ b/src/harfbuzz-khmer.cpp
@@ -510,7 +510,7 @@ static bool khmer_shape_syllable(HB_Bool openType, HB_ShaperItem *item)
#ifndef NO_OPENTYPE
const int availableGlyphs = item->num_glyphs;
#endif
- if (!item->font->klass->stringToGlyphs(item->font,
+ if (!item->face->font->klass->stringToGlyphs(item->face->font,
reordered, len,
item->glyphs, &item->num_glyphs,
item->item.bidiLevel % 2))
diff --git a/src/harfbuzz-myanmar.cpp b/src/harfbuzz-myanmar.cpp
index 9adafe7..0d3fb00 100644
--- a/src/harfbuzz-myanmar.cpp
+++ b/src/harfbuzz-myanmar.cpp
@@ -382,7 +382,7 @@ static bool myanmar_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool i
#ifndef NO_OPENTYPE
const int availableGlyphs = item->num_glyphs;
#endif
- if (!item->font->klass->stringToGlyphs(item->font,
+ if (!item->face->font->klass->stringToGlyphs(item->face->font,
reordered, len,
item->glyphs, &item->num_glyphs,
item->item.bidiLevel % 2))
diff --git a/src/harfbuzz-shaper-private.h b/src/harfbuzz-shaper-private.h
index b96971f..c9de9ec 100644
--- a/src/harfbuzz-shaper-private.h
+++ b/src/harfbuzz-shaper-private.h
@@ -125,7 +125,7 @@ inline bool HB_IsControlChar(HB_UChar16 uc)
inline HB_Bool HB_StringToGlyphs(HB_ShaperItem *shaper_item)
{
- return shaper_item->font->klass->stringToGlyphs(shaper_item->font,
+ return shaper_item->face->font->klass->stringToGlyphs(shaper_item->face->font,
shaper_item->string + shaper_item->item.pos, shaper_item->item.length,
shaper_item->glyphs, &shaper_item->num_glyphs,
shaper_item->item.bidiLevel % 2);
@@ -133,7 +133,7 @@ inline HB_Bool HB_StringToGlyphs(HB_ShaperItem *shaper_item)
inline void HB_GetAdvances(HB_ShaperItem *shaper_item)
{
- shaper_item->font->klass->getAdvances(shaper_item->font,
+ shaper_item->face->font->klass->getAdvances(shaper_item->face->font,
shaper_item->glyphs, shaper_item->num_glyphs,
shaper_item->advances);
}
diff --git a/src/harfbuzz-shaper.cpp b/src/harfbuzz-shaper.cpp
index 62fc172..a9e705c 100644
--- a/src/harfbuzz-shaper.cpp
+++ b/src/harfbuzz-shaper.cpp
@@ -400,7 +400,7 @@ void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item)
// first char in a run is never (treated as) a mark
int cStart = 0;
- const bool symbolFont = item->font->face->isSymbolFont;
+ const bool symbolFont = item->face->isSymbolFont;
attributes[0].mark = false;
attributes[0].clusterStart = true;
attributes[0].dontPrint = (!symbolFont && uc[0] == 0x00ad) || HB_IsControlChar(uc[0]);
@@ -721,36 +721,11 @@ static HB_Bool checkScript(HB_Face face, int script)
return true;
}
-static HB_Stream HB_getTable(FT_Face face, HB_Tag tableTag)
-{
- FT_Error error;
- FT_ULong length = 0;
- HB_Stream stream = 0;
-
- if ( !FT_IS_SFNT(face) )
- return 0;
-
- error = FT_Load_Sfnt_Table(face, tableTag, 0, 0, &length);
- if (error)
- return 0;
- stream = (HB_Stream)malloc(sizeof(HB_StreamRec));
- stream->base = (HB_Byte*)malloc(length);
- error = FT_Load_Sfnt_Table(face, tableTag, 0, stream->base, NULL);
- if (error) {
- HB_close_stream(stream);
- return 0;
- }
- stream->size = length;
- stream->pos = 0;
- stream->cursor = NULL;
- return stream;
-}
-
-HB_Face HB_NewFace(FT_Face ftface)
+HB_Face HB_NewFace(HB_Font font)
{
HB_Face face = (HB_Face )malloc(sizeof(HB_FaceRec));
- face->freetypeFace = ftface;
+ face->font = font;
face->isSymbolFont = false;
face->gdef = 0;
face->gpos = 0;
@@ -766,14 +741,14 @@ HB_Face HB_NewFace(FT_Face ftface)
HB_Stream stream;
HB_Stream gdefStream;
- gdefStream = HB_getTable(ftface, TTAG_GDEF);
+ gdefStream = font->klass->getSFntTable(font, TTAG_GDEF);
if (!gdefStream || (error = HB_Load_GDEF_Table(gdefStream, &face->gdef))) {
//DEBUG("error loading gdef table: %d", error);
face->gdef = 0;
}
//DEBUG() << "trying to load gsub table";
- stream = HB_getTable(ftface, TTAG_GSUB);
+ stream = font->klass->getSFntTable(font, TTAG_GSUB);
if (!stream || (error = HB_Load_GSUB_Table(stream, &face->gsub, face->gdef, gdefStream))) {
face->gsub = 0;
if (error != HB_Err_Table_Missing) {
@@ -784,7 +759,7 @@ HB_Face HB_NewFace(FT_Face ftface)
}
HB_close_stream(stream);
- stream = HB_getTable(ftface, TTAG_GPOS);
+ stream = font->klass->getSFntTable(font, TTAG_GPOS);
if (!stream || (error = HB_Load_GPOS_Table(stream, &face->gpos, face->gdef, gdefStream))) {
face->gpos = 0;
DEBUG("error loading gpos table: %d", error);
@@ -822,10 +797,10 @@ HB_Bool HB_SelectScript(HB_ShaperItem *shaper_item, const HB_OpenTypeFeature *fe
{
HB_Script script = shaper_item->item.script;
- if (!shaper_item->font->face->supported_scripts[script])
+ if (!shaper_item->face->supported_scripts[script])
return false;
- HB_Face face = shaper_item->font->face;
+ HB_Face face = shaper_item->face;
if (face->current_script == script && face->current_flags == shaper_item->shaperFlags)
return true;
@@ -915,7 +890,7 @@ HB_Bool HB_SelectScript(HB_ShaperItem *shaper_item, const HB_OpenTypeFeature *fe
HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const uint32_t *properties)
{
- HB_Face face = item->font->face;
+ HB_Face face = item->face;
face->length = item->num_glyphs;
@@ -964,14 +939,14 @@ HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const uint32_t *properties)
HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters)
{
- HB_Face face = item->font->face;
+ HB_Face face = item->face;
bool glyphs_positioned = false;
if (face->gpos) {
memset(face->buffer->positions, 0, face->buffer->in_length*sizeof(HB_PositionRec));
int loadFlags = (face->current_flags & HB_ShaperFlag_UseDesignMetrics) ? FT_LOAD_NO_HINTING : FT_LOAD_DEFAULT;
// #### check that passing "false,false" is correct
- glyphs_positioned = HB_GPOS_Apply_String(face->freetypeFace, face->gpos, loadFlags, face->buffer, false, false) != HB_Err_Not_Covered;
+ glyphs_positioned = HB_GPOS_Apply_String(face->font->freetypeFace, face->gpos, loadFlags, face->buffer, false, false) != HB_Err_Not_Covered;
}
if (!face->glyphs_substituted && !glyphs_positioned) {
diff --git a/src/harfbuzz-shaper.h b/src/harfbuzz-shaper.h
index 818c97b..5371eba 100644
--- a/src/harfbuzz-shaper.h
+++ b/src/harfbuzz-shaper.h
@@ -152,9 +152,10 @@ typedef struct {
unsigned short combiningClass :8;
} HB_GlyphAttributes;
+typedef struct HB_Font_ *HB_Font;
typedef struct {
- FT_Face freetypeFace;
+ HB_Font font;
HB_Bool isSymbolFont;
HB_GDEF gdef;
@@ -173,10 +174,9 @@ typedef struct {
} HB_FaceRec, *HB_Face;
-HB_Face HB_NewFace(FT_Face ftface);
+HB_Face HB_NewFace(HB_Font font);
void HB_FreeFace(HB_Face face);
-typedef struct HB_Font_ *HB_Font;
typedef struct HB_StreamRec_ *HB_Stream;
typedef struct {
@@ -188,7 +188,7 @@ typedef struct {
typedef struct HB_Font_ {
const HB_FontClass *klass;
- HB_Face face;
+ FT_Face freetypeFace;
void *userData;
} HB_FontRec, *HB_Font;
@@ -196,7 +196,7 @@ typedef struct {
const HB_UChar16 *string;
uint32_t stringLength;
HB_ScriptItem item;
- HB_Font font;
+ HB_Face face;
int shaperFlags; // HB_ShaperFlags
uint32_t num_glyphs; // in: available glyphs out: glyphs used/needed
diff --git a/src/harfbuzz-tibetan.cpp b/src/harfbuzz-tibetan.cpp
index 4c0336e..b9617cd 100644
--- a/src/harfbuzz-tibetan.cpp
+++ b/src/harfbuzz-tibetan.cpp
@@ -108,7 +108,7 @@ static bool tibetan_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool i
#ifndef NO_OPENTYPE
const int availableGlyphs = item->num_glyphs;
#endif
- HB_Bool haveGlyphs = item->font->klass->stringToGlyphs(item->font,
+ HB_Bool haveGlyphs = item->face->font->klass->stringToGlyphs(item->face->font,
str, len,
item->glyphs, &item->num_glyphs,
item->item.bidiLevel % 2);