bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix: RTFConsumer, -currentFont


From: Georg Fleischmann
Subject: Fix: RTFConsumer, -currentFont
Date: Fri, 30 Aug 2002 15:44:09 GMT

Hi,

here is a fix which corrects the RTFConsumer to return the correct font for  
composite fontNames such as Futura-Light or Futura-Book.

Georg



2002-08-30  Georg Fleischmann
        * gui/TextConverters/RTF/RTFConsumer.m [-currentFont]:
        allow composite font names like 'FontFamily-Face'



*** gui/TextConverters/RTF/RTFConsumer.m.old    Tue Jun 11 21:36:51 2002
--- gui/TextConverters/RTF/RTFConsumer.m        Fri Aug 30 17:31:17 2002
***************
*** 115,120 ****
--- 115,130 ----
    NSFont *font;
    NSFontTraitMask traits = 0;
    int weight;
+   NSRange range;
+   NSString *fontFamily;
+
+   /* Check, whether fontName is composite, and extract fontFamily
+    */
+   range = [fontName rangeOfString:@"-"];
+   if (range.length)
+       fontFamily = [fontName substringToIndex:range.location];
+   else
+       fontFamily = fontName;

    if (bold)
      {
***************
*** 136,145 ****
        traits |= NSUnitalicFontMask;
      }

!   font = [[NSFontManager sharedFontManager] fontWithFamily: fontName
                                            traits: traits
                                            weight: weight
                                            size: fontSize];
    if (font == nil)
      {
        NSDebugMLLog(@"RTFParser",
--- 146,165 ----
        traits |= NSUnitalicFontMask;
      }

!   font = [[NSFontManager sharedFontManager] fontWithFamily: fontFamily
                                            traits: traits
                                            weight: weight
                                            size: fontSize];
+   /*  set the typeface for composite names, if it is not correct.
+    */
+   if ( font && range.length
+        && ![[font fontName] rangeOfString:fontName].length )
+     {
+       font = [[NSFontManager sharedFontManager] convertFont:font
+                                                      toFace:fontName];
+       font = [[NSFontManager sharedFontManager] convertFont:font
+                                                 toHaveTrait:traits];
+     }
    if (font == nil)
      {
        NSDebugMLLog(@"RTFParser",




reply via email to

[Prev in Thread] Current Thread [Next in Thread]