[Cairo] Add complex font drawing using HarfbuzzNG

https://bugs.webkit.org/show_bug.cgi?id=91864

Patch by Dominik Röttsches <dominik.rottsches@intel.com> on 2012-07-27
Reviewed by Simon Hausmann and Martin Robinson.

.:

Configuring Freetype backend to use HarfBuzz by default.

* Source/cmake/FindHarfBuzz.cmake: Added pkgconfig based discovery of HarfBuzz.
* Source/cmake/OptionsEfl.cmake: Adding Harfbuzz configuration.

Source/WebCore:

Adding Harfbuzz support to EFL by implementing it with the help of cairo and cairo-ft.
Reusing Chromium's Harfbuzz-NG support.

No new tests, complex font support is covered by existing tests.

* CMakeLists.txt: Adding new cairo based implementations, removing emtpy FontEfl.cpp
* WebCore.gypi: Removing FontEfl.cpp
* platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: Added. New implementation that implements cairo & harfbuzz-ng based complex font drawing.
(WebCore):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):
(WebCore::Font::canReturnFallbackFontsForComplexText):
(WebCore::Font::canExpandAroundIdeographsInComplexText):
(WebCore::Font::floatWidthForComplexText):
(WebCore::Font::offsetForPositionForComplexText):
(WebCore::Font::selectionRectForComplexText):
* platform/graphics/efl/FontEfl.cpp: Removed.
* platform/graphics/freetype/FontPlatformData.h: Adding a getter that retrieves a harfbuzz face.
(FontPlatformData):
* platform/graphics/freetype/FontPlatformDataFreeType.cpp: Adding a getter that retrieves a harfbuzz face.
(WebCore::FontPlatformData::operator=):
(WebCore::FontPlatformData::FontPlatformData):
(WebCore):
(WebCore::FontPlatformData::harfbuzzFace):
* platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp: Added. Cairo-freetype based approach to get complex font metrics.
(WebCore):
(CairoFtFaceLocker):
(WebCore::CairoFtFaceLocker::CairoFtFaceLocker):
(WebCore::CairoFtFaceLocker::lock):
(WebCore::CairoFtFaceLocker::~CairoFtFaceLocker):
(WebCore::floatToHarfBuzzPosition):
(WebCore::doubleToHarfBuzzPosition):
(WebCore::CairoGetGlyphWidthAndExtents):
(WebCore::harfbuzzGetGlyph):
(WebCore::harfbuzzGetGlyphHorizontalAdvance):
(WebCore::harfbuzzGetGlyphHorizontalOrigin):
(WebCore::harfbuzzGetGlyphExtents):
(WebCore::harfbuzzCairoTextGetFontFuncs):
(WebCore::harfbuzzCairoGetTable):
(WebCore::HarfBuzzNGFace::createFace):
(WebCore::HarfBuzzNGFace::createFont):
(WebCore::HarfBuzzShaper::createGlyphBufferAdvance):

Source/WebKit:

Adding includes for harfbuzz folders.

* CMakeLists.txt:

Source/WebKit2:

Adding includes for harfbuzz folders.

* CMakeLists.txt:

Tools:

Bringing Harfbuzz support to EFL with this patch, so we need HarfBuzz in the pulled in jhbuild dependencies.

* WebKitTestRunner/CMakeLists.txt: Adding additional header include directories.
* efl/jhbuild.modules: Adding source for HarfBuzz release version 0.9.0.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123864 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c3e87e81
2012-07-27 Dominik Röttsches <dominik.rottsches@intel.com>
[Cairo] Add complex font drawing using HarfbuzzNG
https://bugs.webkit.org/show_bug.cgi?id=91864
Reviewed by Simon Hausmann and Martin Robinson.
Configuring Freetype backend to use HarfBuzz by default.
* Source/cmake/FindHarfBuzz.cmake: Added pkgconfig based discovery of HarfBuzz.
* Source/cmake/OptionsEfl.cmake: Adding Harfbuzz configuration.
2012-07-26 Dan Bernstein <mitz@apple.com>
When Safari 6 is launched via the WebKit Xcode workspace, it does not link against the built frameworks
......
......@@ -48,6 +48,8 @@ SET(WebCore_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/platform/graphics"
"${WEBCORE_DIR}/platform/graphics/filters"
"${WEBCORE_DIR}/platform/graphics/filters/arm"
"${WEBCORE_DIR}/platform/graphics/harfbuzz"
"${WEBCORE_DIR}/platform/graphics/harfbuzz/ng"
"${WEBCORE_DIR}/platform/graphics/transforms"
"${WEBCORE_DIR}/platform/image-decoders"
"${WEBCORE_DIR}/platform/image-decoders/bmp"
......
2012-07-27 Dominik Röttsches <dominik.rottsches@intel.com>
[Cairo] Add complex font drawing using HarfbuzzNG
https://bugs.webkit.org/show_bug.cgi?id=91864
Reviewed by Simon Hausmann and Martin Robinson.
Adding Harfbuzz support to EFL by implementing it with the help of cairo and cairo-ft.
Reusing Chromium's Harfbuzz-NG support.
No new tests, complex font support is covered by existing tests.
* CMakeLists.txt: Adding new cairo based implementations, removing emtpy FontEfl.cpp
* WebCore.gypi: Removing FontEfl.cpp
* platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: Added. New implementation that implements cairo & harfbuzz-ng based complex font drawing.
(WebCore):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):
(WebCore::Font::canReturnFallbackFontsForComplexText):
(WebCore::Font::canExpandAroundIdeographsInComplexText):
(WebCore::Font::floatWidthForComplexText):
(WebCore::Font::offsetForPositionForComplexText):
(WebCore::Font::selectionRectForComplexText):
* platform/graphics/efl/FontEfl.cpp: Removed.
* platform/graphics/freetype/FontPlatformData.h: Adding a getter that retrieves a harfbuzz face.
(FontPlatformData):
* platform/graphics/freetype/FontPlatformDataFreeType.cpp: Adding a getter that retrieves a harfbuzz face.
(WebCore::FontPlatformData::operator=):
(WebCore::FontPlatformData::FontPlatformData):
(WebCore):
(WebCore::FontPlatformData::harfbuzzFace):
* platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp: Added. Cairo-freetype based approach to get complex font metrics.
(WebCore):
(CairoFtFaceLocker):
(WebCore::CairoFtFaceLocker::CairoFtFaceLocker):
(WebCore::CairoFtFaceLocker::lock):
(WebCore::CairoFtFaceLocker::~CairoFtFaceLocker):
(WebCore::floatToHarfBuzzPosition):
(WebCore::doubleToHarfBuzzPosition):
(WebCore::CairoGetGlyphWidthAndExtents):
(WebCore::harfbuzzGetGlyph):
(WebCore::harfbuzzGetGlyphHorizontalAdvance):
(WebCore::harfbuzzGetGlyphHorizontalOrigin):
(WebCore::harfbuzzGetGlyphExtents):
(WebCore::harfbuzzCairoTextGetFontFuncs):
(WebCore::harfbuzzCairoGetTable):
(WebCore::HarfBuzzNGFace::createFace):
(WebCore::HarfBuzzNGFace::createFont):
(WebCore::HarfBuzzShaper::createGlyphBufferAdvance):
2012-07-27 Adam Barth <abarth@webkit.org>
Add a Setting to expose quantized, rate-limited MemoryInfo values
......@@ -149,15 +149,24 @@ IF (WTF_USE_CAIRO)
IF (WTF_USE_FREETYPE)
LIST(APPEND WebCore_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/platform/graphics/freetype"
"${WEBCORE_DIR}/platform/graphics/harfbuzz/"
"${WEBCORE_DIR}/platform/graphics/harfbuzz/ng"
)
LIST(APPEND WebCore_SOURCES
platform/graphics/WOFFFileFormat.cpp
platform/graphics/efl/FontEfl.cpp
platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
platform/graphics/freetype/FontCacheFreeType.cpp
platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
platform/graphics/freetype/FontPlatformDataFreeType.cpp
platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp
platform/graphics/freetype/SimpleFontDataFreeType.cpp
platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp
platform/graphics/harfbuzz/ng/HarfBuzzNGFace.cpp
platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp
platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp
)
LIST(APPEND WebCore_LIBRARIES
${HARFBUZZ_LIBRARIES}
)
ENDIF ()
......
......@@ -3658,7 +3658,6 @@
'platform/graphics/chromium/VDMXParser.cpp',
'platform/graphics/chromium/VDMXParser.h',
'platform/graphics/cocoa/FontPlatformDataCocoa.mm',
'platform/graphics/efl/FontEfl.cpp',
'platform/graphics/efl/IconEfl.cpp',
'platform/graphics/efl/ImageEfl.cpp',
'platform/graphics/efl/IntPointEfl.cpp',
......
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2012 Intel Corporation
*
* 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 COMPUTER, INC. ``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 COMPUTER, INC. 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 "Font.h"
#include "GraphicsContext.h"
#include "HarfBuzzShaper.h"
#include "Logging.h"
#include "NotImplemented.h"
#include "PlatformContextCairo.h"
#include "SimpleFontData.h"
#include <cairo.h>
namespace WebCore {
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
GlyphBuffer glyphBuffer;
HarfBuzzShaper shaper(this, run);
if (shaper.shape(&glyphBuffer))
drawGlyphBuffer(context, run, glyphBuffer, point);
else
LOG_ERROR("Shaper couldn't shape glyphBuffer.");
}
void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
{
notImplemented();
}
bool Font::canReturnFallbackFontsForComplexText()
{
return false;
}
bool Font::canExpandAroundIdeographsInComplexText()
{
return false;
}
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*, GlyphOverflow*) const
{
HarfBuzzShaper shaper(this, run);
if (shaper.shape())
return shaper.totalWidth();
LOG_ERROR("Shaper couldn't shape text run.");
return 0;
}
int Font::offsetForPositionForComplexText(const TextRun& run, float x, bool) const
{
HarfBuzzShaper shaper(this, run);
if (shaper.shape())
return shaper.offsetForPosition(x);
LOG_ERROR("Shaper couldn't shape text run.");
return 0;
}
FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
{
HarfBuzzShaper shaper(this, run);
if (shaper.shape())
return shaper.selectionRect(point, h, from, to);
LOG_ERROR("Shaper couldn't shape text run.");
return FloatRect();
}
}
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2006 Apple Inc. All rights reserved.
* Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
* Copyright (C) 2009-2010 ProFUSION embedded systems
* Copyright (C) 2009-2010 Samsung Electronics
*
* 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.
*
*/
#include "config.h"
#include "Font.h"
#include "GraphicsContext.h"
#include "NotImplemented.h"
#include "SimpleFontData.h"
#include <cairo.h>
namespace WebCore {
void Font::drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const
{
notImplemented();
}
void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
{
notImplemented();
}
bool Font::canReturnFallbackFontsForComplexText()
{
return false;
}
bool Font::canExpandAroundIdeographsInComplexText()
{
return false;
}
float Font::floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData*>*, GlyphOverflow*) const
{
notImplemented();
return 0.0f;
}
int Font::offsetForPositionForComplexText(const TextRun&, float, bool) const
{
notImplemented();
return 0;
}
FloatRect Font::selectionRectForComplexText(const TextRun&, const FloatPoint&, int, int, int) const
{
notImplemented();
return FloatRect();
}
}
......@@ -29,11 +29,15 @@
#include "FontDescription.h"
#include "FontOrientation.h"
#include "GlyphBuffer.h"
#if USE(HARFBUZZ_NG)
#include "HarfBuzzNGFace.h"
#endif
#include "RefPtrCairo.h"
#include <wtf/Forward.h>
#include <wtf/HashFunctions.h>
typedef struct _FcFontSet FcFontSet;
class HarfBuzzNGFace;
namespace WebCore {
......@@ -63,6 +67,10 @@ public:
~FontPlatformData();
#if USE(HARFBUZZ_NG)
HarfBuzzNGFace* harfbuzzFace() const;
#endif
bool isFixedPitch();
float size() const { return m_size; }
void setSize(float size) { m_size = size; }
......@@ -98,6 +106,9 @@ public:
bool m_syntheticOblique;
bool m_fixedWidth;
cairo_scaled_font_t* m_scaledFont;
#if USE(HARFBUZZ_NG)
mutable RefPtr<HarfBuzzNGFace> m_harfbuzzFace;
#endif
private:
void initializeWithFontFace(cairo_font_face_t*, const FontDescription& = FontDescription());
......
......@@ -186,17 +186,27 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
cairo_scaled_font_destroy(m_scaledFont);
m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont);
#if USE(HARFBUZZ_NG)
m_harfbuzzFace = other.m_harfbuzzFace;
#endif
return *this;
}
FontPlatformData::FontPlatformData(const FontPlatformData& other)
: m_fallbacks(0)
, m_scaledFont(0)
#if USE(HARFBUZZ_NG)
, m_harfbuzzFace(other.m_harfbuzzFace)
#endif
{
*this = other;
}
FontPlatformData::FontPlatformData(const FontPlatformData& other, float size)
#if USE(HARFBUZZ_NG)
: m_harfbuzzFace(other.m_harfbuzzFace)
#endif
{
*this = other;
......@@ -217,6 +227,16 @@ FontPlatformData::~FontPlatformData()
cairo_scaled_font_destroy(m_scaledFont);
}
#if USE(HARFBUZZ_NG)
HarfBuzzNGFace* FontPlatformData::harfbuzzFace() const
{
if (!m_harfbuzzFace)
m_harfbuzzFace = HarfBuzzNGFace::create(const_cast<FontPlatformData*>(this), hash());
return m_harfbuzzFace.get();
}
#endif
bool FontPlatformData::isFixedPitch()
{
return m_fixedWidth;
......
/*
* Copyright (c) 2012 Google Inc. All rights reserved.
* Copyright (c) 2012 Intel Corporation
*
* 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 "HarfBuzzNGFace.h"
#include "FontPlatformData.h"
#include "GlyphBuffer.h"
#include "HarfBuzzShaper.h"
#include "SimpleFontData.h"
#include "TextEncoding.h"
#include <cairo-ft.h>
#include <cairo.h>
#include <freetype/freetype.h>
#include <freetype/tttables.h>
#include <hb.h>
#include <wtf/text/CString.h>
namespace WebCore {
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));
}
static hb_position_t doubleToHarfBuzzPosition(double value)
{
return static_cast<hb_position_t>(value * (1 << 16));
}
static void CairoGetGlyphWidthAndExtents(cairo_scaled_font_t* scaledFont, hb_codepoint_t codepoint, hb_position_t* advance, hb_glyph_extents_t* extents)
{
cairo_text_extents_t glyphExtents;
cairo_glyph_t glyph;
glyph.index = codepoint;
glyph.x = 0;
glyph.y = 0;
cairo_scaled_font_glyph_extents(scaledFont, &glyph, 1, &glyphExtents);
if (advance)
*advance = doubleToHarfBuzzPosition(glyphExtents.x_advance);
if (extents) {
extents->x_bearing = doubleToHarfBuzzPosition(glyphExtents.x_bearing);
extents->y_bearing = doubleToHarfBuzzPosition(glyphExtents.y_bearing);
extents->width = doubleToHarfBuzzPosition(glyphExtents.width);
extents->height = doubleToHarfBuzzPosition(glyphExtents.height);
}
}
static hb_bool_t harfbuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoint_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* userData)
{
FontPlatformData* platformData = reinterpret_cast<FontPlatformData*>(fontData);
cairo_scaled_font_t* scaledFont = platformData->scaledFont();
ASSERT(scaledFont);
CairoFtFaceLocker cairoFtFaceLocker(scaledFont);
FT_Face ftFace = cairoFtFaceLocker.lock();
ASSERT(ftFace);
*glyph = FT_Get_Char_Index(ftFace, unicode);
return !!*glyph;
}
static hb_position_t harfbuzzGetGlyphHorizontalAdvance(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, void* userData)
{
FontPlatformData* platformData = reinterpret_cast<FontPlatformData*>(fontData);
cairo_scaled_font_t* scaledFont = platformData->scaledFont();
ASSERT(scaledFont);
hb_position_t advance = 0;
CairoGetGlyphWidthAndExtents(scaledFont, glyph, &advance, 0);
return advance;
}
static hb_bool_t harfbuzzGetGlyphHorizontalOrigin(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_position_t* x, hb_position_t* y, void* userData)
{
// Just return true, following the way that Harfbuzz-FreeType
// implementation does.
return true;
}
static hb_bool_t harfbuzzGetGlyphExtents(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_glyph_extents_t* extents, void* userData)
{
FontPlatformData* platformData = reinterpret_cast<FontPlatformData*>(fontData);
cairo_scaled_font_t* scaledFont = platformData->scaledFont();
ASSERT(scaledFont);
CairoGetGlyphWidthAndExtents(scaledFont, glyph, 0, extents);
return true;
}
static hb_font_funcs_t* harfbuzzCairoTextGetFontFuncs()
{
static hb_font_funcs_t* harfbuzzCairoFontFuncs = 0;
// We don't set callback functions which we can't support.
// Harfbuzz will use the fallback implementation if they aren't set.
if (!harfbuzzCairoFontFuncs) {
harfbuzzCairoFontFuncs = hb_font_funcs_create();
hb_font_funcs_set_glyph_func(harfbuzzCairoFontFuncs, harfbuzzGetGlyph, 0, 0);
hb_font_funcs_set_glyph_h_advance_func(harfbuzzCairoFontFuncs, harfbuzzGetGlyphHorizontalAdvance, 0, 0);
hb_font_funcs_set_glyph_h_origin_func(harfbuzzCairoFontFuncs, harfbuzzGetGlyphHorizontalOrigin, 0, 0);
hb_font_funcs_set_glyph_extents_func(harfbuzzCairoFontFuncs, harfbuzzGetGlyphExtents, 0, 0);
hb_font_funcs_make_immutable(harfbuzzCairoFontFuncs);
}
return harfbuzzCairoFontFuncs;
}
static hb_blob_t* harfbuzzCairoGetTable(hb_face_t* face, hb_tag_t tag, void* userData)
{
FontPlatformData* font = reinterpret_cast<FontPlatformData*>(userData);
cairo_scaled_font_t* scaledFont = font->scaledFont();
if (!scaledFont)
return 0;
CairoFtFaceLocker cairoFtFaceLocker(scaledFont);
FT_Face ftFont = cairoFtFaceLocker.lock();
if (!ftFont)
return 0;
FT_ULong tableSize = 0;
FT_Error error = FT_Load_Sfnt_Table(ftFont, tag, 0, 0, &tableSize);
if (error)
return 0;
FT_Byte* buffer = reinterpret_cast<FT_Byte*>(fastMalloc(tableSize));
if (!buffer)
return 0;
FT_ULong expectedTableSize = tableSize;
error = FT_Load_Sfnt_Table(ftFont, tag, 0, buffer, &tableSize);
if (error || tableSize != expectedTableSize) {
fastFree(buffer);
return 0;
}
return hb_blob_create(reinterpret_cast<const char*>(buffer), tableSize, HB_MEMORY_MODE_WRITABLE, buffer, fastFree);
}
hb_face_t* HarfBuzzNGFace::createFace()
{
hb_face_t* face = hb_face_create_for_tables(harfbuzzCairoGetTable, m_platformData, 0);
ASSERT(face);
return face;
}
hb_font_t* HarfBuzzNGFace::createFont()
{
hb_font_t* font = hb_font_create(m_face);
hb_font_set_funcs(font, harfbuzzCairoTextGetFontFuncs(), m_platformData, 0);
const float size = m_platformData->size();
if (floorf(size) == size)
hb_font_set_ppem(font, size, size);
int scale = floatToHarfBuzzPosition(size);
hb_font_set_scale(font, scale, scale);
hb_font_make_immutable(font);
return font;
}
GlyphBufferAdvance HarfBuzzShaper::createGlyphBufferAdvance(float width, float height)
{
return GlyphBufferAdvance(width, height);
}
} // namespace WebCore
......@@ -29,6 +29,8 @@ SET(WebKit_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/platform/animation"
"${WEBCORE_DIR}/platform/graphics"
"${WEBCORE_DIR}/platform/graphics/filters"
"${WEBCORE_DIR}/platform/graphics/harfbuzz"
"${WEBCORE_DIR}/platform/graphics/harfbuzz/ng"
"${WEBCORE_DIR}/platform/graphics/transforms"
"${WEBCORE_DIR}/platform/network"
"${WEBCORE_DIR}/platform/sql"
......
2012-07-27 Dominik Röttsches <dominik.rottsches@intel.com>
[Cairo] Add complex font drawing using HarfbuzzNG
https://bugs.webkit.org/show_bug.cgi?id=91864
Reviewed by Simon Hausmann and Martin Robinson.
Adding includes for harfbuzz folders.
* CMakeLists.txt:
2012-07-26 Christophe Dumez <christophe.dumez@intel.com>
[EFL][WK2] Implement Network Information provider
......
......@@ -69,6 +69,8 @@ SET(WebKit2_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/platform/animation"
"${WEBCORE_DIR}/platform/graphics"
"${WEBCORE_DIR}/platform/graphics/filters"
"${WEBCORE_DIR}/platform/graphics/harfbuzz"
"${WEBCORE_DIR}/platform/graphics/harfbuzz/ng"
"${WEBCORE_DIR}/platform/graphics/transforms"
"${WEBCORE_DIR}/platform/network"
"${WEBCORE_DIR}/platform/sql"
......
2012-07-27 Dominik Röttsches <dominik.rottsches@intel.com>
[Cairo] Add complex font drawing using HarfbuzzNG
https://bugs.webkit.org/show_bug.cgi?id=91864
Reviewed by Simon Hausmann and Martin Robinson.
Adding includes for harfbuzz folders.
* CMakeLists.txt:
2012-07-27 Christophe Dumez <christophe.dumez@intel.com>
[EFL][WK2] Add more Ewk_View unit tests
......
# Copyright (c) 2012, Intel Corporation
#
# 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 Intel Corporation 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(FindPkgConfig)
PKG_CHECK_MODULES (harfbuzz REQUIRED harfbuzz>=0.9.0)
PKG_CHECK_MODULES(PC_HARFBUZZ harfbuzz>=0.9.0)
FIND_PATH(HARFBUZZ_INCLUDE_DIRS NAMES hb.h
HINTS ${PC_HARFBUZZ_INCLUDE_DIRS} ${PC_HARFBUZZ_INCLUDEDIR}
)
FIND_LIBRARY(HARFBUZZ_LIBRARIES NAMES harfbuzz
HINTS ${PC_HARFBUZZ_LIBRARY_DIRS} ${PC_HARFBUZZ_LIBDIR}
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HarfBuzz DEFAULT_MSG HARFBUZZ_INCLUDE_DIRS HARFBUZZ_LIBRARIES)
......@@ -119,8 +119,11 @@ ENDIF ()
IF (FONT_BACKEND STREQUAL "freetype")
FIND_PACKAGE(Freetype REQUIRED)
FIND_PACKAGE(HarfBuzz REQUIRED)
SET(WTF_USE_FREETYPE 1)
SET(WTF_USE_HARFBUZZ_NG 1)
ADD_DEFINITIONS(-DWTF_USE_FREETYPE=1)
ADD_DEFINITIONS(-DWTF_USE_HARFBUZZ_NG=1)
ELSE ()
FIND_PACKAGE(Pango REQUIRED)
SET(WTF_USE_PANGO 1)
......
2012-07-27 Dominik Röttsches <dominik.rottsches@intel.com>
[Cairo] Add complex font drawing using HarfbuzzNG
https://bugs.webkit.org/show_bug.cgi?id=91864
Reviewed by Simon Hausmann and Martin Robinson.
Bringing Harfbuzz support to EFL with this patch, so we need HarfBuzz in the pulled in jhbuild dependencies.
* WebKitTestRunner/CMakeLists.txt: Adding additional header include directories.
* efl/jhbuild.modules: Adding source for HarfBuzz release version 0.9.0.
2012-07-27 KwangYong Choi <ky0.choi@samsung.com>