• 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: determining availability of a given glyph via NSFont
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: determining availability of a given glyph via NSFont


  • Subject: Re: determining availability of a given glyph via NSFont
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 7 Feb 2002 12:02:39 -0800

On Wednesday, February 6, 2002, at 10:31 PM, Andy wrote:

--if you want to determine whether a
particular string of characters can be represented using a particular
font, fixFontAttributeInRange: will tell you.

I've been thinking about this for a while, and I'm really not sure I
follow how I can use this method to detect which characters are supported.

After all, its a (void) method and there's no spec for how it does what
it does that I can find.

I'm trying to think of something I could do by adding my own class to
the NSMutableAttributedString cluster, but even then I draw a blank.

I can only think of 2 things I could do:

Is -fixFontAttributeInRange only called when Cocoa has detected that
there is work to do on a range of chars? ie, is the mere fact it gets
called at all for a range an indication that the chacters in the range
cannot be supported by the font currently set on the range? This doesn't
seem right as I note the method is called from endEditing and I guess it
just passes in all the text that changed.

My other idea is I'm supposed to override[1] this method and examine the
characters in the range before and after calling the superclass
implementation. If the font changes, the original font didn't support
the chars in the range. If the font remains the same, I can assume it
supports the chars in the range.

fixFontAttributeInRange: is something that is normally called as part of attribute fixing. Attribute fixing is something that NSTextStorage does automatically after text is put into it and before it comes out, i.e. before any method is called on it that might inspect those attributes. Attribute fixing does such things as making sure that paragraph style attributes apply to whole paragraphs, that attachment attributes apply to attachment characters, and that font attributes apply to characters that can be represented in that font.

There are several ways you could use this. One is that you could put your text in a text storage, and check to see whether it ends up with the same fonts that you put on it originally. Another is that you could invoke font fixing yourself on any old mutable attributed string, and see whether it ends up with the same fonts that you put on it originally. You don't actually have to override the method unless you want to modify the default font substitution behavior.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: determining availability of a given glyph via NSFont (From: Andy <email@hidden>)

  • Prev by Date: Re: NSPopUpButton is too smart for it's own good
  • Next by Date: Re: NSPopUpButton is too smart for it's own good
  • Previous by thread: Re: determining availability of a given glyph via NSFont
  • Next by thread: Re: determining availability of a given glyph via NSFont
  • Index(es):
    • Date
    • Thread