Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (200128 => 200129)
--- trunk/Source/WebCore/CMakeLists.txt 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-04-27 16:47:13 UTC (rev 200129)
@@ -2203,6 +2203,7 @@
platform/graphics/FontDescription.cpp
platform/graphics/FontFeatureSettings.cpp
platform/graphics/FontGenericFamilies.cpp
+ platform/graphics/FontPlatformData.cpp
platform/graphics/FontRanges.cpp
platform/graphics/GeneratedImage.cpp
platform/graphics/GeometryUtilities.cpp
Modified: trunk/Source/WebCore/ChangeLog (200128 => 200129)
--- trunk/Source/WebCore/ChangeLog 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/ChangeLog 2016-04-27 16:47:13 UTC (rev 200129)
@@ -1,3 +1,57 @@
+2016-04-27 Carlos Garcia Campos <[email protected]>
+
+ REGRESSION(r200094): [FreeType] Vertical text is broken after r200094
+ https://bugs.webkit.org/show_bug.cgi?id=157066
+
+ Reviewed by Martin Robinson.
+
+ The problem is that Freetype implementation needs to call buildScaledFont() when orientation, SyntheticOblique
+ or size change, but the new static clone methods don't do that. I think it's the time to stop using our own
+ header for FontPlatformData for the FreeType implementation to make cross-platform changes easier and prevent
+ regressions like this in the future.
+
+ * CMakeLists.txt: Compile FontPlatformData.cpp for all ports.
+ * PlatformMac.cmake: Remove FontPlatformData.cpp.
+ * PlatformWin.cmake: Ditto.
+ * platform/graphics/FontPlatformData.cpp: We need our own clone methods in the FreeType backend.
+ * platform/graphics/FontPlatformData.h: Move FreeType specific methods and members from the old header file.
+ * platform/graphics/cairo/CairoUtilities.cpp:
+ (WebCore::CairoFtFaceLocker::CairoFtFaceLocker): Move CairoFtFaceLocker implementation here from
+ HarfBuzzFaceCairo.cpp to make it available to other classes, and make it handle the case of
+ cairo_ft_scaled_font_lock_face() returning nullptr.
+ (WebCore::CairoFtFaceLocker::~CairoFtFaceLocker):
+ * platform/graphics/cairo/CairoUtilities.h:
+ (WebCore::CairoFtFaceLocker::ftFace):
+ * platform/graphics/freetype/FontCacheFreeType.cpp:
+ (WebCore::findBestFontGivenFallbacks): Move the fallbacks implementation to FontPlatformData where it belongs
+ and here simply use FontPlatformData::fallbacks().
+ * platform/graphics/freetype/FontPlatformData.h: Removed.
+ * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
+ (WebCore::FontPlatformData::FontPlatformData): Remove members already initialized in the header.
+ (WebCore::FontPlatformData::operator=): Add missing members to be copied.
+ (WebCore::FontPlatformData::~FontPlatformData): Do not free m_scaledFont manually since we are now using a smart pointer.
+ (WebCore::FontPlatformData::cloneWithOrientation): Call buildScaledFont() like setOrientation() did.
+ (WebCore::FontPlatformData::cloneWithSyntheticOblique): Call buildScaledFont() like setSyntheticOblique() did.
+ (WebCore::FontPlatformData::cloneWithSize): Call buildScaledFont().
+ (WebCore::FontPlatformData::fallbacks): Lazily initialize fallbacks if needed and return it.
+ (WebCore::FontPlatformData::platformIsEqual): Only compare FreeType specific members.
+ (WebCore::FontPlatformData::buildScaledFont): Use RefPtr for m_scaledFont.
+ (WebCore::FontPlatformData::hasCompatibleCharmap): Use CairoFtFaceLocker.
+ (WebCore::FontPlatformData::openTypeTable): Update to return RefPtr instead of PassRefPtr and use CairoFtFaceLocker.
+ (WebCore::FontPlatformData::operator==): Deleted.
+ (WebCore::FontPlatformData::setOrientation): Deleted.
+ (WebCore::FontPlatformData::setSyntheticOblique): Deleted.
+ * platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp:
+ (WebCore::GlyphPage::fill): Use CairoFtFaceLocker.
+ * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
+ (WebCore::Font::platformInit): Ditto.
+ (WebCore::Font::canRenderCombiningCharacterSequence): Ditto.
+ * platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:
+ (WebCore::harfBuzzCairoGetTable): Ditto.
+ (WebCore::CairoFtFaceLocker::CairoFtFaceLocker): Deleted.
+ (WebCore::CairoFtFaceLocker::lock): Deleted.
+ (WebCore::CairoFtFaceLocker::~CairoFtFaceLocker): Deleted.
+
2016-04-27 Hunseop Jeong <[email protected]>
[EFL][GTK] Volume slider only changes volume when thumb is released, not while dragging
Modified: trunk/Source/WebCore/PlatformMac.cmake (200128 => 200129)
--- trunk/Source/WebCore/PlatformMac.cmake 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/PlatformMac.cmake 2016-04-27 16:47:13 UTC (rev 200129)
@@ -348,7 +348,6 @@
platform/graphics/DisplayRefreshMonitor.cpp
platform/graphics/DisplayRefreshMonitorManager.cpp
- platform/graphics/FontPlatformData.cpp
platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm
platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm
Modified: trunk/Source/WebCore/PlatformWin.cmake (200128 => 200129)
--- trunk/Source/WebCore/PlatformWin.cmake 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/PlatformWin.cmake 2016-04-27 16:47:13 UTC (rev 200129)
@@ -74,7 +74,6 @@
platform/crypto/win/CryptoDigestWin.cpp
- platform/graphics/FontPlatformData.cpp
platform/graphics/GraphicsContext3DPrivate.cpp
platform/graphics/egl/GLContextEGL.cpp
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2016-04-27 16:47:13 UTC (rev 200129)
@@ -62,6 +62,7 @@
}
#endif
+#if !USE(FREETYPE)
FontPlatformData FontPlatformData::cloneWithOrientation(const FontPlatformData& source, FontOrientation orientation)
{
FontPlatformData copy(source);
@@ -82,5 +83,6 @@
copy.m_size = size;
return copy;
}
+#endif
}
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2016-04-27 16:47:13 UTC (rev 200129)
@@ -22,11 +22,6 @@
*
*/
-// FIXME: This is temporary until all ports switch to using this file.
-#if PLATFORM(EFL) || PLATFORM(GTK)
-#include "freetype/FontPlatformData.h"
-#else
-
#ifndef FontPlatformData_h
#define FontPlatformData_h
@@ -42,6 +37,12 @@
#include <cairo.h>
#endif
+#if USE(FREETYPE)
+#include "FcUniquePtr.h"
+#include "HarfBuzzFace.h"
+#include "OpenTypeVerticalData.h"
+#endif
+
#if PLATFORM(COCOA)
#if PLATFORM(IOS)
#import <CoreGraphics/CoreGraphics.h>
@@ -81,7 +82,9 @@
public:
FontPlatformData(WTF::HashTableDeletedValueType);
FontPlatformData();
+#if !USE(FREETYPE)
FontPlatformData(const FontPlatformData&) = default;
+#endif
FontPlatformData(FontPlatformData&&) = default;
FontPlatformData(const FontDescription&, const AtomicString& family);
FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, TextRenderingMode = AutoTextRendering);
@@ -108,6 +111,13 @@
#endif
#endif
+#if USE(FREETYPE)
+ FontPlatformData(FcPattern*, const FontDescription&);
+ FontPlatformData(cairo_font_face_t*, const FontDescription&, bool syntheticBold, bool syntheticOblique);
+ FontPlatformData(const FontPlatformData&);
+ ~FontPlatformData();
+#endif
+
#if PLATFORM(WIN)
HFONT hfont() const { return m_font ? m_font->get() : 0; }
bool useGDI() const { return m_useGDI; }
@@ -149,6 +159,13 @@
cairo_scaled_font_t* scaledFont() const { return m_scaledFont.get(); }
#endif
+#if USE(FREETYPE)
+ HarfBuzzFace* harfBuzzFace() const;
+ bool hasCompatibleCharmap() const;
+ PassRefPtr<OpenTypeVerticalData> verticalData() const;
+ FcFontSet* fallbacks() const;
+#endif
+
unsigned hash() const
{
#if PLATFORM(WIN) && !USE(CAIRO)
@@ -167,7 +184,11 @@
#endif
}
+#if USE(FREETYPE)
+ FontPlatformData& operator=(const FontPlatformData&);
+#else
FontPlatformData& operator=(const FontPlatformData&) = default;
+#endif
bool operator==(const FontPlatformData& other) const
{
@@ -196,7 +217,7 @@
#endif
}
-#if PLATFORM(COCOA) || PLATFORM(WIN)
+#if PLATFORM(COCOA) || PLATFORM(WIN) || USE(FREETYPE)
RefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
#endif
@@ -212,6 +233,9 @@
#if PLATFORM(WIN)
void platformDataInit(HFONT, float size, HDC, WCHAR* faceName);
#endif
+#if USE(FREETYPE)
+ void buildScaledFont(cairo_font_face_t*);
+#endif
#if PLATFORM(COCOA)
// FIXME: Get rid of one of these. These two fonts are subtly different, and it is not obvious which one to use where.
@@ -227,6 +251,11 @@
#if USE(CAIRO)
RefPtr<cairo_scaled_font_t> m_scaledFont;
#endif
+#if USE(FREETYPE)
+ RefPtr<FcPattern> m_pattern;
+ mutable FcUniquePtr<FcFontSet> m_fallbacks;
+ mutable RefPtr<HarfBuzzFace> m_harfBuzzFace;
+#endif
// The values below are common to all ports
// FIXME: If they're common to all ports, they should move to Font
@@ -249,6 +278,9 @@
#if PLATFORM(WIN)
bool m_useGDI { false };
#endif
+#if USE(FREETYPE)
+ bool m_fixedWidth { false };
+#endif
};
#if USE(APPKIT)
@@ -267,5 +299,3 @@
} // namespace WebCore
#endif // FontPlatformData_h
-
-#endif
Modified: trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h 2016-04-27 16:47:13 UTC (rev 200129)
@@ -36,6 +36,10 @@
// This function was added pretty much simultaneous to when 1.13 was branched.
#define HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE CAIRO_VERSION_MAJOR > 1 || (CAIRO_VERSION_MAJOR == 1 && CAIRO_VERSION_MINOR >= 13)
+#if USE(FREETYPE)
+#include <cairo-ft.h>
+#endif
+
namespace WebCore {
class AffineTransform;
class Color;
@@ -46,6 +50,29 @@
class Path;
class Region;
+#if USE(FREETYPE)
+class CairoFtFaceLocker {
+public:
+ CairoFtFaceLocker(cairo_scaled_font_t* scaledFont)
+ : m_scaledFont(scaledFont)
+ , m_ftFace(cairo_ft_scaled_font_lock_face(scaledFont))
+ {
+ }
+
+ ~CairoFtFaceLocker()
+ {
+ if (m_ftFace)
+ cairo_ft_scaled_font_unlock_face(m_scaledFont);
+ }
+
+ FT_Face ftFace() const { return m_ftFace; }
+
+private:
+ cairo_scaled_font_t* m_scaledFont { nullptr };
+ FT_Face m_ftFace { nullptr };
+};
+#endif
+
void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr);
void setSourceRGBAFromColor(cairo_t*, const Color&);
void appendPathToCairoContext(cairo_t* to, cairo_t* from);
Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp 2016-04-27 16:47:13 UTC (rev 200129)
@@ -63,20 +63,12 @@
static RefPtr<FcPattern> findBestFontGivenFallbacks(const FontPlatformData& fontData, FcPattern* pattern)
{
- if (!fontData.m_pattern)
+ FcFontSet* fallbacks = fontData.fallbacks();
+ if (!fallbacks)
return nullptr;
- if (!fontData.m_fallbacks) {
- FcResult fontConfigResult;
- fontData.m_fallbacks = FcFontSort(nullptr, fontData.m_pattern.get(), FcTrue, nullptr, &fontConfigResult);
- }
-
- if (!fontData.m_fallbacks)
- return nullptr;
-
- FcFontSet* sets[] = { fontData.m_fallbacks };
FcResult fontConfigResult;
- return FcFontSetMatch(nullptr, sets, 1, pattern, &fontConfigResult);
+ return FcFontSetMatch(nullptr, &fallbacks, 1, pattern, &fontConfigResult);
}
RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font* originalFontData, bool, const UChar* characters, unsigned length)
Deleted: trunk/Source/WebCore/platform/graphics/freetype/FontPlatformData.h (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/freetype/FontPlatformData.h 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontPlatformData.h 2016-04-27 16:47:13 UTC (rev 200129)
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc.
- * Copyright (C) 2006 Michael Emmel [email protected]
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- * Copyright (C) 2010 Igalia S.L.
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontPlatformDataFreeType_h
-#define FontPlatformDataFreeType_h
-
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "GlyphBuffer.h"
-#include "HarfBuzzFace.h"
-#include "OpenTypeVerticalData.h"
-#include "RefPtrCairo.h"
-#include "SharedBuffer.h"
-#include "TextFlags.h"
-#include <wtf/Forward.h>
-#include <wtf/HashFunctions.h>
-
-typedef struct _FcFontSet FcFontSet;
-class HarfBuzzFace;
-
-namespace WebCore {
-
-class FontPlatformData {
-public:
- FontPlatformData(WTF::HashTableDeletedValueType)
- : m_fallbacks(0)
- , m_size(0)
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_scaledFont(hashTableDeletedFontValue())
- , m_orientation(Horizontal)
- { }
-
- FontPlatformData()
- : m_fallbacks(0)
- , m_size(0)
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_scaledFont(0)
- , m_orientation(Horizontal)
- { }
-
- FontPlatformData(FcPattern*, const FontDescription&);
- FontPlatformData(cairo_font_face_t*, const FontDescription&, bool bold, bool italic);
- FontPlatformData(float size, bool bold, bool italic);
- FontPlatformData(const FontPlatformData&);
- FontPlatformData(const FontPlatformData&, float size);
-
- static FontPlatformData cloneWithOrientation(const FontPlatformData&, FontOrientation);
- static FontPlatformData cloneWithSyntheticOblique(const FontPlatformData&, bool);
- static FontPlatformData cloneWithSize(const FontPlatformData&, float);
-
- ~FontPlatformData();
-
- HarfBuzzFace* harfBuzzFace() const;
-
- bool isFixedPitch() const;
- float size() const { return m_size; }
- void setSize(float size) { m_size = size; }
- bool syntheticBold() const { return m_syntheticBold; }
- bool syntheticOblique() const { return m_syntheticOblique; }
- void setSyntheticOblique(bool);
- bool hasCompatibleCharmap();
-
- FontOrientation orientation() const { return m_orientation; }
- void setOrientation(FontOrientation);
- PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
- PassRefPtr<OpenTypeVerticalData> verticalData() const;
-
- cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
-
- unsigned hash() const
- {
- return PtrHash<cairo_scaled_font_t*>::hash(m_scaledFont);
- }
-
- bool operator==(const FontPlatformData&) const;
- FontPlatformData& operator=(const FontPlatformData&);
- bool isHashTableDeletedValue() const
- {
- return m_scaledFont == hashTableDeletedFontValue();
- }
-
-#ifndef NDEBUG
- String description() const;
-#endif
-
- RefPtr<FcPattern> m_pattern;
- mutable FcFontSet* m_fallbacks; // Initialized lazily.
- float m_size;
- bool m_syntheticBold;
- bool m_syntheticOblique;
- bool m_fixedWidth;
- cairo_scaled_font_t* m_scaledFont;
- mutable RefPtr<HarfBuzzFace> m_harfBuzzFace;
-
-private:
- void buildScaledFont(cairo_font_face_t*);
- static cairo_scaled_font_t* hashTableDeletedFontValue() { return reinterpret_cast<cairo_scaled_font_t*>(-1); }
-
- FontOrientation m_orientation;
-};
-
-}
-
-#endif // FontPlatformDataFreeType_h
Modified: trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2016-04-27 16:47:13 UTC (rev 200129)
@@ -25,10 +25,11 @@
#include "config.h"
#include "FontPlatformData.h"
+#include "CairoUtilities.h"
+#include "FontCache.h"
#include "FontDescription.h"
-#include "RefPtrCairo.h"
+#include "SharedBuffer.h"
#include <cairo-ft.h>
-#include <cairo.h>
#include <fontconfig/fcfreetype.h>
#include <ft2build.h>
#include FT_TRUETYPE_TABLES_H
@@ -136,12 +137,7 @@
FontPlatformData::FontPlatformData(FcPattern* pattern, const FontDescription& fontDescription)
: m_pattern(pattern)
- , m_fallbacks(nullptr)
, m_size(fontDescription.computedPixelSize())
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_fixedWidth(false)
- , m_scaledFont(nullptr)
, m_orientation(fontDescription.orientation())
{
ASSERT(m_pattern);
@@ -175,36 +171,24 @@
buildScaledFont(fontFace.get());
}
-FontPlatformData::FontPlatformData(float size, bool bold, bool italic)
- : m_fallbacks(nullptr)
- , m_size(size)
- , m_syntheticBold(bold)
- , m_syntheticOblique(italic)
- , m_fixedWidth(false)
- , m_scaledFont(nullptr)
- , m_orientation(Horizontal)
-{
- // We cannot create a scaled font here.
-}
-
FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, const FontDescription& description, bool bold, bool italic)
- : m_fallbacks(nullptr)
- , m_size(description.computedPixelSize())
+ : m_size(description.computedPixelSize())
+ , m_orientation(description.orientation())
, m_syntheticBold(bold)
, m_syntheticOblique(italic)
- , m_fixedWidth(false)
- , m_scaledFont(nullptr)
- , m_orientation(description.orientation())
{
buildScaledFont(fontFace);
- FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
- if (fontConfigFace) {
+ CairoFtFaceLocker cairoFtFaceLocker(m_scaledFont.get());
+ if (FT_Face fontConfigFace = cairoFtFaceLocker.ftFace())
m_fixedWidth = fontConfigFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
- cairo_ft_scaled_font_unlock_face(m_scaledFont);
- }
}
+FontPlatformData::FontPlatformData(const FontPlatformData& other)
+{
+ *this = other;
+}
+
FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
{
// Check for self-assignment.
@@ -212,70 +196,50 @@
return *this;
m_size = other.m_size;
+ m_orientation = other.m_orientation;
+ m_widthVariant = other.m_widthVariant;
+ m_textRenderingMode = other.m_textRenderingMode;
+
m_syntheticBold = other.m_syntheticBold;
m_syntheticOblique = other.m_syntheticOblique;
+ m_isColorBitmapFont = other.m_isColorBitmapFont;
+ m_isHashTableDeletedValue = other.m_isHashTableDeletedValue;
+ m_isSystemFont = other.m_isSystemFont;
+
m_fixedWidth = other.m_fixedWidth;
m_pattern = other.m_pattern;
- m_orientation = other.m_orientation;
- if (m_fallbacks) {
- FcFontSetDestroy(m_fallbacks);
- // This will be re-created on demand.
- m_fallbacks = nullptr;
- }
+ // This will be re-created on demand.
+ m_fallbacks = nullptr;
- if (m_scaledFont && m_scaledFont != hashTableDeletedFontValue())
- cairo_scaled_font_destroy(m_scaledFont);
- m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont);
-
+ m_scaledFont = other.m_scaledFont;
m_harfBuzzFace = other.m_harfBuzzFace;
return *this;
}
-FontPlatformData::FontPlatformData(const FontPlatformData& other)
- : m_fallbacks(nullptr)
- , m_scaledFont(nullptr)
- , m_harfBuzzFace(other.m_harfBuzzFace)
-{
- *this = other;
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& other, float size)
- : m_fallbacks(nullptr)
- , m_scaledFont(nullptr)
- , m_harfBuzzFace(other.m_harfBuzzFace)
-{
- *this = other;
-
- // We need to reinitialize the instance, because the difference in size
- // necessitates a new scaled font instance.
- m_size = size;
- buildScaledFont(cairo_scaled_font_get_font_face(m_scaledFont));
-}
-
FontPlatformData::~FontPlatformData()
{
- if (m_fallbacks) {
- FcFontSetDestroy(m_fallbacks);
- m_fallbacks = nullptr;
- }
-
- if (m_scaledFont && m_scaledFont != hashTableDeletedFontValue())
- cairo_scaled_font_destroy(m_scaledFont);
}
FontPlatformData FontPlatformData::cloneWithOrientation(const FontPlatformData& source, FontOrientation orientation)
{
FontPlatformData copy(source);
- copy.m_orientation = orientation;
+ if (copy.m_scaledFont && copy.m_orientation != orientation) {
+ copy.m_orientation = orientation;
+ copy.buildScaledFont(cairo_scaled_font_get_font_face(copy.m_scaledFont.get()));
+ }
return copy;
}
FontPlatformData FontPlatformData::cloneWithSyntheticOblique(const FontPlatformData& source, bool syntheticOblique)
{
FontPlatformData copy(source);
- copy.m_syntheticOblique = syntheticOblique;
+ if (copy.m_syntheticOblique != syntheticOblique) {
+ copy.m_syntheticOblique = syntheticOblique;
+ ASSERT(copy.m_scaledFont.get());
+ copy.buildScaledFont(cairo_scaled_font_get_font_face(copy.m_scaledFont.get()));
+ }
return copy;
}
@@ -283,6 +247,10 @@
{
FontPlatformData copy(source);
copy.m_size = size;
+ // We need to reinitialize the instance, because the difference in size
+ // necessitates a new scaled font instance.
+ ASSERT(copy.m_scaledFont.get());
+ copy.buildScaledFont(cairo_scaled_font_get_font_face(copy.m_scaledFont.get()));
return copy;
}
@@ -294,12 +262,24 @@
return m_harfBuzzFace.get();
}
+FcFontSet* FontPlatformData::fallbacks() const
+{
+ if (m_fallbacks)
+ return m_fallbacks.get();
+
+ if (m_pattern) {
+ FcResult fontConfigResult;
+ m_fallbacks.reset(FcFontSort(nullptr, m_pattern.get(), FcTrue, nullptr, &fontConfigResult));
+ }
+ return m_fallbacks.get();
+}
+
bool FontPlatformData::isFixedPitch() const
{
return m_fixedWidth;
}
-bool FontPlatformData::operator==(const FontPlatformData& other) const
+bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
{
// FcPatternEqual does not support null pointers as arguments.
if ((m_pattern && !other.m_pattern)
@@ -307,11 +287,7 @@
|| (m_pattern != other.m_pattern && !FcPatternEqual(m_pattern.get(), other.m_pattern.get())))
return false;
- return m_scaledFont == other.m_scaledFont
- && m_size == other.m_size
- && m_syntheticOblique == other.m_syntheticOblique
- && m_orientation == other.m_orientation
- && m_syntheticBold == other.m_syntheticBold;
+ return m_scaledFont == other.m_scaledFont;
}
#ifndef NDEBUG
@@ -364,22 +340,20 @@
cairo_matrix_translate(&fontMatrix, 0.0, 1.0);
}
- if (m_scaledFont && m_scaledFont != hashTableDeletedFontValue())
- cairo_scaled_font_destroy(m_scaledFont);
-
- m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
+ m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
cairo_font_options_destroy(options);
}
-bool FontPlatformData::hasCompatibleCharmap()
+bool FontPlatformData::hasCompatibleCharmap() const
{
- ASSERT(m_scaledFont);
- FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
- bool hasCompatibleCharmap = !(FT_Select_Charmap(freeTypeFace, ft_encoding_unicode)
- && FT_Select_Charmap(freeTypeFace, ft_encoding_symbol)
- && FT_Select_Charmap(freeTypeFace, ft_encoding_apple_roman));
- cairo_ft_scaled_font_unlock_face(m_scaledFont);
- return hasCompatibleCharmap;
+ ASSERT(m_scaledFont.get());
+ CairoFtFaceLocker cairoFtFaceLocker(m_scaledFont.get());
+ FT_Face freeTypeFace = cairoFtFaceLocker.ftFace();
+ if (!freeTypeFace)
+ return false;
+ return !(FT_Select_Charmap(freeTypeFace, ft_encoding_unicode)
+ && FT_Select_Charmap(freeTypeFace, ft_encoding_symbol)
+ && FT_Select_Charmap(freeTypeFace, ft_encoding_apple_roman));
}
PassRefPtr<OpenTypeVerticalData> FontPlatformData::verticalData() const
@@ -388,9 +362,10 @@
return FontCache::singleton().getVerticalData(String::number(hash()), *this);
}
-PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
+RefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
{
- FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
+ CairoFtFaceLocker cairoFtFaceLocker(m_scaledFont.get());
+ FT_Face freeTypeFace = cairoFtFaceLocker.ftFace();
if (!freeTypeFace)
return nullptr;
@@ -401,37 +376,15 @@
return nullptr;
RefPtr<SharedBuffer> buffer = SharedBuffer::create(tableSize);
- FT_ULong expectedTableSize = tableSize;
if (buffer->size() != tableSize)
return nullptr;
+ FT_ULong expectedTableSize = tableSize;
FT_Error error = FT_Load_Sfnt_Table(freeTypeFace, tag, 0, reinterpret_cast<FT_Byte*>(const_cast<char*>(buffer->data())), &tableSize);
if (error || tableSize != expectedTableSize)
return nullptr;
- cairo_ft_scaled_font_unlock_face(m_scaledFont);
-
- return buffer.release();
+ return buffer;
}
-void FontPlatformData::setOrientation(FontOrientation orientation)
-{
- if (!m_scaledFont || (m_orientation == orientation))
- return;
-
- ASSERT(m_scaledFont);
- m_orientation = orientation;
- buildScaledFont(cairo_scaled_font_get_font_face(m_scaledFont));
-}
-
-void FontPlatformData::setSyntheticOblique(bool newSyntheticObliqueValue)
-{
- if (newSyntheticObliqueValue == syntheticOblique())
- return;
-
- ASSERT(m_scaledFont);
- m_syntheticOblique = newSyntheticObliqueValue;
- buildScaledFont(cairo_scaled_font_get_font_face(m_scaledFont));
-}
-
-}
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp 2016-04-27 16:47:13 UTC (rev 200129)
@@ -31,6 +31,7 @@
#include "config.h"
#include "GlyphPage.h"
+#include "CairoUtilities.h"
#include "Font.h"
#include "UTF16UChar32Iterator.h"
#include <cairo-ft.h>
@@ -45,7 +46,8 @@
cairo_scaled_font_t* scaledFont = font.platformData().scaledFont();
ASSERT(scaledFont);
- FT_Face face = cairo_ft_scaled_font_lock_face(scaledFont);
+ CairoFtFaceLocker cairoFtFaceLocker(scaledFont);
+ FT_Face face = cairoFtFaceLocker.ftFace();
if (!face)
return false;
@@ -65,7 +67,6 @@
}
}
- cairo_ft_scaled_font_unlock_face(scaledFont);
return haveGlyphs;
}
Modified: trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2016-04-27 16:47:13 UTC (rev 200129)
@@ -33,6 +33,7 @@
#include "config.h"
#include "Font.h"
+#include "CairoUtilities.h"
#include "FloatConversion.h"
#include "FloatRect.h"
#include "FontCache.h"
@@ -53,7 +54,7 @@
void Font::platformInit()
{
- if (!m_platformData.m_size)
+ if (!m_platformData.size())
return;
ASSERT(m_platformData.scaledFont());
@@ -65,20 +66,24 @@
float capHeight = narrowPrecisionToFloat(fontExtents.height);
float lineGap = narrowPrecisionToFloat(fontExtents.height - fontExtents.ascent - fontExtents.descent);
- // If the USE_TYPO_METRICS flag is set in the OS/2 table then we use typo metrics instead.
- FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
- if (TT_OS2* OS2Table = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(freeTypeFace, ft_sfnt_os2))) {
- const FT_Short kUseTypoMetricsMask = 1 << 7;
- if (OS2Table->fsSelection & kUseTypoMetricsMask) {
- // FT_Size_Metrics::y_scale is in 16.16 fixed point format.
- // Its (fractional) value is a factor that converts vertical metrics from design units to units of 1/64 pixels.
- double yscale = (freeTypeFace->size->metrics.y_scale / 65536.0) / 64.0;
- ascent = narrowPrecisionToFloat(yscale * OS2Table->sTypoAscender);
- descent = -narrowPrecisionToFloat(yscale * OS2Table->sTypoDescender);
- lineGap = narrowPrecisionToFloat(yscale * OS2Table->sTypoLineGap);
+ {
+ CairoFtFaceLocker cairoFtFaceLocker(m_platformData.scaledFont());
+
+ // If the USE_TYPO_METRICS flag is set in the OS/2 table then we use typo metrics instead.
+ FT_Face freeTypeFace = cairoFtFaceLocker.ftFace();
+ TT_OS2* OS2Table = freeTypeFace ? static_cast<TT_OS2*>(FT_Get_Sfnt_Table(freeTypeFace, ft_sfnt_os2)) : nullptr;
+ if (OS2Table) {
+ const FT_Short kUseTypoMetricsMask = 1 << 7;
+ if (OS2Table->fsSelection & kUseTypoMetricsMask) {
+ // FT_Size_Metrics::y_scale is in 16.16 fixed point format.
+ // Its (fractional) value is a factor that converts vertical metrics from design units to units of 1/64 pixels.
+ double yscale = (freeTypeFace->size->metrics.y_scale / 65536.0) / 64.0;
+ ascent = narrowPrecisionToFloat(yscale * OS2Table->sTypoAscender);
+ descent = -narrowPrecisionToFloat(yscale * OS2Table->sTypoDescender);
+ lineGap = narrowPrecisionToFloat(yscale * OS2Table->sTypoLineGap);
+ }
}
}
- cairo_ft_scaled_font_unlock_face(m_platformData.scaledFont());
m_fontMetrics.setAscent(ascent);
m_fontMetrics.setDescent(descent);
@@ -100,9 +105,9 @@
m_spaceWidth = narrowPrecisionToFloat((platformData().orientation() == Horizontal) ? textExtents.x_advance : -textExtents.y_advance);
if ((platformData().orientation() == Vertical) && !isTextOrientationFallback()) {
- FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
+ CairoFtFaceLocker cairoFtFaceLocker(m_platformData.scaledFont());
+ FT_Face freeTypeFace = cairoFtFaceLocker.ftFace();
m_fontMetrics.setUnitsPerEm(freeTypeFace->units_per_EM);
- cairo_ft_scaled_font_unlock_face(m_platformData.scaledFont());
}
m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
@@ -179,14 +184,14 @@
if (U_FAILURE(error) || (static_cast<size_t>(normalizedLength) == length))
return false;
- FT_Face face = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
+ CairoFtFaceLocker cairoFtFaceLocker(m_platformData.scaledFont());
+ FT_Face face = cairoFtFaceLocker.ftFace();
if (!face)
return false;
if (FcFreeTypeCharIndex(face, normalizedCharacters[0]))
addResult.iterator->value = true;
- cairo_ft_scaled_font_unlock_face(m_platformData.scaledFont());
return addResult.iterator->value;
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp (200128 => 200129)
--- trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp 2016-04-27 16:47:13 UTC (rev 200129)
@@ -32,6 +32,7 @@
#include "config.h"
#include "HarfBuzzFace.h"
+#include "CairoUtilities.h"
#include "Font.h"
#include "FontPlatformData.h"
#include "GlyphBuffer.h"
@@ -57,21 +58,6 @@
cairo_scaled_font_t* m_cairoScaledFont;
};
-class CairoFtFaceLocker {
-public:
- CairoFtFaceLocker(cairo_scaled_font_t* cairoScaledFont) : m_scaledFont(cairoScaledFont) { };
- FT_Face lock()
- {
- return cairo_ft_scaled_font_lock_face(m_scaledFont);
- };
- ~CairoFtFaceLocker()
- {
- cairo_ft_scaled_font_unlock_face(m_scaledFont);
- }
-private:
- cairo_scaled_font_t* m_scaledFont;
-};
-
static hb_position_t floatToHarfBuzzPosition(float value)
{
return static_cast<hb_position_t>(value * (1 << 16));
@@ -178,9 +164,9 @@
return 0;
CairoFtFaceLocker cairoFtFaceLocker(scaledFont);
- FT_Face ftFont = cairoFtFaceLocker.lock();
+ FT_Face ftFont = cairoFtFaceLocker.ftFace();
if (!ftFont)
- return 0;
+ return nullptr;
FT_ULong tableSize = 0;
FT_Error error = FT_Load_Sfnt_Table(ftFont, tag, 0, 0, &tableSize);
Modified: trunk/Source/WebKit2/ChangeLog (200128 => 200129)
--- trunk/Source/WebKit2/ChangeLog 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebKit2/ChangeLog 2016-04-27 16:47:13 UTC (rev 200129)
@@ -1,3 +1,16 @@
+2016-04-27 Carlos Garcia Campos <[email protected]>
+
+ REGRESSION(r200094): [FreeType] Vertical text is broken after r200094
+ https://bugs.webkit.org/show_bug.cgi?id=157066
+
+ Reviewed by Martin Robinson.
+
+ Add Source/WebCore/platform/graphics/freetype to the list of include dirs, because now FontPlatformData.h
+ includes FcUniquePtr.h.
+
+ * PlatformEfl.cmake:
+ * PlatformGTK.cmake:
+
2016-04-26 Joseph Pecoraro <[email protected]>
Uncaught Exception: SecurityError: DOM Exception 18: An attempt was made to break through the security policy of the user agent.
Modified: trunk/Source/WebKit2/PlatformEfl.cmake (200128 => 200129)
--- trunk/Source/WebKit2/PlatformEfl.cmake 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebKit2/PlatformEfl.cmake 2016-04-27 16:47:13 UTC (rev 200129)
@@ -236,6 +236,7 @@
"${WEBCORE_DIR}/platform/efl"
"${WEBCORE_DIR}/platform/graphics/cairo"
"${WEBCORE_DIR}/platform/graphics/efl"
+ "${WEBCORE_DIR}/platform/graphics/freetype"
"${WEBCORE_DIR}/platform/graphics/opentype"
"${WEBCORE_DIR}/platform/graphics/x11"
"${WEBCORE_DIR}/platform/network/soup"
Modified: trunk/Source/WebKit2/PlatformGTK.cmake (200128 => 200129)
--- trunk/Source/WebKit2/PlatformGTK.cmake 2016-04-27 15:58:44 UTC (rev 200128)
+++ trunk/Source/WebKit2/PlatformGTK.cmake 2016-04-27 16:47:13 UTC (rev 200129)
@@ -495,6 +495,7 @@
"${WEBCORE_DIR}/platform/cairo"
"${WEBCORE_DIR}/platform/gtk"
"${WEBCORE_DIR}/platform/graphics/cairo"
+ "${WEBCORE_DIR}/platform/graphics/freetype"
"${WEBCORE_DIR}/platform/graphics/opentype"
"${WEBCORE_DIR}/platform/graphics/x11"
"${WEBCORE_DIR}/platform/network/soup"