Re: NSHTMLTextDocumentType returns wrong font names
Re: NSHTMLTextDocumentType returns wrong font names
- Subject: Re: NSHTMLTextDocumentType returns wrong font names
- From: Jens Alfke <email@hidden>
- Date: Sat, 04 Jan 2014 13:40:09 -0800
On Jan 4, 2014, at 3:03 AM, Leonardo <email@hidden> wrote:
> I'm trying to export the content of my NSTextView to an HTML page.
> I get the HTML code using
>
> NSDictionary *attributes = [NSDictionary
> dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType,
> NSDocumentTypeDocumentAttribute, nil];
> NSData *htmlData = [textView dataFromRange:editedRange
> attributes error:NULL];
There’s no such method on NSTextView, and the last line isn’t even syntactically correct. I think you’re referring to the NSAttributedString method
- (NSData *)dataFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict error:(NSError **)error;
which you’re probably calling on textView.textStorage.
Can you show us some of the generated HTML with the incorrect font names?
> - if I use the font name Helvetica-LightOblique, it returns 'Helvetica
> Light'. And I get a different font look, as Times.
Yeah, that sounds wrong. By default CSS wants the font’s PostScript name, which is like “Helvetica-LightOblique”. It’s possible to reassign font names using @-directives in the CSS, but that seems like an unlikely thing for AppKit to be generating.
—Jens
_______________________________________________
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