Re: error converting HTML into an attributed string
Re: error converting HTML into an attributed string
- Subject: Re: error converting HTML into an attributed string
- From: Mark Sanvitale <email@hidden>
- Date: Mon, 19 Nov 2007 16:17:30 -0800
Please ignore the mistype where I wrote
"NSTextSizeMultiplierDocumentOption of 0.75". Yes, that will not
result in a 1/3 reduction. Even with the correct value, the problem
persists.
Mark
On Nov 19, 2007, at 4:11 PM, Mark Sanvitale wrote:
The initWithHTML method of NSAttributedString is exactly what I
need, and it works, for the most part. However, I am experiencing
one annoying problem with the conversion, and I'm wondering if
anyone has any insight into it (i.e. despite my displeasure,
perhaps this is the way it is intended to work).
The problem is that the attributed-string / rich-text that I get
from some HTML data always has a font size one-third bigger
(rounded to the nearest whole integer) than what is specified in
the HTML. The fact that I am seeing an exact multiple, I thought
this might (somehow) be on purpose. The HTML I am asking to be
converted is fairly limited. It has a bunch of tags of the form:
<ilayer style="font-family: Courier;font-size: 20pt;color: rgb
(51,139,213);">
i.e. an inconsequential HTML tag that includes inline CSS
properties in order to specify the look of the text. The problem
is that the font size in the CSS does not result in an equivalent
size in the resulting attributed string. In this example, the
resulting font size is 27 (20 * 1 1/3 = 26.66666 = 27 with rounding).
I started experimenting with the initWithHTML method that accepts
an options dictionary so I can specify an
NSTextSizeMultiplierDocumentOption of 0.75, however, that does not
seem to do a round-to-nearest-integral operation so I am ending up
with non-integral font sizes that, while closer to the original,
remain incorrect.
(NOTE: I am in control of the HTML that my code is converting, so
if there is some way to fix this problem through a change to the
HTML then that will suffice.)
Hmm... I just noticed in the attributed string docs that "WebKit–
based HTML importing" is always used on 10.4 and later, so, if no
one has an answer, then I will repost on the web-kit list.
Thanks in advance.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden