• 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
NSHTMLTextDocumentType returns wrong font names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSHTMLTextDocumentType returns wrong font names


  • Subject: NSHTMLTextDocumentType returns wrong font names
  • From: Leonardo <email@hidden>
  • Date: Sat, 04 Jan 2014 12:03:34 +0100
  • Thread-topic: NSHTMLTextDocumentType returns wrong font names

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];

Well, the style text contains wrong font names.
They are not the [NSFont fontName] nor the [NSFont displayName] nor the
[NSFont familyName]. For example:
- if I use the font name Helvetica-LightOblique, it returns 'Helvetica
Light'. And I get a different font look, as Times.
- if I use the font name GuardiLTStd-Black, it returns 'Guardi LT Std'. And
I get a different font look, not black.

Standing by the following table, I can't even replace the wrong font name in
the style text with the real fontName, because it seems it has not a real
logic.
fontName: Helvetica-LightOblique, displayName: Helvetica Light Oblique,
familyName: Helvetica
fontName: GuardiLTStd-Black, displayName: Guardi LT Std 95 Black,
familyName: Guardi LT Std

As I have seen, using the same text, iWeb properly exports the real font
names [NSFont displayName] and the HTML looks perfect.
Should I parse the attributedString and create the HTML code by myself?
Reinvent the wheel?
Is anybody who knows how to solve this trouble?


Regards
-- Leonardo


_______________________________________________

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: Jens Alfke <email@hidden>
  • Prev by Date: Re: Memory Leak on UIImage resizableImageWithCapInsets
  • Next by Date: Another best practice question: storing hotkey assignments
  • Previous by thread: 10.9 breaks overriding -[NSWindowController windowTitleForDocumentDisplayName:]
  • Next by thread: Re: NSHTMLTextDocumentType returns wrong font names
  • Index(es):
    • Date
    • Thread