Commit 19371196 authored by eae@chromium.org's avatar eae@chromium.org

Use FontPlatformDataHarfBuzz.h on Windows

Merge FontPlatformDataWin.h with FontPlatformDataHarfBuzz.h and use the
same version of the FontPlatformData class defintion/header on Windows
as on linux, chromeos and android.

R=dglazkov@chromium.org
BUG=355806

Review URL: https://codereview.chromium.org/205343010

git-svn-id: svn://svn.chromium.org/blink/trunk@170088 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 90f65834
......@@ -323,7 +323,7 @@
['include', 'fonts/skia/SimpleFontDataSkia\\.cpp$'],
['include', 'fonts/win/FontCacheSkiaWin\\.cpp$'],
['include', 'fonts/win/FontFallbackWin\\.(cpp|h)$'],
['include', 'fonts/win/FontPlatformDataWin\\.(cpp|h)$'],
['include', 'fonts/win/FontPlatformDataWin\\.cpp$'],
['exclude', 'fonts/harfbuzz/FontPlatformDataHarfBuzz\\.cpp$'],
# SystemInfo.cpp is useful and we don't want to copy it.
......
......@@ -405,7 +405,6 @@
'fonts/win/FontFallbackWin.cpp',
'fonts/win/FontFallbackWin.h',
'fonts/win/FontPlatformDataWin.cpp',
'fonts/win/FontPlatformDataWin.h',
'geometry/FloatBoxExtent.h',
'geometry/FloatPolygon.cpp',
'geometry/FloatPolygon.h',
......
......@@ -22,10 +22,8 @@
*
*/
// FIXME: This is temporary until all ports switch to using this file.
#if OS(WIN)
#include "platform/fonts/win/FontPlatformDataWin.h"
#elif !OS(MACOSX)
// FIXME: This is temporary until mac switch to using FontPlatformDataHarfBuzz.h and we merge it with this file.
#if !OS(MACOSX)
#include "platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h"
#else
......
......@@ -285,4 +285,9 @@ void FontPlatformData::querySystemForRenderStyle(bool useSkiaSubpixelPositioning
m_style.useSubpixelPositioning = useSkiaSubpixelPositioning;
}
bool FontPlatformData::defaultUseSubpixelPositioning()
{
return FontDescription::subpixelPositioning();
}
} // namespace WebCore
......@@ -51,11 +51,6 @@ namespace WebCore {
class GraphicsContext;
class HarfBuzzFace;
// -----------------------------------------------------------------------------
// FontPlatformData is the handle which WebKit has on a specific face. A face
// is the tuple of (font, size, ...etc). Here we are just wrapping a Skia
// SkTypeface pointer and dealing with the reference counting etc.
// -----------------------------------------------------------------------------
class PLATFORM_EXPORT FontPlatformData {
public:
// Used for deleted values in the font cache's hash tables. The hash table
......@@ -67,32 +62,18 @@ public:
FontPlatformData();
FontPlatformData(float textSize, bool syntheticBold, bool syntheticItalic);
FontPlatformData(const FontPlatformData&);
FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subpixelTextPosition = FontDescription::subpixelPositioning());
FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subpixelTextPosition = defaultUseSubpixelPositioning());
FontPlatformData(const FontPlatformData& src, float textSize);
~FontPlatformData();
String fontFamilyName() const;
// -------------------------------------------------------------------------
// Return true iff this font is monospaced (i.e. every glyph has an equal x
// advance)
// -------------------------------------------------------------------------
float size() const { return m_textSize; }
bool isFixedPitch() const;
// -------------------------------------------------------------------------
// Setup a Skia painting context to use this font.
// -------------------------------------------------------------------------
void setupPaint(SkPaint*, GraphicsContext* = 0) const;
// -------------------------------------------------------------------------
// Return Skia's unique id for this font. This encodes both the style and
// the font's file name so refers to a single face.
// -------------------------------------------------------------------------
SkFontID uniqueID() const;
SkTypeface* typeface() const { return m_typeface.get(); }
HarfBuzzFace* harfBuzzFace() const;
SkFontID uniqueID() const;
unsigned hash() const;
float size() const { return m_textSize; }
FontOrientation orientation() const { return m_orientation; }
void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
......@@ -111,26 +92,31 @@ public:
String description() const;
#endif
HarfBuzzFace* harfBuzzFace() const;
// The returned styles are all actual styles without FontRenderStyle::NoPreference.
const FontRenderStyle& fontRenderStyle() const { return m_style; }
void setupPaint(SkPaint*, GraphicsContext* = 0) const;
// -------------------------------------------------------------------------
// Global font preferences...
#if OS(WIN)
int paintTextFlags() const { return m_paintTextFlags; }
#else
static void setHinting(SkPaint::Hinting);
static void setAutoHint(bool);
static void setUseBitmaps(bool);
static void setAntiAlias(bool);
static void setSubpixelRendering(bool);
#endif
private:
bool static defaultUseSubpixelPositioning();
#if !OS(WIN)
void getRenderStyleForStrike(const char*, int);
void querySystemForRenderStyle(bool useSkiaSubpixelPositioning);
#endif
RefPtr<SkTypeface> m_typeface;
#if !OS(WIN)
CString m_family;
#endif
float m_textSize;
bool m_syntheticBold;
bool m_syntheticItalic;
......@@ -138,6 +124,10 @@ private:
FontRenderStyle m_style;
mutable RefPtr<HarfBuzzFace> m_harfBuzzFace;
bool m_isHashTableDeletedValue;
#if OS(WIN)
int m_paintTextFlags;
bool m_useSubpixelPositioning;
#endif
};
} // namespace WebCore
......
......@@ -37,8 +37,8 @@
#include "SkTypeface_win.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/SimpleFontData.h"
#include "platform/fonts/harfbuzz/FontPlatformDataHarfbuzz.h"
#include "platform/fonts/win/FontFallbackWin.h"
#include "platform/fonts/win/FontPlatformDataWin.h"
namespace WebCore {
......
......@@ -32,6 +32,7 @@
#include "config.h"
#include "platform/fonts/FontPlatformData.h"
#include "SkTypeface.h"
#include "platform/LayoutTestSupport.h"
#include "platform/fonts/FontCache.h"
#include "platform/fonts/harfbuzz/HarfBuzzFace.h"
......@@ -196,6 +197,10 @@ FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family
m_paintTextFlags = computePaintTextFlags(fontFamilyName());
}
FontPlatformData::~FontPlatformData()
{
}
FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
{
if (this != &data) {
......@@ -209,10 +214,6 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
return *this;
}
FontPlatformData::~FontPlatformData()
{
}
String FontPlatformData::fontFamilyName() const
{
// FIXME: This returns the requested name, perhaps a better solution would be to
......@@ -246,6 +247,11 @@ HarfBuzzFace* FontPlatformData::harfBuzzFace() const
return m_harfBuzzFace.get();
}
SkFontID FontPlatformData::uniqueID() const
{
return m_typeface->uniqueID();
}
bool FontPlatformData::defaultUseSubpixelPositioning()
{
return FontCache::fontCache()->useSubpixelPositioning();
......
/*
* Copyright (C) 2006, 2007 Apple Computer, Inc.
* Copyright (c) 2006, 2007, 2008, 2009, 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 FontPlatformDataChromiumWin_h
#define FontPlatformDataChromiumWin_h
#include "SkPaint.h"
#include "SkTypeface.h"
#include "SkTypeface_win.h"
#include "platform/SharedBuffer.h"
#include "platform/fonts/FontOrientation.h"
#include "platform/fonts/opentype/OpenTypeVerticalData.h"
#include "wtf/Forward.h"
#include "wtf/HashTableDeletedValueType.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/text/StringImpl.h"
namespace WebCore {
class FontDescription;
class GraphicsContext;
class HarfBuzzFace;
class PLATFORM_EXPORT FontPlatformData {
public:
// Used for deleted values in the font cache's hash tables. The hash table
// will create us with this structure, and it will compare other values
// to this "Deleted" one. It expects the Deleted one to be differentiable
// from the NULL one (created with the empty constructor), so we can't just
// set everything to NULL.
FontPlatformData(WTF::HashTableDeletedValueType);
FontPlatformData();
FontPlatformData(float size, bool bold, bool oblique);
FontPlatformData(const FontPlatformData&);
FontPlatformData(const FontPlatformData&, float textSize);
FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool useSubpixelPositioning = defaultUseSubpixelPositioning());
void setupPaint(SkPaint*, GraphicsContext* = 0) const;
FontPlatformData& operator=(const FontPlatformData&);
bool isHashTableDeletedValue() const { return m_isHashTableDeletedValue; }
~FontPlatformData();
bool isFixedPitch() const;
float size() const { return m_textSize; }
HarfBuzzFace* harfBuzzFace() const;
SkTypeface* typeface() const { return m_typeface.get(); }
SkFontID uniqueID() const { return m_typeface->uniqueID(); }
int paintTextFlags() const { return m_paintTextFlags; }
String fontFamilyName() const;
FontOrientation orientation() const { return m_orientation; }
void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
unsigned hash() const;
bool operator==(const FontPlatformData&) const;
#if ENABLE(OPENTYPE_VERTICAL)
PassRefPtr<OpenTypeVerticalData> verticalData() const;
PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
#endif
#ifndef NDEBUG
String description() const;
#endif
private:
bool static defaultUseSubpixelPositioning();
float m_textSize; // Point size of the font in pixels.
FontOrientation m_orientation;
bool m_syntheticBold;
bool m_syntheticItalic;
RefPtr<SkTypeface> m_typeface;
int m_paintTextFlags;
mutable RefPtr<HarfBuzzFace> m_harfBuzzFace;
bool m_isHashTableDeletedValue;
bool m_useSubpixelPositioning;
};
} // WebCore
#endif // FontPlatformDataChromiumWin_h
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