Ball Couch

This is pretty awesome:

But is it "$3000 + $200 shipping" awesome? I'm not convinced...

(There are no prices on their web site, so I mailed and asked, and they sent me a PDF that was exactly the same content as their Flash-horror web site -- except that it had prices in it. It's not like this information changes frequently! Thanks for that waste of time, assholes.)

(See also, of course.)

Update: Ok, I bought one, and it is totally awesome, and really comfortable. So I will forgive them for their ill-advised web-design decisions.

Tags: , ,
Current Music: Whale -- Eye 842 ♬

Quartz font metrics

Dear Lazyweb,

I'm lost in a twisty maze of font handling APIs, all alike.

I've got a bunch of Quartz code, and I need to do fonty things. Right now I'm doing this kind of stuff:

<LJ-CUT text=" --More--(16%) ">

    CGContextSelectFont (cgc, "Helvetica Bold", 12, kCGEncodingMacRoman);
    CGContextSetTextMatrix (cgc, CGAffineTransformIdentity);
    CGContextSetTextDrawingMode (cgc, kCGTextFill);
    CGContextSetShouldAntialias (cgc, YES);
    CGContextShowTextAtPoint (cgc, x, y, string, length);

That's all well and good, but now I need per-char metrics: I need to know the ascent, descent, lbearing, rbearing, and bounding box of each character I'm drawing. As far as I can tell, the only thing Quartz will give you is rbearing (aka horizontal cursor motion):

    CGContextSetTextDrawingMode (cgc, kCGTextInvisible);
    CGContextShowTextAtPoint (cgc, 0, 0, &c, 1);
    CGPoint p = CGContextGetTextPosition (cgc);

So should I be using NSFont? ATSU? Something else? I can't tell... I tried to use NSFont, but I can't see how to attach an NSFont to an arbitrary CGContextRef (which might be either a window or bitmap context). I thought it might be:

    NSGraphicsContext *nsctx =
      [NSGraphicsContext graphicsContextWithGraphicsPort:cgc flipped:NO];
    [font setInContext:nsctx];
but that doesn't seem to set the font used by CGContextShowTextAtPoint(). Or is there some other text-drawing routine I should be using with NSFont?

If the answer is ATSU, please point me at some sample code that involves ATSU and Quartz but not Carbon/QuickDraw, because I haven't found any.

Second question:

How does aglUseFont() relate to these other three font APIs (CG, ATSU, and NSFont)? How do I turn "Helvetica Bold" or "Courier" into the kind of "fontID" that it wants?

Update: I did solve this eventually; if you want to see the working code, see the query_font() and draw_string() functions in xscreensaver/OSX/jwxyz.m.

Tags: , , ,