Re: Fonts getting scaled when going XHTML -> NSAttribString
Re: Fonts getting scaled when going XHTML -> NSAttribString
- Subject: Re: Fonts getting scaled when going XHTML -> NSAttribString
- From: Glen Simmons <email@hidden>
- Date: Fri, 18 Nov 2005 17:51:14 -0600
On Nov 18, 2005, at 1:17 PM, Douglas Davidson wrote:
On Nov 18, 2005, at 9:40 AM, Glen Simmons wrote:
I'm creating an NSAttributedString from XHTML that includes style
attributes like this:
<p><font face="Times New Roman" size="4"><span style="font-size:
16pt">Times New Roman 16</span></font></p>
The attributed string gets created with the correct font, but the
size is wrong; it's increased by 33%.
Also, when I ask the attributed string for html data, it gives me
this:
<p><font face="Times New Roman" size="6" style="font: 21.3px Times
New Roman">Times New Roman 16</font></p>
which uses "px" instead of "pt". I need it to be "pt".
The source of confusion here is the manner in which CSS refers to
font sizes (and to dimensions in general). The basic CSS unit of
length is px. CSS also has what is refers to as "absolute length
units", namely in, cm, mm, pt, and pc. In practice, CSS pt is 4/3
px, and similar ratios hold for the other units; this is how
browsers behave, and so it is the de facto standard.
NSAttributedString has chosen to work exclusively in px, primarily
to synchronize the on-screen appearance of HTML between WebView and
NSTextView. If you need some other scaling of font sizes, set the
NSTextSizeMultiplierDocumentOption when creating your
NSAttributedString. If you need to use some other units in your
generated HTML, you will need to modify the output yourself.
Douglas Davidson
Ah, that makes sense. It would be nice if the HTML ->
NSAttributedString and NSAttributedString -> HTML operations were a
bit more interactive. Maybe a set of delegate methods to be able to
tweak things? I know, I know, file a bug. :-) ... Ok, done - 4350138.
Thanks,
Glen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden