summaryrefslogtreecommitdiff
path: root/pango/pango-glyph-item.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-05-02 23:21:48 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-05-02 23:21:48 +0000
commite3eee491d7434dda314b78fad127880943d9c1ba (patch)
treeaac65921f24f0f2846c73f048c660e284a93d95d /pango/pango-glyph-item.c
parent86c5228a67df1d3028439fa1b97310e613e36fee (diff)
downloadpango-e3eee491d7434dda314b78fad127880943d9c1ba.tar.gz
Fix letter-spacing with justification. We now distribute letter-spacing
2007-05-02 Behdad Esfahbod <behdad@gnome.org> * pango/pango-glyph-item.c (pango_glyph_item_letter_space): * pango/pango-item.c (pango_item_split): * pango/pango-layout.c (distribute_letter_spacing), (shape_run), (debug), (process_item), (process_line), (pad_glyphstring_right), (pad_glyphstring_left), (zero_line_final_space), (adjust_line_letter_spacing), (pango_layout_line_postprocess): Fix letter-spacing with justification. We now distribute letter-spacing equally on both sides of clusters, instead of putting it all on one side. svn path=/trunk/; revision=2253
Diffstat (limited to 'pango/pango-glyph-item.c')
-rw-r--r--pango/pango-glyph-item.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/pango/pango-glyph-item.c b/pango/pango-glyph-item.c
index 6d5c5d98..157bb150 100644
--- a/pango/pango-glyph-item.c
+++ b/pango/pango-glyph-item.c
@@ -615,19 +615,50 @@ pango_glyph_item_letter_space (PangoGlyphItem *glyph_item,
int letter_spacing)
{
PangoGlyphItemIter iter;
+ PangoGlyphInfo *glyphs = glyph_item->glyphs->glyphs;
gboolean have_cluster;
+ int space_left, space_right;
+
+ space_left = letter_spacing / 2;
+
+ /* hinting */
+ if ((letter_spacing & (PANGO_SCALE - 1)) == 0)
+ {
+ space_left = PANGO_UNITS_ROUND (space_left);
+ }
+
+ space_right = letter_spacing - space_left;
for (have_cluster = _pango_glyph_item_iter_init_start (&iter, glyph_item, text);
have_cluster;
have_cluster = _pango_glyph_item_iter_next_cluster (&iter))
{
- if (iter.start_char > 0 &&
- log_attrs[iter.start_char].is_cursor_position)
+ if (!log_attrs[iter.start_char].is_cursor_position)
+ continue;
+
+ if (iter.start_glyph < iter.end_glyph) /* LTR */
+ {
+ if (iter.start_char > 0)
+ {
+ glyphs[iter.start_glyph].geometry.width += space_left ;
+ glyphs[iter.start_glyph].geometry.x_offset += space_left ;
+ }
+ if (iter.end_char < glyph_item->item->num_chars)
+ {
+ glyphs[iter.end_glyph-1].geometry.width += space_right;
+ }
+ }
+ else /* RTL */
{
- if (iter.start_glyph < iter.end_glyph) /* LTR */
- glyph_item->glyphs->glyphs[iter.start_glyph - 1].geometry.width += letter_spacing;
- else /* RTL */
- glyph_item->glyphs->glyphs[iter.start_glyph].geometry.width += letter_spacing;
+ if (iter.start_char > 0)
+ {
+ glyphs[iter.start_glyph].geometry.width += space_right;
+ }
+ if (iter.end_char < glyph_item->item->num_chars)
+ {
+ glyphs[iter.end_glyph+1].geometry.x_offset += space_left ;
+ glyphs[iter.end_glyph+1].geometry.width += space_left ;
+ }
}
}
}