summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-04-29 05:52:35 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-04-29 05:52:35 +0000
commit6ba19a0b8cc7f9c05f2df899fce69036d6bca9bc (patch)
tree24d25802b41dfef43761e30448e398ef396596fa
parent73747bd0e4599b0777149215b6ae2a982e1166d9 (diff)
downloadpango-6ba19a0b8cc7f9c05f2df899fce69036d6bca9bc.tar.gz
Bug 307196 – Unhinted fonts are measured incorrectly and drawing
2006-04-29 Behdad Esfahbod <behdad@gnome.org> Bug 307196 – Unhinted fonts are measured incorrectly and drawing problems occur as a result * pango/pangofc-font.c (get_face_metrics), (pango_fc_font_get_raw_extents): * pango/pangoxft-font.c (_pango_xft_font_new): Rollback previous change that forced metrics hinting always on. * pango/pangocairo-fcfont.c (_pango_cairo_fc_font_new): Set fcfont metrics hinting based on cairo font options.
-rw-r--r--ChangeLog13
-rw-r--r--pango/pangocairo-fcfont.c5
-rw-r--r--pango/pangofc-font.c45
-rw-r--r--pango/pangoxft-font.c6
4 files changed, 61 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fb678d5..07e1821f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-04-29 Behdad Esfahbod <behdad@gnome.org>
+
+ Bug 307196 – Unhinted fonts are measured incorrectly and drawing
+ problems occur as a result
+
+ * pango/pangofc-font.c (get_face_metrics),
+ (pango_fc_font_get_raw_extents):
+ * pango/pangoxft-font.c (_pango_xft_font_new): Rollback previous
+ change that forced metrics hinting always on.
+
+ * pango/pangocairo-fcfont.c (_pango_cairo_fc_font_new): Set fcfont
+ metrics hinting based on cairo font options.
+
2006-04-28 Behdad Esfahbod <behdad@gnome.org>
Bug 339749 – pango_language_from_string issues
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index af4647c1..43882c83 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -645,5 +645,10 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap,
cffont->options = cairo_font_options_copy (_pango_cairo_context_get_merged_font_options (context));
+ /* fcfont's is_hinted controls metric hinting
+ */
+ PANGO_FC_FONT(cffont)->is_hinted =
+ (cairo_font_options_get_hint_metrics(cffont->options) != CAIRO_HINT_METRICS_OFF);
+
return PANGO_FC_FONT (cffont);
}
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index a3583234..e3585acf 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -306,11 +306,22 @@ get_face_metrics (PangoFcFont *fcfont,
FT_Vector_Transform (&vector, &ft_matrix);
metrics->ascent = PANGO_UNITS_26_6 (vector.y);
}
- else
+ else if (fcfont->is_hinted ||
+ (face->face_flags & FT_FACE_FLAG_SCALABLE) == 0)
{
metrics->descent = - PANGO_UNITS_26_6 (face->size->metrics.descender);
metrics->ascent = PANGO_UNITS_26_6 (face->size->metrics.ascender);
}
+ else
+ {
+ FT_Fixed ascender, descender;
+
+ descender = FT_MulFix (face->descender, face->size->metrics.y_scale);
+ metrics->descent = - PANGO_UNITS_26_6 (descender);
+
+ ascender = FT_MulFix (face->ascender, face->size->metrics.y_scale);
+ metrics->ascent = PANGO_UNITS_26_6 (ascender);
+ }
/* Versions of FreeType < 2.1.8 get underline thickness wrong
* for Postscript fonts (always zero), so we need a fallback
@@ -348,12 +359,16 @@ get_face_metrics (PangoFcFont *fcfont,
metrics->strikethrough_position = (PANGO_SCALE * face->size->metrics.y_ppem) / 4;
}
- /* Quantize the underline and strikethrough position to integer values.
+ /* If hinting is on for this font, quantize the underline and strikethrough position
+ * to integer values.
*/
- pango_quantize_line_geometry (&metrics->underline_thickness,
- &metrics->underline_position);
- pango_quantize_line_geometry (&metrics->strikethrough_thickness,
- &metrics->strikethrough_position);
+ if (fcfont->is_hinted)
+ {
+ pango_quantize_line_geometry (&metrics->underline_thickness,
+ &metrics->underline_position);
+ pango_quantize_line_geometry (&metrics->strikethrough_thickness,
+ &metrics->strikethrough_position);
+ }
PANGO_FC_FONT_UNLOCK_FACE (fcfont);
}
@@ -812,8 +827,22 @@ pango_fc_font_get_raw_extents (PangoFcFont *fcfont,
{
logical_rect->x = 0;
logical_rect->width = PANGO_UNITS_26_6 (gm->horiAdvance);
- logical_rect->y = - PANGO_UNITS_26_6 (face->size->metrics.ascender);
- logical_rect->height = PANGO_UNITS_26_6 (face->size->metrics.ascender - face->size->metrics.descender);
+ if (fcfont->is_hinted ||
+ (face->face_flags & FT_FACE_FLAG_SCALABLE) == 0)
+ {
+ logical_rect->y = - PANGO_UNITS_26_6 (face->size->metrics.ascender);
+ logical_rect->height = PANGO_UNITS_26_6 (face->size->metrics.ascender - face->size->metrics.descender);
+ }
+ else
+ {
+ FT_Fixed ascender, descender;
+
+ ascender = FT_MulFix (face->ascender, face->size->metrics.y_scale);
+ descender = FT_MulFix (face->descender, face->size->metrics.y_scale);
+
+ logical_rect->y = - PANGO_UNITS_26_6 (ascender);
+ logical_rect->height = PANGO_UNITS_26_6 (ascender - descender);
+ }
}
}
else
diff --git a/pango/pangoxft-font.c b/pango/pangoxft-font.c
index d0ef5caa..fe3844fb 100644
--- a/pango/pangoxft-font.c
+++ b/pango/pangoxft-font.c
@@ -96,6 +96,12 @@ _pango_xft_font_new (PangoXftFontMap *xftfontmap,
"pattern", pattern,
NULL);
+ /* Hack to force hinting of vertical metrics; hinting off for
+ * a Xft font just means to not hint outlines, but we still
+ * want integer line spacing, underline positions, etc
+ */
+ PANGO_FC_FONT (xfont)->is_hinted = TRUE;
+
xfont->xft_font = NULL;
return xfont;