summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
Diffstat (limited to 'skia')
-rw-r--r--skia/include/SkPaint.h13
-rw-r--r--skia/include/SkScalerContext.h10
-rw-r--r--skia/ports/SkFontHost_FreeType.cpp132
-rw-r--r--skia/ports/SkFontHost_TrueType_Tables.cpp189
-rw-r--r--skia/sgl/SkGlyphCache.cpp12
-rw-r--r--skia/sgl/SkGlyphCache.h11
-rw-r--r--skia/sgl/SkPaint.cpp12
-rw-r--r--skia/skia.gyp11
8 files changed, 2 insertions, 388 deletions
diff --git a/skia/include/SkPaint.h b/skia/include/SkPaint.h
index d13d090..14691b7 100644
--- a/skia/include/SkPaint.h
+++ b/skia/include/SkPaint.h
@@ -39,8 +39,6 @@ class SkDrawLooper;
class SkTypeface;
class SkXfermode;
-typedef struct HB_ShaperItem_ HB_ShaperItem;
-
typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**,
SkFixed x, SkFixed y);
@@ -620,12 +618,6 @@ public:
SkScalar fXMin; //!< The minimum bounding box x value for all glyphs
SkScalar fXMax; //!< The maximum bounding box x value for all glyphs
SkScalar fXHeight; //!< the height of an 'x' in px, or 0 if no 'x' in face
-
- // VDMX values are exact ascent and descent values for scalable fonts at
- // a certain pixel size.
- bool fVDMXMetricsValid; //!< If true, the following members are valid
- unsigned fVDMXAscent;
- unsigned fVDMXDescent;
};
/** Return the recommend spacing between lines (which will be
@@ -735,11 +727,6 @@ public:
void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y,
SkPath* path) const;
-#ifdef SKIA_HARFBUZZ
- void setupShaper(HB_ShaperItem* item);
- void releaseShaper(HB_ShaperItem* item);
-#endif
-
private:
SkTypeface* fTypeface;
SkScalar fTextSize;
diff --git a/skia/include/SkScalerContext.h b/skia/include/SkScalerContext.h
index 1299f1b..df846f2 100644
--- a/skia/include/SkScalerContext.h
+++ b/skia/include/SkScalerContext.h
@@ -28,8 +28,6 @@ class SkMaskFilter;
class SkPathEffect;
class SkRasterizer;
-typedef struct HB_ShaperItem_ HB_ShaperItem;
-
// needs to be != to any valid SkMask::Format
#define MASK_FORMAT_JUST_ADVANCE (0xFF)
@@ -194,14 +192,6 @@ public:
static inline void MakeRec(const SkPaint&, const SkMatrix*, Rec* rec);
static SkScalerContext* Create(const SkDescriptor*);
-#ifdef SKIA_HARFBUZZ
- // This will fill in |item->font| and |item->face| with valid values for
- // this font.
- virtual void setupShaper(HB_ShaperItem* item) = 0;
- // This will release the references held by |item->font| and |item->face|.
- virtual void releaseShaper(HB_ShaperItem* item) = 0;
-#endif
-
protected:
Rec fRec;
unsigned fBaseGlyphCount;
diff --git a/skia/ports/SkFontHost_FreeType.cpp b/skia/ports/SkFontHost_FreeType.cpp
index b18796a..a356da7 100644
--- a/skia/ports/SkFontHost_FreeType.cpp
+++ b/skia/ports/SkFontHost_FreeType.cpp
@@ -36,13 +36,6 @@
#include FT_ADVANCES_H
#endif
-#ifdef SKIA_HARFBUZZ
-extern "C" {
-#include <harfbuzz-shaper.h>
-#include <harfbuzz-freetype.h>
-}
-#endif
-
#if 0
// Also include the files by name for build tools which require this.
#include <freetype/freetype.h>
@@ -80,15 +73,11 @@ class SkScalerContext_FreeType : public SkScalerContext {
public:
SkScalerContext_FreeType(const SkDescriptor* desc);
virtual ~SkScalerContext_FreeType();
+
bool success() const {
return fFaceRec != NULL && fFTSize != NULL;
}
-#ifdef SKIA_HARFBUZZ
- virtual void setupShaper(HB_ShaperItem* item);
- virtual void releaseShaper(HB_ShaperItem* item);
-#endif
-
protected:
virtual unsigned generateGlyphCount() const;
virtual uint16_t generateCharToGlyph(SkUnichar uni);
@@ -123,25 +112,9 @@ struct SkFaceRec {
uint32_t fRefCnt;
uint32_t fFontID;
-#ifdef SKIA_HARFBUZZ
- // A lazily created Harfbuzz face object.
- HB_Face fHBFace;
- // If |fHBFace| is non-NULL, then this member is valid.
- HB_FontRec* fHBFont;
-
- void setupShaper(HB_ShaperItem* item);
- void releaseShaper(HB_ShaperItem* item);
-#endif
-
+ // assumes ownership of the stream, will call unref() when its done
SkFaceRec(SkStream* strm, uint32_t fontID);
~SkFaceRec() {
-#ifdef SKIA_HARFBUZZ
- if (fHBFace) {
- free(fHBFace);
- free(fHBFont);
- }
-#endif
-
fSkStream->unref();
}
};
@@ -186,11 +159,6 @@ SkFaceRec::SkFaceRec(SkStream* strm, uint32_t fontID)
fFTStream.descriptor.pointer = fSkStream;
fFTStream.read = sk_stream_read;
fFTStream.close = sk_stream_close;
-
-#ifdef SKIA_HARFBUZZ
- fHBFace = NULL;
-#endif
-
}
// Will return 0 on failure
@@ -268,29 +236,6 @@ static void unref_ft_face(FT_Face face) {
SkASSERT("shouldn't get here, face not in list");
}
-#ifdef SKIA_HARFBUZZ
-void SkFaceRec::setupShaper(HB_ShaperItem* item) {
- if (!fHBFace) {
- fHBFace = HB_NewFace(fFace, hb_freetype_table_sfnt_get);
- fHBFont = (HB_FontRec *) calloc(sizeof(HB_FontRec), 1);
- fHBFont->klass = &hb_freetype_class;
- fHBFont->userData = fFace;
- fHBFont->x_ppem = fFace->size->metrics.x_ppem;
- fHBFont->y_ppem = fFace->size->metrics.y_ppem;
- fHBFont->x_scale = fFace->size->metrics.x_scale;
- fHBFont->y_scale = fFace->size->metrics.y_scale;
- }
-
- item->face = fHBFace;
- item->font = fHBFont;
- fRefCnt++;
-}
-
-void SkFaceRec::releaseShaper(HB_ShaperItem* item) {
- fRefCnt--;
-}
-#endif
-
///////////////////////////////////////////////////////////////////////////
SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc)
@@ -706,16 +651,6 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
}
}
-#ifdef SKIA_HARFBUZZ
-void SkScalerContext_FreeType::setupShaper(HB_ShaperItem* item) {
- fFaceRec->setupShaper(item);
-}
-
-void SkScalerContext_FreeType::releaseShaper(HB_ShaperItem* item) {
- fFaceRec->releaseShaper(item);
-}
-#endif
-
///////////////////////////////////////////////////////////////////////////////
#define ft2sk(x) SkFixedToScalar((x) << 10)
@@ -799,51 +734,6 @@ void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph,
path->close();
}
-// -----------------------------------------------------------------------------
-// This is an extern from SkFontHost_TrueType_VDMX. See comments there in for
-// details of the arguments.
-// -----------------------------------------------------------------------------
-extern bool VDMX_Parse(int* ymax, int* ymin, const uint8_t* vdmx,
- const size_t vdmx_length, const unsigned target_pelsize);
-
-// -----------------------------------------------------------------------------
-// Attempt to load and parse a VDMX table from the given face, extracting a
-// ascender and descender values for the given pelsize.
-// ymax: (output) the ascender value from the table
-// ymin: (output) the descender value from the table (negative!)
-// face: A FreeType TrueType or OpenType font
-// target_pelsize: the pixel size of the font (e.g. 16)
-//
-// Returns true iff a suitable match are found. Otherwise, *ymax and *ymin are
-// untouched.
-// -----------------------------------------------------------------------------
-static bool
-SkFontHost_VDMX_Parse(int* ymax, int* ymin,
- FT_Face face, unsigned target_pelsize) {
- FT_Error error;
-
- // Request the length of the VDMX table (if any)
- FT_ULong vdmx_length = 0;
- error = FT_Load_Sfnt_Table(face, FT_MAKE_TAG('V', 'D', 'M', 'X'),
- 0, NULL, &vdmx_length);
-
- if (error || vdmx_length > 1024 * 1024)
- return false;
-
- uint8_t* vdmx = (uint8_t *) malloc(vdmx_length);
- error = FT_Load_Sfnt_Table(face, FT_MAKE_TAG('V', 'D', 'M', 'X'),
- 0, vdmx, NULL);
- if (error) {
- free(vdmx);
- return false;
- }
-
- bool result = VDMX_Parse(ymax, ymin, vdmx, vdmx_length, target_pelsize);
- free(vdmx);
-
- return result;
-}
-
void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
SkPaint::FontMetrics* my) {
if (NULL == mx && NULL == my) {
@@ -883,10 +773,6 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
ys[0] = -face->bbox.yMax;
ys[1] = -face->ascender;
- // Bodge this for now. I need another round trip land a patch in
- // WebKit to fix it correctly, but noones's around now and I
- // probably won't get a chance before the merge tomorrow morning
- // -- agl
ys[2] = -face->descender;
ys[3] = -face->bbox.yMin;
ys[4] = leading;
@@ -926,10 +812,6 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
mx->fXMin = xmin;
mx->fXMax = xmax;
mx->fXHeight = x_height;
-
- // The VDMX metrics only make sense in the horizontal direction
- // I believe
- my->fVDMXMetricsValid = false;
}
if (my) {
my->fTop = pts[0].fY;
@@ -941,16 +823,6 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
my->fXMin = xmin;
my->fXMax = xmax;
my->fXHeight = x_height;
- my->fVDMXMetricsValid = false;
-
- // Attempt to parse the VDMX table to get exact metrics
- unsigned pelsize = (fScaleY + 0x8000) >> 16;
- int ymax, ymin;
- if (SkFontHost_VDMX_Parse(&ymax, &ymin, face, pelsize)) {
- my->fVDMXMetricsValid = true;
- my->fVDMXAscent = ymax;
- my->fVDMXDescent = -ymin;
- }
}
}
diff --git a/skia/ports/SkFontHost_TrueType_Tables.cpp b/skia/ports/SkFontHost_TrueType_Tables.cpp
deleted file mode 100644
index 49b4670..0000000
--- a/skia/ports/SkFontHost_TrueType_Tables.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/* libs/graphics/ports/SkFontHost_TrueType_VDMX.cpp
-**
-** Copyright 2008, Google Inc.
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-// -----------------------------------------------------------------------------
-// VDMX parsing code.
-//
-// VDMX tables are found in some TrueType/OpenType fonts and contain
-// ascender/descender overrides for certain (usually small) sizes. This is
-// needed in order to match font metrics on Windows.
-//
-// Freetype does not parse these tables so we do so here. In the future we
-// might support loading of arbitary fonts. This is not something that one
-// would wish to do, dangerous as it is, so we are careful where we tread.
-// -----------------------------------------------------------------------------
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-
-// For htons/ntohs
-#include <arpa/inet.h>
-
-// -----------------------------------------------------------------------------
-// Buffer helper class
-//
-// This class perform some trival buffer operations while checking for
-// out-of-bounds errors. As a family they return false if anything is amiss,
-// updating the current offset otherwise.
-// -----------------------------------------------------------------------------
-class Buffer {
- public:
- Buffer(const uint8_t* buffer, size_t length)
- : buffer_(buffer),
- length_(length),
- offset_(0) { }
-
- bool Skip(size_t n_bytes) {
- if (offset_ + n_bytes > length_)
- return false;
- offset_ += n_bytes;
- return true;
- }
-
- bool ReadU8(uint8_t* value) {
- if (offset_ + 1 > length_)
- return false;
- *value = buffer_[offset_];
- offset_++;
- return true;
- }
-
- bool ReadU16(uint16_t* value) {
- if (offset_ + 2 > length_)
- return false;
- memcpy(value, buffer_ + offset_, sizeof(uint16_t));
- *value = ntohs(*value);
- offset_ += 2;
- return true;
- }
-
- bool ReadS16(int16_t* value) {
- return ReadU16(reinterpret_cast<uint16_t*>(value));
- }
-
- size_t offset() const { return offset_; }
-
- void set_offset(size_t newoffset) { offset_ = newoffset; }
-
- private:
- const uint8_t *const buffer_;
- const size_t length_;
- size_t offset_;
-};
-
-// -----------------------------------------------------------------------------
-// Parse a TrueType VDMX table.
-// ymax: (output) the ascender value from the table
-// ymin: (output) the descender value from the table (negative!)
-// vdmx: the table bytes
-// vdmx_length: length of @vdmx, in bytes
-// target_pelsize: the pixel size of the font (e.g. 16)
-//
-// Returns true iff a suitable match are found. Otherwise, *ymax and *ymin are
-// untouched. size_t must be 32-bits to avoid overflow.
-//
-// See http://www.microsoft.com/opentype/otspec/vdmx.htm
-// -----------------------------------------------------------------------------
-bool
-VDMX_Parse(int* ymax, int* ymin,
- const uint8_t* vdmx, const size_t vdmx_length,
- const unsigned target_pelsize) {
- Buffer buf(vdmx, vdmx_length);
-
- // We ignore the version. Future tables should be backwards compatible with
- // this layout.
- uint16_t numratios;
- if (!buf.Skip(4) ||
- !buf.ReadU16(&numratios))
- return false;
-
- // Now we have two tables. Firstly we have @numratios Ratio records, then a
- // matching array of @numratios offsets. We save the offset of the beginning
- // of this second table.
- //
- // Range 6 <= x <= 262146
- unsigned long offset_table_offset =
- buf.offset() + 4 /* sizeof struct ratio */ * numratios;
-
- unsigned desired_ratio = 0xffffffff;
- // We read 4 bytes per record, so the offset range is
- // 6 <= x <= 524286
- for (unsigned i = 0; i < numratios; ++i) {
- uint8_t xratio, yratio1, yratio2;
-
- if (!buf.Skip(1) ||
- !buf.ReadU8(&xratio) ||
- !buf.ReadU8(&yratio1) ||
- !buf.ReadU8(&yratio2))
- return false;
-
- // This either covers 1:1, or this is the default entry (0, 0, 0)
- if ((xratio == 1 && yratio1 <= 1 && yratio2 >= 1) ||
- (xratio == 0 && yratio1 == 0 && yratio2 == 0)) {
- desired_ratio = i;
- break;
- }
- }
-
- if (desired_ratio == 0xffffffff) {
- // no ratio found
- return false;
- }
-
- // Range 10 <= x <= 393216
- buf.set_offset(offset_table_offset + sizeof(uint16_t) * desired_ratio);
-
- // Now we read from the offset table to get the offset of another array
- uint16_t group_offset;
- if (!buf.ReadU16(&group_offset))
- return false;
- // Range 0 <= x <= 65535
- buf.set_offset(group_offset);
-
- uint16_t num_records;
- if (!buf.ReadU16(&num_records) ||
- !buf.Skip(sizeof(uint16_t)))
- return false;
-
- // We read 6 bytes per record, so the offset range is
- // 4 <= x <= 458749
- for (unsigned i = 0; i < num_records; ++i) {
- uint16_t pel_size;
- if (!buf.ReadU16(&pel_size))
- return false;
- // the entries are sorted, so we can abort early if need be
- if (pel_size > target_pelsize)
- return false;
-
- if (pel_size == target_pelsize) {
- int16_t t_ymax, t_ymin;
- if (!buf.ReadS16(&t_ymax) ||
- !buf.ReadS16(&t_ymin))
- return false;
- *ymin = t_ymin;
- *ymax = t_ymax;
- return true;
- } else {
- if (!buf.Skip(2 * sizeof(int16_t)))
- return false;
- }
- }
-
- return false;
-}
diff --git a/skia/sgl/SkGlyphCache.cpp b/skia/sgl/SkGlyphCache.cpp
index 9836c73..6b214df 100644
--- a/skia/sgl/SkGlyphCache.cpp
+++ b/skia/sgl/SkGlyphCache.cpp
@@ -328,18 +328,6 @@ const SkPath* SkGlyphCache::findPath(const SkGlyph& glyph) {
///////////////////////////////////////////////////////////////////////////////
-#ifdef SKIA_HARFBUZZ
-void SkGlyphCache::setupShaper(HB_ShaperItem* item) {
- fScalerContext->setupShaper(item);
-}
-
-void SkGlyphCache::releaseShaper(HB_ShaperItem* item) {
- fScalerContext->releaseShaper(item);
-}
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-
bool SkGlyphCache::getAuxProcData(void (*proc)(void*), void** dataPtr) const {
const AuxProcRec* rec = fAuxProcList;
while (rec) {
diff --git a/skia/sgl/SkGlyphCache.h b/skia/sgl/SkGlyphCache.h
index db9e8d5..2462ea5 100644
--- a/skia/sgl/SkGlyphCache.h
+++ b/skia/sgl/SkGlyphCache.h
@@ -27,7 +27,6 @@
class SkPaint;
class SkGlyphCache_Globals;
-typedef struct HB_ShaperItem_ HB_ShaperItem;
/** \class SkGlyphCache
@@ -87,16 +86,6 @@ public:
const SkPaint::FontMetrics& getFontMetricsY() const {
return fFontMetricsY;
}
-
-#ifdef SKIA_HARFBUZZ
- /** Setup a Harfbuzz shaper item with the correct |font| and |face| members.
- */
- void setupShaper(HB_ShaperItem* item);
- /** Release the given references associated with |item|.
- */
- void releaseShaper(HB_ShaperItem* item);
-#endif
-
/* AuxProc/Data allow a client to associate data with this cache entry.
Multiple clients can use this, as their data is keyed with a function
diff --git a/skia/sgl/SkPaint.cpp b/skia/sgl/SkPaint.cpp
index 5fc1f14..bb6b31e 100644
--- a/skia/sgl/SkPaint.cpp
+++ b/skia/sgl/SkPaint.cpp
@@ -365,18 +365,6 @@ int SkPaint::textToGlyphs(const void* textData, size_t byteLength,
return gptr - glyphs;
}
-#ifdef SKIA_HARFBUZZ
-void SkPaint::setupShaper(HB_ShaperItem* item) {
- SkAutoGlyphCache autoCache(*this, NULL);
- autoCache.getCache()->setupShaper(item);
-}
-
-void SkPaint::releaseShaper(HB_ShaperItem* item) {
- SkAutoGlyphCache autoCache(*this, NULL);
- autoCache.getCache()->releaseShaper(item);
-}
-#endif
-
///////////////////////////////////////////////////////////////////////////////
static uint32_t sk_glyphID_next(const char** text)
diff --git a/skia/skia.gyp b/skia/skia.gyp
index 568e4e8..ae3cc55 100644
--- a/skia/skia.gyp
+++ b/skia/skia.gyp
@@ -466,7 +466,6 @@
#'ports/SkFontHost_linux.cpp',
#'ports/SkFontHost_mac.cpp',
'ports/SkFontHost_none.cpp',
- 'ports/SkFontHost_TrueType_Tables.cpp',
#'ports/SkFontHost_win.cpp',
'ports/SkGlobals_global.cpp',
'ports/SkImageDecoder_Factory.cpp',
@@ -674,7 +673,6 @@
'sources/': [ ['exclude', '_linux\\.(cc|cpp)$'] ],
'sources!': [
'ports/SkFontHost_FreeType.cpp',
- 'ports/SkFontHost_TryeType_Tables.cpp',
'ports/SkFontHost_gamma_none.cpp',
'ports/SkFontHost_fontconfig.cpp',
'ports/SkFontHost_tables.cpp',
@@ -704,14 +702,6 @@
'ports/SkFontHost_none.cpp',
'sgl/SkTypeface_fake.cpp',
],
- 'defines': [
- 'SKIA_HARFBUZZ',
- ],
- 'direct_dependent_settings': {
- 'defines': [
- 'SKIA_HARFBUZZ',
- ],
- },
'export_dependent_settings': [
'../third_party/harfbuzz/harfbuzz.gyp:harfbuzz',
'../third_party/harfbuzz/harfbuzz.gyp:harfbuzz_interface',
@@ -725,7 +715,6 @@
[ 'OS == "win"', {
'sources!': [
'images/SkMMapStream.cpp',
- 'ports/SkFontHost_TrueType_Tables.cpp',
'ports/SkThread_pthread.cpp',
'ports/SkTime_Unix.cc',
],