diff options
| author | Jan Djärv | 2013-09-15 19:58:46 +0200 |
|---|---|---|
| committer | Jan Djärv | 2013-09-15 19:58:46 +0200 |
| commit | 3fa2054efdfa3c22456072254e6c67682a595233 (patch) | |
| tree | f882ecc281d2ac5d5aefd27e2c22ece5a0bb0ca4 | |
| parent | c089653d568d5c696f2d35e1bcf9bba64af85b97 (diff) | |
| download | emacs-3fa2054efdfa3c22456072254e6c67682a595233.tar.gz emacs-3fa2054efdfa3c22456072254e6c67682a595233.zip | |
Port the font backend from the Mac port.
* configure.ac: Add check for OSX 10.5, required for macfont.o.
* etc/NEWS: Mention the macfont backend.
* src/Makefile.in (NS_OBJ, SOME_MACHINE_OBJECTS): Add macfont.o.
* src/font.c (syms_of_font): Call syms_of_macfont.
* src/font.h: Declare syms_of_macfont.
* src/nsfns.m: Include macfont.h.
(Fx_create_frame): Register macfont driver, make a better default font.
(Fns_popup_font_panel): Get font from macfont driver, if used.
* src/nsfont.m (ns_tmp_flags, ns_tmp_font): Remove.
(nsfont_open): Set font driver type.
Set font->ascent and font->descent. Figure out font instead of
ns_tmp_font, and flags instead of ns_tmp_flags.
Fix indentation. Remove call to ns_draw_text_decoration,
moved to nsterm.
* src/nsterm.m: Include macfont.h.
(ns_tmp_flags, ns_tmp_font): Remove.
(ns_compute_glyph_string_overhangs): Check for driver Qns.
(ns_draw_glyph_string): Use local variables instead of ns_tmp_flags,
ns_tmp_font. Call ns_draw_text_decoration here instead of nsfont.m.
(changeFont:): Fix code style. Check for font driver type when
getiing font.
* src/nsterm.h (FONT_DESCENT, FONT_ASCENT): Define to (f)->ascent and
(f)->descent.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | configure.ac | 34 | ||||
| -rw-r--r-- | etc/ChangeLog | 4 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | src/ChangeLog | 32 | ||||
| -rw-r--r-- | src/Makefile.in | 4 | ||||
| -rw-r--r-- | src/font.c | 1 | ||||
| -rw-r--r-- | src/font.h | 1 | ||||
| -rw-r--r-- | src/nsfns.m | 32 | ||||
| -rw-r--r-- | src/nsfont.m | 35 | ||||
| -rw-r--r-- | src/nsterm.h | 6 | ||||
| -rw-r--r-- | src/nsterm.m | 66 |
12 files changed, 175 insertions, 49 deletions
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-09-15 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * configure.ac: Add check for OSX 10.5, required for macfont.o. | ||
| 4 | |||
| 1 | 2013-09-09 Glenn Morris <rgm@gnu.org> | 5 | 2013-09-09 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * configure.ac (LDFLAGS_NOCOMBRELOC): New variable. | 7 | * configure.ac (LDFLAGS_NOCOMBRELOC): New variable. |
diff --git a/configure.ac b/configure.ac index ab2e48b6f0f..86a5f300982 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -1623,7 +1623,10 @@ fail; | |||
| 1623 | [AC_MSG_ERROR([`--with-ns' was specified, but the include | 1623 | [AC_MSG_ERROR([`--with-ns' was specified, but the include |
| 1624 | files are missing or cannot be compiled.])]) | 1624 | files are missing or cannot be compiled.])]) |
| 1625 | 1625 | ||
| 1626 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>], | 1626 | macfont_file="" |
| 1627 | if test "${NS_IMPL_COCOA}" = "yes"; then | ||
| 1628 | AC_MSG_CHECKING([for OSX 10.4 or newer]) | ||
| 1629 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>], | ||
| 1627 | [ | 1630 | [ |
| 1628 | #ifdef MAC_OS_X_VERSION_MAX_ALLOWED | 1631 | #ifdef MAC_OS_X_VERSION_MAX_ALLOWED |
| 1629 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 | 1632 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 |
| @@ -1635,13 +1638,33 @@ fail; | |||
| 1635 | ])], | 1638 | ])], |
| 1636 | ns_osx_have_104=yes, | 1639 | ns_osx_have_104=yes, |
| 1637 | ns_osx_have_104=no) | 1640 | ns_osx_have_104=no) |
| 1641 | AC_MSG_RESULT([$ns_osx_have_104]) | ||
| 1642 | |||
| 1643 | if test $ns_osx_have_104 = no; then | ||
| 1644 | AC_MSG_ERROR([`OSX 10.4 or newer is required']); | ||
| 1645 | fi | ||
| 1646 | AC_MSG_CHECKING([for OSX 10.5 or newer]) | ||
| 1647 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>], | ||
| 1648 | [ | ||
| 1649 | #ifdef MAC_OS_X_VERSION_MAX_ALLOWED | ||
| 1650 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 | ||
| 1651 | ; /* OK */ | ||
| 1652 | #else | ||
| 1653 | #error "OSX 10.5 not found" | ||
| 1654 | #endif | ||
| 1655 | #endif | ||
| 1656 | ])], | ||
| 1657 | ns_osx_have_105=yes, | ||
| 1658 | ns_osx_have_105=no) | ||
| 1659 | AC_MSG_RESULT([$ns_osx_have_105]) | ||
| 1660 | if test $ns_osx_have_105 = yes; then | ||
| 1661 | macfont_file="macfont.o" | ||
| 1662 | fi | ||
| 1663 | fi | ||
| 1638 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Foundation/NSObjCRuntime.h>], | 1664 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Foundation/NSObjCRuntime.h>], |
| 1639 | [NSInteger i;])], | 1665 | [NSInteger i;])], |
| 1640 | ns_have_nsinteger=yes, | 1666 | ns_have_nsinteger=yes, |
| 1641 | ns_have_nsinteger=no) | 1667 | ns_have_nsinteger=no) |
| 1642 | if test $ns_osx_have_104 = no; then | ||
| 1643 | AC_MSG_ERROR([`OSX 10.4 or newer is required']); | ||
| 1644 | fi | ||
| 1645 | if test $ns_have_nsinteger = yes; then | 1668 | if test $ns_have_nsinteger = yes; then |
| 1646 | AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.]) | 1669 | AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.]) |
| 1647 | fi | 1670 | fi |
| @@ -1677,7 +1700,8 @@ if test "${HAVE_NS}" = yes; then | |||
| 1677 | leimdir="\${ns_appresdir}/leim" | 1700 | leimdir="\${ns_appresdir}/leim" |
| 1678 | INSTALL_ARCH_INDEP_EXTRA= | 1701 | INSTALL_ARCH_INDEP_EXTRA= |
| 1679 | fi | 1702 | fi |
| 1680 | NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o" | 1703 | |
| 1704 | NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o $macfont_file" | ||
| 1681 | fi | 1705 | fi |
| 1682 | CFLAGS="$tmp_CFLAGS" | 1706 | CFLAGS="$tmp_CFLAGS" |
| 1683 | CPPFLAGS="$tmp_CPPFLAGS" | 1707 | CPPFLAGS="$tmp_CPPFLAGS" |
diff --git a/etc/ChangeLog b/etc/ChangeLog index bd5534d9446..5483d824da4 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-09-15 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * NEWS: Mention the macfont backend. | ||
| 4 | |||
| 1 | 2013-09-09 Glenn Morris <rgm@gnu.org> | 5 | 2013-09-09 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * refcards/Makefile (PS_ENGLISH, PS_CZECH, PS_FRENCH, PS_GERMAN) | 7 | * refcards/Makefile (PS_ENGLISH, PS_CZECH, PS_FRENCH, PS_GERMAN) |
| @@ -54,6 +54,11 @@ and zlib-format compressed data. | |||
| 54 | ** Emacs for NS (OSX, GNUStep) can be built with ImageMagick support. | 54 | ** Emacs for NS (OSX, GNUStep) can be built with ImageMagick support. |
| 55 | pkg-config is required to find ImageMagick libraries. | 55 | pkg-config is required to find ImageMagick libraries. |
| 56 | 56 | ||
| 57 | ** For OSX >= 10.5, the Core text based font backend from the Mac port is used. | ||
| 58 | For GNUStep and OSX 10.4 the old backend is used. | ||
| 59 | To use the old backend by default, do on the command line: | ||
| 60 | % defaults write org.gnu.Emacs FontBackend ns | ||
| 61 | |||
| 57 | 62 | ||
| 58 | * Startup Changes in Emacs 24.4 | 63 | * Startup Changes in Emacs 24.4 |
| 59 | 64 | ||
diff --git a/src/ChangeLog b/src/ChangeLog index 5f28dc3d7df..e3b29c9b21d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,35 @@ | |||
| 1 | 2013-09-15 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsterm.m: Include macfont.h. | ||
| 4 | (ns_tmp_flags, ns_tmp_font): Remove. | ||
| 5 | (ns_compute_glyph_string_overhangs): Check for driver Qns. | ||
| 6 | (ns_draw_glyph_string): Use local variables instead of ns_tmp_flags, | ||
| 7 | ns_tmp_font. Call ns_draw_text_decoration here instead of nsfont.m. | ||
| 8 | (changeFont:): Fix code style. Check for font driver type when | ||
| 9 | getiing font. | ||
| 10 | |||
| 11 | * nsterm.h (FONT_DESCENT, FONT_ASCENT): Define to (f)->ascent and | ||
| 12 | (f)->descent. | ||
| 13 | |||
| 14 | * nsfont.m (ns_tmp_flags, ns_tmp_font): Remove. | ||
| 15 | (nsfont_open): Set font driver type. | ||
| 16 | Set font->ascent and font->descent. Figure out font instead of | ||
| 17 | ns_tmp_font, and flags instead of ns_tmp_flags. | ||
| 18 | Fix indentation. Remove call to ns_draw_text_decoration, | ||
| 19 | moved to nsterm. | ||
| 20 | |||
| 21 | * nsfns.m: Include macfont.h. | ||
| 22 | (Fx_create_frame): Register macfont driver, make a better default font. | ||
| 23 | (Fns_popup_font_panel): Get font from macfont driver, if used. | ||
| 24 | |||
| 25 | * macfont.m, macfont.h, maccuvs.h: New files. | ||
| 26 | |||
| 27 | * font.h: Declare syms_of_macfont. | ||
| 28 | |||
| 29 | * font.c (syms_of_font): Call syms_of_macfont. | ||
| 30 | |||
| 31 | * Makefile.in (NS_OBJ, SOME_MACHINE_OBJECTS): Add macfont.o. | ||
| 32 | |||
| 1 | 2013-09-15 Dmitry Antipov <dmantipov@yandex.ru> | 33 | 2013-09-15 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 34 | ||
| 3 | Drop VERTICAL_SCROLL_BAR_WIDTH_TRIM. For X, it is zero since 1999, | 35 | Drop VERTICAL_SCROLL_BAR_WIDTH_TRIM. For X, it is zero since 1999, |
diff --git a/src/Makefile.in b/src/Makefile.in index fe8d2d13ce0..254aa175d49 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -266,7 +266,7 @@ MSDOS_OBJ = | |||
| 266 | MSDOS_X_OBJ = | 266 | MSDOS_X_OBJ = |
| 267 | 267 | ||
| 268 | NS_OBJ=@NS_OBJ@ | 268 | NS_OBJ=@NS_OBJ@ |
| 269 | ## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS. | 269 | ## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o if HAVE_NS. |
| 270 | NS_OBJC_OBJ=@NS_OBJC_OBJ@ | 270 | NS_OBJC_OBJ=@NS_OBJC_OBJ@ |
| 271 | ## Only set if NS_IMPL_GNUSTEP. | 271 | ## Only set if NS_IMPL_GNUSTEP. |
| 272 | GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@ | 272 | GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@ |
| @@ -388,7 +388,7 @@ obj = $(base_obj) $(NS_OBJC_OBJ) | |||
| 388 | SOME_MACHINE_OBJECTS = dosfns.o msdos.o \ | 388 | SOME_MACHINE_OBJECTS = dosfns.o msdos.o \ |
| 389 | xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ | 389 | xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ |
| 390 | fontset.o dbusbind.o cygw32.o \ | 390 | fontset.o dbusbind.o cygw32.o \ |
| 391 | nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \ | 391 | nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o \ |
| 392 | w32.o w32console.o w32fns.o w32heap.o w32inevt.o w32notify.o \ | 392 | w32.o w32console.o w32fns.o w32heap.o w32inevt.o w32notify.o \ |
| 393 | w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \ | 393 | w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \ |
| 394 | w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \ | 394 | w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \ |
diff --git a/src/font.c b/src/font.c index fb64f2d9071..27f4f5dca91 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -5199,6 +5199,7 @@ EMACS_FONT_LOG is set. Otherwise, it is set to t. */); | |||
| 5199 | #endif /* HAVE_NTGUI */ | 5199 | #endif /* HAVE_NTGUI */ |
| 5200 | #ifdef HAVE_NS | 5200 | #ifdef HAVE_NS |
| 5201 | syms_of_nsfont (); | 5201 | syms_of_nsfont (); |
| 5202 | syms_of_macfont (); | ||
| 5202 | #endif /* HAVE_NS */ | 5203 | #endif /* HAVE_NS */ |
| 5203 | #endif /* HAVE_WINDOW_SYSTEM */ | 5204 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 5204 | } | 5205 | } |
diff --git a/src/font.h b/src/font.h index 3e0d97baaac..0ec56590916 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -825,6 +825,7 @@ extern void syms_of_w32font (void); | |||
| 825 | extern Lisp_Object Qfontsize; | 825 | extern Lisp_Object Qfontsize; |
| 826 | extern struct font_driver nsfont_driver; | 826 | extern struct font_driver nsfont_driver; |
| 827 | extern void syms_of_nsfont (void); | 827 | extern void syms_of_nsfont (void); |
| 828 | extern void syms_of_macfont (void); | ||
| 828 | #endif /* HAVE_NS */ | 829 | #endif /* HAVE_NS */ |
| 829 | 830 | ||
| 830 | #ifndef FONT_DEBUG | 831 | #ifndef FONT_DEBUG |
diff --git a/src/nsfns.m b/src/nsfns.m index 8eaf529ed04..1b4e6b7f57e 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -46,6 +46,9 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) | |||
| 46 | 46 | ||
| 47 | #ifdef NS_IMPL_COCOA | 47 | #ifdef NS_IMPL_COCOA |
| 48 | #include <IOKit/graphics/IOGraphicsLib.h> | 48 | #include <IOKit/graphics/IOGraphicsLib.h> |
| 49 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 | ||
| 50 | #include "macfont.h" | ||
| 51 | #endif | ||
| 49 | #endif | 52 | #endif |
| 50 | 53 | ||
| 51 | #if 0 | 54 | #if 0 |
| @@ -1171,7 +1174,17 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 1171 | } | 1174 | } |
| 1172 | 1175 | ||
| 1173 | block_input (); | 1176 | block_input (); |
| 1177 | |||
| 1178 | #ifdef NS_IMPL_GNUSTEP || \ | ||
| 1179 | MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 | ||
| 1174 | register_font_driver (&nsfont_driver, f); | 1180 | register_font_driver (&nsfont_driver, f); |
| 1181 | #else | ||
| 1182 | if (CTGetCoreTextVersion != NULL | ||
| 1183 | && CTGetCoreTextVersion () >= kCTVersionNumber10_5) | ||
| 1184 | mac_register_font_driver (f); | ||
| 1185 | register_font_driver (&nsfont_driver, f); | ||
| 1186 | #endif | ||
| 1187 | |||
| 1175 | x_default_parameter (f, parms, Qfont_backend, Qnil, | 1188 | x_default_parameter (f, parms, Qfont_backend, Qnil, |
| 1176 | "fontBackend", "FontBackend", RES_TYPE_STRING); | 1189 | "fontBackend", "FontBackend", RES_TYPE_STRING); |
| 1177 | 1190 | ||
| @@ -1181,8 +1194,13 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 1181 | x_default_parameter (f, parms, Qfontsize, | 1194 | x_default_parameter (f, parms, Qfontsize, |
| 1182 | make_number (0 /*(int)[font pointSize]*/), | 1195 | make_number (0 /*(int)[font pointSize]*/), |
| 1183 | "fontSize", "FontSize", RES_TYPE_NUMBER); | 1196 | "fontSize", "FontSize", RES_TYPE_NUMBER); |
| 1197 | // Remove ' Regular', not handled by backends. | ||
| 1198 | char *fontname = xstrdup ([[font displayName] UTF8String]); | ||
| 1199 | int len = strlen (fontname); | ||
| 1200 | if (len > 8 && strcmp (fontname + len - 8, " Regular") == 0) | ||
| 1201 | fontname[len-8] = '\0'; | ||
| 1184 | x_default_parameter (f, parms, Qfont, | 1202 | x_default_parameter (f, parms, Qfont, |
| 1185 | build_string ([[font fontName] UTF8String]), | 1203 | build_string (fontname), |
| 1186 | "font", "Font", RES_TYPE_STRING); | 1204 | "font", "Font", RES_TYPE_STRING); |
| 1187 | } | 1205 | } |
| 1188 | unblock_input (); | 1206 | unblock_input (); |
| @@ -1362,9 +1380,15 @@ DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel, | |||
| 1362 | { | 1380 | { |
| 1363 | struct frame *f = decode_window_system_frame (frame); | 1381 | struct frame *f = decode_window_system_frame (frame); |
| 1364 | id fm = [NSFontManager sharedFontManager]; | 1382 | id fm = [NSFontManager sharedFontManager]; |
| 1365 | 1383 | struct font *font = f->output_data.ns->font; | |
| 1366 | [fm setSelectedFont: ((struct nsfont_info *)f->output_data.ns->font)->nsfont | 1384 | NSFont *nsfont; |
| 1367 | isMultiple: NO]; | 1385 | if (EQ (font->driver->type, Qns)) |
| 1386 | nsfont = ((struct nsfont_info *)font)->nsfont; | ||
| 1387 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 | ||
| 1388 | else | ||
| 1389 | nsfont = (NSFont *) macfont_get_nsctfont (font); | ||
| 1390 | #endif | ||
| 1391 | [fm setSelectedFont: nsfont isMultiple: NO]; | ||
| 1368 | [fm orderFrontFontPanel: NSApp]; | 1392 | [fm orderFrontFontPanel: NSApp]; |
| 1369 | return Qnil; | 1393 | return Qnil; |
| 1370 | } | 1394 | } |
diff --git a/src/nsfont.m b/src/nsfont.m index b61147d66c4..d9c8660f1cd 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -51,8 +51,6 @@ static Lisp_Object Qapple, Qroman, Qmedium; | |||
| 51 | static Lisp_Object Qcondensed, Qexpanded; | 51 | static Lisp_Object Qcondensed, Qexpanded; |
| 52 | extern Lisp_Object Qappend; | 52 | extern Lisp_Object Qappend; |
| 53 | extern float ns_antialias_threshold; | 53 | extern float ns_antialias_threshold; |
| 54 | extern int ns_tmp_flags; | ||
| 55 | extern struct nsfont_info *ns_tmp_font; | ||
| 56 | 54 | ||
| 57 | 55 | ||
| 58 | /* font glyph and metrics caching functions, implemented at end */ | 56 | /* font glyph and metrics caching functions, implemented at end */ |
| @@ -798,6 +796,7 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size) | |||
| 798 | 796 | ||
| 799 | font_object = font_make_object (VECSIZE (struct nsfont_info), | 797 | font_object = font_make_object (VECSIZE (struct nsfont_info), |
| 800 | font_entity, pixel_size); | 798 | font_entity, pixel_size); |
| 799 | ASET (font_object, FONT_TYPE_INDEX, nsfont_driver.type); | ||
| 801 | font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); | 800 | font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); |
| 802 | font = (struct font *) font_info; | 801 | font = (struct font *) font_info; |
| 803 | if (!font) | 802 | if (!font) |
| @@ -871,10 +870,11 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size) | |||
| 871 | font_info->size = font->pixel_size; | 870 | font_info->size = font->pixel_size; |
| 872 | 871 | ||
| 873 | /* max bounds */ | 872 | /* max bounds */ |
| 874 | font_info->max_bounds.ascent = lrint ([sfont ascender]); | 873 | font->ascent = font_info->max_bounds.ascent = lrint ([sfont ascender]); |
| 875 | /* Descender is usually negative. Use floor to avoid | 874 | /* Descender is usually negative. Use floor to avoid |
| 876 | clipping descenders. */ | 875 | clipping descenders. */ |
| 877 | font_info->max_bounds.descent = -lrint (floor(adjusted_descender)); | 876 | font->descent = |
| 877 | font_info->max_bounds.descent = -lrint (floor(adjusted_descender)); | ||
| 878 | font_info->height = | 878 | font_info->height = |
| 879 | font_info->max_bounds.ascent + font_info->max_bounds.descent; | 879 | font_info->max_bounds.ascent + font_info->max_bounds.descent; |
| 880 | font_info->max_bounds.width = lrint (font_info->width); | 880 | font_info->max_bounds.width = lrint (font_info->width); |
| @@ -1051,16 +1051,26 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1051 | #endif | 1051 | #endif |
| 1052 | struct face *face; | 1052 | struct face *face; |
| 1053 | NSRect r; | 1053 | NSRect r; |
| 1054 | struct nsfont_info *font = ns_tmp_font; | 1054 | struct nsfont_info *font; |
| 1055 | NSColor *col, *bgCol; | 1055 | NSColor *col, *bgCol; |
| 1056 | unsigned short *t = s->char2b; | 1056 | unsigned short *t = s->char2b; |
| 1057 | int i, len; | 1057 | int i, len, flags; |
| 1058 | char isComposite = s->first_glyph->type == COMPOSITE_GLYPH; | 1058 | char isComposite = s->first_glyph->type == COMPOSITE_GLYPH; |
| 1059 | int end = isComposite ? s->cmp_to : s->nchars; | 1059 | int end = isComposite ? s->cmp_to : s->nchars; |
| 1060 | 1060 | ||
| 1061 | block_input (); | 1061 | block_input (); |
| 1062 | |||
| 1063 | font = (struct nsfont_info *)s->face->font; | ||
| 1064 | if (font == NULL) | ||
| 1065 | font = (struct nsfont_info *)FRAME_FONT (s->f); | ||
| 1066 | |||
| 1062 | /* Select face based on input flags */ | 1067 | /* Select face based on input flags */ |
| 1063 | switch (ns_tmp_flags) | 1068 | flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR : |
| 1069 | (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE : | ||
| 1070 | (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND : | ||
| 1071 | NS_DUMPGLYPH_NORMAL)); | ||
| 1072 | |||
| 1073 | switch (flags) | ||
| 1064 | { | 1074 | { |
| 1065 | case NS_DUMPGLYPH_CURSOR: | 1075 | case NS_DUMPGLYPH_CURSOR: |
| 1066 | face = s->face; | 1076 | face = s->face; |
| @@ -1188,8 +1198,8 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1188 | col = (NS_FACE_FOREGROUND (face) != 0 | 1198 | col = (NS_FACE_FOREGROUND (face) != 0 |
| 1189 | ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f) | 1199 | ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f) |
| 1190 | : FRAME_FOREGROUND_COLOR (s->f)); | 1200 | : FRAME_FOREGROUND_COLOR (s->f)); |
| 1191 | /* FIXME: find another way to pass this */ | 1201 | |
| 1192 | bgCol = (ns_tmp_flags != NS_DUMPGLYPH_FOREGROUND ? nil | 1202 | bgCol = (flags != NS_DUMPGLYPH_FOREGROUND ? nil |
| 1193 | : (NS_FACE_BACKGROUND (face) != 0 | 1203 | : (NS_FACE_BACKGROUND (face) != 0 |
| 1194 | ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) | 1204 | ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f) |
| 1195 | : FRAME_BACKGROUND_COLOR (s->f))); | 1205 | : FRAME_BACKGROUND_COLOR (s->f))); |
| @@ -1264,22 +1274,19 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1264 | 1274 | ||
| 1265 | CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); | 1275 | CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); |
| 1266 | CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from, | 1276 | CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from, |
| 1267 | advances, len); | 1277 | advances, len); |
| 1268 | 1278 | ||
| 1269 | if (face->overstrike) | 1279 | if (face->overstrike) |
| 1270 | { | 1280 | { |
| 1271 | CGContextSetTextPosition (gcontext, r.origin.x+0.5, r.origin.y); | 1281 | CGContextSetTextPosition (gcontext, r.origin.x+0.5, r.origin.y); |
| 1272 | CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from, | 1282 | CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from, |
| 1273 | advances, len); | 1283 | advances, len); |
| 1274 | } | 1284 | } |
| 1275 | 1285 | ||
| 1276 | CGContextRestoreGState (gcontext); | 1286 | CGContextRestoreGState (gcontext); |
| 1277 | } | 1287 | } |
| 1278 | #endif /* NS_IMPL_COCOA */ | 1288 | #endif /* NS_IMPL_COCOA */ |
| 1279 | 1289 | ||
| 1280 | /* Draw underline, overline, strike-through. */ | ||
| 1281 | ns_draw_text_decoration (s, face, col, r.size.width, r.origin.x); | ||
| 1282 | |||
| 1283 | unblock_input (); | 1290 | unblock_input (); |
| 1284 | return to-from; | 1291 | return to-from; |
| 1285 | } | 1292 | } |
diff --git a/src/nsterm.h b/src/nsterm.h index d8482cebbb0..1b5804b98b5 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -701,10 +701,8 @@ struct x_output | |||
| 701 | 701 | ||
| 702 | #define FONT_WIDTH(f) ((f)->max_width) | 702 | #define FONT_WIDTH(f) ((f)->max_width) |
| 703 | #define FONT_HEIGHT(f) ((f)->height) | 703 | #define FONT_HEIGHT(f) ((f)->height) |
| 704 | /*#define FONT_BASE(f) ((f)->ascent) */ | 704 | #define FONT_BASE(f) ((f)->ascent) |
| 705 | #define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent) | 705 | #define FONT_DESCENT(f) ((f)->descent) |
| 706 | /*#define FONT_DESCENT(f) ((f)->descent) */ | ||
| 707 | #define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent) | ||
| 708 | 706 | ||
| 709 | #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID) | 707 | #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID) |
| 710 | 708 | ||
diff --git a/src/nsterm.m b/src/nsterm.m index 1dac6ba9fe4..2fc8a09c80f 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -64,6 +64,12 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) | |||
| 64 | #include "process.h" | 64 | #include "process.h" |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| 67 | #ifdef NS_IMPL_COCOA | ||
| 68 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 | ||
| 69 | #include "macfont.h" | ||
| 70 | #endif | ||
| 71 | #endif | ||
| 72 | |||
| 67 | /* call tracing */ | 73 | /* call tracing */ |
| 68 | #if 0 | 74 | #if 0 |
| 69 | int term_trace_num = 0; | 75 | int term_trace_num = 0; |
| @@ -198,8 +204,6 @@ static NSRect uRect; | |||
| 198 | #endif | 204 | #endif |
| 199 | static BOOL gsaved = NO; | 205 | static BOOL gsaved = NO; |
| 200 | static BOOL ns_fake_keydown = NO; | 206 | static BOOL ns_fake_keydown = NO; |
| 201 | int ns_tmp_flags; /* FIXME */ | ||
| 202 | struct nsfont_info *ns_tmp_font; /* FIXME */ | ||
| 203 | #ifdef NS_IMPL_COCOA | 207 | #ifdef NS_IMPL_COCOA |
| 204 | static BOOL ns_menu_bar_is_hidden = NO; | 208 | static BOOL ns_menu_bar_is_hidden = NO; |
| 205 | #endif | 209 | #endif |
| @@ -2158,8 +2162,11 @@ ns_compute_glyph_string_overhangs (struct glyph_string *s) | |||
| 2158 | else | 2162 | else |
| 2159 | { | 2163 | { |
| 2160 | s->left_overhang = 0; | 2164 | s->left_overhang = 0; |
| 2161 | s->right_overhang = ((struct nsfont_info *)font)->ital ? | 2165 | if (EQ (font->driver->type, Qns)) |
| 2162 | FONT_HEIGHT (font) * 0.2 : 0; | 2166 | s->right_overhang = ((struct nsfont_info *)font)->ital ? |
| 2167 | FONT_HEIGHT (font) * 0.2 : 0; | ||
| 2168 | else | ||
| 2169 | s->right_overhang = 0; | ||
| 2163 | } | 2170 | } |
| 2164 | } | 2171 | } |
| 2165 | 2172 | ||
| @@ -3133,8 +3140,10 @@ ns_draw_glyph_string (struct glyph_string *s) | |||
| 3133 | { | 3140 | { |
| 3134 | /* TODO (optimize): focus for box and contents draw */ | 3141 | /* TODO (optimize): focus for box and contents draw */ |
| 3135 | NSRect r[2]; | 3142 | NSRect r[2]; |
| 3136 | int n; | 3143 | int n, flags; |
| 3137 | char box_drawn_p = 0; | 3144 | char box_drawn_p = 0; |
| 3145 | struct font *font = s->face->font; | ||
| 3146 | if (! font) font = FRAME_FONT (s->f); | ||
| 3138 | 3147 | ||
| 3139 | NSTRACE (ns_draw_glyph_string); | 3148 | NSTRACE (ns_draw_glyph_string); |
| 3140 | 3149 | ||
| @@ -3201,13 +3210,10 @@ ns_draw_glyph_string (struct glyph_string *s) | |||
| 3201 | ns_maybe_dumpglyphs_background | 3210 | ns_maybe_dumpglyphs_background |
| 3202 | (s, s->first_glyph->type == COMPOSITE_GLYPH); | 3211 | (s, s->first_glyph->type == COMPOSITE_GLYPH); |
| 3203 | 3212 | ||
| 3204 | ns_tmp_flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR : | 3213 | flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR : |
| 3205 | (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE : | 3214 | (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE : |
| 3206 | (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND : | 3215 | (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND : |
| 3207 | NS_DUMPGLYPH_NORMAL)); | 3216 | NS_DUMPGLYPH_NORMAL)); |
| 3208 | ns_tmp_font = (struct nsfont_info *)s->face->font; | ||
| 3209 | if (ns_tmp_font == NULL) | ||
| 3210 | ns_tmp_font = (struct nsfont_info *)FRAME_FONT (s->f); | ||
| 3211 | 3217 | ||
| 3212 | if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR) | 3218 | if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR) |
| 3213 | { | 3219 | { |
| @@ -3216,10 +3222,21 @@ ns_draw_glyph_string (struct glyph_string *s) | |||
| 3216 | NS_FACE_FOREGROUND (s->face) = tmp; | 3222 | NS_FACE_FOREGROUND (s->face) = tmp; |
| 3217 | } | 3223 | } |
| 3218 | 3224 | ||
| 3219 | ns_tmp_font->font.driver->draw | 3225 | font->driver->draw |
| 3220 | (s, 0, s->nchars, s->x, s->y, | 3226 | (s, 0, s->nchars, s->x, s->y, |
| 3221 | (ns_tmp_flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p) | 3227 | (flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p) |
| 3222 | || ns_tmp_flags == NS_DUMPGLYPH_MOUSEFACE); | 3228 | || flags == NS_DUMPGLYPH_MOUSEFACE); |
| 3229 | |||
| 3230 | { | ||
| 3231 | NSColor *col = (NS_FACE_FOREGROUND (s->face) != 0 | ||
| 3232 | ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (s->face), | ||
| 3233 | s->f) | ||
| 3234 | : FRAME_FOREGROUND_COLOR (s->f)); | ||
| 3235 | [col set]; | ||
| 3236 | |||
| 3237 | /* Draw underline, overline, strike-through. */ | ||
| 3238 | ns_draw_text_decoration (s, s->face, col, s->width, s->x); | ||
| 3239 | } | ||
| 3223 | 3240 | ||
| 3224 | if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR) | 3241 | if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR) |
| 3225 | { | 3242 | { |
| @@ -3959,7 +3976,7 @@ static struct redisplay_interface ns_redisplay_interface = | |||
| 3959 | 0, /* define_fringe_bitmap */ /* FIXME: simplify ns_draw_fringe_bitmap */ | 3976 | 0, /* define_fringe_bitmap */ /* FIXME: simplify ns_draw_fringe_bitmap */ |
| 3960 | 0, /* destroy_fringe_bitmap */ | 3977 | 0, /* destroy_fringe_bitmap */ |
| 3961 | ns_compute_glyph_string_overhangs, | 3978 | ns_compute_glyph_string_overhangs, |
| 3962 | ns_draw_glyph_string, /* interface to nsfont.m */ | 3979 | ns_draw_glyph_string, |
| 3963 | ns_define_frame_cursor, | 3980 | ns_define_frame_cursor, |
| 3964 | ns_clear_frame_area, | 3981 | ns_clear_frame_area, |
| 3965 | ns_draw_window_cursor, | 3982 | ns_draw_window_cursor, |
| @@ -4809,17 +4826,26 @@ not_in_argv (NSString *arg) | |||
| 4809 | /* called on font panel selection */ | 4826 | /* called on font panel selection */ |
| 4810 | - (void)changeFont: (id)sender | 4827 | - (void)changeFont: (id)sender |
| 4811 | { | 4828 | { |
| 4812 | NSEvent *e =[[self window] currentEvent]; | 4829 | NSEvent *e = [[self window] currentEvent]; |
| 4813 | struct face *face =FRAME_DEFAULT_FACE (emacsframe); | 4830 | struct face *face = FRAME_DEFAULT_FACE (emacsframe); |
| 4831 | struct font *font = face->font; | ||
| 4814 | id newFont; | 4832 | id newFont; |
| 4815 | CGFloat size; | 4833 | CGFloat size; |
| 4834 | NSFont *nsfont; | ||
| 4816 | 4835 | ||
| 4817 | NSTRACE (changeFont); | 4836 | NSTRACE (changeFont); |
| 4837 | |||
| 4818 | if (!emacs_event) | 4838 | if (!emacs_event) |
| 4819 | return; | 4839 | return; |
| 4820 | 4840 | ||
| 4821 | if ((newFont = [sender convertFont: | 4841 | if (EQ (font->driver->type, Qns)) |
| 4822 | ((struct nsfont_info *)face->font)->nsfont])) | 4842 | nsfont = ((struct nsfont_info *)font)->nsfont; |
| 4843 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 | ||
| 4844 | else | ||
| 4845 | nsfont = (NSFont *) macfont_get_nsctfont (font); | ||
| 4846 | #endif | ||
| 4847 | |||
| 4848 | if ((newFont = [sender convertFont: nsfont])) | ||
| 4823 | { | 4849 | { |
| 4824 | SET_FRAME_GARBAGED (emacsframe); /* now needed as of 2008/10 */ | 4850 | SET_FRAME_GARBAGED (emacsframe); /* now needed as of 2008/10 */ |
| 4825 | 4851 | ||