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..5e8378f4d5892874359e718e414a681817912d25 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,36 @@ 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()), |
Ilya Kulshin
2016/06/21 15:43:42
I'm not familiar with how harfbuzz handles object
drott
2016/06/22 07:19:48
Thanks for pointing that out. The hb_face_create()
|
+ typefaceStream->getLength(), |
+ HB_MEMORY_MODE_READONLY, |
+ typefaceStream, |
+ deleteTypefaceStream), |
+ hb_blob_destroy); |
+ face = hb_face_create(faceBlob.get(), 0); |
+ } |
+ |
+ // Fallback to table copies if there is no in-memory access. |
+ face = hb_face_create_for_tables(harfBuzzSkiaGetTable, m_platformData->typeface(), 0); |
Ilya Kulshin
2016/06/21 15:43:42
Doesn't this always overwrite |face| and ignore th
drott
2016/06/22 07:19:48
Oups, yes, my bad. There was an "if (face)" in my
|
#endif |
ASSERT(face); |
return face; |