emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114295: Port the font backend from the Mac port.


From: Jan D.
Subject: [Emacs-diffs] trunk r114295: Port the font backend from the Mac port.
Date: Sun, 15 Sep 2013 17:58:55 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114295
revision-id: address@hidden
parent: address@hidden
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Sun 2013-09-15 19:58:46 +0200
message:
  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.
modified:
  ChangeLog                      changelog-20091113204419-o5vbwnq5f7feedwu-1538
  configure.ac                   
configure.in-20091113204419-o5vbwnq5f7feedwu-783
  etc/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1485
  etc/NEWS                       news-20100311060928-aoit31wvzf25yr1z-1
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/Makefile.in                makefile.in-20091113204419-o5vbwnq5f7feedwu-631
  src/font.c                     font.c-20091113204419-o5vbwnq5f7feedwu-8540
  src/font.h                     font.h-20091113204419-o5vbwnq5f7feedwu-8541
  src/nsfns.m                    nsfns.m-20091113204419-o5vbwnq5f7feedwu-8741
  src/nsfont.m                   nsfont.m-20091113204419-o5vbwnq5f7feedwu-8748
  src/nsterm.h                   nsterm.h-20091113204419-o5vbwnq5f7feedwu-8746
  src/nsterm.m                   nsterm.m-20091113204419-o5vbwnq5f7feedwu-8747
=== modified file 'ChangeLog'
--- a/ChangeLog 2013-09-09 15:54:03 +0000
+++ b/ChangeLog 2013-09-15 17:58:46 +0000
@@ -1,3 +1,7 @@
+2013-09-15  Jan Djärv  <address@hidden>
+
+       * configure.ac: Add check for OSX 10.5, required for macfont.o.
+
 2013-09-09  Glenn Morris  <address@hidden>
 
        * configure.ac (LDFLAGS_NOCOMBRELOC): New variable.

=== modified file 'configure.ac'
--- a/configure.ac      2013-09-09 18:14:50 +0000
+++ b/configure.ac      2013-09-15 17:58:46 +0000
@@ -1623,7 +1623,10 @@
                  [AC_MSG_ERROR([`--with-ns' was specified, but the include
   files are missing or cannot be compiled.])])
 
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
+  macfont_file=""
+  if test "${NS_IMPL_COCOA}" = "yes"; then
+    AC_MSG_CHECKING([for OSX 10.4 or newer])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
                                      [
 #ifdef MAC_OS_X_VERSION_MAX_ALLOWED
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
@@ -1635,13 +1638,33 @@
                    ])],
                    ns_osx_have_104=yes,
                    ns_osx_have_104=no)
+    AC_MSG_RESULT([$ns_osx_have_104])
+
+    if test $ns_osx_have_104 = no; then
+       AC_MSG_ERROR([`OSX 10.4 or newer is required']);
+    fi
+    AC_MSG_CHECKING([for OSX 10.5 or newer])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
+                                     [
+#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
+ ; /* OK */
+#else
+#error "OSX 10.5 not found"
+#endif
+#endif
+                   ])],
+                   ns_osx_have_105=yes,
+                   ns_osx_have_105=no)
+    AC_MSG_RESULT([$ns_osx_have_105])
+    if test $ns_osx_have_105 = yes; then
+      macfont_file="macfont.o"
+    fi
+  fi
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Foundation/NSObjCRuntime.h>],
                                      [NSInteger i;])],
                    ns_have_nsinteger=yes,
                    ns_have_nsinteger=no)
-  if test $ns_osx_have_104 = no; then
-     AC_MSG_ERROR([`OSX 10.4 or newer is required']);
-  fi
   if test $ns_have_nsinteger = yes; then
     AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.])
   fi
@@ -1677,7 +1700,8 @@
      leimdir="\${ns_appresdir}/leim"
      INSTALL_ARCH_INDEP_EXTRA=
   fi
-  NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
+
+  NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o 
$macfont_file"
 fi
 CFLAGS="$tmp_CFLAGS"
 CPPFLAGS="$tmp_CPPFLAGS"

=== modified file 'etc/ChangeLog'
--- a/etc/ChangeLog     2013-09-09 16:59:07 +0000
+++ b/etc/ChangeLog     2013-09-15 17:58:46 +0000
@@ -1,3 +1,7 @@
+2013-09-15  Jan Djärv  <address@hidden>
+
+       * NEWS: Mention the macfont backend.
+
 2013-09-09  Glenn Morris  <address@hidden>
 
        * refcards/Makefile (PS_ENGLISH, PS_CZECH, PS_FRENCH, PS_GERMAN)

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2013-09-11 06:44:35 +0000
+++ b/etc/NEWS  2013-09-15 17:58:46 +0000
@@ -54,6 +54,11 @@
 ** Emacs for NS (OSX, GNUStep) can be built with ImageMagick support.
 pkg-config is required to find ImageMagick libraries.
 
+** For OSX >= 10.5, the Core text based font backend from the Mac port is used.
+For GNUStep and OSX 10.4 the old backend is used.
+To use the old backend by default, do on the command line:
+% defaults write org.gnu.Emacs FontBackend ns
+
 
 * Startup Changes in Emacs 24.4
 

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-09-15 08:28:30 +0000
+++ b/src/ChangeLog     2013-09-15 17:58:46 +0000
@@ -1,3 +1,35 @@
+2013-09-15  Jan Djärv  <address@hidden>
+
+       * 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.
+
+       * nsterm.h (FONT_DESCENT, FONT_ASCENT): Define to (f)->ascent and
+       (f)->descent.
+
+       * 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.
+
+       * 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.
+
+       * macfont.m, macfont.h, maccuvs.h: New files.
+
+       * font.h: Declare syms_of_macfont.
+
+       * font.c (syms_of_font): Call syms_of_macfont.
+
+       * Makefile.in (NS_OBJ, SOME_MACHINE_OBJECTS): Add macfont.o.
+
 2013-09-15  Dmitry Antipov  <address@hidden>
 
        Drop VERTICAL_SCROLL_BAR_WIDTH_TRIM.  For X, it is zero since 1999,

=== modified file 'src/Makefile.in'
--- a/src/Makefile.in   2013-09-04 06:45:44 +0000
+++ b/src/Makefile.in   2013-09-15 17:58:46 +0000
@@ -266,7 +266,7 @@
 MSDOS_X_OBJ =
 
 address@hidden@
-## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS.
+## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o if 
HAVE_NS.
 address@hidden@
 ## Only set if NS_IMPL_GNUSTEP.
 address@hidden@
@@ -388,7 +388,7 @@
 SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
   xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
   fontset.o dbusbind.o cygw32.o \
-  nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
+  nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o \
   w32.o w32console.o w32fns.o w32heap.o w32inevt.o w32notify.o \
   w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
   w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \

=== modified file 'src/font.c'
--- a/src/font.c        2013-09-13 15:03:51 +0000
+++ b/src/font.c        2013-09-15 17:58:46 +0000
@@ -5199,6 +5199,7 @@
 #endif /* HAVE_NTGUI */
 #ifdef HAVE_NS
   syms_of_nsfont ();
+  syms_of_macfont ();
 #endif /* HAVE_NS */
 #endif /* HAVE_WINDOW_SYSTEM */
 }

=== modified file 'src/font.h'
--- a/src/font.h        2013-09-05 06:25:12 +0000
+++ b/src/font.h        2013-09-15 17:58:46 +0000
@@ -825,6 +825,7 @@
 extern Lisp_Object Qfontsize;
 extern struct font_driver nsfont_driver;
 extern void syms_of_nsfont (void);
+extern void syms_of_macfont (void);
 #endif /* HAVE_NS */
 
 #ifndef FONT_DEBUG

=== modified file 'src/nsfns.m'
--- a/src/nsfns.m       2013-09-13 16:46:18 +0000
+++ b/src/nsfns.m       2013-09-15 17:58:46 +0000
@@ -46,6 +46,9 @@
 
 #ifdef NS_IMPL_COCOA
 #include <IOKit/graphics/IOGraphicsLib.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+#include "macfont.h"
+#endif
 #endif
 
 #if 0
@@ -1171,7 +1174,17 @@
     }
 
   block_input ();
-  register_font_driver (&nsfont_driver, f);
+
+#ifdef NS_IMPL_GNUSTEP ||                               \
+  MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+  register_font_driver (&nsfont_driver, f);
+#else
+  if (CTGetCoreTextVersion != NULL
+      && CTGetCoreTextVersion () >= kCTVersionNumber10_5)
+    mac_register_font_driver (f);
+  register_font_driver (&nsfont_driver, f);
+#endif
+
   x_default_parameter (f, parms, Qfont_backend, Qnil,
                        "fontBackend", "FontBackend", RES_TYPE_STRING);
 
@@ -1181,8 +1194,13 @@
     x_default_parameter (f, parms, Qfontsize,
                                     make_number (0 /*(int)[font pointSize]*/),
                                     "fontSize", "FontSize", RES_TYPE_NUMBER);
+    // Remove ' Regular', not handled by backends.
+    char *fontname = xstrdup ([[font displayName] UTF8String]);
+    int len = strlen (fontname);
+    if (len > 8 && strcmp (fontname + len - 8, " Regular") == 0)
+      fontname[len-8] = '\0';
     x_default_parameter (f, parms, Qfont,
-                                 build_string ([[font fontName] UTF8String]),
+                                 build_string (fontname),
                                  "font", "Font", RES_TYPE_STRING);
   }
   unblock_input ();
@@ -1362,9 +1380,15 @@
 {
   struct frame *f = decode_window_system_frame (frame);
   id fm = [NSFontManager sharedFontManager];
-
-  [fm setSelectedFont: ((struct nsfont_info *)f->output_data.ns->font)->nsfont
-           isMultiple: NO];
+  struct font *font = f->output_data.ns->font;
+  NSFont *nsfont;
+  if (EQ (font->driver->type, Qns))
+    nsfont = ((struct nsfont_info *)font)->nsfont;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+  else
+    nsfont = (NSFont *) macfont_get_nsctfont (font);
+#endif
+  [fm setSelectedFont: nsfont isMultiple: NO];
   [fm orderFrontFontPanel: NSApp];
   return Qnil;
 }

=== modified file 'src/nsfont.m'
--- a/src/nsfont.m      2013-09-13 15:03:51 +0000
+++ b/src/nsfont.m      2013-09-15 17:58:46 +0000
@@ -51,8 +51,6 @@
 static Lisp_Object Qcondensed, Qexpanded;
 extern Lisp_Object Qappend;
 extern float ns_antialias_threshold;
-extern int ns_tmp_flags;
-extern struct nsfont_info *ns_tmp_font;
 
 
 /* font glyph and metrics caching functions, implemented at end */
@@ -798,6 +796,7 @@
 
   font_object = font_make_object (VECSIZE (struct nsfont_info),
                                   font_entity, pixel_size);
+  ASET (font_object, FONT_TYPE_INDEX, nsfont_driver.type);
   font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
   font = (struct font *) font_info;
   if (!font)
@@ -871,10 +870,11 @@
     font_info->size = font->pixel_size;
 
     /* max bounds */
-    font_info->max_bounds.ascent = lrint ([sfont ascender]);
+    font->ascent = font_info->max_bounds.ascent = lrint ([sfont ascender]);
     /* Descender is usually negative.  Use floor to avoid
        clipping descenders. */
-    font_info->max_bounds.descent = -lrint (floor(adjusted_descender));
+    font->descent =
+      font_info->max_bounds.descent = -lrint (floor(adjusted_descender));
     font_info->height =
       font_info->max_bounds.ascent + font_info->max_bounds.descent;
     font_info->max_bounds.width = lrint (font_info->width);
@@ -1051,16 +1051,26 @@
 #endif
   struct face *face;
   NSRect r;
-  struct nsfont_info *font = ns_tmp_font;
+  struct nsfont_info *font;
   NSColor *col, *bgCol;
   unsigned short *t = s->char2b;
-  int i, len;
+  int i, len, flags;
   char isComposite = s->first_glyph->type == COMPOSITE_GLYPH;
   int end = isComposite ? s->cmp_to : s->nchars;
 
   block_input ();
+
+  font = (struct nsfont_info *)s->face->font;
+  if (font == NULL)
+    font = (struct nsfont_info *)FRAME_FONT (s->f);
+
   /* Select face based on input flags */
-  switch (ns_tmp_flags)
+  flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR :
+    (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE :
+     (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND :
+      NS_DUMPGLYPH_NORMAL));
+
+  switch (flags)
     {
     case NS_DUMPGLYPH_CURSOR:
       face = s->face;
@@ -1188,8 +1198,8 @@
   col = (NS_FACE_FOREGROUND (face) != 0
          ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f)
          : FRAME_FOREGROUND_COLOR (s->f));
-  /* FIXME: find another way to pass this */
-  bgCol = (ns_tmp_flags != NS_DUMPGLYPH_FOREGROUND ? nil
+
+  bgCol = (flags != NS_DUMPGLYPH_FOREGROUND ? nil
            : (NS_FACE_BACKGROUND (face) != 0
               ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f)
               : FRAME_BACKGROUND_COLOR (s->f)));
@@ -1264,22 +1274,19 @@
 
     CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y);
     CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from,
-                                    advances, len);
+                                     advances, len);
 
     if (face->overstrike)
       {
         CGContextSetTextPosition (gcontext, r.origin.x+0.5, r.origin.y);
         CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from,
-                                        advances, len);
+                                         advances, len);
       }
 
     CGContextRestoreGState (gcontext);
   }
 #endif  /* NS_IMPL_COCOA */
 
-  /* Draw underline, overline, strike-through. */
-  ns_draw_text_decoration (s, face, col, r.size.width, r.origin.x);
-
   unblock_input ();
   return to-from;
 }

=== modified file 'src/nsterm.h'
--- a/src/nsterm.h      2013-09-15 08:28:30 +0000
+++ b/src/nsterm.h      2013-09-15 17:58:46 +0000
@@ -701,10 +701,8 @@
 
 #define FONT_WIDTH(f)  ((f)->max_width)
 #define FONT_HEIGHT(f) ((f)->height)
-/*#define FONT_BASE(f)    ((f)->ascent) */
-#define FONT_BASE(f)    (((struct nsfont_info *)f)->max_bounds.ascent)
-/*#define FONT_DESCENT(f) ((f)->descent) */
-#define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
+#define FONT_BASE(f)    ((f)->ascent)
+#define FONT_DESCENT(f) ((f)->descent)
 
 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
 

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2013-09-13 15:03:51 +0000
+++ b/src/nsterm.m      2013-09-15 17:58:46 +0000
@@ -64,6 +64,12 @@
 #include "process.h"
 #endif
 
+#ifdef NS_IMPL_COCOA
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+#include "macfont.h"
+#endif
+#endif
+
 /* call tracing */
 #if 0
 int term_trace_num = 0;
@@ -198,8 +204,6 @@
 #endif
 static BOOL gsaved = NO;
 static BOOL ns_fake_keydown = NO;
-int ns_tmp_flags; /* FIXME */
-struct nsfont_info *ns_tmp_font; /* FIXME */
 #ifdef NS_IMPL_COCOA
 static BOOL ns_menu_bar_is_hidden = NO;
 #endif
@@ -2158,8 +2162,11 @@
   else
     {
       s->left_overhang = 0;
-      s->right_overhang = ((struct nsfont_info *)font)->ital ?
-        FONT_HEIGHT (font) * 0.2 : 0;
+      if (EQ (font->driver->type, Qns))
+        s->right_overhang = ((struct nsfont_info *)font)->ital ?
+          FONT_HEIGHT (font) * 0.2 : 0;
+      else
+        s->right_overhang = 0;
     }
 }
 
@@ -3133,8 +3140,10 @@
 {
   /* TODO (optimize): focus for box and contents draw */
   NSRect r[2];
-  int n;
+  int n, flags;
   char box_drawn_p = 0;
+  struct font *font = s->face->font;
+  if (! font) font = FRAME_FONT (s->f);
 
   NSTRACE (ns_draw_glyph_string);
 
@@ -3201,13 +3210,10 @@
         ns_maybe_dumpglyphs_background
           (s, s->first_glyph->type == COMPOSITE_GLYPH);
 
-      ns_tmp_flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR :
-                    (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE :
-                     (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND :
-                      NS_DUMPGLYPH_NORMAL));
-      ns_tmp_font = (struct nsfont_info *)s->face->font;
-      if (ns_tmp_font == NULL)
-          ns_tmp_font = (struct nsfont_info *)FRAME_FONT (s->f);
+      flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR :
+        (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE :
+         (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND :
+          NS_DUMPGLYPH_NORMAL));
 
       if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR)
         {
@@ -3216,10 +3222,21 @@
           NS_FACE_FOREGROUND (s->face) = tmp;
         }
 
-      ns_tmp_font->font.driver->draw
+      font->driver->draw
         (s, 0, s->nchars, s->x, s->y,
-         (ns_tmp_flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p)
-         || ns_tmp_flags == NS_DUMPGLYPH_MOUSEFACE);
+         (flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p)
+         || flags == NS_DUMPGLYPH_MOUSEFACE);
+
+      {
+        NSColor *col = (NS_FACE_FOREGROUND (s->face) != 0
+                        ? ns_lookup_indexed_color (NS_FACE_FOREGROUND 
(s->face),
+                                                   s->f)
+                        : FRAME_FOREGROUND_COLOR (s->f));
+        [col set];
+
+        /* Draw underline, overline, strike-through. */
+        ns_draw_text_decoration (s, s->face, col, s->width, s->x);
+      }
 
       if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR)
         {
@@ -3959,7 +3976,7 @@
   0, /* define_fringe_bitmap */ /* FIXME: simplify ns_draw_fringe_bitmap */
   0, /* destroy_fringe_bitmap */
   ns_compute_glyph_string_overhangs,
-  ns_draw_glyph_string, /* interface to nsfont.m */
+  ns_draw_glyph_string,
   ns_define_frame_cursor,
   ns_clear_frame_area,
   ns_draw_window_cursor,
@@ -4809,17 +4826,26 @@
 /* called on font panel selection */
 - (void)changeFont: (id)sender
 {
-  NSEvent *e =[[self window] currentEvent];
-  struct face *face =FRAME_DEFAULT_FACE (emacsframe);
+  NSEvent *e = [[self window] currentEvent];
+  struct face *face = FRAME_DEFAULT_FACE (emacsframe);
+  struct font *font = face->font;
   id newFont;
   CGFloat size;
+  NSFont *nsfont;
 
   NSTRACE (changeFont);
+
   if (!emacs_event)
     return;
 
-  if ((newFont = [sender convertFont:
-                           ((struct nsfont_info *)face->font)->nsfont]))
+  if (EQ (font->driver->type, Qns))
+    nsfont = ((struct nsfont_info *)font)->nsfont;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+  else
+    nsfont = (NSFont *) macfont_get_nsctfont (font);
+#endif
+
+  if ((newFont = [sender convertFont: nsfont]))
     {
       SET_FRAME_GARBAGED (emacsframe); /* now needed as of 2008/10 */
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]