int i;
push_fg_gc (d, gc, YES);
CGContextBeginPath (d->cgc);
+ float x = 0, y = 0;
for (i = 0; i < npoints; i++) {
- float x, y;
if (i > 0 && mode == CoordModePrevious) {
x += points[i].x;
y -= points[i].y;
g = (hex[spec[3]] << 4) | hex[spec[4]];
b = (hex[spec[5]] << 4) | hex[spec[6]];
} else if (!strcasecmp(spec,"black")) {
- r = g = b = 0;
+// r = g = b = 0;
} else if (!strcasecmp(spec,"white")) {
r = g = b = 255;
} else if (!strcasecmp(spec,"red")) {
Font fid = (Font) calloc (1, sizeof(*fid));
fid->nsfont = try_native_font (name, &fid->ps_name, &fid->size);
+
+ if (!fid->nsfont && name &&
+ strchr (name, ' ') &&
+ !strchr (name, '*')) {
+ // If name contains a space but no stars, it is a native font spec --
+ // return NULL so that we know it really didn't exist. Else, it is an
+ // XLFD font, so keep trying.
+ XUnloadFont (dpy, fid);
+ return 0;
+ }
+
if (! fid->nsfont)
fid->nsfont = try_xlfd_font (name, &fid->ps_name, &fid->size);
+
+ // We should never return NULL for XLFD fonts.
if (!fid->nsfont) {
NSLog(@"no NSFont for \"%s\"", name);
abort();
XLoadQueryFont (Display *dpy, const char *name)
{
Font fid = XLoadFont (dpy, name);
+ if (!fid) return 0;
return XQueryFont (dpy, fid);
}
int
XUnloadFont (Display *dpy, Font fid)
{
- free (fid->ps_name);
- free (fid->metrics.per_char);
+ if (fid->ps_name)
+ free (fid->ps_name);
+ if (fid->metrics.per_char)
+ free (fid->metrics.per_char);
// #### DAMMIT! I can't tell what's going wrong here, but I keep getting
// crashes in [NSFont ascender] <- query_font, and it seems to go away