Commit 8c85d97b authored by mitz@apple.com's avatar mitz@apple.com

Added Font::typesettingFeatures() and deployed it

Reviewed by Sam Weinig.

No change in funcitonality

* WebCore.xcodeproj/project.pbxproj: Added TypesettingFeatures.h.
* platform/graphics/Font.h:
(WebCore::Font::typesettingFeatures): Added. Determines the typesetting
    features from the text redndering mode.
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::canUseGlyphCache): Use typesettingFeatures().
* platform/graphics/SimpleFontData.h:
* platform/graphics/TypesettingFeatures.h: Added.
* platform/graphics/mac/ComplexTextControllerATSUI.cpp:
(WebCore::disableLigatures): Take TypesettingFeatures instead of
    TextRenderingMode.
(WebCore::initializeATSUStyle): Ditto.
(WebCore::ComplexTextController::collectComplexTextRunsForCharactersATSUI):
    Use typesettingFeatures().
* platform/graphics/mac/ComplexTextControllerCoreText.cpp:
(WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText):
    Ditto.
* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::SimpleFontData::getCFStringAttributes): Take
    TypesettingFeatures instead of TextRenderingMode.
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::findNextLineBreak): Use TypesettingFeatures().



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52931 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9a2423f8
2010-01-07 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
Added Font::typesettingFeatures() and deployed it
No change in funcitonality
* WebCore.xcodeproj/project.pbxproj: Added TypesettingFeatures.h.
* platform/graphics/Font.h:
(WebCore::Font::typesettingFeatures): Added. Determines the typesetting
features from the text redndering mode.
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::canUseGlyphCache): Use typesettingFeatures().
* platform/graphics/SimpleFontData.h:
* platform/graphics/TypesettingFeatures.h: Added.
* platform/graphics/mac/ComplexTextControllerATSUI.cpp:
(WebCore::disableLigatures): Take TypesettingFeatures instead of
TextRenderingMode.
(WebCore::initializeATSUStyle): Ditto.
(WebCore::ComplexTextController::collectComplexTextRunsForCharactersATSUI):
Use typesettingFeatures().
* platform/graphics/mac/ComplexTextControllerCoreText.cpp:
(WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText):
Ditto.
* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::SimpleFontData::getCFStringAttributes): Take
TypesettingFeatures instead of TextRenderingMode.
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::findNextLineBreak): Use TypesettingFeatures().
2010-01-07 Dimitri Glazkov <dglazkov@chromium.org>
No review, rolling out r52900.
......@@ -697,6 +697,7 @@
37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; };
37C238211098C84200EF9F72 /* ComplexTextControllerATSUI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2381F1098C84200EF9F72 /* ComplexTextControllerATSUI.cpp */; };
37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.cpp */; };
37C28A6810F659CC008C7813 /* TypesettingFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C28A6710F659CC008C7813 /* TypesettingFeatures.h */; };
37F818FD0D657606005E1F05 /* WebCoreURLResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
37F818FE0D657606005E1F05 /* WebCoreURLResponse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */; };
41002CCD0F66EDEF009E660D /* ScriptFunctionCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */; };
......@@ -5967,6 +5968,7 @@
37C2360F1097EE7700EF9F72 /* ComplexTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplexTextController.h; sourceTree = "<group>"; };
37C2381F1098C84200EF9F72 /* ComplexTextControllerATSUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextControllerATSUI.cpp; sourceTree = "<group>"; };
37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextControllerCoreText.cpp; sourceTree = "<group>"; };
37C28A6710F659CC008C7813 /* TypesettingFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypesettingFeatures.h; sourceTree = "<group>"; };
37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreURLResponse.h; sourceTree = "<group>"; };
37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreURLResponse.mm; sourceTree = "<group>"; };
41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptFunctionCall.h; sourceTree = "<group>"; };
......@@ -14309,6 +14311,7 @@
B23540F10D00782E002382FA /* StringTruncator.h */,
930FC6891072B9280045293E /* TextRenderingMode.h */,
A824B4640E2EF2EA0081A7B7 /* TextRun.h */,
37C28A6710F659CC008C7813 /* TypesettingFeatures.h */,
E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
939B02EC0EA2DBC400C54570 /* WidthIterator.cpp */,
939B02ED0EA2DBC400C54570 /* WidthIterator.h */,
......@@ -18309,6 +18312,7 @@
5112247410CFB8D8008099D7 /* ThreadableWebSocketChannel.h in Headers */,
5112247610CFB8E8008099D7 /* ThreadableWebSocketChannelClientWrapper.h in Headers */,
5112247A10CFB8FF008099D7 /* WorkerThreadableWebSocketChannel.h in Headers */,
37C28A6810F659CC008C7813 /* TypesettingFeatures.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -29,6 +29,7 @@
#include "TextRun.h"
#include "FontDescription.h"
#include "SimpleFontData.h"
#include "TypesettingFeatures.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/MathExtras.h>
......@@ -98,6 +99,12 @@ public:
FontRenderingMode renderingMode() const { return m_fontDescription.renderingMode(); }
TypesettingFeatures typesettingFeatures() const
{
TextRenderingMode textRenderingMode = m_fontDescription.textRenderingMode();
return textRenderingMode == OptimizeLegibility || textRenderingMode == GeometricPrecision ? Kerning | Ligatures : 0;
}
FontFamily& firstFamily() { return m_fontDescription.firstFamily(); }
const FontFamily& family() const { return m_fontDescription.family(); }
......
......@@ -245,8 +245,7 @@ bool Font::canUseGlyphCache(const TextRun& run) const
return false;
}
TextRenderingMode textMode = m_fontDescription.textRenderingMode();
if (textMode == OptimizeLegibility || textMode == GeometricPrecision)
if (typesettingFeatures())
return false;
return true;
......
......@@ -28,7 +28,7 @@
#include "FontPlatformData.h"
#include "GlyphPageTreeNode.h"
#include "GlyphWidthMap.h"
#include "TextRenderingMode.h"
#include "TypesettingFeatures.h"
#include <wtf/OwnPtr.h>
#if USE(ATSUI)
......@@ -121,7 +121,7 @@ public:
#if USE(CORE_TEXT)
CTFontRef getCTFont() const;
CFDictionaryRef getCFStringAttributes(TextRenderingMode) const;
CFDictionaryRef getCFStringAttributes(TypesettingFeatures) const;
#endif
#if USE(ATSUI)
......
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TypesettingFeatures_h
#define TypesettingFeatures_h
namespace WebCore {
enum TypesettingFeature {
Kerning = 1 << 0,
Ligatures = 1 << 1,
};
typedef unsigned TypesettingFeatures;
} // namespace WebCore
#endif // TypesettingFeatures_h
......@@ -257,12 +257,12 @@ static bool fontHasMirroringInfo(ATSUFontID fontID)
return false;
}
static void disableLigatures(const SimpleFontData* fontData, TextRenderingMode textMode)
static void disableLigatures(const SimpleFontData* fontData, TypesettingFeatures typesettingFeatures)
{
// Don't be too aggressive: if the font doesn't contain 'a', then assume that any ligatures it contains are
// in characters that always go through ATSUI, and therefore allow them. Geeza Pro is an example.
// See bugzilla 5166.
if (textMode == OptimizeLegibility || textMode == GeometricPrecision || fontData->platformData().allowsLigatures())
if ((typesettingFeatures & Ligatures) || fontData->platformData().allowsLigatures())
return;
ATSUFontFeatureType featureTypes[] = { kLigaturesType };
......@@ -272,7 +272,7 @@ static void disableLigatures(const SimpleFontData* fontData, TextRenderingMode t
LOG_ERROR("ATSUSetFontFeatures failed (%d) -- ligatures remain enabled", static_cast<int>(status));
}
static void initializeATSUStyle(const SimpleFontData* fontData, TextRenderingMode textMode)
static void initializeATSUStyle(const SimpleFontData* fontData, TypesettingFeatures typesettingFeatures)
{
if (fontData->m_ATSUStyleInitialized)
return;
......@@ -295,14 +295,14 @@ static void initializeATSUStyle(const SimpleFontData* fontData, TextRenderingMod
ATSUAttributeTag styleTags[4] = { kATSUSizeTag, kATSUFontTag, kATSUFontMatrixTag, kATSUKerningInhibitFactorTag };
ATSUAttributeValuePtr styleValues[4] = { &fontSize, &fontID, &verticalFlip, &kerningInhibitFactor };
bool allowKerning = textMode == OptimizeLegibility || textMode == GeometricPrecision;
bool allowKerning = typesettingFeatures & Kerning;
status = ATSUSetAttributes(fontData->m_ATSUStyle, allowKerning ? 3 : 4, styleTags, styleSizes, styleValues);
if (status != noErr)
LOG_ERROR("ATSUSetAttributes failed (%d)", static_cast<int>(status));
fontData->m_ATSUMirrors = fontHasMirroringInfo(fontID);
disableLigatures(fontData, textMode);
disableLigatures(fontData, typesettingFeatures);
fontData->m_ATSUStyleInitialized = true;
}
......@@ -318,7 +318,7 @@ void ComplexTextController::collectComplexTextRunsForCharactersATSUI(const UChar
if (m_fallbackFonts && fontData != m_font.primaryFont())
m_fallbackFonts->add(fontData);
initializeATSUStyle(fontData, m_font.fontDescription().textRenderingMode());
initializeATSUStyle(fontData, m_font.typesettingFeatures());
OSStatus status;
ATSUTextLayout atsuTextLayout;
......
......@@ -117,7 +117,7 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC
RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(NULL, cp, length, kCFAllocatorNull));
RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(NULL, string.get(), fontData->getCFStringAttributes(m_font.fontDescription().textRenderingMode())));
RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(NULL, string.get(), fontData->getCFStringAttributes(m_font.typesettingFeatures())));
RetainPtr<CTTypesetterRef> typesetter;
......
......@@ -444,13 +444,12 @@ CTFontRef SimpleFontData::getCTFont() const
return m_CTFont.get();
}
CFDictionaryRef SimpleFontData::getCFStringAttributes(TextRenderingMode textMode) const
CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typesettingFeatures) const
{
if (m_CFStringAttributes)
return m_CFStringAttributes.get();
bool allowKerning = textMode == OptimizeLegibility || textMode == GeometricPrecision;
bool allowLigatures = platformData().allowsLigatures() || allowKerning;
bool allowLigatures = platformData().allowsLigatures() || (typesettingFeatures & Ligatures);
static const int ligaturesNotAllowedValue = 0;
static CFNumberRef ligaturesNotAllowed = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &ligaturesNotAllowedValue);
......@@ -458,7 +457,7 @@ CFDictionaryRef SimpleFontData::getCFStringAttributes(TextRenderingMode textMode
static const int ligaturesAllowedValue = 1;
static CFNumberRef ligaturesAllowed = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &ligaturesAllowedValue);
if (!allowKerning) {
if (!(typesettingFeatures & Kerning)) {
static const float kerningAdjustmentValue = 0;
static CFNumberRef kerningAdjustment = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &kerningAdjustmentValue);
static const void* keysWithKerningDisabled[] = { kCTFontAttributeName, kCTKernAttributeName, kCTLigatureAttributeName };
......
......@@ -1804,10 +1804,9 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
int wordSpacing = o->style()->wordSpacing();
int lastSpaceWordSpacing = 0;
TextRenderingMode textRenderingMode = f.fontDescription().textRenderingMode();
// Non-zero only when kerning is enabled, in which case we measure words with their trailing
// space, then subtract its width.
int wordTrailingSpaceWidth = textRenderingMode == OptimizeLegibility || textRenderingMode == GeometricPrecision ? f.spaceWidth() + wordSpacing : 0;
int wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.spaceWidth() + wordSpacing : 0;
int wrapW = tmpW + inlineWidth(o, !appliedStartWidth, true);
int charWidth = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment