summaryrefslogtreecommitdiff
path: root/pango/pango-ot-buffer.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-04-12 23:55:33 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-04-12 23:55:33 +0000
commit8ec2822cc5b8839996aaeb062f6acc0a899d98b4 (patch)
tree4ea746ea30fb59c7f7cb2bd9c15c444c8e94c6f2 /pango/pango-ot-buffer.c
parent5a6d314da7216520b3b2d7f30ca3da5ef4444ecb (diff)
downloadpango-8ec2822cc5b8839996aaeb062f6acc0a899d98b4.tar.gz
Quantize kerning adjustment, otherwise all the metrics hinting effort will
2007-04-12 Behdad Esfahbod <behdad@gnome.org> * pango/pango-ot-buffer.c (apply_gpos_ltr), (apply_gpos_rtl), (pango_ot_buffer_output): * pango/pango-types.h: * pango/pangofc-font.c (pango_fc_font_kern_glyphs): * pango/pangofc-private.h: Quantize kerning adjustment, otherwise all the metrics hinting effort will be ruined by a non-whole-pixel kerning value. In the future we want to take lsb_delta and rsb_delta into the game before quantizing the adjustment here, but we don't have those values handy right now. svn path=/trunk/; revision=2225
Diffstat (limited to 'pango/pango-ot-buffer.c')
-rw-r--r--pango/pango-ot-buffer.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/pango/pango-ot-buffer.c b/pango/pango-ot-buffer.c
index 539d5fd9..ca1ae99d 100644
--- a/pango/pango-ot-buffer.c
+++ b/pango/pango-ot-buffer.c
@@ -22,9 +22,7 @@
#include <config.h>
#include "pango-ot-private.h"
-
-#define PANGO_SCALE_26_6 (PANGO_SCALE / (1<<6))
-#define PANGO_UNITS_26_6(d) (PANGO_SCALE_26_6 * (d))
+#include "pangofc-private.h"
/**
* pango_ot_buffer_new
@@ -198,7 +196,8 @@ swap_range (PangoGlyphString *glyphs, int start, int end)
static void
apply_gpos_ltr (PangoGlyphString *glyphs,
- HB_Position positions)
+ HB_Position positions,
+ gboolean is_hinted)
{
int i;
@@ -208,6 +207,19 @@ apply_gpos_ltr (PangoGlyphString *glyphs,
FT_Pos y_pos = positions[i].y_pos;
int back = i;
int j;
+ int adjustment;
+
+
+ adjustment = PANGO_UNITS_26_6(positions[i].x_advance);
+
+ if (is_hinted)
+ adjustment = PANGO_UNITS_ROUND (adjustment);
+
+ if (positions[i].new_advance)
+ glyphs->glyphs[i].geometry.width = adjustment;
+ else
+ glyphs->glyphs[i].geometry.width += adjustment;
+
while (positions[back].back != 0)
{
@@ -221,17 +233,13 @@ apply_gpos_ltr (PangoGlyphString *glyphs,
glyphs->glyphs[i].geometry.x_offset += PANGO_UNITS_26_6(x_pos);
glyphs->glyphs[i].geometry.y_offset -= PANGO_UNITS_26_6(y_pos);
-
- if (positions[i].new_advance)
- glyphs->glyphs[i].geometry.width = PANGO_UNITS_26_6(positions[i].x_advance);
- else
- glyphs->glyphs[i].geometry.width += PANGO_UNITS_26_6(positions[i].x_advance);
}
}
static void
apply_gpos_rtl (PangoGlyphString *glyphs,
- HB_Position positions)
+ HB_Position positions,
+ gboolean is_hinted)
{
int i;
@@ -243,6 +251,19 @@ apply_gpos_rtl (PangoGlyphString *glyphs,
FT_Pos x_pos = positions[i_rev].x_pos;
FT_Pos y_pos = positions[i_rev].y_pos;
int j;
+ int adjustment;
+
+
+ adjustment = PANGO_UNITS_26_6(positions[i_rev].x_advance);
+
+ if (is_hinted)
+ adjustment = PANGO_UNITS_ROUND (adjustment);
+
+ if (positions[i_rev].new_advance)
+ glyphs->glyphs[i].geometry.width = adjustment;
+ else
+ glyphs->glyphs[i].geometry.width += adjustment;
+
while (positions[back_rev].back != 0)
{
@@ -258,11 +279,6 @@ apply_gpos_rtl (PangoGlyphString *glyphs,
glyphs->glyphs[i].geometry.x_offset += PANGO_UNITS_26_6(x_pos);
glyphs->glyphs[i].geometry.y_offset -= PANGO_UNITS_26_6(y_pos);
-
- if (positions[i_rev].new_advance)
- glyphs->glyphs[i].geometry.width = PANGO_UNITS_26_6(positions[i_rev].x_advance);
- else
- glyphs->glyphs[i].geometry.width += PANGO_UNITS_26_6(positions[i_rev].x_advance);
}
}
@@ -350,9 +366,9 @@ pango_ot_buffer_output (PangoOTBuffer *buffer,
if (buffer->applied_gpos)
{
if (buffer->rtl)
- apply_gpos_rtl (glyphs, buffer->buffer->positions);
+ apply_gpos_rtl (glyphs, buffer->buffer->positions, buffer->font->is_hinted);
else
- apply_gpos_ltr (glyphs, buffer->buffer->positions);
+ apply_gpos_ltr (glyphs, buffer->buffer->positions, buffer->font->is_hinted);
}
else
pango_fc_font_kern_glyphs (buffer->font, glyphs);