Index: NSAttributedString.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSAttributedString.m,v retrieving revision 1.49 diff -u -r1.49 NSAttributedString.m --- NSAttributedString.m 9 Aug 2004 22:51:38 -0000 1.49 +++ NSAttributedString.m 3 Nov 2004 13:13:31 -0000 @@ -876,18 +876,28 @@ - (void) fixFontAttributeInRange: (NSRange)range { + unsigned int i; if (NSMaxRange (range) > [self length]) { [NSException raise: NSRangeException format: @"RangeError in method -fixFontAttributeInRange:"]; } - // FIXME: Should check for each character if it is supported by the - // assigned font - /* - Note that this needs to be done on a script basis. Per-character checks - are difficult to do at all, don't give reasonable results, and would have - really poor performance. - */ + for (i = range.location; i < range.location + range.length; i++) + { + unichar ch = [[self string] characterAtIndex: i]; + NSFont *f = [self attribute: NSFontAttributeName + atIndex: i + effectiveRange: NULL]; + + if (ch>32 && ![f glyphForCharacter: ch]) + { + f = [f substituteFontWithCharacter: ch]; + if (f) + [self addAttribute: NSFontAttributeName + value: f + range: NSMakeRange(i, 1)]; + } + } } - (void) fixParagraphStyleAttributeInRange: (NSRange)range Index: NSFont.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSFont.m,v retrieving revision 1.78 diff -u -r1.78 NSFont.m --- NSFont.m 17 Oct 2004 18:52:48 -0000 1.78 +++ NSFont.m 3 Nov 2004 13:13:31 -0000 @@ -899,6 +899,35 @@ return AUTORELEASE(RETAIN(cachedScreenFont)); } +-(NSFont *) substituteFontWithCharacter: (unichar)ch +{ +static NSArray *substitutionFonts; +static int c; + NSFont *f; + int i; + + if (!substitutionFonts) + { + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + substitutionFonts = [[defs objectForKey: @"GSSubstituteFonts"] retain]; + c = [substitutionFonts count]; + } + + for (i = 0; i < c; i++) + { + f=[[isa alloc] initWithName: [substitutionFonts objectAtIndex: i] + matrix: matrix + fix: matrixExplicitlySet + screenFont: screenFont + role: role]; + if ([f glyphForCharacter: ch]) + return AUTORELEASE(f); + RELEASE(f); + } + + return nil; +} + - (float) ascender { return [fontInfo ascender]; } - (float) descender { return [fontInfo descender]; } - (float) capHeight { return [fontInfo capHeight]; }