[cairo-commit] src/cairo-ft-font.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Mar 8 03:23:04 PST 2013
src/cairo-ft-font.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
New commits:
commit a8f1b456db744e33a10b2301df03528787e5b1ca
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Mar 8 06:21:59 2013 -0500
[FT] Prefer downscaling bitmap glyphs to upscaling
Say, you have bitmap strikes for sizes 50ppem and 100ppem.
To render at 60ppem, it's much better to downscale the 100ppem
bitmap than upscale 50ppem one. Prefer downscaling.
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 8ebadb4..90f410c 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -739,6 +739,7 @@ _compute_transform (cairo_ft_font_transform_t *sf,
if (unscaled && (unscaled->face->face_flags & FT_FACE_FLAG_SCALABLE) == 0) {
double min_distance = DBL_MAX;
+ cairo_bool_t magnify = TRUE;
int i;
int best_i = 0;
double best_x_size = 0;
@@ -747,10 +748,18 @@ _compute_transform (cairo_ft_font_transform_t *sf,
for (i = 0; i < unscaled->face->num_fixed_sizes; i++) {
double x_size = unscaled->face->available_sizes[i].y_ppem / 64.;
double y_size = unscaled->face->available_sizes[i].y_ppem / 64.;
- double distance = fabs (y_size - y_scale);
+ double distance = y_size - y_scale;
- if (distance <= min_distance) {
- min_distance = distance;
+ /*
+ * distance is positive if current strike is larger than desired
+ * size, and negative if smaller.
+ *
+ * We like to prefer down-scaling to upscaling.
+ */
+
+ if ((magnify && distance >= 0) || fabs (distance) <= min_distance) {
+ magnify = distance < 0;
+ min_distance = abs (distance);
best_i = i;
best_x_size = x_size;
best_y_size = y_size;
More information about the cairo-commit
mailing list