HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* progmodes/compile.el (compilation-mode-hook)
[bpt/emacs.git]
/
src
/
nsfont.m
diff --git
a/src/nsfont.m
b/src/nsfont.m
index
2ba38b7
..
ebee363
100644
(file)
--- a/
src/nsfont.m
+++ b/
src/nsfont.m
@@
-1,6
+1,6
@@
/* Font back-end driver for the NeXT/Open/GNUstep and MacOSX window system.
See font.h
/* Font back-end driver for the NeXT/Open/GNUstep and MacOSX window system.
See font.h
- Copyright (C) 2006-201
2
Free Software Foundation, Inc.
+ Copyright (C) 2006-201
3
Free Software Foundation, Inc.
This file is part of GNU Emacs.
This file is part of GNU Emacs.
@@
-44,6
+44,7
@@
Author: Adrian Robert (arobert@cogsci.ucsd.edu)
#endif
#define NSFONT_TRACE 0
#endif
#define NSFONT_TRACE 0
+#define LCD_SMOOTHING_MARGIN 2
extern Lisp_Object Qns;
extern Lisp_Object Qnormal, Qbold, Qitalic;
extern Lisp_Object Qns;
extern Lisp_Object Qnormal, Qbold, Qitalic;
@@
-74,10
+75,9
@@
static void ns_glyph_metrics (struct nsfont_info *font_info,
static void
ns_escape_name (char *name)
{
static void
ns_escape_name (char *name)
{
- int i =0, len =strlen (name);
- for ( ; i<len; i++)
- if (name[i] == ' ')
- name[i] = '_';
+ for (; *name; name++)
+ if (*name == ' ')
+ *name = '_';
}
}
@@
-85,10
+85,9
@@
ns_escape_name (char *name)
static void
ns_unescape_name (char *name)
{
static void
ns_unescape_name (char *name)
{
- int i =0, len =strlen (name);
- for ( ; i<len; i++)
- if (name[i] == '_')
- name[i] = ' ';
+ for (; *name; name++)
+ if (*name == '_')
+ *name = ' ';
}
}
@@
-363,7
+362,7
@@
static NSString
while CONSP (rts)
{
r = XCAR (XCAR (rts));
while CONSP (rts)
{
r = XCAR (XCAR (rts));
- if (!strncmp
(SSDATA(r), reg, strlen(SSDATA(r)
)))
+ if (!strncmp
(SSDATA (r), reg, SBYTES (r
)))
{
script = XCDR (XCAR (rts));
return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (script))];
{
script = XCDR (XCAR (rts));
return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (script))];
@@
-546,6
+545,7
@@
ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
NSSet *cFamilies;
BOOL foundItal = NO;
NSSet *cFamilies;
BOOL foundItal = NO;
+ block_input ();
if (NSFONT_TRACE)
{
fprintf (stderr, "nsfont: %s for fontspec:\n ",
if (NSFONT_TRACE)
{
fprintf (stderr, "nsfont: %s for fontspec:\n ",
@@
-560,10
+560,7
@@
ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
if (isMatch)
[fkeys removeObject: NSFontFamilyAttribute];
if (isMatch)
[fkeys removeObject: NSFontFamilyAttribute];
- if ([fkeys count] > 0)
- matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys: fkeys];
- else
- matchingDescs = [NSMutableArray array];
+ matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys: fkeys];
if (NSFONT_TRACE)
NSLog(@"Got desc %@ and found %d matching fonts from it: ", fdesc,
if (NSFONT_TRACE)
NSLog(@"Got desc %@ and found %d matching fonts from it: ", fdesc,
@@
-598,6
+595,8
@@
ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
[s1 release];
}
[s1 release];
}
+ unblock_input ();
+
/* Return something if was a match and nothing found. */
if (isMatch)
return ns_fallback_entity ();
/* Return something if was a match and nothing found. */
if (isMatch)
return ns_fallback_entity ();
@@
-701,10
+700,12
@@
static Lisp_Object
nsfont_list_family (Lisp_Object frame)
{
Lisp_Object list = Qnil;
nsfont_list_family (Lisp_Object frame)
{
Lisp_Object list = Qnil;
- NSEnumerator *families =
- [[[NSFontManager sharedFontManager] availableFontFamilies]
- objectEnumerator];
+ NSEnumerator *families;
NSString *family;
NSString *family;
+
+ block_input ();
+ families = [[[NSFontManager sharedFontManager] availableFontFamilies]
+ objectEnumerator];
while ((family = [families nextObject]))
list = Fcons (intern ([family UTF8String]), list);
/* FIXME: escape the name? */
while ((family = [families nextObject]))
list = Fcons (intern ([family UTF8String]), list);
/* FIXME: escape the name? */
@@
-713,6
+714,7
@@
nsfont_list_family (Lisp_Object frame)
fprintf (stderr, "nsfont: list families returning %"pI"d entries\n",
XINT (Flength (list)));
fprintf (stderr, "nsfont: list families returning %"pI"d entries\n",
XINT (Flength (list)));
+ unblock_input ();
return list;
}
return list;
}
@@
-735,6
+737,8
@@
nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
Lisp_Object font_object;
int fixLeopardBug;
Lisp_Object font_object;
int fixLeopardBug;
+ block_input ();
+
if (NSFONT_TRACE)
{
fprintf (stderr, "nsfont: open size %d of fontentity:\n ", pixel_size);
if (NSFONT_TRACE)
{
fprintf (stderr, "nsfont: open size %d of fontentity:\n ", pixel_size);
@@
-794,13
+798,14
@@
nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
font = (struct font *) font_info;
if (!font)
font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
font = (struct font *) font_info;
if (!font)
- return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */
+ {
+ unblock_input ();
+ return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */
+ }
font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs);
font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics);
font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs);
font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics);
- block_input ();
-
/* for metrics */
#ifdef NS_IMPL_COCOA
sfont = [nsfont screenFontWithRenderingMode:
/* for metrics */
#ifdef NS_IMPL_COCOA
sfont = [nsfont screenFontWithRenderingMode:
@@
-1051,6
+1056,7
@@
nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
char isComposite = s->first_glyph->type == COMPOSITE_GLYPH;
int end = isComposite ? s->cmp_to : s->nchars;
char isComposite = s->first_glyph->type == COMPOSITE_GLYPH;
int end = isComposite ? s->cmp_to : s->nchars;
+ block_input ();
/* Select face based on input flags */
switch (ns_tmp_flags)
{
/* Select face based on input flags */
switch (ns_tmp_flags)
{
@@
-1240,7
+1246,6
@@
nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
else
CGContextSetShouldAntialias (gcontext, 1);
else
CGContextSetShouldAntialias (gcontext, 1);
- CGContextSetShouldSmoothFonts (gcontext, NO);
CGContextSetTextMatrix (gcontext, fliptf);
if (bgCol != nil)
CGContextSetTextMatrix (gcontext, fliptf);
if (bgCol != nil)
@@
-1273,6
+1278,7
@@
nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
/* Draw underline, overline, strike-through. */
ns_draw_text_decoration (s, face, col, r.size.width, r.origin.x);
/* Draw underline, overline, strike-through. */
ns_draw_text_decoration (s, face, col, r.size.width, r.origin.x);
+ unblock_input ();
return to-from;
}
return to-from;
}
@@
-1406,11
+1412,12
@@
ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
lb = r.origin.x;
rb = r.size.width - w;
lb = r.origin.x;
rb = r.size.width - w;
+ // Add to bearing for LCD smoothing. We don't know if it is there.
if (lb < 0)
if (lb < 0)
- metrics->lbearing = round (lb);
+ metrics->lbearing = round (lb
- LCD_SMOOTHING_MARGIN
);
if (font_info->ital)
rb += 0.22 * font_info->height;
if (font_info->ital)
rb += 0.22 * font_info->height;
- metrics->rbearing = lrint (w + rb);
+ metrics->rbearing = lrint (w + rb
+ LCD_SMOOTHING_MARGIN
);
metrics->descent = r.origin.y < 0 ? -r.origin.y : 0;
/*lrint (hshrink * [sfont ascender] + expand * hd/2); */
metrics->descent = r.origin.y < 0 ? -r.origin.y : 0;
/*lrint (hshrink * [sfont ascender] + expand * hd/2); */