#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_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);
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;
}
/* 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;
}
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)
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)));
}
{
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. */
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];