diff options
| author | Jason Rumney | 2008-06-16 09:11:05 +0000 |
|---|---|---|
| committer | Jason Rumney | 2008-06-16 09:11:05 +0000 |
| commit | 3ef8c1b49e06347a04ec6cbdc7bd5f0432ca583d (patch) | |
| tree | 2b34bdab8ff6ff005ae6ede4c4878c987c117b48 | |
| parent | def61be2348d06f8e43b615aeb4f061dd2b932ef (diff) | |
| download | emacs-3ef8c1b49e06347a04ec6cbdc7bd5f0432ca583d.tar.gz emacs-3ef8c1b49e06347a04ec6cbdc7bd5f0432ca583d.zip | |
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.
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/font.c | 15 | ||||
| -rw-r--r-- | src/font.h | 4 | ||||
| -rw-r--r-- | src/w32font.c | 46 |
4 files changed, 36 insertions, 39 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 2eeb98135eb..3ccbdc87439 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2008-06-16 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * font.h (font_style_symbolic_from_value): Remove. | ||
| 4 | |||
| 5 | * font.c (font_style_symbolic_from_value): Remove. | ||
| 6 | (font_style_symbolic): Revert to pre 2008-06-13 version. | ||
| 7 | |||
| 8 | * w32font.c (w32_to_fc_weight): New function. | ||
| 9 | (w32font_full_name, logfont_to_fcname): Use it. | ||
| 10 | |||
| 1 | 2008-06-16 Kenichi Handa <handa@m17n.org> | 11 | 2008-06-16 Kenichi Handa <handa@m17n.org> |
| 2 | 12 | ||
| 3 | * font.c (font_check_object): Delete it. | 13 | * font.c (font_check_object): Delete it. |
diff --git a/src/font.c b/src/font.c index 60c0b4fdcf6..4d2f486181f 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -357,11 +357,12 @@ font_style_to_value (prop, val, noerror) | |||
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | Lisp_Object | 359 | Lisp_Object |
| 360 | font_style_symbolic_from_value (prop, val, for_face) | 360 | font_style_symbolic (font, prop, for_face) |
| 361 | Lisp_Object font; | ||
| 361 | enum font_property_index prop; | 362 | enum font_property_index prop; |
| 362 | Lisp_Object val; | ||
| 363 | int for_face; | 363 | int for_face; |
| 364 | { | 364 | { |
| 365 | Lisp_Object val = AREF (font, prop); | ||
| 365 | Lisp_Object table, elt; | 366 | Lisp_Object table, elt; |
| 366 | int i; | 367 | int i; |
| 367 | 368 | ||
| @@ -375,16 +376,6 @@ font_style_symbolic_from_value (prop, val, for_face) | |||
| 375 | return (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1)); | 376 | return (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1)); |
| 376 | } | 377 | } |
| 377 | 378 | ||
| 378 | Lisp_Object | ||
| 379 | font_style_symbolic (font, prop, for_face) | ||
| 380 | Lisp_Object font; | ||
| 381 | enum font_property_index prop; | ||
| 382 | int for_face; | ||
| 383 | { | ||
| 384 | Lisp_Object val = AREF (font, prop); | ||
| 385 | return font_style_symbolic_from_value (prop, val, for_face); | ||
| 386 | } | ||
| 387 | |||
| 388 | extern Lisp_Object Vface_alternative_font_family_alist; | 379 | extern Lisp_Object Vface_alternative_font_family_alist; |
| 389 | 380 | ||
| 390 | extern Lisp_Object find_font_encoding P_ ((Lisp_Object)); | 381 | extern Lisp_Object find_font_encoding P_ ((Lisp_Object)); |
diff --git a/src/font.h b/src/font.h index cc14365508c..522343255e7 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -776,10 +776,6 @@ extern int font_style_to_value P_ ((enum font_property_index prop, | |||
| 776 | extern Lisp_Object font_style_symbolic P_ ((Lisp_Object font, | 776 | extern Lisp_Object font_style_symbolic P_ ((Lisp_Object font, |
| 777 | enum font_property_index prop, | 777 | enum font_property_index prop, |
| 778 | int for_face)); | 778 | int for_face)); |
| 779 | extern Lisp_Object font_style_symbolic_from_value | ||
| 780 | P_ ((enum font_property_index prop, | ||
| 781 | Lisp_Object val, | ||
| 782 | int for_face)); | ||
| 783 | 779 | ||
| 784 | extern int font_match_p P_ ((Lisp_Object spec, Lisp_Object entity)); | 780 | extern int font_match_p P_ ((Lisp_Object spec, Lisp_Object entity)); |
| 785 | extern Lisp_Object font_list_entities P_ ((Lisp_Object frame, | 781 | extern Lisp_Object font_list_entities P_ ((Lisp_Object frame, |
diff --git a/src/w32font.c b/src/w32font.c index 862bdabec96..9e4bb494e70 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -1487,6 +1487,19 @@ w32_encode_weight (n) | |||
| 1487 | return 0; | 1487 | return 0; |
| 1488 | } | 1488 | } |
| 1489 | 1489 | ||
| 1490 | /* Convert a Windows font weight into one of the weights supported | ||
| 1491 | by fontconfig (see font.c:font_parse_fcname). */ | ||
| 1492 | static Lisp_Object | ||
| 1493 | w32_to_fc_weight (n) | ||
| 1494 | int n; | ||
| 1495 | { | ||
| 1496 | if (n >= FW_EXTRABOLD) return intern ("black"); | ||
| 1497 | if (n >= FW_BOLD) return intern ("bold"); | ||
| 1498 | if (n >= FW_SEMIBOLD) return intern ("demibold"); | ||
| 1499 | if (n >= FW_NORMAL) return intern ("medium"); | ||
| 1500 | return intern ("light"); | ||
| 1501 | } | ||
| 1502 | |||
| 1490 | /* Fill in all the available details of LOGFONT from FONT_SPEC. */ | 1503 | /* Fill in all the available details of LOGFONT from FONT_SPEC. */ |
| 1491 | static void | 1504 | static void |
| 1492 | fill_in_logfont (f, logfont, font_spec) | 1505 | fill_in_logfont (f, logfont, font_spec) |
| @@ -1869,8 +1882,8 @@ w32font_full_name (font, font_obj, pixel_size, name, nbytes) | |||
| 1869 | 1882 | ||
| 1870 | if (font->lfWeight && font->lfWeight != FW_NORMAL) | 1883 | if (font->lfWeight && font->lfWeight != FW_NORMAL) |
| 1871 | { | 1884 | { |
| 1872 | weight = FONT_WEIGHT_SYMBOLIC (font_obj); | 1885 | weight = w32_to_fc_weight (font->lfWeight); |
| 1873 | len += 8 + SBYTES (SYMBOL_NAME (weight)); /* :weight=NAME */ | 1886 | len += 1 + SBYTES (SYMBOL_NAME (weight)); /* :WEIGHT */ |
| 1874 | } | 1887 | } |
| 1875 | 1888 | ||
| 1876 | antialiasing = lispy_antialias_type (font->lfQuality); | 1889 | antialiasing = lispy_antialias_type (font->lfQuality); |
| @@ -1900,12 +1913,12 @@ w32font_full_name (font, font_obj, pixel_size, name, nbytes) | |||
| 1900 | p += sprintf (p, ":pixelsize=%d", height); | 1913 | p += sprintf (p, ":pixelsize=%d", height); |
| 1901 | } | 1914 | } |
| 1902 | 1915 | ||
| 1916 | if (SYMBOLP (weight) && ! NILP (weight)) | ||
| 1917 | p += sprintf (p, ":%s", SDATA (SYMBOL_NAME (weight))); | ||
| 1918 | |||
| 1903 | if (font->lfItalic) | 1919 | if (font->lfItalic) |
| 1904 | p += sprintf (p, ":italic"); | 1920 | p += sprintf (p, ":italic"); |
| 1905 | 1921 | ||
| 1906 | if (SYMBOLP (weight) && ! NILP (weight)) | ||
| 1907 | p += sprintf (p, ":weight=%s", SDATA (SYMBOL_NAME (weight))); | ||
| 1908 | |||
| 1909 | if (SYMBOLP (antialiasing) && ! NILP (antialiasing)) | 1922 | if (SYMBOLP (antialiasing) && ! NILP (antialiasing)) |
| 1910 | p += sprintf (p, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing))); | 1923 | p += sprintf (p, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing))); |
| 1911 | 1924 | ||
| @@ -1940,19 +1953,8 @@ static int logfont_to_fcname(font, pointsize, fcname, size) | |||
| 1940 | len += 7; /* :italic */ | 1953 | len += 7; /* :italic */ |
| 1941 | if (font->lfWeight && font->lfWeight != FW_NORMAL) | 1954 | if (font->lfWeight && font->lfWeight != FW_NORMAL) |
| 1942 | { | 1955 | { |
| 1943 | int fc_weight = w32_decode_weight (font->lfWeight); | 1956 | weight = w32_to_fc_weight (font->lfWeight); |
| 1944 | weight = font_style_symbolic_from_value (FONT_WEIGHT_INDEX, | 1957 | len += SBYTES (SYMBOL_NAME (weight)) + 1; |
| 1945 | make_number (fc_weight), 0); | ||
| 1946 | len += 8; /* :weight= */ | ||
| 1947 | if (SYMBOLP (weight)) | ||
| 1948 | len += SBYTES (SYMBOL_NAME (weight)); | ||
| 1949 | else | ||
| 1950 | { | ||
| 1951 | weight = make_number (fc_weight); | ||
| 1952 | len++; | ||
| 1953 | while (fc_weight /= 10) | ||
| 1954 | len++; | ||
| 1955 | } | ||
| 1956 | } | 1958 | } |
| 1957 | 1959 | ||
| 1958 | if (len > size) | 1960 | if (len > size) |
| @@ -1962,14 +1964,12 @@ static int logfont_to_fcname(font, pointsize, fcname, size) | |||
| 1962 | if (pointsize % 10) | 1964 | if (pointsize % 10) |
| 1963 | p += sprintf (p, ".%d", pointsize % 10); | 1965 | p += sprintf (p, ".%d", pointsize % 10); |
| 1964 | 1966 | ||
| 1967 | if (SYMBOLP (weight) && !NILP (weight)) | ||
| 1968 | p += sprintf (p, ":%s", SDATA (SYMBOL_NAME (weight))); | ||
| 1969 | |||
| 1965 | if (font->lfItalic) | 1970 | if (font->lfItalic) |
| 1966 | p += sprintf (p, ":italic"); | 1971 | p += sprintf (p, ":italic"); |
| 1967 | 1972 | ||
| 1968 | if (SYMBOLP (weight) && !NILP (weight)) | ||
| 1969 | p += sprintf (p, "weight=%s", SDATA (SYMBOL_NAME (weight))); | ||
| 1970 | else if (INTEGERP (weight)) | ||
| 1971 | p += sprintf (p, "weight=%d", XINT (weight)); | ||
| 1972 | |||
| 1973 | return (p - fcname); | 1973 | return (p - fcname); |
| 1974 | } | 1974 | } |
| 1975 | 1975 | ||