diff options
| author | Jason Rumney | 2008-03-01 21:22:50 +0000 |
|---|---|---|
| committer | Jason Rumney | 2008-03-01 21:22:50 +0000 |
| commit | 67997c793bb684a0b441f5a555b78e01a95b60c7 (patch) | |
| tree | 0671faa2c20dff18eebacab4e724fe1253fbea58 /src | |
| parent | 1c3b663ff9ddd975a2a502299c5aa6da623cee3e (diff) | |
| download | emacs-67997c793bb684a0b441f5a555b78e01a95b60c7.tar.gz emacs-67997c793bb684a0b441f5a555b78e01a95b60c7.zip | |
(w32font_full_name): New function.
(w32font_open_internal): Use it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/w32font.c | 58 |
2 files changed, 62 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 2af96f8d65a..c6183a0cc6d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-03-01 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * w32font.c (w32font_full_name): New function. | ||
| 4 | (w32font_open_internal): Use it. | ||
| 5 | |||
| 1 | 2008-03-01 Kim F. Storm <storm@cua.dk> | 6 | 2008-03-01 Kim F. Storm <storm@cua.dk> |
| 2 | 7 | ||
| 3 | * dispnew.c (line_draw_cost): Fix invalid glyph check. | 8 | * dispnew.c (line_draw_cost): Fix invalid glyph check. |
diff --git a/src/w32font.c b/src/w32font.c index b781494e366..ff0344c7912 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -76,6 +76,8 @@ static BYTE w32_antialias_type P_ ((Lisp_Object type)); | |||
| 76 | static Lisp_Object lispy_antialias_type P_ ((BYTE type)); | 76 | static Lisp_Object lispy_antialias_type P_ ((BYTE type)); |
| 77 | 77 | ||
| 78 | static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig)); | 78 | static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE * sig)); |
| 79 | static int w32font_full_name P_ ((LOGFONT * font, Lisp_Object font_obj, | ||
| 80 | int pixel_size, char *name, int nbytes)); | ||
| 79 | 81 | ||
| 80 | /* From old font code in w32fns.c */ | 82 | /* From old font code in w32fns.c */ |
| 81 | char * w32_to_x_charset P_ ((int charset, char * matching)); | 83 | char * w32_to_x_charset P_ ((int charset, char * matching)); |
| @@ -757,7 +759,8 @@ w32font_open_internal (f, font_entity, pixel_size, w32_font) | |||
| 757 | 96 bytes and go up in steps of 32. */ | 759 | 96 bytes and go up in steps of 32. */ |
| 758 | len = 96; | 760 | len = 96; |
| 759 | name = xmalloc (len); | 761 | name = xmalloc (len); |
| 760 | while (name && font_unparse_fcname (font_entity, pixel_size, name, len) < 0) | 762 | while (name && w32font_full_name (&logfont, font_entity, pixel_size, |
| 763 | name, len) < 0) | ||
| 761 | { | 764 | { |
| 762 | char *new = xrealloc (name, len += 32); | 765 | char *new = xrealloc (name, len += 32); |
| 763 | 766 | ||
| @@ -1539,6 +1542,59 @@ font_supported_scripts (FONTSIGNATURE * sig) | |||
| 1539 | return supported; | 1542 | return supported; |
| 1540 | } | 1543 | } |
| 1541 | 1544 | ||
| 1545 | /* Generate a full name for a Windows font. | ||
| 1546 | The full name is in fcname format, with weight, slant and antialiasing | ||
| 1547 | specified if they are not "normal". */ | ||
| 1548 | static int | ||
| 1549 | w32font_full_name (font, font_obj, pixel_size, name, nbytes) | ||
| 1550 | LOGFONT * font; | ||
| 1551 | Lisp_Object font_obj; | ||
| 1552 | int pixel_size; | ||
| 1553 | char *name; | ||
| 1554 | int nbytes; | ||
| 1555 | { | ||
| 1556 | int len; | ||
| 1557 | char *p; | ||
| 1558 | Lisp_Object antialiasing, weight = Qnil; | ||
| 1559 | |||
| 1560 | len = strlen (font->lfFaceName) + 21; /* :pixelsize=SIZE */ | ||
| 1561 | |||
| 1562 | if (font->lfItalic) | ||
| 1563 | len += 7; /* :italic */ | ||
| 1564 | |||
| 1565 | if (font->lfWeight && font->lfWeight != FW_NORMAL) | ||
| 1566 | { | ||
| 1567 | weight = font_symbolic_weight (font_obj); | ||
| 1568 | len += 8 + SBYTES (SYMBOL_NAME (weight)); /* :weight=NAME */ | ||
| 1569 | } | ||
| 1570 | |||
| 1571 | antialiasing = lispy_antialias_type (font->lfQuality); | ||
| 1572 | if (! NILP (antialiasing)) | ||
| 1573 | len += 11 + SBYTES (SYMBOL_NAME (antialiasing)); /* :antialias=NAME */ | ||
| 1574 | |||
| 1575 | /* Check that the buffer is big enough */ | ||
| 1576 | if (len > nbytes) | ||
| 1577 | return -1; | ||
| 1578 | |||
| 1579 | p = name; | ||
| 1580 | p += sprintf (p, "%s", font->lfFaceName); | ||
| 1581 | |||
| 1582 | if (font->lfHeight) | ||
| 1583 | p += sprintf (p, ":pixelsize=%d", eabs (font->lfHeight)); | ||
| 1584 | else if (pixel_size > 0) | ||
| 1585 | p += sprintf (p, ":pixelsize=%d", pixel_size); | ||
| 1586 | |||
| 1587 | if (font->lfItalic) | ||
| 1588 | p += sprintf (p, ":italic"); | ||
| 1589 | |||
| 1590 | if (SYMBOLP (weight) && ! NILP (weight)) | ||
| 1591 | p += sprintf (p, ":weight=%s", SDATA (SYMBOL_NAME (weight))); | ||
| 1592 | |||
| 1593 | if (SYMBOLP (antialiasing) && ! NILP (antialiasing)) | ||
| 1594 | p += sprintf (p, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing))); | ||
| 1595 | |||
| 1596 | return (p - name); | ||
| 1597 | } | ||
| 1542 | 1598 | ||
| 1543 | struct font_driver w32font_driver = | 1599 | struct font_driver w32font_driver = |
| 1544 | { | 1600 | { |