O.K. Sorry for another reply This patch fixes the upside-down problem. The attached screenshot uses English font as default font and Chinese font as substitute. I probably need to find a Japanese font and a symbol font to test multiple substitute. By the way, the speed is not bad. Previously I said that it takes 1-2 seconds for 25,000+ Chinese glyphs is including putting all glyphs on a NSMatrix. So it is fast to get the coverage in NSFont.
Yen-Ju On 8/10/07, Yen-Ju Chen <[EMAIL PROTECTED]> wrote: > Another issue is that sometimes freetype fails to get the coverage. > Therefore, NSCharacterSet raise an exception: > "Specified range exceeds character set". > So this patch prevents NSAttributedString from using all available fonts > to eliminate the possibility of using bad fonts. > It only uses user specified fonts for substitution. > And I hope GNUstep can add an user default to specify the preferred fonts. > > Once the patch is applied, the font substitute basically works, but > has one problem. > I attach a screenshot to explain that. > The left window is using English font as default font and no preferred font. > So you only see English 'GNUstep'. > The middle window is using Chinese font as default font and no preferred font. > Because Chinese font also contains English letter, > you see both English and Chinese. > You can tell the English letter is from different font. > The right window is using English font as default font and Chinese > font as substitute. > Again, you can see both English and Chinese character. > But the funny thing is the Chinese character is upside-down. > I have no idea why it happens, but I suspect gui or back cache the font matrix > so the matrix of English font is applied to the Chinese font. > The hint of Chinese font is also different between middle and right window. > The middle one is sharp while the right one is blur. > It indicates something is cached, probably for the English font at the > start of the text. > Maybe someone has insights about what may cause it. > > Yen-Ju > > On 8/10/07, Yen-Ju Chen <[EMAIL PROTECTED]> wrote: > > Hi, > > > > [NSFont coveredCharacterSet] is broken. > > I attach a patch. > > A quick test shows that a Chinese font which contains 25,000+ glyph > > takes only about 1-2 seconds to go through. > > It's on a powerbook G4 1GHz. > > So cache may not be needed for coveredCharacterSet. > > I haven't test the preferredFont yet. > > Hope this patch can go in soon. > > > > Yen-Ju > > > > On 8/9/07, Yen-Ju Chen <[EMAIL PROTECTED]> wrote: > > > On 8/9/07, Fred Kiefer <[EMAIL PROTECTED]> wrote: > > > > Yen-Ju Chen wrote: > > > > > On 8/8/07, Fred Kiefer <[EMAIL PROTECTED]> wrote: > > > > >> Yen-Ju Chen wrote: > > > > >>> Another thing I am thinking is to save the coveredCharacterSet on > > > > >>> disk. > > > > >>> Font does not change frequently, > > > > >>> and it does take time to generate coveredCharacterSet for each > > > > >>> font, > > > > >>> especially for CJK. > > > > >>> If the cached coveredCharacterSet can be saved on disk and loaded > > > > >>> later, > > > > >>> it can reduce the overhead of starting an application. > > > > >>> For art backend, it can even pack the saved coveredCharacterSet > > > > >>> in nfont. > > > > >>> So for small font, it is fine to check the covered character each > > > > >>> time. > > > > >>> For big font, saved character set is better. > > > > >>> > > > > >> Great idea! Would you like to work on that? > > > > > > > > > > If the patch you have goes into the -trunk, > > > > > I can play with it and see how much it effects the speed > > > > > and decide what's the best way to do the cache if needed. > > > > > > > > > > > > > I just committed this change, now it is your turn :-) > > > > > > Thanx. I will take a look shortly. > > > > > > Yen-Ju > > > > > > > > > > > > > > > >
Index: NSAttributedString.m
===================================================================
--- NSAttributedString.m (revision 25384)
+++ NSAttributedString.m (working copy)
@@ -990,7 +990,7 @@
- (NSFont*)_substituteFontWithName: (NSString*)fontName font: (NSFont*)baseFont
{
// FIXME: Catch case were baseFont is nil
- return [NSFont fontWithName: fontName matrix: [baseFont matrix]];
+ return [NSFont fontWithName: fontName size: [baseFont pointSize]];
}
- (NSFont*)_substituteFontFor: (unichar)uchar font: (NSFont*)baseFont fromList: (NSArray *)fonts
@@ -1061,13 +1061,6 @@
{
return subFont;
}
-
- subFont = [self _substituteFontFor: uchar font: baseFont fromList:
- [[NSFontManager sharedFontManager] availableFonts]];
- if (subFont != nil)
- {
- return subFont;
- }
return nil;
}
<<attachment: font_sub2.png>>
_______________________________________________ Discuss-gnustep mailing list [email protected] http://lists.gnu.org/mailman/listinfo/discuss-gnustep
