summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/arabic/arabic-fc.c2
-rw-r--r--modules/arabic/arabic-x.c2
-rw-r--r--modules/arabic/arabic-xft.c2
-rw-r--r--modules/basic/basic-fc.c2
-rw-r--r--modules/basic/basic-ft2.c2
-rw-r--r--modules/basic/basic-win32.c2
-rw-r--r--modules/basic/basic-x.c141
-rw-r--r--modules/basic/basic-xft.c2
-rw-r--r--modules/basic/tables-big.i7
-rw-r--r--modules/hangul/hangul-x.c2
-rw-r--r--modules/hebrew/hebrew-x.c2
-rw-r--r--modules/indic/bengali-x.c2
-rw-r--r--modules/indic/devanagari-x.c2
-rw-r--r--modules/indic/gujarati-x.c2
-rw-r--r--modules/indic/gurmukhi-x.c2
-rw-r--r--modules/indic/myanmar-x.c2
-rw-r--r--modules/tamil/tamil-x.c2
-rw-r--r--modules/tamil/tamil-xft.c2
-rw-r--r--modules/thai/thai-x.c2
19 files changed, 149 insertions, 33 deletions
diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c
index 4ee981a2..0771d6df 100644
--- a/modules/arabic/arabic-fc.c
+++ b/modules/arabic/arabic-fc.c
@@ -301,7 +301,7 @@ arabic_engine_shape (PangoFont *font,
static PangoCoverage *
arabic_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
return pango_font_get_coverage (font, lang);
}
diff --git a/modules/arabic/arabic-x.c b/modules/arabic/arabic-x.c
index 4ab5d6bf..75534025 100644
--- a/modules/arabic/arabic-x.c
+++ b/modules/arabic/arabic-x.c
@@ -298,7 +298,7 @@ arabic_engine_shape (PangoFont *font,
static PangoCoverage *
arabic_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
gunichar i;
PangoCoverage *result = pango_coverage_new ();
diff --git a/modules/arabic/arabic-xft.c b/modules/arabic/arabic-xft.c
index 4ee981a2..0771d6df 100644
--- a/modules/arabic/arabic-xft.c
+++ b/modules/arabic/arabic-xft.c
@@ -301,7 +301,7 @@ arabic_engine_shape (PangoFont *font,
static PangoCoverage *
arabic_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
return pango_font_get_coverage (font, lang);
}
diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c
index 6f6e869a..7df5a129 100644
--- a/modules/basic/basic-fc.c
+++ b/modules/basic/basic-fc.c
@@ -226,7 +226,7 @@ basic_engine_shape (PangoFont *font,
static PangoCoverage *
basic_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
return pango_font_get_coverage (font, lang);
}
diff --git a/modules/basic/basic-ft2.c b/modules/basic/basic-ft2.c
index 01218dc5..9c5dac66 100644
--- a/modules/basic/basic-ft2.c
+++ b/modules/basic/basic-ft2.c
@@ -283,7 +283,7 @@ basic_engine_shape (PangoFont *font,
static PangoCoverage *
basic_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
PangoCoverage *result;
#if 0
diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c
index 4581cc52..bd1b6dbe 100644
--- a/modules/basic/basic-win32.c
+++ b/modules/basic/basic-win32.c
@@ -221,7 +221,7 @@ basic_engine_shape (PangoFont *font,
static PangoCoverage *
basic_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
PangoCoverage *result = pango_coverage_new ();
gunichar wc;
diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c
index 54417064..99316cc9 100644
--- a/modules/basic/basic-x.c
+++ b/modules/basic/basic-x.c
@@ -28,7 +28,9 @@
typedef struct _CharRange CharRange;
typedef struct _Charset Charset;
+typedef struct _CharsetOrdering CharsetOrdering;
typedef struct _CharCache CharCache;
+typedef struct _CharCachePointer CharCachePointer;
typedef struct _MaskTable MaskTable;
typedef PangoGlyph (*ConvFunc) (CharCache *cache,
@@ -47,6 +49,12 @@ struct _Charset
ConvFunc conv_func;
};
+struct _CharsetOrdering
+{
+ const char *langs;
+ char charsets[MAX_CHARSETS];
+};
+
struct _CharRange
{
guint16 start;
@@ -64,10 +72,18 @@ struct _MaskTable
struct _CharCache
{
+ guint ref_count;
+ CharsetOrdering *ordering;
MaskTable *mask_tables[256];
GIConv converters[MAX_CHARSETS];
};
+struct _CharCachePointer
+{
+ PangoLanguage *lang;
+ CharCache *cache;
+};
+
static PangoGlyph conv_8bit (CharCache *cache,
Charset *charset,
const char *input);
@@ -112,17 +128,37 @@ static gint n_script_engines = G_N_ELEMENTS (script_engines);
* X window system script engine portion
*/
+/* Structure of our cache:
+ *
+ * PangoFont => CharCachePointer ===\
+ * | \
+ * CharCachePointer ======> CharCache => CharsetOrdering
+ * | |======> MaskTable[0] => {subfonts,charset}[n_subfonts],
+ * | |======> MaskTable[1] => {subfonts,charset}[n_subfonts],
+ * | \======> MaskTable[...] => {subfonts,charset}[n_subfonts]
+ * |
+ * CharCachePointer ======> CharCache => CharsetOrdering
+ * |======> MaskTable[0] => {subfonts,charset}[n_subfonts],
+ * |======> MaskTable[1] => {subfonts,charset}[n_subfonts],
+ * \======> MaskTable[...] => {subfonts,charset}[n_subfonts]
+ *
+ * A CharCache structure caches the lookup of what subfonts can be used for what characters for a pair of a Font
+ * and CharsetOrdering. Multiple language tags can share the same CharsetOrdering - the list of CharCachePointer
+ * structures that is attached to the font as object data provides lookups from language tag to charcache.
+ */
static CharCache *
-char_cache_new (void)
+char_cache_new (CharsetOrdering *ordering)
{
CharCache *result;
int i;
result = g_new0 (CharCache, 1);
+ result->ref_count = 1;
+ result->ordering = ordering;
for (i=0; i<MAX_CHARSETS; i++)
result->converters[i] = (GIConv)-1;
-
+
return result;
}
@@ -188,10 +224,12 @@ find_char (CharCache *cache, PangoFont *font, gunichar wc, const char *input)
for (i=0; i<G_N_ELEMENTS(charsets); i++)
{
- if (mask & (1 << i))
+ int charset_index = cache->ordering->charsets[i];
+
+ if (mask & (1 << charset_index))
{
- charset_names[n_charsets] = charsets[i].x_charset;
- charsets_map[n_charsets] = &charsets[i];
+ charset_names[n_charsets] = charsets[charset_index].x_charset;
+ charsets_map[n_charsets] = &charsets[charset_index];
n_charsets++;
}
@@ -329,19 +367,90 @@ swap_range (PangoGlyphString *glyphs, int start, int end)
}
}
+static void
+char_caches_free (GSList *caches)
+{
+ GSList *tmp_list = caches;
+ while (tmp_list)
+ {
+ CharCachePointer *pointer = tmp_list->data;
+
+ pointer->cache->ref_count--;
+ if (pointer->cache->ref_count == 0)
+ char_cache_free (pointer->cache);
+ g_free (pointer);
+
+ tmp_list = tmp_list->next;
+ }
+ g_slist_free (caches);
+}
+
+static CharsetOrdering *
+ordering_for_lang (PangoLanguage *lang)
+{
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (charset_orderings) - 1; i++)
+ {
+ if (pango_language_matches (lang, charset_orderings[i].langs))
+ return &charset_orderings[i];
+ }
+
+ return &charset_orderings[i];
+}
+
static CharCache *
-get_char_cache (PangoFont *font)
+get_char_cache (PangoFont *font,
+ PangoLanguage *lang)
{
GQuark cache_id = g_quark_from_string ("basic-char-cache");
-
- CharCache *cache = g_object_get_qdata (G_OBJECT (font), cache_id);
- if (!cache)
+ CharCache *cache = NULL;
+ CharCachePointer *pointer;
+ CharsetOrdering *ordering;
+ GSList *caches;
+ GSList *tmp_list;
+
+ caches = g_object_get_qdata (G_OBJECT (font), cache_id);
+ tmp_list = caches;
+ while (tmp_list)
+ {
+ pointer = tmp_list->data;
+ if (pointer->lang == lang)
+ return pointer->cache;
+
+ tmp_list = tmp_list->next;
+ }
+
+ ordering = ordering_for_lang (lang);
+
+ tmp_list = caches;
+ while (tmp_list)
{
- cache = char_cache_new ();
- g_object_set_qdata_full (G_OBJECT (font), cache_id,
- cache, (GDestroyNotify)char_cache_free);
+ pointer = tmp_list->data;
+ if (pointer->cache->ordering == ordering)
+ {
+ cache = pointer->cache;
+ break;
+ }
+
+ tmp_list = tmp_list->next;
}
+ if (!cache)
+ cache = char_cache_new (ordering);
+ else
+ cache->ref_count++;
+
+ pointer = g_new (CharCachePointer, 1);
+ pointer->lang = lang;
+ pointer->cache = cache;
+
+ caches = g_slist_prepend (caches, pointer);
+
+ g_object_steal_qdata (G_OBJECT (font), cache_id);
+ g_object_set_qdata_full (G_OBJECT (font), cache_id,
+ caches, (GDestroyNotify)char_caches_free);
+
return cache;
}
@@ -363,7 +472,7 @@ basic_engine_shape (PangoFont *font,
g_return_if_fail (length >= 0);
g_return_if_fail (analysis != NULL);
- cache = get_char_cache (font);
+ cache = get_char_cache (font, analysis->language);
n_chars = g_utf8_strlen (text, length);
pango_glyph_string_set_size (glyphs, n_chars);
@@ -451,10 +560,10 @@ basic_engine_shape (PangoFont *font,
}
static PangoCoverage *
-basic_engine_get_coverage (PangoFont *font,
- const char *lang)
+basic_engine_get_coverage (PangoFont *font,
+ PangoLanguage *lang)
{
- CharCache *cache = get_char_cache (font);
+ CharCache *cache = get_char_cache (font, lang);
PangoCoverage *result = pango_coverage_new ();
gunichar wc;
diff --git a/modules/basic/basic-xft.c b/modules/basic/basic-xft.c
index 6f6e869a..7df5a129 100644
--- a/modules/basic/basic-xft.c
+++ b/modules/basic/basic-xft.c
@@ -226,7 +226,7 @@ basic_engine_shape (PangoFont *font,
static PangoCoverage *
basic_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
return pango_font_get_coverage (font, lang);
}
diff --git a/modules/basic/tables-big.i b/modules/basic/tables-big.i
index 2de955b9..3db74926 100644
--- a/modules/basic/tables-big.i
+++ b/modules/basic/tables-big.i
@@ -42,6 +42,13 @@ Charset charsets[] = {
{ 18, "ISO-10646", "iso10646-1", conv_ucs4 }
};
+CharsetOrdering charset_orderings[] = {
+ { "zh-cn", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 15, 17 } },
+ { "zh-tw", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 15, 17 } },
+ { "ja", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 16, 17 } },
+ { NULL, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 18, 15, 16, 17 } },
+};
+
const guint32 char_mask_map[] = {
0,
ENC_ISO_8859_10|ENC_ISO_8859_1|ENC_ISO_8859_13|ENC_ISO_8859_14|ENC_ISO_8859_15|ENC_ISO_8859_2|ENC_ISO_8859_3|ENC_ISO_8859_4|ENC_ISO_8859_5|ENC_ISO_8859_6|ENC_ISO_8859_7|ENC_ISO_8859_8|ENC_ISO_8859_9|ENC_KOI8_R,
diff --git a/modules/hangul/hangul-x.c b/modules/hangul/hangul-x.c
index 0cc03e05..951819b1 100644
--- a/modules/hangul/hangul-x.c
+++ b/modules/hangul/hangul-x.c
@@ -661,7 +661,7 @@ hangul_engine_shape (PangoFont *font,
static PangoCoverage *
hangul_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
PangoCoverage *result = pango_coverage_new ();
PangoXSubfont subfont;
diff --git a/modules/hebrew/hebrew-x.c b/modules/hebrew/hebrew-x.c
index 250840ef..ac4be81f 100644
--- a/modules/hebrew/hebrew-x.c
+++ b/modules/hebrew/hebrew-x.c
@@ -492,7 +492,7 @@ hebrew_engine_shape (PangoFont *font,
static PangoCoverage *
hebrew_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
PangoCoverage *result = pango_coverage_new ();
diff --git a/modules/indic/bengali-x.c b/modules/indic/bengali-x.c
index 64843c4c..308d3a23 100644
--- a/modules/indic/bengali-x.c
+++ b/modules/indic/bengali-x.c
@@ -106,7 +106,7 @@ static PangoEngineRange pango_indic_range[] =
SCRIPT_ENGINE_DEFINITION
static PangoCoverage *
-pango_indic_engine_get_coverage (PangoFont * font, const char *lang)
+pango_indic_engine_get_coverage (PangoFont * font, PangoLanguage *lang)
{
gunichar i;
PangoCoverage *result = pango_coverage_new ();
diff --git a/modules/indic/devanagari-x.c b/modules/indic/devanagari-x.c
index d024e41f..8c7e1a75 100644
--- a/modules/indic/devanagari-x.c
+++ b/modules/indic/devanagari-x.c
@@ -81,7 +81,7 @@ static PangoEngineRange pango_indic_range[] =
SCRIPT_ENGINE_DEFINITION
static PangoCoverage *
-pango_indic_engine_get_coverage (PangoFont * font, const char *lang)
+pango_indic_engine_get_coverage (PangoFont * font, PangoLanguage *lang)
{
gunichar i;
PangoCoverage *result = pango_coverage_new ();
diff --git a/modules/indic/gujarati-x.c b/modules/indic/gujarati-x.c
index ce1ffeac..f5e939dc 100644
--- a/modules/indic/gujarati-x.c
+++ b/modules/indic/gujarati-x.c
@@ -67,7 +67,7 @@ static PangoEngineRange pango_indic_range[] =
SCRIPT_ENGINE_DEFINITION
static PangoCoverage *
-pango_indic_engine_get_coverage (PangoFont * font, const char *lang)
+pango_indic_engine_get_coverage (PangoFont * font, PangoLanguage *lang)
{
gunichar i;
PangoCoverage *result = pango_coverage_new ();
diff --git a/modules/indic/gurmukhi-x.c b/modules/indic/gurmukhi-x.c
index a8429ee3..f810e648 100644
--- a/modules/indic/gurmukhi-x.c
+++ b/modules/indic/gurmukhi-x.c
@@ -67,7 +67,7 @@ static PangoEngineRange pango_indic_range[] =
SCRIPT_ENGINE_DEFINITION
static PangoCoverage *
-pango_indic_engine_get_coverage (PangoFont * font, const char *lang)
+pango_indic_engine_get_coverage (PangoFont * font, PangoLanguage *lang)
{
gunichar i;
PangoCoverage *result = pango_coverage_new ();
diff --git a/modules/indic/myanmar-x.c b/modules/indic/myanmar-x.c
index 1eb9dfce..bf6378b6 100644
--- a/modules/indic/myanmar-x.c
+++ b/modules/indic/myanmar-x.c
@@ -69,7 +69,7 @@ static PangoEngineRange pango_indic_range[] =
SCRIPT_ENGINE_DEFINITION
static PangoCoverage *
-pango_engine_get_coverage (PangoFont * font, const char *lang)
+pango_engine_get_coverage (PangoFont * font, PangoLanguage *lang)
{
gunichar i;
PangoCoverage *result = pango_coverage_new ();
diff --git a/modules/tamil/tamil-x.c b/modules/tamil/tamil-x.c
index 76cd7c25..0e3009db 100644
--- a/modules/tamil/tamil-x.c
+++ b/modules/tamil/tamil-x.c
@@ -361,7 +361,7 @@ tamil_engine_shape (PangoFont *font,
static PangoCoverage *
tamil_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
PangoCoverage *result = pango_coverage_new ();
diff --git a/modules/tamil/tamil-xft.c b/modules/tamil/tamil-xft.c
index e1d32926..4e411625 100644
--- a/modules/tamil/tamil-xft.c
+++ b/modules/tamil/tamil-xft.c
@@ -377,7 +377,7 @@ tamil_engine_shape (PangoFont *font,
static PangoCoverage *
tamil_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
return pango_font_get_coverage (font, lang);
}
diff --git a/modules/thai/thai-x.c b/modules/thai/thai-x.c
index 0fa21585..47310e54 100644
--- a/modules/thai/thai-x.c
+++ b/modules/thai/thai-x.c
@@ -847,7 +847,7 @@ thai_engine_shape (PangoFont *font,
static PangoCoverage *
thai_engine_get_coverage (PangoFont *font,
- const char *lang)
+ PangoLanguage *lang)
{
PangoCoverage *result = pango_coverage_new ();