How do I get a font of size N?
How do I get a font of size N?
- Subject: How do I get a font of size N?
- From: Paul Fox <email@hidden>
- Date: Fri, 20 Sep 2002 21:29:10 +0000
I am trying to do printing. It mostly works but I have a problem with
fonts.
When printing, you have a piece of 'paper' of size WxH, with
an appropriate top/bottom/left/margin.
In my case my paper size is 612x792, top margin = 90, bottom margin = 90.
So printable height of page is 792 - 2 * 90 = 612
Now I want to print 64 lines of text on that piece of paper, so
612 / 64 = 9.9.5625 approx.
So I ask for a font:
[NSFont fontWithName: @"Monaco" size: 9.5625];
Now if I do a
[NSString sizeWithAttributes: ...];
then the font height is given as 11. Now a font isnt a square rectangle
but given by a width * height specification. Ive read up on NSFont
and I can create a font of the appropriate 'size' but the horizontal
and vertical sizes dont seem to match up.
How can I calculate the font size to use, or how do I ask for a font
of height N -- irrespective of width?
I know I can ask for a font of size WxH using the matrix specification
but this presumes I might be able to calculate or know the
relative proportion of font-height to font-width.
On a related note, regarding printing. When printing, the NSView
gets called with appropraiate:
drawRect
endPage
drawRect
endPage
...
methods. But I would rather a single call to drawRect and be able
to emit a page-throw, e.g. something like:
[self startPage]; // or super
This way I might not need to worry about calculating an exact font
height in the first place.
thanx
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.