#include "window.h"
#include "fontset.h"
#include "nsterm.h"
-#include "frame.h"
#include "character.h"
#include "font.h"
#include "termchar.h"
static void ns_glyph_metrics (struct nsfont_info *font_info,
unsigned char block);
+#define INVALID_GLYPH 0xFFFF
/* ==========================================================================
{
NSDictionary *tdict = [fdesc objectForKey: NSFontTraitsAttribute];
NSNumber *val = [tdict objectForKey: trait];
- return val == nil ? 0.0 : [val floatValue];
+ return val == nil ? 0.0F : [val floatValue];
}
/* add each attr in font_spec to fdAttrs.. */
n = min (FONT_WEIGHT_NUMERIC (font_spec), 200);
if (n != -1 && n != STYLE_REF)
- [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
+ [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontWeightTrait];
n = min (FONT_SLANT_NUMERIC (font_spec), 200);
if (n != -1 && n != STYLE_REF)
- [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
+ [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontSlantTrait];
n = min (FONT_WIDTH_NUMERIC (font_spec), 200);
if (n > -1 && (n > STYLE_REF + 10 || n < STYLE_REF - 10))
- [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
+ [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontWidthTrait];
if ([tdict count] > 0)
[fdAttrs setObject: tdict forKey: NSFontTraitsAttribute];
- fdesc = [NSFontDescriptor fontDescriptorWithFontAttributes: fdAttrs];
+ fdesc = [[[NSFontDescriptor fontDescriptorWithFontAttributes: fdAttrs]
+ retain] autorelease];
+
if (family != nil)
{
- fdesc = [fdesc fontDescriptorWithFamily: family];
+ NSFontDescriptor *fdesc2 = [fdesc fontDescriptorWithFamily: family];
+ fdesc = [[fdesc2 retain] autorelease];
}
[fdAttrs release];
/* Utility: get width of a char c in screen font SFONT */
-static float
+static CGFloat
ns_char_width (NSFont *sfont, int c)
{
- float w = -1.0;
+ CGFloat w = -1.0;
NSString *cstr = [NSString stringWithFormat: @"%c", c];
#ifdef NS_IMPL_COCOA
static int
ns_ascii_average_width (NSFont *sfont)
{
- float w = -1.0;
+ CGFloat w = -1.0;
if (!ascii_printable)
{
w = [sfont advancementForGlyph: glyph].width;
#endif
- if (w < 0.0)
+ if (w < (CGFloat) 0.0)
{
NSDictionary *attrsDictionary =
[NSDictionary dictionaryWithObject: sfont forKey: NSFontAttributeName];
w = [ascii_printable sizeWithAttributes: attrsDictionary].width;
}
- return lrint (w / 95.0);
+ return lrint (w / (CGFloat) 95.0);
}
off++;
}
//fprintf(stderr, "off = %d\ttot = %d\n", off,tot);
- return (float)off / tot < 1.0 - pct;
+ return (float)off / tot < 1.0F - pct;
}
*ns_registry_to_script (char *reg)
{
Lisp_Object script, r, rts = Vns_reg_to_script;
- while CONSP (rts)
+ while (CONSP (rts))
{
r = XCAR (XCAR (rts));
if (!strncmp (SSDATA (r), reg, SBYTES (r)))
{
Lisp_Object ranges, range_list;
- ranges = Fcons (script, Qnil);
+ ranges = list1 (script);
map_char_table (accumulate_script_ranges, Qnil, Vchar_script_table,
ranges);
range_list = Fnreverse (XCDR (ranges));
if (ns_charset_covers(fset, charset, pct))
[families addObject: family];
}
- pct -= 0.2;
- if ([families count] > 0 || pct < 0.05)
+ pct -= 0.2F;
+ if ([families count] > 0 || pct < 0.05F)
break;
}
[charset release];
========================================================================== */
-static Lisp_Object nsfont_get_cache (FRAME_PTR frame);
-static Lisp_Object nsfont_list (Lisp_Object frame, Lisp_Object font_spec);
-static Lisp_Object nsfont_match (Lisp_Object frame, Lisp_Object font_spec);
-static Lisp_Object nsfont_list_family (Lisp_Object frame);
-static Lisp_Object nsfont_open (FRAME_PTR f, Lisp_Object font_entity,
+static Lisp_Object nsfont_get_cache (struct frame *frame);
+static Lisp_Object nsfont_list (struct frame *, Lisp_Object);
+static Lisp_Object nsfont_match (struct frame *, Lisp_Object);
+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 (FRAME_PTR f, struct font *font);
+static void nsfont_close (struct frame *f, 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,
/* Return a cache of font-entities on FRAME. The cache must be a
cons whose cdr part is the actual cache area. */
static Lisp_Object
-nsfont_get_cache (FRAME_PTR frame)
+nsfont_get_cache (struct frame *frame)
{
- Display_Info *dpyinfo = FRAME_NS_DISPLAY_INFO (frame);
+ Display_Info *dpyinfo = FRAME_DISPLAY_INFO (frame);
return (dpyinfo->name_list_element);
}
weight, slant, width, size (0 if scalable),
dpi, spacing, avgwidth (0 if scalable) */
static Lisp_Object
-nsfont_list (Lisp_Object frame, Lisp_Object font_spec)
+nsfont_list (struct frame *f, Lisp_Object font_spec)
{
- return ns_findfonts (font_spec, NO);
+ return ns_findfonts (font_spec, NO);
}
`face-font-selection-order' is ignored here.
Properties to be considered are same as for list(). */
static Lisp_Object
-nsfont_match (Lisp_Object frame, Lisp_Object font_spec)
+nsfont_match (struct frame *f, Lisp_Object font_spec)
{
- return ns_findfonts(font_spec, YES);
+ return ns_findfonts (font_spec, YES);
}
/* List available families. The value is a list of family names
(symbols). */
static Lisp_Object
-nsfont_list_family (Lisp_Object frame)
+nsfont_list_family (struct frame *f)
{
Lisp_Object list = Qnil;
NSEnumerator *families;
/* Open a font specified by FONT_ENTITY on frame F. If the font is
scalable, open it with PIXEL_SIZE. */
static Lisp_Object
-nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
+nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
{
BOOL synthItal;
unsigned int traits = 0;
family = [[NSFont userFixedPitchFontOfSize: 0] familyName];
/* Should be > 0.23 as some font descriptors (e.g. Terminus) set to that
when setting family in ns_spec_to_descriptor(). */
- if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50)
+ if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50F)
traits |= NSBoldFontMask;
- if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05))
+ if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F))
traits |= NSItalicFontMask;
/* see http://cocoadev.com/forums/comments.php?DiscussionID=74 */
font_info->max_bounds.width = lrint (font_info->width);
font_info->max_bounds.lbearing = lrint (brect.origin.x);
font_info->max_bounds.rbearing =
- lrint (brect.size.width - font_info->width);
+ lrint (brect.size.width - (CGFloat) font_info->width);
#ifdef NS_IMPL_COCOA
/* set up synthItal and the CG font */
font->underline_thickness = lrint (font_info->underwidth);
font->props[FONT_NAME_INDEX] = Ffont_xlfd_name (font_object, Qnil);
- font->props[FONT_FULLNAME_INDEX] =
- make_unibyte_string (font_info->name, strlen (font_info->name));
+ font->props[FONT_FULLNAME_INDEX] = build_unibyte_string (font_info->name);
}
unblock_input ();
/* Close FONT on frame F. */
static void
-nsfont_close (FRAME_PTR f, struct font *font)
+nsfont_close (struct frame *f, struct font *font)
{
struct nsfont_info *font_info = (struct nsfont_info *)font;
int i;
ns_uni_to_glyphs (font_info, high);
g = font_info->glyphs[high][low];
- return g == 0xFFFF ? FONT_INVALID_CODE : g;
+ return g == INVALID_GLYPH ? FONT_INVALID_CODE : g;
}
/* NOTE: focus and clip must be set
also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */
{
- static char cbuf[1024];
- char *c = cbuf;
+ static unsigned char cbuf[1024];
+ unsigned char *c = cbuf;
#ifdef NS_IMPL_GNUSTEP
static float advances[1024];
float *adv = advances;
: FRAME_BACKGROUND_COLOR (s->f)) set];
else
{
- struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (s->f);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f);
[[dpyinfo->bitmaps[face->stipple-1].img stippleMask] set];
}
NSRectFill (br);
[bgCol set];
DPSmoveto (context, r.origin.x, r.origin.y);
/*[context GSSetTextDrawingMode: GSTextFillStroke]; /// not implemented yet */
- DPSxshow (context, cbuf, advances, len);
+ DPSxshow (context, (const char *) cbuf, advances, len);
DPSstroke (context);
[col set];
/*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */
/* draw with DPSxshow () */
DPSmoveto (context, r.origin.x, r.origin.y);
- DPSxshow (context, cbuf, advances, len);
+ DPSxshow (context, (const char *) cbuf, advances, len);
DPSstroke (context);
DPSgrestore (context);
#else
g = glyphStorage->cglyphs[i];
/* TODO: is this a good check? maybe need to use coveredChars.. */
- if (g > numGlyphs)
- g = 0xFFFF; /* hopefully unused... */
+ if (g > numGlyphs || g == NSNullGlyph)
+ g = INVALID_GLYPH; /* hopefully unused... */
#endif
*glyphs = g;
}
metrics = font_info->metrics[block];
for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++)
{
- float w, lb, rb;
+ CGFloat w, lb, rb;
NSRect r = [sfont boundingRectForGlyph: g];
w = max ([sfont advancementForGlyph: g].width, 2.0);
if (lb < 0)
metrics->lbearing = round (lb - LCD_SMOOTHING_MARGIN);
if (font_info->ital)
- rb += 0.22 * font_info->height;
+ rb += (CGFloat) (0.22F * font_info->height);
metrics->rbearing = lrint (w + rb + LCD_SMOOTHING_MARGIN);
metrics->descent = r.origin.y < 0 ? -r.origin.y : 0;
characterIndex: (NSUInteger)charIndex
{
len = glyphIndex+length;
- for (i =glyphIndex; i<len; i++)
+ for (i =glyphIndex; i<len; i++)
cglyphs[i] = glyphs[i-glyphIndex];
if (len > maxGlyph)
maxGlyph = len;