[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756
agl at chromium.org
agl at chromium.org
Fri Feb 26 22:27:12 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit f9924e9245fca5115e931a68319832fdd6292a6f
Author: agl at chromium.org <agl at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Feb 22 18:36:50 2010 +0000
2009-02-22 Adam Langley <agl at google.com>
Reviewed by Darin Fisher.
fontconfig on Linux can change the render preferences on a per strike
basis (a strike a combination of face and size). Because of this, we
need to query fontconfig each time a new FontPlatformData is created
for a new size.
This patch adds support for querying this via ChromiumBridge.
https://bugs.webkit.org/show_bug.cgi?id=33065
* platform/chromium/ChromiumBridge.h: add getRenderStyleForStrike
* platform/graphics/chromium/FontCacheLinux.cpp:
(WebCore::FontCache::createFontPlatformData):
* platform/graphics/chromium/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* platform/graphics/chromium/FontPlatformDataLinux.cpp:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::operator=):
(WebCore::FontPlatformData::setupPaint):
(WebCore::FontPlatformData::queryStyle):
add code to query fontconfig via ChromiumBridge
* platform/graphics/chromium/FontPlatformDataLinux.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55089 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ce47047..9ab91b9 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2009-02-22 Adam Langley <agl at google.com>
+
+ Reviewed by Darin Fisher.
+
+ fontconfig on Linux can change the render preferences on a per strike
+ basis (a strike a combination of face and size). Because of this, we
+ need to query fontconfig each time a new FontPlatformData is created
+ for a new size.
+
+ This patch adds support for querying this via ChromiumBridge.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33065
+
+ * platform/chromium/ChromiumBridge.h: add getRenderStyleForStrike
+ * platform/graphics/chromium/FontCacheLinux.cpp:
+ (WebCore::FontCache::createFontPlatformData):
+ * platform/graphics/chromium/FontCustomPlatformData.cpp:
+ (WebCore::FontCustomPlatformData::fontPlatformData):
+ * platform/graphics/chromium/FontPlatformDataLinux.cpp:
+ (WebCore::FontPlatformData::FontPlatformData):
+ (WebCore::FontPlatformData::operator=):
+ (WebCore::FontPlatformData::setupPaint):
+ (WebCore::FontPlatformData::queryStyle):
+ add code to query fontconfig via ChromiumBridge
+ * platform/graphics/chromium/FontPlatformDataLinux.h:
+
2010-02-22 Gustavo Noronha Silva <gustavo.noronha at collabora.co.uk>
Build fix for make distcheck.
diff --git a/WebCore/platform/chromium/ChromiumBridge.h b/WebCore/platform/chromium/ChromiumBridge.h
index 5a085be..f672d11 100644
--- a/WebCore/platform/chromium/ChromiumBridge.h
+++ b/WebCore/platform/chromium/ChromiumBridge.h
@@ -64,6 +64,7 @@ namespace WebCore {
struct Cookie;
struct PluginInfo;
+ struct FontRenderStyle;
// An interface to the embedding layer, which has the ability to answer
// questions about the system and so on...
@@ -113,6 +114,7 @@ namespace WebCore {
static bool ensureFontLoaded(HFONT font);
#endif
#if OS(LINUX)
+ static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result);
static String getFontFamilyForCharacters(const UChar*, size_t numCharacters);
#endif
diff --git a/WebCore/platform/graphics/chromium/FontCacheLinux.cpp b/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
index 03d23c7..91dd471 100644
--- a/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
+++ b/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
@@ -145,6 +145,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
FontPlatformData* result =
new FontPlatformData(tf,
+ name,
fontDescription.computedSize(),
(style & SkTypeface::kBold) && !tf->isBold(),
(style & SkTypeface::kItalic) && !tf->isItalic());
diff --git a/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp b/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
index 6432e17..74f1e26 100644
--- a/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
@@ -101,7 +101,7 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b
return FontPlatformData(hfont, size);
#elif OS(LINUX)
ASSERT(m_fontReference);
- return FontPlatformData(m_fontReference, size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic());
+ return FontPlatformData(m_fontReference, "", size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic());
#else
notImplemented();
return FontPlatformData();
diff --git a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp
index bf4697f..6b49a24 100644
--- a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp
+++ b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "FontPlatformData.h"
+#include "ChromiumBridge.h"
#include "HarfbuzzSkia.h"
#include "NotImplemented.h"
#include "PlatformString.h"
@@ -66,31 +67,37 @@ FontPlatformData::RefCountedHarfbuzzFace::~RefCountedHarfbuzzFace()
FontPlatformData::FontPlatformData(const FontPlatformData& src)
: m_typeface(src.m_typeface)
+ , m_family(src.m_family)
, m_textSize(src.m_textSize)
, m_fakeBold(src.m_fakeBold)
, m_fakeItalic(src.m_fakeItalic)
+ , m_style(src.m_style)
, m_harfbuzzFace(src.m_harfbuzzFace)
{
m_typeface->safeRef();
}
-FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold, bool fakeItalic)
+FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float textSize, bool fakeBold, bool fakeItalic)
: m_typeface(tf)
+ , m_family(family)
, m_textSize(textSize)
, m_fakeBold(fakeBold)
, m_fakeItalic(fakeItalic)
{
m_typeface->safeRef();
+ querySystemForRenderStyle();
}
FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
: m_typeface(src.m_typeface)
+ , m_family(src.m_family)
, m_textSize(textSize)
, m_fakeBold(src.m_fakeBold)
, m_fakeItalic(src.m_fakeItalic)
, m_harfbuzzFace(src.m_harfbuzzFace)
{
m_typeface->safeRef();
+ querySystemForRenderStyle();
}
FontPlatformData::~FontPlatformData()
@@ -102,10 +109,12 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
{
SkRefCnt_SafeAssign(m_typeface, src.m_typeface);
+ m_family = src.m_family;
m_textSize = src.m_textSize;
m_fakeBold = src.m_fakeBold;
m_fakeItalic = src.m_fakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
+ m_style = src.m_style;
return *this;
}
@@ -121,13 +130,15 @@ void FontPlatformData::setupPaint(SkPaint* paint) const
{
const float ts = m_textSize > 0 ? m_textSize : 12;
- paint->setAntiAlias(isSkiaAntiAlias);
- paint->setHinting(skiaHinting);
- paint->setLCDRenderText(isSkiaSubpixelGlyphs);
+ paint->setAntiAlias(m_style.useAntiAlias == FontRenderStyle::NoPreference ? isSkiaAntiAlias : m_style.useAntiAlias);
+ paint->setHinting(m_style.useHinting == FontRenderStyle::NoPreference ? skiaHinting : (SkPaint::Hinting) m_style.hintStyle);
paint->setTextSize(SkFloatToScalar(ts));
paint->setTypeface(m_typeface);
paint->setFakeBoldText(m_fakeBold);
paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0);
+
+ if (m_style.useAntiAlias == 1 || m_style.useAntiAlias == FontRenderStyle::NoPreference && isSkiaAntiAlias)
+ paint->setLCDRenderText(m_style.useSubpixel == FontRenderStyle::NoPreference ? isSkiaSubpixelGlyphs : m_style.useSubpixel);
}
SkFontID FontPlatformData::uniqueID() const
@@ -184,4 +195,21 @@ HB_FaceRec_* FontPlatformData::harfbuzzFace() const
return m_harfbuzzFace->face();
}
+void FontPlatformData::querySystemForRenderStyle()
+{
+ if (m_family.length()) {
+ // We don't have a family for this. Probably because it's a webfont. We
+ // set all the values to 'no preference' and take the defaults passed
+ // in from XSETTINGS.
+ m_style.useBitmaps = FontRenderStyle::NoPreference;
+ m_style.useAutoHint = FontRenderStyle::NoPreference;
+ m_style.useHinting = FontRenderStyle::NoPreference;
+ m_style.useAntiAlias = FontRenderStyle::NoPreference;
+ m_style.useSubpixel = FontRenderStyle::NoPreference;
+ return;
+ }
+
+ ChromiumBridge::getRenderStyleForStrike(m_family.data(), (((int)m_textSize) << 2) | (m_typeface->style() & 3), &m_style);
+}
+
} // namespace WebCore
diff --git a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
index 29ce8e7..585471e 100644
--- a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
+++ b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
@@ -31,6 +31,8 @@
#ifndef FontPlatformDataLinux_h
#define FontPlatformDataLinux_h
+#include "CString.h"
+#include "FontRenderStyle.h"
#include "StringImpl.h"
#include <wtf/RefPtr.h>
#include <SkPaint.h>
@@ -43,7 +45,6 @@ struct HB_FaceRec_;
namespace WebCore {
class FontDescription;
-class String;
// -----------------------------------------------------------------------------
// FontPlatformData is the handle which WebKit has on a specific face. A face
@@ -79,7 +80,7 @@ public:
{ }
FontPlatformData(const FontPlatformData&);
- FontPlatformData(SkTypeface*, float textSize, bool fakeBold, bool fakeItalic);
+ FontPlatformData(SkTypeface*, const char* name, float textSize, bool fakeBold, bool fakeItalic);
FontPlatformData(const FontPlatformData& src, float textSize);
~FontPlatformData();
@@ -140,11 +141,15 @@ private:
HB_FaceRec_* m_harfbuzzFace;
};
+ void querySystemForRenderStyle();
+
// FIXME: Could SkAutoUnref be used here?
SkTypeface* m_typeface;
+ CString m_family;
float m_textSize;
bool m_fakeBold;
bool m_fakeItalic;
+ FontRenderStyle m_style;
mutable RefPtr<RefCountedHarfbuzzFace> m_harfbuzzFace;
SkTypeface* hashTableDeletedFontValue() const { return reinterpret_cast<SkTypeface*>(-1); }
diff --git a/WebCore/platform/graphics/chromium/FontRenderStyle.h b/WebCore/platform/graphics/chromium/FontRenderStyle.h
new file mode 100644
index 0000000..1a3c736
--- /dev/null
+++ b/WebCore/platform/graphics/chromium/FontRenderStyle.h
@@ -0,0 +1,56 @@
+/* Copyright (c) 2010, Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 FontRenderStyle_h
+#define FontRenderStyle_h
+
+namespace WebCore {
+
+// FontRenderStyle describes the user's preferences for rendering a font at a
+// given size.
+struct FontRenderStyle {
+ enum {
+ NoPreference = 2,
+ };
+
+ // Each of the use* members below can take one of three values:
+ // 0: off
+ // 1: on
+ // NoPreference: no preference expressed
+ char useBitmaps; // use embedded bitmap strike if possible
+ char useAutoHint; // use 'auto' hinting (FreeType specific)
+ char useHinting; // hint glyphs to the pixel grid
+ char hintStyle; // level of hinting, 0..3
+ char useAntiAlias; // antialias glyph shapes
+ char useSubpixel; // use subpixel antialias
+};
+
+}
+
+#endif // FontRenderStyle_h
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 58095b8..12aecc2 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,24 @@
+2009-02-22 Adam Langley <agl at google.com>
+
+ Reviewed by Darin Fisher.
+
+ fontconfig on Linux can change the render preferences on a per strike
+ basis (a strike a combination of face and size). Because of this, we
+ need to query fontconfig each time a new FontPlatformData is created
+ for a new size.
+
+ This patch adds support for querying this via ChromiumBridge.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33065
+
+ * WebKit.gyp:
+ * public/gtk/WebFontInfo.h:
+ * public/linux/WebSandboxSupport.h:
+ * src/ChromiumBridge.cpp:
+ (WebCore::ChromiumBridge::getRenderStyleForStrike):
+ * src/gtk/WebFontInfo.cpp:
+ (WebKit::WebFontInfo::renderStyleForStrike):
+
2010-02-22 Alexander Pavlov <apavlov at chromium.org>
Reviewed by Pavel Feldman.
@@ -2925,7 +2946,6 @@
(WebKit::AutocompletePopupMenuClient::resetLastFieldValue):
* src/AutocompletePopupMenuClient.h:
-
2009-12-28 Kinuko Yasuda <kinuko at chromium.org>
Reviewed by Maciej Stachowiak.
diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp
index 0c76dd3..08b7d5e 100644
--- a/WebKit/chromium/WebKit.gyp
+++ b/WebKit/chromium/WebKit.gyp
@@ -71,6 +71,7 @@
'public/GeolocationServiceBridgeChromium.h',
'public/gtk/WebInputEventFactory.h',
'public/linux/WebFontRendering.h',
+ 'public/linux/WebFontRenderStyle.h',
'public/linux/WebRenderTheme.h',
'public/x11/WebScreenInfoFactory.h',
'public/mac/WebInputEventFactory.h',
@@ -240,6 +241,7 @@
'src/InspectorClientImpl.cpp',
'src/InspectorClientImpl.h',
'src/linux/WebFontRendering.cpp',
+ 'src/linux/WebFontRenderStyle.cpp',
'src/linux/WebRenderTheme.cpp',
'src/x11/WebScreenInfoFactory.cpp',
'src/mac/WebInputEventFactory.mm',
diff --git a/WebKit/chromium/public/gtk/WebFontInfo.h b/WebKit/chromium/public/gtk/WebFontInfo.h
index ad37680..fae792d 100644
--- a/WebKit/chromium/public/gtk/WebFontInfo.h
+++ b/WebKit/chromium/public/gtk/WebFontInfo.h
@@ -32,6 +32,7 @@
#define WebFontInfo_h
#include "../WebCString.h"
+#include "../linux/WebFontRenderStyle.h"
#include <string.h>
#include <unistd.h>
@@ -48,6 +49,19 @@ public:
// Returns: the font family or an empty string if the request could not be
// satisfied.
WEBKIT_API static WebCString familyForChars(const WebUChar* characters, size_t numCharacters);
+
+ // Fill out the given WebFontRenderStyle with the user's preferences for
+ // rendering the given font at the given size.
+ // family: i.e. "Times New Roman"
+ // sizeAndStyle:
+ // 3322222222221111111111
+ // 10987654321098765432109876543210
+ // +--------------------------------+
+ // |..............Size............IB|
+ // +--------------------------------+
+ // I: italic flag
+ // B: bold flag
+ WEBKIT_API static void renderStyleForStrike(const char* family, int sizeAndStyle, WebFontRenderStyle* result);
};
} // namespace WebKit
diff --git a/WebKit/chromium/public/linux/WebFontRenderStyle.h b/WebKit/chromium/public/linux/WebFontRenderStyle.h
new file mode 100644
index 0000000..a3b180f
--- /dev/null
+++ b/WebKit/chromium/public/linux/WebFontRenderStyle.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebFontRenderStyle_h
+#define WebFontRenderStyle_h
+
+#include "../WebCommon.h"
+
+namespace WebCore { struct FontRenderStyle; }
+
+namespace WebKit {
+
+struct WebFontRenderStyle {
+ // Each of the use* members below can take one of three values:
+ // 0: off
+ // 1: on
+ // 2: no preference expressed
+ char useBitmaps; // use embedded bitmap strike if possible
+ char useAutoHint; // use 'auto' hinting (FreeType specific)
+ char useHinting; // hint glyphs to the pixel grid
+ char hintStyle; // level of hinting, 0..3
+ char useAntiAlias; // antialias glyph shapes
+ char useSubpixel; // use subpixel antialias
+
+#ifdef WEBKIT_IMPLEMENTATION
+ // Translates the members of this struct to a FontRenderStyle
+ void toFontRenderStyle(WebCore::FontRenderStyle*);
+#endif
+
+ void setDefaults();
+};
+
+} // namespace WebKit
+
+#endif // WebFontRenderStyle_h
diff --git a/WebKit/chromium/public/linux/WebSandboxSupport.h b/WebKit/chromium/public/linux/WebSandboxSupport.h
index 5edceb2..6990abe 100644
--- a/WebKit/chromium/public/linux/WebSandboxSupport.h
+++ b/WebKit/chromium/public/linux/WebSandboxSupport.h
@@ -36,6 +36,8 @@
namespace WebKit {
+struct WebFontRenderStyle;
+
// Put methods here that are required due to sandbox restrictions.
class WebSandboxSupport {
public:
@@ -49,6 +51,7 @@ public:
// Returns a string with the font family on an empty string if the
// request cannot be satisfied.
virtual WebString getFontFamilyForCharacters(const WebUChar* characters, size_t numCharacters) = 0;
+ virtual void getRenderStyleForStrike(const char* family, int sizeAndStyle, WebFontRenderStyle* style) = 0;
};
} // namespace WebKit
diff --git a/WebKit/chromium/src/ChromiumBridge.cpp b/WebKit/chromium/src/ChromiumBridge.cpp
index e04226e..1eba862 100644
--- a/WebKit/chromium/src/ChromiumBridge.cpp
+++ b/WebKit/chromium/src/ChromiumBridge.cpp
@@ -65,6 +65,7 @@
#if OS(LINUX)
#include "WebSandboxSupport.h"
#include "WebFontInfo.h"
+#include "WebFontRenderStyle.h"
#endif
#if WEBKIT_USING_SKIA
@@ -356,6 +357,18 @@ String ChromiumBridge::getFontFamilyForCharacters(const UChar* characters, size_
return WebString();
}
+
+void ChromiumBridge::getRenderStyleForStrike(const char* font, int sizeAndStyle, FontRenderStyle* result)
+{
+ WebFontRenderStyle style;
+
+ if (webKitClient()->sandboxSupport())
+ webKitClient()->sandboxSupport()->getRenderStyleForStrike(font, sizeAndStyle, &style);
+ else
+ WebFontInfo::renderStyleForStrike(font, sizeAndStyle, &style);
+
+ style.toFontRenderStyle(result);
+}
#endif
// Geolocation ----------------------------------------------------------------
diff --git a/WebKit/chromium/src/gtk/WebFontInfo.cpp b/WebKit/chromium/src/gtk/WebFontInfo.cpp
index 76ed618..3ac0b00 100644
--- a/WebKit/chromium/src/gtk/WebFontInfo.cpp
+++ b/WebKit/chromium/src/gtk/WebFontInfo.cpp
@@ -30,6 +30,7 @@
#include "config.h"
#include "WebFontInfo.h"
+#include "WebFontRenderStyle.h"
#include <fontconfig/fontconfig.h>
#include <string.h>
@@ -55,11 +56,11 @@ WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCha
FcValue fcvalue;
fcvalue.type = FcTypeCharSet;
fcvalue.u.c = cset;
- FcPatternAdd(pattern, FC_CHARSET, fcvalue, 0);
+ FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
fcvalue.type = FcTypeBool;
fcvalue.u.b = FcTrue;
- FcPatternAdd(pattern, FC_SCALABLE, fcvalue, 0);
+ FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
@@ -104,4 +105,68 @@ WebCString WebFontInfo::familyForChars(const WebUChar* characters, size_t numCha
return WebCString();
}
+void WebFontInfo::renderStyleForStrike(const char* family, int sizeAndStyle, WebFontRenderStyle* out)
+{
+ bool isBold = sizeAndStyle & 1;
+ bool isItalic = sizeAndStyle & 2;
+ int pixelSize = sizeAndStyle >> 2;
+
+ FcPattern* pattern = FcPatternCreate();
+ FcValue fcvalue;
+
+ fcvalue.type = FcTypeString;
+ fcvalue.u.s = reinterpret_cast<const FcChar8 *>(family);
+ FcPatternAdd(pattern, FC_FAMILY, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeInteger;
+ fcvalue.u.i = isBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
+ FcPatternAdd(pattern, FC_WEIGHT, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeInteger;
+ fcvalue.u.i = isItalic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
+ FcPatternAdd(pattern, FC_SLANT, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeBool;
+ fcvalue.u.b = FcTrue;
+ FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeDouble;
+ fcvalue.u.d = pixelSize;
+ FcPatternAdd(pattern, FC_SIZE, fcvalue, FcFalse);
+
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ FcResult result;
+ // Some versions of fontconfig don't actually write a value into result.
+ // However, it's not clear from the documentation if result should be a
+ // non-0 pointer: future versions might expect to be able to write to
+ // it. So we pass in a valid pointer and ignore it.
+ FcPattern* match = FcFontMatch(0, pattern, &result);
+ FcPatternDestroy(pattern);
+
+ out->setDefaults();
+
+ if (!match) {
+ FcPatternDestroy(match);
+ return;
+ }
+
+ FcBool b;
+ int i;
+
+ if (FcPatternGetBool(match, FC_ANTIALIAS, 0, &b) == FcResultMatch)
+ out->useAntiAlias = b;
+ if (FcPatternGetBool(match, FC_EMBEDDED_BITMAP, 0, &b) == FcResultMatch)
+ out->useBitmaps = b;
+ if (FcPatternGetBool(match, FC_AUTOHINT, 0, &b) == FcResultMatch)
+ out->useAutoHint = b;
+ if (FcPatternGetBool(match, FC_HINTING, 0, &b) == FcResultMatch)
+ out->useHinting = b;
+ if (FcPatternGetInteger(match, FC_HINT_STYLE, 0, &i) == FcResultMatch)
+ out->hintStyle = i;
+
+ FcPatternDestroy(match);
+}
+
} // namespace WebKit
diff --git a/WebKit/chromium/src/linux/WebFontRenderStyle.cpp b/WebKit/chromium/src/linux/WebFontRenderStyle.cpp
new file mode 100644
index 0000000..0b864d1
--- /dev/null
+++ b/WebKit/chromium/src/linux/WebFontRenderStyle.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "WebFontRenderStyle.h"
+
+#include "FontRenderStyle.h"
+
+using WebCore::FontRenderStyle;
+
+namespace WebKit {
+
+void WebFontRenderStyle::toFontRenderStyle(FontRenderStyle* out)
+{
+ out->useBitmaps = useBitmaps;
+ out->useAutoHint = useAutoHint;
+ out->useHinting = useHinting;
+ out->hintStyle = hintStyle;
+ out->useAntiAlias = useAntiAlias;
+ out->useSubpixel = useSubpixel;
+}
+
+void WebFontRenderStyle::setDefaults()
+{
+ useBitmaps = 2;
+ useAutoHint = 2;
+ useHinting = 2;
+ hintStyle = 0;
+ useAntiAlias = 2;
+ useSubpixel = 2;
+}
+
+} // namespace WebKit
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list