• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSHTMLTextDocumentType returns wrong font names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSHTMLTextDocumentType returns wrong font names
      • From: Leonardo <email@hidden>
References: 
 >NSHTMLTextDocumentType returns wrong font names (From: Leonardo <email@hidden>)

  • Prev by Date: Re: Another best practice question: storing hotkey assignments
  • Next by Date: Re: Another best practice question: storing hotkey assignments
  • Previous by thread: NSHTMLTextDocumentType returns wrong font names
  • Next by thread: Re: NSHTMLTextDocumentType returns wrong font names
  • Index(es):
    • Date
    • Thread