summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-06-05 02:04:56 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-06-05 02:04:56 +0000
commit78059d83ba56f36c874cdf71dcb07a6724bf355f (patch)
treed9026b55a0a3a5a6478fd66f9cca8357ce52316b /pango
parent9df621b3fa0a1e49c75eac8fc239138f8991b536 (diff)
downloadpango-78059d83ba56f36c874cdf71dcb07a6724bf355f.tar.gz
Zero glyphs->num_glyphs before calling into shape engine.
2007-06-04 Behdad Esfahbod <behdad@gnome.org> * pango/shape.c (pango_shape): Zero glyphs->num_glyphs before calling into shape engine. * pango/pango-engine.c (fallback_engine_shape): Improve, to support clusters and what not. * pango/pangocairo-font.c (_pango_cairo_font_get_hex_box_info): Use "pango_script_get_sample_language (PANGO_SCRIPT_LATIN)" instead of hardcoding "en". Handle cairo_scaled_font_extents() failure. svn path=/trunk/; revision=2332
Diffstat (limited to 'pango')
-rw-r--r--pango/pango-engine.c18
-rw-r--r--pango/pangocairo-font.c8
-rw-r--r--pango/shape.c2
3 files changed, 24 insertions, 4 deletions
diff --git a/pango/pango-engine.c b/pango/pango-engine.c
index c8461892..a21e5d84 100644
--- a/pango/pango-engine.c
+++ b/pango/pango-engine.c
@@ -103,8 +103,9 @@ fallback_engine_shape (PangoEngineShape *engine,
PangoGlyphString *glyphs)
{
int n_chars;
- int i;
const char *p;
+ int cluster = 0;
+ int i;
n_chars = text ? g_utf8_strlen (text, length) : 0;
@@ -113,8 +114,19 @@ fallback_engine_shape (PangoEngineShape *engine,
p = text;
for (i = 0; i < n_chars; i++)
{
+ gunichar wc;
+ PangoGlyph glyph;
PangoRectangle logical_rect;
- PangoGlyph glyph = g_utf8_get_char (p) | PANGO_GLYPH_UNKNOWN_FLAG;
+
+ wc = g_utf8_get_char (p);
+
+ if (g_unichar_type (wc) != G_UNICODE_NON_SPACING_MARK)
+ cluster = p - text;
+
+ if (pango_is_zero_width (wc))
+ glyph = PANGO_GLYPH_EMPTY;
+ else
+ glyph = PANGO_GET_UNKNOWN_GLYPH (wc);
pango_font_get_glyph_extents (analysis->font, glyph, NULL, &logical_rect);
@@ -124,7 +136,7 @@ fallback_engine_shape (PangoEngineShape *engine,
glyphs->glyphs[i].geometry.y_offset = 0;
glyphs->glyphs[i].geometry.width = logical_rect.width;
- glyphs->log_clusters[i] = p - text;
+ glyphs->log_clusters[i] = cluster;
p = g_utf8_next_char (p);
}
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index a8d011f2..2595c0ef 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -241,7 +241,7 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
context = pango_cairo_font_map_create_context ((PangoCairoFontMap *) (fontmap));
pango_context_set_matrix (context, &pango_ctm);
- pango_context_set_language (context, pango_language_from_string ("en"));
+ pango_context_set_language (context, pango_script_get_sample_language (PANGO_SCRIPT_LATIN));
pango_cairo_context_set_font_options (context, font_options);
mini_font = pango_font_map_load_font (fontmap, context, desc);
@@ -265,6 +265,12 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
}
cairo_scaled_font_extents (scaled_font, &font_extents);
+ if (font_extents.ascent + font_extents.descent <= 0)
+ {
+ font_extents.ascent = PANGO_UNKNOWN_GLYPH_HEIGHT;
+ font_extents.descent = 0;
+ }
+
pad = (font_extents.ascent + font_extents.descent) / 43;
pad = MIN (pad, mini_size);
diff --git a/pango/shape.c b/pango/shape.c
index 8e535aca..96bcb672 100644
--- a/pango/shape.c
+++ b/pango/shape.c
@@ -46,6 +46,8 @@ pango_shape (const gchar *text,
int i;
int last_cluster;
+ glyphs->num_glyphs = 0;
+
if (G_LIKELY (PANGO_IS_ENGINE_SHAPE (analysis->shape_engine) && PANGO_IS_FONT (analysis->font)))
{
_pango_engine_shape_shape (analysis->shape_engine, analysis->font,