Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Source/platform/fonts/FontPlatformData.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef const struct __CTFont* CTFontRef;

#include <CoreFoundation/CFBase.h>
#include <objc/objc-auto.h>
#include <CoreGraphics/CGAffineTransform.h>
#endif

#include "wtf/Forward.h"
Expand Down Expand Up @@ -102,6 +103,9 @@ class PLATFORM_EXPORT FontPlatformData {
#if OS(MACOSX)
CGFontRef cgFont() const { return m_cgFont.get(); }
CTFontRef ctFont() const;
CTFontRef ctBitmapColorFont() const;
CGAffineTransform ctBitmapColorFontMat() const { return m_CTColorBitmapFontMat; }

SkTypeface* typeface() const;

bool roundsGlyphAdvances() const;
Expand Down Expand Up @@ -195,6 +199,8 @@ class PLATFORM_EXPORT FontPlatformData {
#if OS(MACOSX)
RetainPtr<CGFontRef> m_cgFont;
mutable RetainPtr<CTFontRef> m_CTFont;
mutable RetainPtr<CTFontRef> m_CTColorBitmapFont;
mutable CGAffineTransform m_CTColorBitmapFontMat;

RefPtr<MemoryActivatedFont> m_inMemoryFont;
RefPtr<HarfBuzzFace> m_harfBuzzFace;
Expand Down
25 changes: 23 additions & 2 deletions Source/platform/fonts/cocoa/FontPlatformDataCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
CGFontRef cgFont = 0;
loadFont(nsFont, size, m_font, cgFont);

#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
// FIXME: Chromium: The following code isn't correct for the Chromium port since the sandbox might
// have blocked font loading, in which case we'll only have the real loaded font file after the call to loadFont().
{
Expand Down Expand Up @@ -84,6 +84,8 @@

m_cgFont = f.m_cgFont;
m_CTFont = f.m_CTFont;
m_CTColorBitmapFont = f.m_CTColorBitmapFont;
m_CTColorBitmapFontMat = f.m_CTColorBitmapFontMat;

#if OS(MACOSX)
m_inMemoryFont = f.m_inMemoryFont;
Expand All @@ -103,6 +105,8 @@
CFRelease(m_font);
m_font = f.m_font;
m_CTFont = f.m_CTFont;
m_CTColorBitmapFont = f.m_CTColorBitmapFont;
m_CTColorBitmapFontMat = f.m_CTColorBitmapFontMat;
#if OS(MACOSX)
m_inMemoryFont = f.m_inMemoryFont;
m_harfBuzzFace = f.m_harfBuzzFace;
Expand Down Expand Up @@ -147,7 +151,7 @@
#endif

m_cgFont.adoptCF(cgFont);
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
{
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font));
m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait;
Expand All @@ -157,6 +161,8 @@
}
#endif
m_CTFont = 0;
m_CTColorBitmapFont = 0;
m_CTColorBitmapFontMat = CGAffineTransformIdentity;
}

bool FontPlatformData::roundsGlyphAdvances() const
Expand Down Expand Up @@ -280,6 +286,21 @@ static CTFontDescriptorRef cascadeToLastResortAndDisableSwashesFontDescriptor()

return m_CTFont.get();
}

CTFontRef FontPlatformData::ctBitmapColorFont() const
{
if (m_CTColorBitmapFont)
return m_CTColorBitmapFont.get();

CTFontRef origFont = ctFont();
m_CTColorBitmapFont = CTFontCreateCopyWithAttributes(origFont, 1, &CGAffineTransformIdentity, NULL);

CGAffineTransform fontMat = CTFontGetMatrix(origFont);
CGFloat fontSize = CTFontGetSize(origFont);
m_CTColorBitmapFontMat = CGAffineTransformScale(fontMat, fontSize, fontSize);

return m_CTColorBitmapFont.get();
}

SkTypeface* FontPlatformData::typeface() const{
if (m_typeface)
Expand Down
7 changes: 7 additions & 0 deletions Source/platform/fonts/mac/ComplexTextController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,13 @@ void ComplexTextController::adjustGlyphsAndAdvances()
advance.width = 0;
glyph = fontData->spaceGlyph();
}

if (fontData->platformData().isColorBitmapFont()) {
CTFontRef colorFont = fontData->platformData().ctBitmapColorFont();
CGAffineTransform fontMat = fontData->platformData().ctBitmapColorFontMat();
CTFontGetAdvancesForGlyphs(colorFont, kCTFontOrientationHorizontal, &glyph, &advance, 1);
advance = CGSizeApplyAffineTransform(advance, fontMat);
}

float roundedAdvanceWidth = roundf(advance.width);
if (roundsAdvances)
Expand Down
4 changes: 0 additions & 4 deletions Source/platform/fonts/mac/FontCacheMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ static inline bool isAppKitFontWeightBold(NSInteger appKitFontWeight)
if (!substituteFont)
return nullptr;

// Chromium can't render AppleColorEmoji.
if ([[substituteFont familyName] isEqual:@"Apple Color Emoji"])
return nullptr;

// Use the family name from the AppKit-supplied substitute font, requesting the
// traits, weight, and size we want. One way this does better than the original
// AppKit request is that it takes synthetic bold and oblique into account.
Expand Down
8 changes: 6 additions & 2 deletions Source/platform/fonts/mac/SimpleFontDataMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,12 @@ static CFDataRef copyFontTableForTag(FontPlatformData& platformData, FourCharCod
CGSize advance = CGSizeZero;
if (platformData().orientation() == Horizontal || m_isBrokenIdeographFallback) {
NSFont *font = platformData().font();
if (font && platformData().isColorBitmapFont())
advance = NSSizeToCGSize([font advancementForGlyph:glyph]);
if (font && platformData().isColorBitmapFont()) {
CTFontRef colorFont = platformData().ctBitmapColorFont();
CGAffineTransform fontMat = platformData().ctBitmapColorFontMat();
CTFontGetAdvancesForGlyphs(colorFont, kCTFontOrientationHorizontal, &glyph, &advance, 1);
advance = CGSizeApplyAffineTransform(advance, fontMat);
}
else {
float pointSize = platformData().m_size;
CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
Expand Down