• Mariia Leliuk's avatar
    Fix for Appkit sometimes making the font italic when changing font's weight · 515f516d
    Mariia Leliuk authored
    When trying to get Semibold font using cocoa's convertWeight it somehow becomes
    Italic.
    It looks like there is a problem in cocoa. I have tried the following test
    (which follows the steps to get Semibold font in platform_font_mac.mm) and it
    fails on the last line:
    
      NSFont* ns_font = [NSFont systemFontOfSize:13];
      NSFontManager* font_manager = [NSFontManager sharedFontManager];
    
      ns_font = [font_manager convertFont:ns_font toHaveTrait:NSBoldFontMask];
      {
        NSFontTraitMask traits = [font_manager traitsOfFont:ns_font];
        EXPECT_FALSE(traits & NSItalicFontMask);
      }
    
      ns_font = [font_manager convertWeight:NO ofFont:ns_font];
      {
        NSFontTraitMask traits = [font_manager traitsOfFont:ns_font];
        EXPECT_FALSE(traits & NSItalicFontMask);
      }
    
    So we should better apply NSFontTraitMask to the derived font unconditionally.
    
    BUG=742261
    
    Change-Id: If7d6c93cd95a3afce0909d65a8668f7a111eb429
    Reviewed-on: https://chromium-review.googlesource.com/570041Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
    Reviewed-by: default avatarAlexei Svitkine (slow) <asvitkine@chromium.org>
    Commit-Queue: Trent Apted <tapted@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#487416}
    515f516d
platform_font_mac.mm 14.1 KB