Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp

Issue 2080243002: Access font tables in memory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not oversimplify fallback case Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698