X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/fcd42c11c0e0e5fa3ab931ad2126b1d855ba240f..89f20e05797d4d69a0731559c87c656fd54ac338:/src/nsfns.m diff --git a/src/nsfns.m b/src/nsfns.m index 8eaf529ed0..24edd4366c 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) #ifdef NS_IMPL_COCOA #include +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#include "macfont.h" +#endif #endif #if 0 @@ -1171,7 +1174,16 @@ This function is an internal primitive--use `make-frame' instead. */) } block_input (); + +#ifdef NS_IMPL_COCOA +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if (CTGetCoreTextVersion != NULL + && CTGetCoreTextVersion () >= kCTVersionNumber10_5) + mac_register_font_driver (f); +#endif +#endif register_font_driver (&nsfont_driver, f); + x_default_parameter (f, parms, Qfont_backend, Qnil, "fontBackend", "FontBackend", RES_TYPE_STRING); @@ -1181,8 +1193,13 @@ This function is an internal primitive--use `make-frame' instead. */) 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 +1379,15 @@ DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel, { 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; } @@ -2025,16 +2048,27 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc, /* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping, remove this. */ NSString *utfStr; - Lisp_Object ret; + Lisp_Object ret = Qnil; + NSAutoreleasePool *pool; CHECK_STRING (str); - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - utfStr = [NSString stringWithUTF8String: SSDATA (str)]; + pool = [[NSAutoreleasePool alloc] init]; + utfStr = [NSString stringWithUTF8String: SSDATA (str)]; #ifdef NS_IMPL_COCOA - utfStr = [utfStr precomposedStringWithCanonicalMapping]; + if (utfStr) + utfStr = [utfStr precomposedStringWithCanonicalMapping]; #endif - ret = build_string ([utfStr UTF8String]); + if (utfStr) + { + const char *cstr = [utfStr UTF8String]; + if (cstr) + ret = build_string (cstr); + } + [pool release]; + if (NILP (ret)) + error ("Invalid UTF-8"); + return ret; } @@ -2188,17 +2222,13 @@ x_set_scroll_bar_default_width (struct frame *f) wid - 1) / wid; } - -extern const char *x_get_string_resource (XrmDatabase, char *, char *); - - /* terms impl this instead of x-get-resource directly */ -const char * -x_get_string_resource (XrmDatabase rdb, char *name, char *class) +char * +x_get_string_resource (XrmDatabase rdb, const char *name, const char *class) { /* remove appname prefix; TODO: allow for !="Emacs" */ - char *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0); - const char *res; + const char *res, *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0); + check_window_system (NULL); if (inhibit_x_resources) @@ -2206,9 +2236,9 @@ x_get_string_resource (XrmDatabase rdb, char *name, char *class) return NULL; res = ns_get_defaults_value (toCheck); - return !res ? NULL : - (!c_strncasecmp (res, "YES", 3) ? "true" : - (!c_strncasecmp (res, "NO", 2) ? "false" : res)); + return (!res ? NULL : + (!c_strncasecmp (res, "YES", 3) ? "true" : + (!c_strncasecmp (res, "NO", 2) ? "false" : (char *) res))); } @@ -2545,6 +2575,7 @@ compute_tip_xy (struct frame *f, { Lisp_Object left, top; EmacsView *view = FRAME_NS_VIEW (f); + struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); NSPoint pt; /* Start with user-specified or mouse position. */ @@ -2553,7 +2584,8 @@ compute_tip_xy (struct frame *f, if (!INTEGERP (left) || !INTEGERP (top)) { - pt = last_mouse_motion_position; + pt.x = dpyinfo->last_mouse_motion_x; + pt.y = dpyinfo->last_mouse_motion_y; /* Convert to screen coordinates */ pt = [view convertPoint: pt toView: nil]; pt = [[view window] convertBaseToScreen: pt];