Andrea,
I think what you are missing is the height is calculated as a multiple of the 'natural line height' of the font. This comes from apple's text engine and is the height from tallest character to the lowest descender. Most fonts are going to have caps with accents that will be higher than ascenders--think of the 'A' with a ring above it used in Danish. It's a little complicated to figure out how to do what you want in anything other than a case by case method, I think, but here are some Appkit methods that are easy to use in nodebox that might help a bit.
from AppKit import * helv = NSFont.fontWithName_size_("Helvetica", 32) defaultHeight = helv.defaultLineHeightForFont() capHeight = helv.capHeight() descender = helv.descender() xheight = helv.xHeight() print helv.leading() font("Helvetica", 32) lineheight((xheight)/defaultHeight) text("xxxx\nxxxx", 0,54, 281 ) lineheight((capHeight)/defaultHeight) text("MMMM\nMMMM", 0,104, 281 ) lineheight((capHeight-descender)/defaultHeight) text("jjjjjj\nMMMM", 0,167, 292 )I don't know if this forum software takes unicode so this last line might by messed up, but it's not important--you get the idea:
lineheight(1) text(u"jjjjjjjjjjjÅÅÅ", 30,243, 95 )Good luck, hopes this helps a bit.
Uh, thanks a lot, Mark.
Perfect, I understood the problem.
But it would be nice to have documentation (or at least some hints) about the module you used.
Best
-a-
Hi Andrea,
The Appkit library comes with the Mac. It isn't a nodebox module per se--anymore than any other python library is.
Despite that, there is a really good intro on using it with Nodebox that will get you started here:
http://www.nodebox.net/code/index.php/PyObjC
It is very powerful because it gives you access to most of the apple API, and because of this, there is a bit of learning curve.
Ah, didn't take a look to that page...
many thanks
-a-
lineheight: set solid
Posted by andrea on Apr 19, 2008(I'm sorry for the bombing but I need to understand...)
What am I missing?I think I'm missing something with lineheight()
If I set it to 1 I guess I should set solid. But ascenders and descenders don't touch. I'm having a set solid with a 0.78 value (approx).
e.g.
Many thanks
-a-