/* Font back-end driver for the NeXT/Open/GNUstep and MacOSX window system.
See font.h
- Copyright (C) 2006-2013 Free Software Foundation, Inc.
+ Copyright (C) 2006-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
static Lisp_Object nsfont_list_family (struct frame *);
static Lisp_Object nsfont_open (struct frame *f, Lisp_Object font_entity,
int pixel_size);
-static void nsfont_close (struct frame *f, struct font *font);
+static void nsfont_close (struct font *font);
static int nsfont_has_char (Lisp_Object entity, int c);
static unsigned int nsfont_encode_char (struct font *font, int c);
static int nsfont_text_extents (struct font *font, unsigned int *code,
font->vertical_centering = 0;
font->baseline_offset = 0;
font->relative_compose = 0;
- font->font_encoder = NULL;
font->props[FONT_FORMAT_INDEX] = Qns;
font->props[FONT_FILE_INDEX] = Qnil;
}
-/* Close FONT on frame F. */
+/* Close FONT. */
static void
-nsfont_close (struct frame *f, struct font *font)
+nsfont_close (struct font *font)
{
- struct nsfont_info *font_info = (struct nsfont_info *)font;
- int i;
-
- /* FIXME: this occurs apparently due to same failure to detect same font
- that causes need for cache in nsfont_open () */
- if (!font_info)
- return;
+ struct nsfont_info *font_info = (struct nsfont_info *) font;
- for (i =0; i<0x100; i++)
+ /* FIXME: font_info may be NULL due to same failure to detect
+ same font that causes need for cache in nsfont_open. */
+ if (font_info && font_info->name)
{
- xfree (font_info->glyphs[i]);
- xfree (font_info->metrics[i]);
- }
- [font_info->nsfont release];
+ int i;
+
+ for (i = 0; i < 0x100; i++)
+ {
+ xfree (font_info->glyphs[i]);
+ xfree (font_info->metrics[i]);
+ }
+ [font_info->nsfont release];
#ifdef NS_IMPL_COCOA
- CGFontRelease (font_info->cgfont);
+ CGFontRelease (font_info->cgfont);
#endif
- xfree (font_info->name);
- xfree (font_info);
+ xfree (font_info->name);
+ font_info->name = NULL;
+ }
}
static int
nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
bool with_background)
-/* NOTE: focus and clip must be set
- also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */
+/* NOTE: focus and clip must be set */
{
static unsigned char cbuf[1024];
unsigned char *c = cbuf;
unsigned short *t = s->char2b;
int i, len, flags;
char isComposite = s->first_glyph->type == COMPOSITE_GLYPH;
- int end = isComposite ? s->cmp_to : s->nchars;
block_input ();
int cwidth, twidth = 0;
int hi, lo;
/* FIXME: composition: no vertical displacement is considered. */
- t += s->cmp_from; /* advance into composition */
- for (i = s->cmp_from; i < end; i++, t++)
+ t += from; /* advance into composition */
+ for (i = from; i < to; i++, t++)
{
hi = (*t & 0xFF00) >> 8;
lo = *t & 0x00FF;
/* set up for character rendering */
- r.origin.y = s->ybase;
+ r.origin.y = y;
col = (NS_FACE_FOREGROUND (face) != 0
? ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f)
[col set];
CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y);
- CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from,
+ CGContextShowGlyphsWithAdvances (gcontext, s->char2b + from,
advances, len);
if (face->overstrike)
{
CGContextSetTextPosition (gcontext, r.origin.x+0.5, r.origin.y);
- CGContextShowGlyphsWithAdvances (gcontext, s->char2b + s->cmp_from,
+ CGContextShowGlyphsWithAdvances (gcontext, s->char2b + from,
advances, len);
}