Skip navigation.
 
mlRe: NSTextView Font Substitution
FROM : Jens Alfke
DATE : Sun May 18 18:49:26 2008

On 17 May '08, at 6:36 AM, Gerriet M. Denkmann wrote:

> I have an NSTextView with no "Multiple fonts allowed" (isRichText = 
> NO).
> The font is the userFixedPitchFontOfSize: 0 (Monaco 10 pt).
> But when I insert a THAI CHARACTER SARA E (Unicode 0E40), which has 
> no glyph in Monaco, a replacement font is used.


Yup. Technically this is glyph substitution, not a change of font, so 
it's considered correct behavior even with multiple-fonts disallowed.

> This is Lucida Grande, which is not a FixedPitchFont.
> So things meant to be in nice columns get all messed up.
> But if one has the "Additional Asian Fonts" installed, there is also 
> Ayuthaya, which, being a FixedPitchFont, would be a much better 
> replacement.
> So: is there a way in Tiger to tell the text system to prefer 
> FixedPitchFonts?


Not that I know of. But even if there were, there's no reason the 
character width in Ayuthaya has to match that of Monaco (or Courier or 
Andale Mono or...) so the column layout would probably still get 
messed up.

The only real solution would be to customize the layout manager to 
force it to use a single width for all glyphs, regardless of font. I 
think this could probably be done by subclassing NSLayoutManager, but 
I don't know the details.

(Of existing programmers' editors, I know that Xcode uses NSTextView 
but supports multiple fonts and so doesn't assume that text will 
always be fixed-pitch; while TextMate uses a custom text editing 
engine that always uses fixed character spacing.)

—Jens

Related mailsAuthorDate
mlNSTextView Font Substitution Gerriet M. Denkman… May 17, 15:36
mlRe: NSTextView Font Substitution Jens Alfke May 18, 18:49
mlRe: NSTextView Font Substitution Ken Thomases May 18, 20:49