Chromium Code Reviews| Index: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp |
| diff --git a/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp b/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp |
| index 3dffa865fa78be278de638b8fbc22ff511942c9c..d8041c1e56000ec73dc36c3c138aef1e34ae3a59 100644 |
| --- a/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp |
| +++ b/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp |
| @@ -50,6 +50,7 @@ |
| #include <SkPath.h> |
| #include <SkPoint.h> |
| #include <SkRect.h> |
| +#include <SkStream.h> |
| #include <SkTypeface.h> |
| @@ -311,12 +312,37 @@ static hb_blob_t* harfBuzzSkiaGetTable(hb_face_t* face, hb_tag_t tag, void* user |
| } |
| #endif |
| +#if !OS(MACOSX) |
| +static void deleteTypefaceStream(void* streamAssetPtr) |
| +{ |
| + SkStreamAsset* streamAsset = reinterpret_cast<SkStreamAsset*>(streamAssetPtr); |
| + delete streamAsset; |
| +} |
| +#endif |
| + |
| hb_face_t* HarfBuzzFace::createFace() |
| { |
| #if OS(MACOSX) |
| hb_face_t* face = hb_coretext_face_create(m_platformData->cgFont()); |
| #else |
| - hb_face_t* face = hb_face_create_for_tables(harfBuzzSkiaGetTable, m_platformData->typeface(), 0); |
| + hb_face_t* face = nullptr; |
| + |
| + SkTypeface* typeface = m_platformData->typeface(); |
| + SkStreamAsset* typefaceStream = typeface->openStream(0); |
| + if (typefaceStream->getMemoryBase()) { |
| + std::unique_ptr<hb_blob_t, void(*)(hb_blob_t*)> faceBlob(hb_blob_create( |
| + reinterpret_cast<const char*>(typefaceStream->getMemoryBase()), |
| + typefaceStream->getLength(), |
| + HB_MEMORY_MODE_READONLY, |
| + typefaceStream, |
| + deleteTypefaceStream), |
| + hb_blob_destroy); |
| + face = hb_face_create(faceBlob.get(), 0); |
|
behdad
2016/06/23 13:27:36
Instead of 0, you need the TTC index of the face.
|
| + } |
| + |
| + // Fallback to table copies if there is no in-memory access. |
| + if (!face) |
| + face = hb_face_create_for_tables(harfBuzzSkiaGetTable, m_platformData->typeface(), 0); |
| #endif |
| ASSERT(face); |
| return face; |