summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-03-07 02:02:15 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-03-07 02:02:15 +0000
commitdd0b4a5064c6f60adcfd2ea02e2d61fb60254d20 (patch)
tree39a121f4bd40300bcd67521104db86c12bd33165 /modules
parent6278d373c1a564ae4233a2e4b6d428a9f6202728 (diff)
downloadpango-dd0b4a5064c6f60adcfd2ea02e2d61fb60254d20.tar.gz
Convert log_clusters[] use from char offsets to byte offset - should make
Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com> * libpango/mapping.c example/viewer.c: * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c: Convert log_clusters[] use from char offsets to byte offset - should make it easier to have all interface deal with stuff in byte offsets. * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x to make them "member functions" of glyph_string. * libpango/pango-types.h: Add a rectangle type for use in storing glyph/glyph-string extents, plus macros for extracting ascent/descent. * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize glyph extents function into the font. * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to new rationalized unit system - everything in 1000ths of a point or 1000ths of a glyph unit. * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get extents of a glyph string. (We may want to fastpath the width in the future, since getting the width seems to be a very common and time-critical operation)
Diffstat (limited to 'modules')
-rw-r--r--modules/basic/basic-x.c15
-rw-r--r--modules/basic/basic.c15
-rw-r--r--modules/hangul/hangul-x.c64
-rw-r--r--modules/hangul/hangul.c64
-rw-r--r--modules/tamil/tamil-x.c19
-rw-r--r--modules/tamil/tamil.c19
6 files changed, 104 insertions, 92 deletions
diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c
index acd4a947..5e524f72 100644
--- a/modules/basic/basic-x.c
+++ b/modules/basic/basic-x.c
@@ -278,20 +278,19 @@ find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input)
}
static void
-set_glyph (PangoFont *font, PangoGlyphString *glyphs, gint i, PangoGlyph glyph)
+set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGlyph glyph)
{
- gint width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = glyph;
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- glyphs->log_clusters[i] = i;
+ glyphs->log_clusters[i] = offset;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
static iconv_t
@@ -445,7 +444,7 @@ basic_engine_shape (PangoFont *font,
index = find_char (cache, font, wc, p);
if (index)
{
- set_glyph (font, glyphs, i, index);
+ set_glyph (font, glyphs, i, p - text, index);
if (unicode_type (wc) == UNICODE_NON_SPACING_MARK)
{
@@ -459,7 +458,7 @@ basic_engine_shape (PangoFont *font,
}
}
else
- set_glyph (font, glyphs, i, pango_x_get_unknown_glyph (font));
+ set_glyph (font, glyphs, i, p - text, pango_x_get_unknown_glyph (font));
p = next;
}
diff --git a/modules/basic/basic.c b/modules/basic/basic.c
index acd4a947..5e524f72 100644
--- a/modules/basic/basic.c
+++ b/modules/basic/basic.c
@@ -278,20 +278,19 @@ find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input)
}
static void
-set_glyph (PangoFont *font, PangoGlyphString *glyphs, gint i, PangoGlyph glyph)
+set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGlyph glyph)
{
- gint width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = glyph;
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- glyphs->log_clusters[i] = i;
+ glyphs->log_clusters[i] = offset;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
static iconv_t
@@ -445,7 +444,7 @@ basic_engine_shape (PangoFont *font,
index = find_char (cache, font, wc, p);
if (index)
{
- set_glyph (font, glyphs, i, index);
+ set_glyph (font, glyphs, i, p - text, index);
if (unicode_type (wc) == UNICODE_NON_SPACING_MARK)
{
@@ -459,7 +458,7 @@ basic_engine_shape (PangoFont *font,
}
}
else
- set_glyph (font, glyphs, i, pango_x_get_unknown_glyph (font));
+ set_glyph (font, glyphs, i, p - text, pango_x_get_unknown_glyph (font));
p = next;
}
diff --git a/modules/hangul/hangul-x.c b/modules/hangul/hangul-x.c
index 8b07f115..4a3aeb96 100644
--- a/modules/hangul/hangul-x.c
+++ b/modules/hangul/hangul-x.c
@@ -87,19 +87,21 @@ hangul_engine_lang_new ()
*/
static void
-set_glyph (PangoGlyphString *glyphs, int i,
- PangoFont *font, PangoXSubfont subfont, guint16 gindex)
+set_glyph (PangoGlyphString *glyphs,
+ int i,
+ PangoFont *font,
+ PangoXSubfont subfont,
+ guint16 gindex)
{
- int width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
@@ -134,7 +136,7 @@ set_glyph (PangoGlyphString *glyphs, int i,
typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters);
+ int *n_glyphs, int cluster_offset);
@@ -210,7 +212,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
} \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -230,7 +232,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
\
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -240,7 +242,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
__jongseong_map[v - VBASE]; \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -248,7 +250,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
{ \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -260,7 +262,7 @@ static void
render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
JOHAB_COMMON
@@ -289,7 +291,7 @@ JOHAB_COMMON
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
else
@@ -302,7 +304,7 @@ static void
render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
JOHAB_COMMON
@@ -318,13 +320,13 @@ JOHAB_COMMON
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_johabfont[wc - LBASE][j]);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
if (IS_L (wc))
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -335,7 +337,7 @@ static void
render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
guint16 gindex;
int i;
@@ -382,7 +384,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
/* easy for composed syllables. */
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
return;
}
@@ -394,7 +396,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
gindex = text[i];
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -403,7 +405,7 @@ static void
render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
guint16 sindex;
guint16 gindex;
@@ -468,7 +470,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
return;
}
@@ -486,7 +488,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_ksc5601[gindex - LBASE][j]);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -589,7 +591,7 @@ hangul_engine_shape (PangoFont *font,
GUChar2 jamos[4];
int n_jamos = 0;
- int n_glyphs = 0, n_clusters = 0;
+ int n_glyphs = 0, cluster_offset = 0;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
@@ -641,15 +643,15 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
n_jamos = 0;
}
/* Draw a syllable. */
(*render_func) (font, subfont, wcs, 3,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
/* Clear. */
}
else if (wc4 >= 0x1100 && wc4 <= 0x11ff)
@@ -669,8 +671,8 @@ hangul_engine_shape (PangoFont *font,
{
/* Draw a syllable. */
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
/* Clear. */
n_jamos = 0;
}
@@ -690,8 +692,8 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
n_jamos = 0;
}
}
diff --git a/modules/hangul/hangul.c b/modules/hangul/hangul.c
index 8b07f115..4a3aeb96 100644
--- a/modules/hangul/hangul.c
+++ b/modules/hangul/hangul.c
@@ -87,19 +87,21 @@ hangul_engine_lang_new ()
*/
static void
-set_glyph (PangoGlyphString *glyphs, int i,
- PangoFont *font, PangoXSubfont subfont, guint16 gindex)
+set_glyph (PangoGlyphString *glyphs,
+ int i,
+ PangoFont *font,
+ PangoXSubfont subfont,
+ guint16 gindex)
{
- int width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
@@ -134,7 +136,7 @@ set_glyph (PangoGlyphString *glyphs, int i,
typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters);
+ int *n_glyphs, int cluster_offset);
@@ -210,7 +212,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
} \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -230,7 +232,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
\
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -240,7 +242,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
__jongseong_map[v - VBASE]; \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -248,7 +250,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
{ \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -260,7 +262,7 @@ static void
render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
JOHAB_COMMON
@@ -289,7 +291,7 @@ JOHAB_COMMON
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
else
@@ -302,7 +304,7 @@ static void
render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
JOHAB_COMMON
@@ -318,13 +320,13 @@ JOHAB_COMMON
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_johabfont[wc - LBASE][j]);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
if (IS_L (wc))
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -335,7 +337,7 @@ static void
render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
guint16 gindex;
int i;
@@ -382,7 +384,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
/* easy for composed syllables. */
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
return;
}
@@ -394,7 +396,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
gindex = text[i];
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -403,7 +405,7 @@ static void
render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
guint16 sindex;
guint16 gindex;
@@ -468,7 +470,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
return;
}
@@ -486,7 +488,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_ksc5601[gindex - LBASE][j]);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -589,7 +591,7 @@ hangul_engine_shape (PangoFont *font,
GUChar2 jamos[4];
int n_jamos = 0;
- int n_glyphs = 0, n_clusters = 0;
+ int n_glyphs = 0, cluster_offset = 0;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
@@ -641,15 +643,15 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
n_jamos = 0;
}
/* Draw a syllable. */
(*render_func) (font, subfont, wcs, 3,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
/* Clear. */
}
else if (wc4 >= 0x1100 && wc4 <= 0x11ff)
@@ -669,8 +671,8 @@ hangul_engine_shape (PangoFont *font,
{
/* Draw a syllable. */
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
/* Clear. */
n_jamos = 0;
}
@@ -690,8 +692,8 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
n_jamos = 0;
}
}
diff --git a/modules/tamil/tamil-x.c b/modules/tamil/tamil-x.c
index 908aaa94..9d7b4e92 100644
--- a/modules/tamil/tamil-x.c
+++ b/modules/tamil/tamil-x.c
@@ -11,6 +11,7 @@
#include "pangox.h"
#include "utils.h"
#include "taconv.h"
+#include <unicode.h>
static PangoEngineRange tamil_range[] = {
{ 0x0b80, 0x0bff, "*" },
@@ -94,21 +95,21 @@ tamil_engine_lang_new ()
* But we can live with this for time being
*/
static void
-set_glyph (PangoGlyphString *glyphs, int i,
+set_glyph (PangoGlyphString *glyphs, int i, int cluster_start,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
int width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- glyphs->log_clusters[i] = i;
+ glyphs->log_clusters[i] = cluster_start;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
static PangoXSubfont
@@ -140,6 +141,7 @@ tamil_engine_shape (PangoFont *font,
{
int n_chars, n_glyph;
int i, j;
+ const char *cluster_start;
const char *p;
const char *next;
GUChar4 *wc, *uni_str;
@@ -177,6 +179,7 @@ tamil_engine_shape (PangoFont *font,
n_glyph = 0;
uni_str = wc;
+ cluster_start = text;
j = 0;
while (j < n_chars)
{
@@ -186,17 +189,19 @@ tamil_engine_shape (PangoFont *font,
/* We need to differentiate between different return codes later */
if (res != TA_SUCCESS)
{
- set_glyph (glyphs, n_glyph, font, tscii_font, ' ');
+ set_glyph (glyphs, n_glyph, cluster_start - text, font, tscii_font, ' ');
n_glyph++;
j = j + nuni;
continue;
}
for (i = 0; i < ntsc; i++)
{
- set_glyph (glyphs, n_glyph, font, tscii_font, (PangoGlyph) tsc_str[i]);
+ set_glyph (glyphs, n_glyph, cluster_start - text, font, tscii_font, (PangoGlyph) tsc_str[i]);
n_glyph++;
}
j = j + nuni;
+ while (nuni--)
+ cluster_start = unicode_next_utf8 (cluster_start);
}
pango_glyph_string_set_size (glyphs, n_glyph);
diff --git a/modules/tamil/tamil.c b/modules/tamil/tamil.c
index 908aaa94..9d7b4e92 100644
--- a/modules/tamil/tamil.c
+++ b/modules/tamil/tamil.c
@@ -11,6 +11,7 @@
#include "pangox.h"
#include "utils.h"
#include "taconv.h"
+#include <unicode.h>
static PangoEngineRange tamil_range[] = {
{ 0x0b80, 0x0bff, "*" },
@@ -94,21 +95,21 @@ tamil_engine_lang_new ()
* But we can live with this for time being
*/
static void
-set_glyph (PangoGlyphString *glyphs, int i,
+set_glyph (PangoGlyphString *glyphs, int i, int cluster_start,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
int width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- glyphs->log_clusters[i] = i;
+ glyphs->log_clusters[i] = cluster_start;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
static PangoXSubfont
@@ -140,6 +141,7 @@ tamil_engine_shape (PangoFont *font,
{
int n_chars, n_glyph;
int i, j;
+ const char *cluster_start;
const char *p;
const char *next;
GUChar4 *wc, *uni_str;
@@ -177,6 +179,7 @@ tamil_engine_shape (PangoFont *font,
n_glyph = 0;
uni_str = wc;
+ cluster_start = text;
j = 0;
while (j < n_chars)
{
@@ -186,17 +189,19 @@ tamil_engine_shape (PangoFont *font,
/* We need to differentiate between different return codes later */
if (res != TA_SUCCESS)
{
- set_glyph (glyphs, n_glyph, font, tscii_font, ' ');
+ set_glyph (glyphs, n_glyph, cluster_start - text, font, tscii_font, ' ');
n_glyph++;
j = j + nuni;
continue;
}
for (i = 0; i < ntsc; i++)
{
- set_glyph (glyphs, n_glyph, font, tscii_font, (PangoGlyph) tsc_str[i]);
+ set_glyph (glyphs, n_glyph, cluster_start - text, font, tscii_font, (PangoGlyph) tsc_str[i]);
n_glyph++;
}
j = j + nuni;
+ while (nuni--)
+ cluster_start = unicode_next_utf8 (cluster_start);
}
pango_glyph_string_set_size (glyphs, n_glyph);