Changeset 112816 in webkit


Ignore:
Timestamp:
Apr 1, 2012 11:21:10 AM (12 years ago)
Author:
mitz@apple.com
Message:

Source/WebCore: Composite Font References is a new established standard (ISO/IEC 14496-28:2012) for specifying
composite fonts from existing physical fonts.
<rdar://problem/10717370>
https://bugs.webkit.org/show_bug.cgi?id=82810

CoreText have already the features enabled, here we added this to WebKit text layout and rendering.
A member function getCompositeFontReferenceFontData is added to the SimpleFontData class for the component font
correspond to the platformData, in this case, a NSFont. This is used when CoreText layout had resulted
a component of the Composite Font Reference and its corresponding SimpleFontData object is then cached
in the SimpleFontData object of the posting font (Composite Font Reference).

When glyphs are encoded to form the GlyphPage for rendering, the Composite Font Reference is handled throught
the CoreText layout path (using CTLine), here the resulting glyph is associated with a font which could
be not the original font request. In this case, these are the component fonts of the Composite Font
Reference. This is then identified and then added to the GlyphPage appropriately.

To support this feature, a member function isCompositeFontReference is added to FontPlatformData to
indicate a font is a Composite Font Reference. Also in order to pass the component font correctly a boolean
isPrinterFont is added to one the FontPlatformData constructors to describe the NSFont.

Patch by Tony Tseung <tseung@apple.com> on 2012-04-01
Reviewed by Dan Bernstein.

Added test LayoutTests/fast/text/international/text-spliced-font.html

  • WebCore.exp.in:

Replaced obsolete FontPlatformData constructor entry.

  • platform/graphics/FontPlatformData.cpp:

(WebCore::FontPlatformData::FontPlatformData):
Copy of the additional m_isCompositeFontReference and m_isPrinterFont data members.

(WebCore::FontPlatformData::operator=):
Assignment of the additional m_isCompositeFontReference and m_isPrinterFont data members.

  • platform/graphics/FontPlatformData.h:

(WebCore::FontPlatformData::FontPlatformData):
(FontPlatformData):
Default value of m_isCompositeFontReference and m_isPrinterFont data members are set to false in various constructors.

(WebCore::FontPlatformData::isCompositeFontReference):
Newly added for Composite Font Reference type font.

(WebCore::FontPlatformData::isPrinterFont):
Newly added for describing the NSFont parameter if is applicable.

(WebCore::FontPlatformData::operator==):
Comparison of the additional m_isCompositeFontReference and m_isPrinterFont data members.

  • platform/graphics/SimpleFontData.cpp:

(WebCore::SimpleFontData::DerivedFontData::~DerivedFontData):
Clean up the cache for component fonts of the Composite Font References.

  • platform/graphics/SimpleFontData.h:

(SimpleFontData):
Added member function const SimpleFontData* getCompositeFontReferenceFontData(NSFont *key) const.

(DerivedFontData):
Added CFDictionary for caching the component font of Composite Font Reference.

  • platform/graphics/cocoa/FontPlatformDataCocoa.mm:

(WebCore::FontPlatformData::FontPlatformData):
Data members m_isCompositeFontReference and m_isPrinterFont are initialised and their values are determined in the body of the contructor.

(WebCore::FontPlatformData::setFont):
Data members m_isCompositeFontReference and m_isPrinterFont are determined and set.

  • platform/graphics/mac/FontCacheMac.mm:

(WebCore::FontCache::createFontPlatformData):
Boolean value isUsingPrinterFont is passed in the new FontPlatformData constructor.

  • platform/graphics/mac/GlyphPageTreeNodeMac.cpp:

(WebCore::shouldUseCoreText):
Added the condition for Composite Font Reference type font.

(WebCore::GlyphPage::fill):
In the case of Composite Font Reference, when iterate the runs, component font of Composite Font
Reference is used to fill the glyph index in the GlyphPage.

  • platform/graphics/mac/SimpleFontDataMac.mm:

(WebCore::SimpleFontData::getCompositeFontReferenceFontData):
Newly added method for the component fonts correspond to the platformData, in this case, a NSFont.
This SimpleFontData is created and cached in this object and will only be deleted when the destructor
if this is called.

Tools: Composite Font References is a new established standard (ISO/IEC 14496-28:2012) for specifying
composite fonts from existing physical fonts.
<rdar://problem/10717370>
https://bugs.webkit.org/show_bug.cgi?id=82810

A new test font of this kind as been added to the test tools for running the webkit-tests

Patch by Tony Tseung <tseung@apple.com> on 2012-04-01
Reviewed by Dan Bernstein.

  • DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:

Added new dependency SampleFont.sfont

  • DumpRenderTree/fonts/SampleFont.sfont: Added.


  • DumpRenderTree/mac/Configurations/DumpRenderTree.xcconfig:
  • DumpRenderTree/mac/DumpRenderTree.mm:

(allowedFontFamilySet):
Added the Composite Font Referene sample font "Hiragino Maru Gothic Monospaced" entry to the fonts white-list

(activateTestingFonts):
Added the registration of the Composite Font Referene sample font

  • WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm:

(WTR::allowedFontFamilySet):
Added the Composite Font Referene sample font "Hiragino Maru Gothic Monospaced" entry to the fonts white-list

(WTR::activateFonts):
Added the registration of the Composite Font Referene sample font

  • WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:

Added new dependency SampleFont.sfont

  • WebKitTestRunner/fonts/SampleFont.sfont: Added.

LayoutTests: Composite Font References is a new established standard (ISO/IEC 14496-28:2012) for specifying
composite fonts from existing physical fonts.
<rdar://problem/10717370>
https://bugs.webkit.org/show_bug.cgi?id=82810

Added new LayoutTests/fast/text/international/text-spliced-font.html

Patch by Tony Tseung <tseung@apple.com> on 2012-04-01
Reviewed by Dan Bernstein.

  • fast/text/international/text-spliced-font.html: Added.
  • platform/mac/fast/text/international/text-spliced-font-expected.png: Added.
  • platform/mac/fast/text/international/text-spliced-font-expected.txt: Added.
Location:
trunk
Files:
18 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112815 r112816  
     12012-04-01  Tony Tseung  <tseung@apple.com>
     2
     3        Composite Font References is a new established standard (ISO/IEC 14496-28:2012) for specifying
     4        composite fonts from existing physical fonts.
     5        <rdar://problem/10717370>
     6        https://bugs.webkit.org/show_bug.cgi?id=82810
     7           
     8        Added new LayoutTests/fast/text/international/text-spliced-font.html
     9
     10        Reviewed by Dan Bernstein.
     11
     12        * fast/text/international/text-spliced-font.html: Added.
     13        * platform/mac/fast/text/international/text-spliced-font-expected.png: Added.
     14        * platform/mac/fast/text/international/text-spliced-font-expected.txt: Added.
     15
    1162012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r112815 r112816  
     12012-04-01  Tony Tseung  <tseung@apple.com>
     2
     3        Composite Font References is a new established standard (ISO/IEC 14496-28:2012) for specifying
     4        composite fonts from existing physical fonts.
     5        <rdar://problem/10717370>
     6        https://bugs.webkit.org/show_bug.cgi?id=82810
     7       
     8        CoreText have already the features enabled, here we added this to WebKit text layout and rendering.
     9        A member function getCompositeFontReferenceFontData is added to the SimpleFontData class for the component font
     10        correspond to the platformData, in this case, a NSFont. This is used when CoreText layout had resulted
     11        a component of the Composite Font Reference and its corresponding SimpleFontData object is then cached
     12        in the SimpleFontData object of the posting font (Composite Font Reference).
     13       
     14        When glyphs are encoded to form the GlyphPage for rendering, the Composite Font Reference is handled throught
     15        the CoreText layout path (using CTLine), here the resulting glyph is associated with a font which could
     16        be not the original font request. In this case, these are the component fonts of the Composite Font
     17        Reference. This is then identified and then added to the GlyphPage appropriately.
     18       
     19        To support this feature, a member function isCompositeFontReference is added to FontPlatformData to
     20        indicate a font is a Composite Font Reference. Also in order to pass the component font correctly a boolean
     21        isPrinterFont is added to one the FontPlatformData constructors to describe the NSFont.
     22
     23        Reviewed by Dan Bernstein.
     24
     25        Added test LayoutTests/fast/text/international/text-spliced-font.html
     26
     27        * WebCore.exp.in:
     28        Replaced obsolete FontPlatformData constructor entry.
     29
     30        * platform/graphics/FontPlatformData.cpp:
     31        (WebCore::FontPlatformData::FontPlatformData):
     32        Copy of the additional m_isCompositeFontReference and m_isPrinterFont data members.
     33       
     34        (WebCore::FontPlatformData::operator=):
     35        Assignment of the additional m_isCompositeFontReference and m_isPrinterFont data members.
     36       
     37        * platform/graphics/FontPlatformData.h:
     38        (WebCore::FontPlatformData::FontPlatformData):
     39        (FontPlatformData):
     40        Default value of m_isCompositeFontReference and m_isPrinterFont data members are set to false in various constructors.
     41       
     42        (WebCore::FontPlatformData::isCompositeFontReference):
     43        Newly added for Composite Font Reference type font.
     44
     45        (WebCore::FontPlatformData::isPrinterFont):
     46        Newly added for describing the NSFont parameter if is applicable.
     47
     48        (WebCore::FontPlatformData::operator==):
     49        Comparison of the additional m_isCompositeFontReference and m_isPrinterFont data members.
     50
     51        * platform/graphics/SimpleFontData.cpp:
     52        (WebCore::SimpleFontData::DerivedFontData::~DerivedFontData):
     53        Clean up the cache for component fonts of the Composite Font References.
     54
     55        * platform/graphics/SimpleFontData.h:
     56        (SimpleFontData):
     57        Added member function const SimpleFontData* getCompositeFontReferenceFontData(NSFont *key) const.
     58       
     59        (DerivedFontData):
     60        Added CFDictionary for caching the component font of Composite Font Reference.
     61
     62        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
     63        (WebCore::FontPlatformData::FontPlatformData):
     64        Data members m_isCompositeFontReference and m_isPrinterFont are initialised and their values are determined in the body of the contructor.
     65
     66        (WebCore::FontPlatformData::setFont):
     67        Data members m_isCompositeFontReference and m_isPrinterFont are determined and set.
     68       
     69        * platform/graphics/mac/FontCacheMac.mm:
     70        (WebCore::FontCache::createFontPlatformData):
     71        Boolean value isUsingPrinterFont is passed in the new FontPlatformData constructor.
     72       
     73        * platform/graphics/mac/GlyphPageTreeNodeMac.cpp:
     74        (WebCore::shouldUseCoreText):
     75        Added the condition for Composite Font Reference type font.
     76       
     77        (WebCore::GlyphPage::fill):
     78        In the case of Composite Font Reference, when iterate the runs, component font of Composite Font
     79        Reference is used to fill the glyph index in the GlyphPage.
     80       
     81        * platform/graphics/mac/SimpleFontDataMac.mm:
     82        (WebCore::SimpleFontData::getCompositeFontReferenceFontData):
     83        Newly added method for the component fonts correspond to the platformData, in this case, a NSFont.
     84        This SimpleFontData is created and cached in this object and will only be deleted when the destructor
     85        if this is called.
     86       
    1872012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    288
  • trunk/Source/WebCore/WebCore.exp.in

    r112771 r112816  
    477477__ZN7WebCore16DeviceMotionData6createEN3WTF10PassRefPtrINS0_12AccelerationEEES4_NS2_INS0_12RotationRateEEEbd
    478478__ZN7WebCore16FontFallbackList15releaseFontDataEv
    479 __ZN7WebCore16FontPlatformDataC1EP6NSFontfbbNS_15FontOrientationENS_15TextOrientationENS_16FontWidthVariantE
     479__ZN7WebCore16FontPlatformDataC1EP6NSFontfbbbNS_15FontOrientationENS_15TextOrientationENS_16FontWidthVariantE
     480__ZN7WebCore16FontPlatformDataC2EP6NSFontfbbbNS_15FontOrientationENS_15TextOrientationENS_16FontWidthVariantE
    480481__ZN7WebCore16FontPlatformDataD1Ev
    481482__ZN7WebCore16HTMLInputElement13setAutofilledEb
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp

    r112771 r112816  
    4040    , m_widthVariant(source.m_widthVariant)
    4141    , m_isColorBitmapFont(source.m_isColorBitmapFont)
     42    , m_isCompositeFontReference(source.m_isCompositeFontReference)
     43#if OS(DARWIN)
     44    , m_isPrinterFont(source.m_isPrinterFont)
     45#endif
    4246{
    4347    platformDataInit(source);
     
    5761    m_widthVariant = other.m_widthVariant;
    5862    m_isColorBitmapFont = other.m_isColorBitmapFont;
     63    m_isCompositeFontReference = other.m_isCompositeFontReference;
     64#if OS(DARWIN)
     65    m_isPrinterFont = other.m_isPrinterFont;
     66#endif
    5967
    6068    return platformDataAssign(other);
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r112771 r112816  
    118118#endif
    119119        , m_isColorBitmapFont(false)
     120        , m_isCompositeFontReference(false)
     121#if OS(DARWIN)
     122        , m_isPrinterFont(false)
     123#endif
    120124#if PLATFORM(WIN)
    121125        , m_useGDI(false)
     
    140144#endif
    141145        , m_isColorBitmapFont(false)
     146        , m_isCompositeFontReference(false)
     147#if OS(DARWIN)
     148        , m_isPrinterFont(false)
     149#endif
    142150#if PLATFORM(WIN)
    143151        , m_useGDI(false)
     
    165173#endif
    166174        , m_isColorBitmapFont(false)
     175        , m_isCompositeFontReference(false)
     176#if OS(DARWIN)
     177        , m_isPrinterFont(false)
     178#endif
    167179#if PLATFORM(WIN)
    168180        , m_useGDI(false)
     
    172184
    173185#if OS(DARWIN)
    174     FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = Horizontal,
    175                      TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth);
     186    FontPlatformData(NSFont*, float size, bool isPrinterFont = false, bool syntheticBold = false, bool syntheticOblique = false,
     187                     FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth);
    176188#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
    177189    FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation,
     
    186198        , m_cgFont(cgFont)
    187199        , m_isColorBitmapFont(false)
     200        , m_isCompositeFontReference(false)
     201        , m_isPrinterFont(false)
    188202    {
    189203    }
     
    228242    bool syntheticOblique() const { return m_syntheticOblique; }
    229243    bool isColorBitmapFont() const { return m_isColorBitmapFont; }
     244    bool isCompositeFontReference() const { return m_isCompositeFontReference; }
     245#if OS(DARWIN)
     246    bool isPrinterFont() const { return m_isPrinterFont; }
     247#endif
    230248    FontOrientation orientation() const { return m_orientation; }
    231249    TextOrientation textOrientation() const { return m_textOrientation; }
     
    246264        ASSERT(m_font || !m_cgFont);
    247265#endif
    248         uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, m_textOrientation << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique };
     266        uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, m_isPrinterFont << 4 | m_textOrientation << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique };
    249267        return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
    250268#elif USE(CAIRO)
     
    262280            && m_syntheticOblique == other.m_syntheticOblique
    263281            && m_isColorBitmapFont == other.m_isColorBitmapFont
     282            && m_isCompositeFontReference == other.m_isCompositeFontReference
     283#if OS(DARWIN)
     284            && m_isPrinterFont == other.m_isPrinterFont
     285#endif
    264286            && m_orientation == other.m_orientation
    265287            && m_textOrientation == other.m_textOrientation
     
    340362
    341363    bool m_isColorBitmapFont;
     364    bool m_isCompositeFontReference;
     365#if OS(DARWIN)
     366    bool m_isPrinterFont;
     367#endif
    342368
    343369#if PLATFORM(WIN)
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp

    r112771 r112816  
    218218    if (uprightOrientation)
    219219        GlyphPageTreeNode::pruneTreeCustomFontData(uprightOrientation.get());
     220#if PLATFORM(MAC)
     221    if (compositeFontReferences) {
     222        CFDictionaryRef dictionary = CFDictionaryRef(compositeFontReferences.get());
     223        CFIndex count = CFDictionaryGetCount(dictionary);
     224        if (count > 0) {
     225            Vector<SimpleFontData*, 2> stash(count);
     226            SimpleFontData** fonts = stash.data();
     227            CFDictionaryGetKeysAndValues(dictionary, 0, (const void **)fonts);
     228            while (count-- > 0 && *fonts) {
     229                OwnPtr<SimpleFontData> afont = adoptPtr(*fonts++);
     230                GlyphPageTreeNode::pruneTreeCustomFontData(afont.get());
     231            }
     232        }
     233    }
     234#endif
    220235}
    221236
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.h

    r112771 r112816  
    166166
    167167#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
     168    const SimpleFontData* getCompositeFontReferenceFontData(NSFont *key) const;
    168169    NSFont* getNSFont() const { return m_platformData.font(); }
    169170#elif (PLATFORM(WX) && OS(DARWIN))
     
    264265        OwnPtr<SimpleFontData> verticalRightOrientation;
    265266        OwnPtr<SimpleFontData> uprightOrientation;
    266 
     267#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
     268        mutable RetainPtr<CFMutableDictionaryRef> compositeFontReferences;
     269#endif
     270       
    267271    private:
    268272        DerivedFontData(bool custom)
  • trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm

    r112771 r112816  
    4242#endif  // PLATFORM(MAC)
    4343
    44 FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation,
     44FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool isPrinterFont, bool syntheticBold, bool syntheticOblique, FontOrientation orientation,
    4545                                   TextOrientation textOrientation, FontWidthVariant widthVariant)
    4646    : m_syntheticBold(syntheticBold)
     
    5151    , m_widthVariant(widthVariant)
    5252    , m_font(nsFont)
     53    , m_isColorBitmapFont(false)
     54    , m_isCompositeFontReference(false)
     55    , m_isPrinterFont(isPrinterFont)
     56{
     57    ASSERT_ARG(nsFont, nsFont);
     58
     59    CGFontRef cgFont = 0;
     60    loadFont(nsFont, size, m_font, cgFont);
     61   
    5362#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    5463    // FIXME: Chromium: The following code isn't correct for the Chromium port since the sandbox might
    5564    // have blocked font loading, in which case we'll only have the real loaded font file after the call to loadFont().
    56     , m_isColorBitmapFont(CTFontGetSymbolicTraits(toCTFontRef(nsFont)) & kCTFontColorGlyphsTrait)
    57 #else
    58     , m_isColorBitmapFont(false)
    59 #endif
    60 {
    61     ASSERT_ARG(nsFont, nsFont);
    62 
    63     CGFontRef cgFont = 0;
    64     loadFont(nsFont, size, m_font, cgFont);
     65    {
     66        CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font));
     67        m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait;
     68#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) && !PLATFORM(IOS)
     69        m_isCompositeFontReference = traits & kCTFontCompositeTrait;
     70#endif
     71    }
     72#endif
    6573
    6674    if (m_font)
     
    142150    m_cgFont.adoptCF(cgFont);
    143151#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    144     m_isColorBitmapFont = CTFontGetSymbolicTraits(toCTFontRef(m_font)) & kCTFontColorGlyphsTrait;
     152    {
     153        CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font));
     154        m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait;
     155#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION)
     156        m_isCompositeFontReference = traits & kCTFontCompositeTrait;
     157#endif
     158    }
    145159#endif
    146160    m_CTFont = 0;
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm

    r110857 r112816  
    276276                    // using the font as returned, even though it may not have the best NSFontRenderingMode.
    277277                    if (!runFontData) {
    278                         FontPlatformData runFontPlatformData((NSFont *)runFont, CTFontGetSize(runFont));
     278                        FontPlatformData runFontPlatformData((NSFont *)runFont, CTFontGetSize(runFont), m_font.fontDescription().usePrinterFont());
    279279                        runFontData = fontCache()->getCachedFontData(&runFontPlatformData, FontCache::DoNotRetain);
    280280                    }
  • trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm

    r112771 r112816  
    159159    substituteFontWeight = [fontManager weightOfFont:substituteFont];
    160160
    161     FontPlatformData alternateFont(substituteFont, platformData.size(),
     161    FontPlatformData alternateFont(substituteFont, platformData.size(), platformData.isPrinterFont(),
    162162        !font.isPlatformFont() && isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFontWeight),
    163163        !font.isPlatformFont() && (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTrait),
     
    231231    bool syntheticOblique = (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
    232232
    233     return new FontPlatformData(platformFont, size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.textOrientation(), fontDescription.widthVariant());
     233    return new FontPlatformData(platformFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.textOrientation(), fontDescription.widthVariant());
    234234}
    235235
  • trunk/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp

    r112771 r112816  
    3939static bool shouldUseCoreText(UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
    4040{
     41    if (fontData->platformData().isCompositeFontReference())
     42        return true;
    4143    if (fontData->platformData().widthVariant() != RegularWidth || fontData->hasVerticalGlyphs()) {
    4244        // Ideographs don't have a vertical variant or width variants.
     
    6567            }
    6668        }
    67     } else if ((fontData->platformData().widthVariant() == RegularWidth) ? wkGetVerticalGlyphsForCharacters(fontData->platformData().ctFont(), buffer, glyphs.data(), bufferLength)
    68         : CTFontGetGlyphsForCharacters(fontData->platformData().ctFont(), buffer, glyphs.data(), bufferLength)) {
     69    } else if (!fontData->platformData().isCompositeFontReference() && ((fontData->platformData().widthVariant() == RegularWidth) ? wkGetVerticalGlyphsForCharacters(fontData->platformData().ctFont(), buffer, glyphs.data(), bufferLength)
     70               : CTFontGetGlyphsForCharacters(fontData->platformData().ctFont(), buffer, glyphs.data(), bufferLength))) {
    6971        for (unsigned i = 0; i < length; ++i) {
    7072            if (!glyphs[i])
     
    106108            RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont, 0));
    107109            // Use CGFont here as CFEqual for CTFont counts all attributes for font.
    108             if (CFEqual(cgFont.get(), runCGFont.get())) {
     110            bool gotBaseFont = CFEqual(cgFont.get(), runCGFont.get());
     111            if (gotBaseFont || fontData->platformData().isCompositeFontReference()) {
    109112                // This run uses the font we want. Extract glyphs.
    110113                CFIndex glyphCount = CTRunGetGlyphCount(ctRun);
     
    122125                }
    123126
    124                 for (CFIndex i = 0; i < glyphCount; ++i) {
    125                     if (stringIndices[i] >= static_cast<CFIndex>(length)) {
    126                         done = true;
    127                         break;
     127                if (gotBaseFont) {
     128                    for (CFIndex i = 0; i < glyphCount; ++i) {
     129                        if (stringIndices[i] >= static_cast<CFIndex>(length)) {
     130                            done = true;
     131                            break;
     132                        }
     133                        if (glyphs[i]) {
     134                            setGlyphDataForIndex(offset + stringIndices[i], glyphs[i], fontData);
     135                            haveGlyphs = true;
     136                        }
    128137                    }
    129                     if (glyphs[i]) {
    130                         setGlyphDataForIndex(offset + stringIndices[i], glyphs[i], fontData);
    131                         haveGlyphs = true;
     138                } else {
     139                    const SimpleFontData* runSimple = fontData->getCompositeFontReferenceFontData((NSFont *)runFont);
     140                    if (runSimple) {
     141                        for (CFIndex i = 0; i < glyphCount; ++i) {
     142                            if (stringIndices[i] >= static_cast<CFIndex>(length)) {
     143                                done = true;
     144                                break;
     145                            }
     146                            if (glyphs[i]) {
     147                                setGlyphDataForIndex(offset + stringIndices[i], glyphs[i], runSimple);
     148                                haveGlyphs = true;
     149                            }
     150                        }
    132151                    }
    133152                }
  • trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

    r112771 r112816  
    109109#endif // __LP64__
    110110#endif // !ERROR_DISABLED
     111
     112const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *key) const
     113{
     114    if (key && !CFEqual(RetainPtr<CFStringRef>(AdoptCF, CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort"))) {
     115        if (!m_derivedFontData)
     116            m_derivedFontData = DerivedFontData::create(isCustomFont());
     117        if (!m_derivedFontData->compositeFontReferences)
     118            m_derivedFontData->compositeFontReferences.adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL));
     119        else {
     120            const SimpleFontData* found = static_cast<const SimpleFontData*>(CFDictionaryGetValue(m_derivedFontData->compositeFontReferences.get(), static_cast<const void *>(key)));
     121            if (found)
     122                return found;
     123        }
     124        if (CFMutableDictionaryRef dictionary = m_derivedFontData->compositeFontReferences.get()) {
     125            bool isUsingPrinterFont = platformData().isPrinterFont();
     126            NSFont *substituteFont = isUsingPrinterFont ? [key printerFont] : [key screenFont];
     127
     128            CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(substituteFont));
     129            bool syntheticBold = platformData().syntheticBold() && !(traits & kCTFontBoldTrait);
     130            bool syntheticOblique = platformData().syntheticOblique() && !(traits & kCTFontItalicTrait);
     131
     132            FontPlatformData substitutePlatform(substituteFont, platformData().size(), isUsingPrinterFont, syntheticBold, syntheticOblique, platformData().orientation(), platformData().textOrientation(), platformData().widthVariant());
     133            SimpleFontData* value = new SimpleFontData(substitutePlatform, isCustomFont());
     134            if (value) {
     135                CFDictionaryAddValue(dictionary, key, value);
     136                return value;
     137            }
     138        }
     139    }
     140    return 0;
     141}
    111142
    112143void SimpleFontData::platformInit()
     
    307338    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    308339    float size = m_platformData.size() * scaleFactor;
    309     FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFont:m_platformData.font() toSize:size], size, false, false, m_platformData.orientation());
     340    FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFont:m_platformData.font() toSize:size], size, m_platformData.isPrinterFont(), false, false, m_platformData.orientation());
    310341
    311342    // AppKit resets the type information (screen/printer) when you convert a font to a different size.
  • trunk/Tools/ChangeLog

    r112815 r112816  
     12012-04-01  Tony Tseung  <tseung@apple.com>
     2
     3        Composite Font References is a new established standard (ISO/IEC 14496-28:2012) for specifying
     4        composite fonts from existing physical fonts.
     5        <rdar://problem/10717370>
     6        https://bugs.webkit.org/show_bug.cgi?id=82810
     7           
     8        A new test font of this kind as been added to the test tools for running the webkit-tests
     9
     10        Reviewed by Dan Bernstein.
     11
     12        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
     13        Added new dependency SampleFont.sfont
     14       
     15        * DumpRenderTree/fonts/SampleFont.sfont: Added.
     16       
     17        * DumpRenderTree/mac/Configurations/DumpRenderTree.xcconfig:
     18        * DumpRenderTree/mac/DumpRenderTree.mm:
     19        (allowedFontFamilySet):
     20        Added the Composite Font Referene sample font "Hiragino Maru Gothic Monospaced" entry to the fonts white-list
     21       
     22        (activateTestingFonts):
     23        Added the registration of the Composite Font Referene sample font
     24       
     25        * WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm:
     26        (WTR::allowedFontFamilySet):
     27        Added the Composite Font Referene sample font "Hiragino Maru Gothic Monospaced" entry to the fonts white-list
     28
     29        (WTR::activateFonts):
     30        Added the registration of the Composite Font Referene sample font
     31
     32        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
     33        Added new dependency SampleFont.sfont
     34
     35        * WebKitTestRunner/fonts/SampleFont.sfont: Added.
     36
    1372012-04-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    238
  • trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj

    r112771 r112816  
    8686                80045AEE147718E7008290A8 /* AccessibilityNotificationHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 80045AEC147718E7008290A8 /* AccessibilityNotificationHandler.mm */; };
    8787                8465E2C70FFA8DF2003B8342 /* PixelDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8465E2C60FFA8DF2003B8342 /* PixelDumpSupport.cpp */; };
     88                8CCDA82A151A72D10003F937 /* SampleFont.sfont in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 8CCDA81F151A56550003F937 /* SampleFont.sfont */; };
    8889                9340994C08540CAE007F3BC8 /* DumpRenderTreePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = 32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */; };
    8990                9340995108540CAE007F3BC8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9335435F03D75502008635CE /* WebKit.framework */; };
     
    204205                        dstSubfolderSpec = 7;
    205206                        files = (
     207                                8CCDA82A151A72D10003F937 /* SampleFont.sfont in Copy Font Files */,
    206208                                5DB9AC970F722C3600684641 /* AHEM____.TTF in Copy Font Files */,
    207209                                5DB9AC980F722C3600684641 /* WebKitWeightWatcher100.ttf in Copy Font Files */,
     
    276278                80045AEC147718E7008290A8 /* AccessibilityNotificationHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityNotificationHandler.mm; path = mac/AccessibilityNotificationHandler.mm; sourceTree = "<group>"; };
    277279                8465E2C60FFA8DF2003B8342 /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; };
     280                8CCDA81F151A56550003F937 /* SampleFont.sfont */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = SampleFont.sfont; path = fonts/SampleFont.sfont; sourceTree = "<group>"; };
    278281                9335435F03D75502008635CE /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    279282                9340995408540CAF007F3BC8 /* DumpRenderTree */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DumpRenderTree; sourceTree = BUILT_PRODUCTS_DIR; };
     
    592595                                375F09780DAC3CB600C8B4E5 /* WebKitWeightWatcher800.ttf */,
    593596                                375F09790DAC3CB600C8B4E5 /* WebKitWeightWatcher900.ttf */,
     597                                8CCDA81F151A56550003F937 /* SampleFont.sfont */,
    594598                        );
    595599                        name = Resources;
  • trunk/Tools/DumpRenderTree/mac/Configurations/DumpRenderTree.xcconfig

    r112771 r112816  
    2222// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2323
    24 OTHER_LDFLAGS = -sectcreate __DATA Ahem qt/fonts/AHEM____.TTF -sectcreate __DATA WeightWatcher100 fonts/WebKitWeightWatcher100.ttf -sectcreate __DATA WeightWatcher200 fonts/WebKitWeightWatcher200.ttf -sectcreate __DATA WeightWatcher300 fonts/WebKitWeightWatcher300.ttf -sectcreate __DATA WeightWatcher400 fonts/WebKitWeightWatcher400.ttf -sectcreate __DATA WeightWatcher500 fonts/WebKitWeightWatcher500.ttf -sectcreate __DATA WeightWatcher600 fonts/WebKitWeightWatcher600.ttf -sectcreate __DATA WeightWatcher700 fonts/WebKitWeightWatcher700.ttf -sectcreate __DATA WeightWatcher800 fonts/WebKitWeightWatcher800.ttf -sectcreate __DATA WeightWatcher900 fonts/WebKitWeightWatcher900.ttf
     24OTHER_LDFLAGS = -sectcreate __DATA Ahem qt/fonts/AHEM____.TTF -sectcreate __DATA WeightWatcher100 fonts/WebKitWeightWatcher100.ttf -sectcreate __DATA WeightWatcher200 fonts/WebKitWeightWatcher200.ttf -sectcreate __DATA WeightWatcher300 fonts/WebKitWeightWatcher300.ttf -sectcreate __DATA WeightWatcher400 fonts/WebKitWeightWatcher400.ttf -sectcreate __DATA WeightWatcher500 fonts/WebKitWeightWatcher500.ttf -sectcreate __DATA WeightWatcher600 fonts/WebKitWeightWatcher600.ttf -sectcreate __DATA WeightWatcher700 fonts/WebKitWeightWatcher700.ttf -sectcreate __DATA WeightWatcher800 fonts/WebKitWeightWatcher800.ttf -sectcreate __DATA WeightWatcher900 fonts/WebKitWeightWatcher900.ttf -sectcreate __DATA HiraMaruMono-W4 fonts/SampleFont.sfont
    2525LD_RUNPATH_SEARCH_PATHS = "@loader_path/.";
    2626PRODUCT_NAME = DumpRenderTree
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r112771 r112816  
    287287        @"Hiragino Kaku Gothic Std",
    288288        @"Hiragino Kaku Gothic StdN",
     289        @"Hiragino Maru Gothic Monospaced",
    289290        @"Hiragino Maru Gothic Pro",
    290291        @"Hiragino Maru Gothic ProN",
     
    418419        "WebKitWeightWatcher800.ttf",
    419420        "WebKitWeightWatcher900.ttf",
     421#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION)
     422        "SampleFont.sfont",
     423#endif
    420424        0
    421425    };
  • trunk/Tools/WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm

    r112771 r112816  
    104104        @"Hiragino Kaku Gothic Std",
    105105        @"Hiragino Kaku Gothic StdN",
     106        @"Hiragino Maru Gothic Monospaced",
    106107        @"Hiragino Maru Gothic Pro",
    107108        @"Hiragino Maru Gothic ProN",
     
    234235        "WebKitWeightWatcher800.ttf",
    235236        "WebKitWeightWatcher900.ttf",
     237#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION)
     238        "SampleFont.sfont",
     239#endif
    236240        0
    237241    };
  • trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj

    r112771 r112816  
    5353                8034C6621487636400AC32E9 /* AccessibilityControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8034C6611487636400AC32E9 /* AccessibilityControllerMac.mm */; };
    5454                8097338A14874A5A008156D9 /* AccessibilityNotificationHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8097338914874A5A008156D9 /* AccessibilityNotificationHandler.mm */; };
     55                8CCDA823151A570B0003F937 /* SampleFont.sfont in Resources */ = {isa = PBXBuildFile; fileRef = 8CCDA822151A570B0003F937 /* SampleFont.sfont */; };
    5556                A664BC7613A5F3A9009A7B25 /* libWebCoreTestSupport.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 41230E16138C78BF00BCCFCA /* libWebCoreTestSupport.dylib */; };
    5657                BC14E4DB120E02D000826C0C /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC14E4D9120E02D000826C0C /* GCController.cpp */; };
     
    151152                8097338814874A5A008156D9 /* AccessibilityNotificationHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AccessibilityNotificationHandler.h; path = mac/AccessibilityNotificationHandler.h; sourceTree = "<group>"; };
    152153                8097338914874A5A008156D9 /* AccessibilityNotificationHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityNotificationHandler.mm; path = mac/AccessibilityNotificationHandler.mm; sourceTree = "<group>"; };
     154                8CCDA822151A570B0003F937 /* SampleFont.sfont */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = SampleFont.sfont; path = fonts/SampleFont.sfont; sourceTree = "<group>"; };
    153155                8DD76FA10486AA7600D96B5E /* WebKitTestRunner */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = WebKitTestRunner; sourceTree = BUILT_PRODUCTS_DIR; };
    154156                BC14E4D8120E02D000826C0C /* GCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCController.h; sourceTree = "<group>"; };
     
    363365                                6510A78011EC643800410867 /* WebKitWeightWatcher800.ttf */,
    364366                                6510A78111EC643800410867 /* WebKitWeightWatcher900.ttf */,
     367                                8CCDA822151A570B0003F937 /* SampleFont.sfont */,
    365368                        );
    366369                        name = Resources;
     
    528531                                6510A78B11EC643800410867 /* WebKitWeightWatcher800.ttf in Resources */,
    529532                                6510A78C11EC643800410867 /* WebKitWeightWatcher900.ttf in Resources */,
     533                                8CCDA823151A570B0003F937 /* SampleFont.sfont in Resources */,
    530534                        );
    531535                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.