Skip to content
Permalink
Browse files
Use SkTypeface API directly, rather than (soon to be private) SkFontHost
https://bugs.webkit.org/show_bug.cgi?id=111588

Reviewed by Stephen White.

No new tests, as existing tests in fast/writing-mode exercise this code.

e.g. japanese-rl-text-with-broken-font.html
     vertical-subst-font-vert-no-dflt.html

* platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp:
(WebCore::FontPlatformData::emSizeInFontUnits):
(WebCore::FontPlatformData::openTypeTable):
* platform/graphics/harfbuzz/HarfBuzzFaceSkia.cpp:
(WebCore::harfBuzzSkiaGetTable):
(WebCore::HarfBuzzFace::createFace):
* platform/graphics/skia/SimpleFontDataSkia.cpp:
(WebCore::SimpleFontData::platformInit):


Canonical link: https://commits.webkit.org/129989@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144976 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
reed-at-google committed Mar 6, 2013
1 parent 7c03224 commit 61460468f3a155b09341eb6641a81ad890231e37
Showing 5 changed files with 36 additions and 16 deletions.
@@ -1,3 +1,24 @@
2013-03-06 Mike Reed <reed@google.com>

Use SkTypeface API directly, rather than (soon to be private) SkFontHost
https://bugs.webkit.org/show_bug.cgi?id=111588

Reviewed by Stephen White.

No new tests, as existing tests in fast/writing-mode exercise this code.

e.g. japanese-rl-text-with-broken-font.html
vertical-subst-font-vert-no-dflt.html

* platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp:
(WebCore::FontPlatformData::emSizeInFontUnits):
(WebCore::FontPlatformData::openTypeTable):
* platform/graphics/harfbuzz/HarfBuzzFaceSkia.cpp:
(WebCore::harfBuzzSkiaGetTable):
(WebCore::HarfBuzzFace::createFace):
* platform/graphics/skia/SimpleFontDataSkia.cpp:
(WebCore::SimpleFontData::platformInit):

2013-03-06 Victor Costan <costan@gmail.com>

Cleanup in multipart FormData sending code.
@@ -35,7 +35,6 @@
#include "HarfBuzzFace.h"
#include "NotImplemented.h"
#include "SkAdvancedTypefaceMetrics.h"
#include "SkFontHost.h"
#include "SkPaint.h"
#include "SkTypeface.h"

@@ -171,7 +170,7 @@ int FontPlatformData::emSizeInFontUnits() const
#if OS(ANDROID)
// Android doesn't currently support Skia's getAdvancedTypefaceMetrics(),
// but it has access to another method to replace this functionality.
m_emSizeInFontUnits = SkFontHost::GetUnitsPerEm(m_typeface->uniqueID());
m_emSizeInFontUnits = m_typeface->getUnitsPerEm();
#else
SkAdvancedTypefaceMetrics* metrics = m_typeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
m_emSizeInFontUnits = metrics->fEmSize;
@@ -335,10 +334,10 @@ PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
RefPtr<SharedBuffer> buffer;

SkFontTableTag tag = reverseByteOrder(table);
const size_t tableSize = SkFontHost::GetTableSize(uniqueID(), tag);
const size_t tableSize = m_typeface->getTableSize(tag);
if (tableSize) {
Vector<char> tableBuffer(tableSize);
SkFontHost::GetTableData(uniqueID(), tag, 0, tableSize, &tableBuffer[0]);
m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]);
buffer = SharedBuffer::adoptVector(tableBuffer);
}
return buffer.release();
@@ -85,6 +85,7 @@ class FontPlatformData {
// the font's file name so refers to a single face.
// -------------------------------------------------------------------------
SkFontID uniqueID() const;
SkTypeface* typeface() const { return m_typeface; }

unsigned hash() const;
float size() const { return m_textSize; }
@@ -35,11 +35,11 @@
#include "GlyphBuffer.h"
#include "HarfBuzzShaper.h"
#include "SimpleFontData.h"
#include "SkFontHost.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPoint.h"
#include "SkRect.h"
#include "SkTypeface.h"
#include "SkUtils.h"

#include "hb.h"
@@ -144,16 +144,16 @@ static hb_font_funcs_t* harfBuzzSkiaGetFontFuncs()

static hb_blob_t* harfBuzzSkiaGetTable(hb_face_t* face, hb_tag_t tag, void* userData)
{
SkFontID uniqueID = static_cast<SkFontID>(reinterpret_cast<uint64_t>(userData));
SkTypeface* typeface = reinterpret_cast<SkTypeface*>(userData);

const size_t tableSize = SkFontHost::GetTableSize(uniqueID, tag);
const size_t tableSize = typeface->getTableSize(tag);
if (!tableSize)
return 0;

char* buffer = reinterpret_cast<char*>(fastMalloc(tableSize));
if (!buffer)
return 0;
size_t actualSize = SkFontHost::GetTableData(uniqueID, tag, 0, tableSize, buffer);
size_t actualSize = typeface->getTableData(tag, 0, tableSize, buffer);
if (tableSize != actualSize) {
fastFree(buffer);
return 0;
@@ -170,7 +170,7 @@ static void destroyHarfBuzzFontData(void* userData)

hb_face_t* HarfBuzzFace::createFace()
{
hb_face_t* face = hb_face_create_for_tables(harfBuzzSkiaGetTable, reinterpret_cast<void*>(m_platformData->uniqueID()), 0);
hb_face_t* face = hb_face_create_for_tables(harfBuzzSkiaGetTable, m_platformData->typeface(), 0);
ASSERT(face);
return face;
}
@@ -36,7 +36,6 @@
#include "FontCache.h"
#include "FontDescription.h"
#include "Logging.h"
#include "SkFontHost.h"
#include "SkPaint.h"
#include "SkTime.h"
#include "SkTypeface.h"
@@ -64,18 +63,18 @@ void SimpleFontData::platformInit()

m_platformData.setupPaint(&paint);
paint.getFontMetrics(&metrics);
const SkFontID fontID = m_platformData.uniqueID();
SkTypeface* face = paint.getTypeface();

static const uint32_t vdmxTag = SkSetFourByteTag('V', 'D', 'M', 'X');
int pixelSize = m_platformData.size() + 0.5;
int vdmxAscent, vdmxDescent;
bool isVDMXValid = false;

size_t vdmxSize = SkFontHost::GetTableSize(fontID, vdmxTag);
size_t vdmxSize = face->getTableSize(vdmxTag);
if (vdmxSize && vdmxSize < maxVDMXTableSize) {
uint8_t* vdmxTable = (uint8_t*) fastMalloc(vdmxSize);
if (vdmxTable
&& SkFontHost::GetTableData(fontID, vdmxTag, 0, vdmxSize, vdmxTable) == vdmxSize
&& face->getTableData(vdmxTag, 0, vdmxSize, vdmxTable) == vdmxSize
&& parseVDMX(&vdmxAscent, &vdmxDescent, vdmxTable, vdmxSize, pixelSize))
isVDMXValid = true;
fastFree(vdmxTable);
@@ -126,8 +125,8 @@ void SimpleFontData::platformInit()
if (platformData().orientation() == Vertical && !isTextOrientationFallback()) {
static const uint32_t vheaTag = SkSetFourByteTag('v', 'h', 'e', 'a');
static const uint32_t vorgTag = SkSetFourByteTag('V', 'O', 'R', 'G');
size_t vheaSize = SkFontHost::GetTableSize(fontID, vheaTag);
size_t vorgSize = SkFontHost::GetTableSize(fontID, vorgTag);
size_t vheaSize = face->getTableSize(vheaTag);
size_t vorgSize = face->getTableSize(vorgTag);
if ((vheaSize > 0) || (vorgSize > 0))
m_hasVerticalGlyphs = true;
}
@@ -161,7 +160,7 @@ void SimpleFontData::platformInit()
}
}

if (int unitsPerEm = paint.getTypeface()->getUnitsPerEm())
if (int unitsPerEm = face->getUnitsPerEm())
m_fontMetrics.setUnitsPerEm(unitsPerEm);
}

0 comments on commit 6146046

Please sign in to comment.