From 3db1b8ff083035f4ec7aceac4dd7bfe2e198f2a8 Mon Sep 17 00:00:00 2001 From: handa Date: Wed, 24 Aug 2005 05:23:53 +0000 Subject: [PATCH] (STRDUP_LOWER): Ignore the tailing spaces. (fc_get_pattern): Handle the case of font->size < 0. (ft_open): Set ascent, descent, and max_advance members of rfont. (ft_find_metric): Improve rounding. (mfont__ft_parse_name): If FC_PIXEL_SIZE is not available, set FC_SIZE. --- src/font-ft.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/font-ft.c b/src/font-ft.c index 41b6aab..a704ea6 100644 --- a/src/font-ft.c +++ b/src/font-ft.c @@ -135,7 +135,8 @@ static int all_fonts_scaned; (s1) = alloca (len), (size) = len; \ for (p1 = (s1), p2 = (s2); *p2; p1++, p2++) \ *p1 = (*p2 >= 'A' && *p2 <= 'Z' ? *p2 + 'a' - 'A' : *p2); \ - *p1 = *p2; \ + while (p1 > (s1) && p1[-1] == ' ') p1--; \ + *p1 = '\0'; \ } while (0) @@ -325,6 +326,11 @@ fc_get_pattern (MFont *font) double size = font->size; FcPatternAddDouble (pat, FC_PIXEL_SIZE, size / 10); } + else if (font->size < 0) + { + double size = - font->size; + FcPatternAddDouble (pat, FC_SIZE, size / 10); + } return pat; } @@ -1250,14 +1256,14 @@ ft_find_metric (MRealizedFont *rfont, MGlyphString *gstring, { if (FT_IS_SCALABLE (ft_face)) { - unsigned unitsPerEm = ft_face->units_per_EM; - int size = rfont->spec.size / 10; + unsigned unitsPerEm10 = ft_face->units_per_EM * 10; + int size = rfont->spec.size; g->lbearing = 0; - g->rbearing = ft_face->max_advance_width * size / unitsPerEm; + g->rbearing = ft_face->max_advance_width * size / unitsPerEm10; g->width = g->rbearing; - g->ascent = ft_face->ascender * size / unitsPerEm; - g->descent = (- ft_face->descender) * size / unitsPerEm; + g->ascent = ft_face->ascender * size / unitsPerEm10; + g->descent = (- ft_face->descender) * size / unitsPerEm10; } else { @@ -1821,7 +1827,9 @@ mfont__ft_parse_name (const char *name, MFont *font) fc_decode_prop (val, fc_width_table, fc_width_table_size)); if (FcPatternGetDouble (pat, FC_PIXEL_SIZE, 0, &size) == FcResultMatch) - font->size = size * 10; + font->size = size * 10 + 0.5; + else if (FcPatternGetDouble (pat, FC_SIZE, 0, &size) == FcResultMatch) + font->size = - (size * 10 + 0.5); if (FcPatternGetString (pat, FC_FILE, 0, &str) == FcResultMatch) { font->file = msymbol ((char *) str); -- 1.7.10.4