* 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.
+2013-09-15 Jan Djärv <jan.h.d@swipnet.se>
+
+ * configure.ac: Add check for OSX 10.5, required for macfont.o.
+
2013-09-09 Glenn Morris <rgm@gnu.org>
* configure.ac (LDFLAGS_NOCOMBRELOC): New variable.
[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
])],
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
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"
+2013-09-15 Jan Djärv <jan.h.d@swipnet.se>
+
+ * NEWS: Mention the macfont backend.
+
2013-09-09 Glenn Morris <rgm@gnu.org>
* refcards/Makefile (PS_ENGLISH, PS_CZECH, PS_FRENCH, PS_GERMAN)
** 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
+
\f
* Startup Changes in Emacs 24.4
+2013-09-15 Jan Djärv <jan.h.d@swipnet.se>
+
+ * 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 <dmantipov@yandex.ru>
Drop VERTICAL_SCROLL_BAR_WIDTH_TRIM. For X, it is zero since 1999,
MSDOS_X_OBJ =
NS_OBJ=@NS_OBJ@
-## 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.
NS_OBJC_OBJ=@NS_OBJC_OBJ@
## Only set if NS_IMPL_GNUSTEP.
GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@
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 \
#endif /* HAVE_NTGUI */
#ifdef HAVE_NS
syms_of_nsfont ();
+ syms_of_macfont ();
#endif /* HAVE_NS */
#endif /* HAVE_WINDOW_SYSTEM */
}
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
#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
}
block_input ();
+
+#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);
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 ();
{
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;
}
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 */
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)
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);
#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;
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)));
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;
}
#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)
#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;
#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
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;
}
}
{
/* 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);
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)
{
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)
{
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,
/* 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 */