mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-10 05:30:45 -08:00
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.
This commit is contained in:
parent
def61be234
commit
3ef8c1b49e
4 changed files with 36 additions and 39 deletions
|
|
@ -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.
|
||||
|
|
|
|||
15
src/font.c
15
src/font.c
|
|
@ -357,11 +357,12 @@ font_style_to_value (prop, val, noerror)
|
|||
}
|
||||
|
||||
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 @@ font_style_symbolic_from_value (prop, val, for_face)
|
|||
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));
|
||||
|
|
|
|||
|
|
@ -776,10 +776,6 @@ extern int font_style_to_value P_ ((enum font_property_index prop,
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -1487,6 +1487,19 @@ w32_encode_weight (n)
|
|||
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 @@ w32font_full_name (font, font_obj, pixel_size, name, nbytes)
|
|||
|
||||
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 @@ w32font_full_name (font, font_obj, pixel_size, name, nbytes)
|
|||
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 @@ static int logfont_to_fcname(font, pointsize, fcname, size)
|
|||
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 @@ static int logfont_to_fcname(font, pointsize, fcname, size)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue