Mercurial > emacs
changeset 96005:66f0213be62a
Fix crashing bug in use of bold fonts from x-select-font on W32.
* w32font.c (w32_to_fc_weight): New function.
(w32font_full_name, logfont_to_fcname): Use it.
* font.h (font_style_symbolic_from_value): Remove.
* font.c (font_style_symbolic_from_value): Remove.
(font_style_symbolic): Revert to pre 2008-06-13 version.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Mon, 16 Jun 2008 09:11:05 +0000 |
parents | 376c1b70d15b |
children | 4a520700b8b4 |
files | src/ChangeLog src/font.c src/font.h src/w32font.c |
diffstat | 4 files changed, 36 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Mon Jun 16 08:55:56 2008 +0000 +++ b/src/ChangeLog Mon Jun 16 09:11:05 2008 +0000 @@ -1,3 +1,13 @@ +2008-06-16 Jason Rumney <jasonr@gnu.org> + + * font.h (font_style_symbolic_from_value): Remove. + + * font.c (font_style_symbolic_from_value): Remove. + (font_style_symbolic): Revert to pre 2008-06-13 version. + + * w32font.c (w32_to_fc_weight): New function. + (w32font_full_name, logfont_to_fcname): Use it. + 2008-06-16 Kenichi Handa <handa@m17n.org> * font.c (font_check_object): Delete it.
--- a/src/font.c Mon Jun 16 08:55:56 2008 +0000 +++ b/src/font.c Mon Jun 16 09:11:05 2008 +0000 @@ -357,11 +357,12 @@ } Lisp_Object -font_style_symbolic_from_value (prop, val, for_face) +font_style_symbolic (font, prop, for_face) + Lisp_Object font; enum font_property_index prop; - Lisp_Object val; int for_face; { + Lisp_Object val = AREF (font, prop); Lisp_Object table, elt; int i; @@ -375,16 +376,6 @@ return (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1)); } -Lisp_Object -font_style_symbolic (font, prop, for_face) - Lisp_Object font; - enum font_property_index prop; - int for_face; -{ - Lisp_Object val = AREF (font, prop); - return font_style_symbolic_from_value (prop, val, for_face); -} - extern Lisp_Object Vface_alternative_font_family_alist; extern Lisp_Object find_font_encoding P_ ((Lisp_Object));
--- a/src/font.h Mon Jun 16 08:55:56 2008 +0000 +++ b/src/font.h Mon Jun 16 09:11:05 2008 +0000 @@ -776,10 +776,6 @@ extern Lisp_Object font_style_symbolic P_ ((Lisp_Object font, enum font_property_index prop, int for_face)); -extern Lisp_Object font_style_symbolic_from_value - P_ ((enum font_property_index prop, - Lisp_Object val, - int for_face)); extern int font_match_p P_ ((Lisp_Object spec, Lisp_Object entity)); extern Lisp_Object font_list_entities P_ ((Lisp_Object frame,
--- a/src/w32font.c Mon Jun 16 08:55:56 2008 +0000 +++ b/src/w32font.c Mon Jun 16 09:11:05 2008 +0000 @@ -1487,6 +1487,19 @@ return 0; } +/* Convert a Windows font weight into one of the weights supported + by fontconfig (see font.c:font_parse_fcname). */ +static Lisp_Object +w32_to_fc_weight (n) + int n; +{ + if (n >= FW_EXTRABOLD) return intern ("black"); + if (n >= FW_BOLD) return intern ("bold"); + if (n >= FW_SEMIBOLD) return intern ("demibold"); + if (n >= FW_NORMAL) return intern ("medium"); + return intern ("light"); +} + /* Fill in all the available details of LOGFONT from FONT_SPEC. */ static void fill_in_logfont (f, logfont, font_spec) @@ -1869,8 +1882,8 @@ if (font->lfWeight && font->lfWeight != FW_NORMAL) { - weight = FONT_WEIGHT_SYMBOLIC (font_obj); - len += 8 + SBYTES (SYMBOL_NAME (weight)); /* :weight=NAME */ + weight = w32_to_fc_weight (font->lfWeight); + len += 1 + SBYTES (SYMBOL_NAME (weight)); /* :WEIGHT */ } antialiasing = lispy_antialias_type (font->lfQuality); @@ -1900,12 +1913,12 @@ p += sprintf (p, ":pixelsize=%d", height); } + if (SYMBOLP (weight) && ! NILP (weight)) + p += sprintf (p, ":%s", SDATA (SYMBOL_NAME (weight))); + if (font->lfItalic) p += sprintf (p, ":italic"); - if (SYMBOLP (weight) && ! NILP (weight)) - p += sprintf (p, ":weight=%s", SDATA (SYMBOL_NAME (weight))); - if (SYMBOLP (antialiasing) && ! NILP (antialiasing)) p += sprintf (p, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing))); @@ -1940,19 +1953,8 @@ len += 7; /* :italic */ if (font->lfWeight && font->lfWeight != FW_NORMAL) { - int fc_weight = w32_decode_weight (font->lfWeight); - weight = font_style_symbolic_from_value (FONT_WEIGHT_INDEX, - make_number (fc_weight), 0); - len += 8; /* :weight= */ - if (SYMBOLP (weight)) - len += SBYTES (SYMBOL_NAME (weight)); - else - { - weight = make_number (fc_weight); - len++; - while (fc_weight /= 10) - len++; - } + weight = w32_to_fc_weight (font->lfWeight); + len += SBYTES (SYMBOL_NAME (weight)) + 1; } if (len > size) @@ -1962,14 +1964,12 @@ if (pointsize % 10) p += sprintf (p, ".%d", pointsize % 10); + if (SYMBOLP (weight) && !NILP (weight)) + p += sprintf (p, ":%s", SDATA (SYMBOL_NAME (weight))); + if (font->lfItalic) p += sprintf (p, ":italic"); - if (SYMBOLP (weight) && !NILP (weight)) - p += sprintf (p, "weight=%s", SDATA (SYMBOL_NAME (weight))); - else if (INTEGERP (weight)) - p += sprintf (p, "weight=%d", XINT (weight)); - return (p - fcname); }