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

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

Issue 1397423004: Improve shaping segmentation for grapheme cluster based font fallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge TestExpectations with the HarfBuzz rebaselines Created 5 years, 2 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
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 9dcf816d9abab7fe1288fbb4f16d9d5a1ddfc34d..946d9037845e3908a946363c0f709b7d5877e998 100644
--- a/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp
+++ b/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp
@@ -112,10 +112,12 @@ HarfBuzzFace::~HarfBuzzFace()
}
struct HarfBuzzFontData {
- HarfBuzzFontData(WTF::HashMap<uint32_t, uint16_t>* glyphCacheForFaceCacheEntry, hb_face_t* face)
+ HarfBuzzFontData(WTF::HashMap<uint32_t, uint16_t>* glyphCacheForFaceCacheEntry, hb_face_t* face, unsigned rangeFrom, unsigned rangeTo)
: m_glyphCacheForFaceCacheEntry(glyphCacheForFaceCacheEntry)
, m_face(face)
, m_hbOpenTypeFont(nullptr)
+ , m_rangeFrom(rangeFrom)
+ , m_rangeTo(rangeTo)
{ }
~HarfBuzzFontData()
@@ -129,6 +131,8 @@ struct HarfBuzzFontData {
WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry;
hb_face_t* m_face;
hb_font_t* m_hbOpenTypeFont;
+ unsigned m_rangeFrom;
+ unsigned m_rangeTo;
};
static hb_position_t SkiaScalarToHarfBuzzPosition(SkScalar value)
@@ -175,6 +179,10 @@ static hb_bool_t harfBuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin
{
HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData);
+ RELEASE_ASSERT(hbFontData);
+ if (unicode < hbFontData->m_rangeFrom || unicode > hbFontData->m_rangeTo)
+ return false;
+
if (variationSelector) {
#if !HB_VERSION_ATLEAST(0, 9, 28)
return false;
@@ -338,9 +346,9 @@ hb_face_t* HarfBuzzFace::createFace()
return face;
}
-hb_font_t* HarfBuzzFace::createFont() const
+hb_font_t* HarfBuzzFace::createFont(unsigned rangeFrom, unsigned rangeTo) const
{
- HarfBuzzFontData* hbFontData = new HarfBuzzFontData(m_glyphCacheForFaceCacheEntry, m_face);
+ HarfBuzzFontData* hbFontData = new HarfBuzzFontData(m_glyphCacheForFaceCacheEntry, m_face, rangeFrom, rangeTo);
m_platformData->setupPaint(&hbFontData->m_paint);
hbFontData->m_simpleFontData = FontCache::fontCache()->fontDataFromFontPlatformData(m_platformData);
ASSERT(hbFontData->m_simpleFontData);

Powered by Google App Engine
This is Rietveld 408576698