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

Unified Diff: Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 1239513004: Change fallback font collection in HarfBuzzShaper (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Kill _ALL_ the new lines Created 5 years, 5 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: Source/platform/fonts/shaping/HarfBuzzShaper.cpp
diff --git a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
index a19cb91cf4c3e50adb823b9b647270446d8542a5..f6846d3764a540d4cca0f149719e381949aef115 100644
--- a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
+++ b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
@@ -484,6 +484,15 @@ int ShapeResult::offsetForPosition(float targetX)
return charactersSoFar;
}
+void ShapeResult::fallbackFonts(HashSet<const SimpleFontData*>* fallback) const
+{
+ ASSERT(fallback);
+ for (unsigned i = 0; i < m_runs.size(); ++i) {
+ if (m_runs[i]->m_fontData != m_primaryFont)
+ fallback->add(m_runs[i]->m_fontData);
+ }
+}
+
unsigned ShapeResult::numberOfRunsForTesting() const
{
return m_runs.size();
@@ -592,17 +601,13 @@ static void normalizeCharacters(const TextRun& run, unsigned length, UChar* dest
}
}
-HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run,
- HashSet<const SimpleFontData*>* fallbackFonts)
- : Shaper(font, run, nullptr, fallbackFonts)
+HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run)
+ : Shaper(font, run)
, m_normalizedBufferLength(0)
, m_wordSpacingAdjustment(font->fontDescription().wordSpacing())
, m_letterSpacing(font->fontDescription().letterSpacing())
, m_expansionOpportunityCount(0)
{
- // TODO(eae): Once SimpleShaper is gone the ownership of this should shift
- // to HarfBuzzShaper.
- ASSERT(fallbackFonts);
m_normalizedBuffer = adoptArrayPtr(new UChar[m_textRun.length() + 1]);
normalizeCharacters(m_textRun, m_textRun.length(), m_normalizedBuffer.get(), &m_normalizedBufferLength);
setExpansion(m_textRun.expansion());
@@ -752,6 +757,7 @@ PassRefPtr<ShapeResult> HarfBuzzShaper::shapeResult()
ShapeResult* result = new ShapeResult();
result->m_numCharacters = m_normalizedBufferLength;
result->m_direction = m_textRun.direction();
+ result->m_primaryFont = m_font->primaryFont();
if (!shapeHarfBuzzRuns(result)) {
delete result;
@@ -974,8 +980,6 @@ void HarfBuzzShaper::addHarfBuzzRun(unsigned startCharacter,
{
ASSERT(endCharacter > startCharacter);
ASSERT(script != USCRIPT_INVALID_CODE);
- if (m_fallbackFonts)
- trackNonPrimaryFallbackFont(fontData);
return m_harfBuzzRuns.append(HarfBuzzRun::create(fontData,
startCharacter, endCharacter - startCharacter,
TextDirectionToHBDirection(m_textRun.direction(), m_font->fontDescription().orientation(), fontData),
@@ -1131,7 +1135,6 @@ void HarfBuzzShaper::shapeResult(ShapeResult* result, unsigned index,
run->m_width = totalAdvance > 0.0 ? totalAdvance : 0.0;
result->m_width += run->m_width;
- result->m_fallbackFonts = *m_fallbackFonts;
}
float HarfBuzzShaper::adjustSpacing(ShapeResult::RunInfo* run, size_t glyphIndex, unsigned currentCharacterIndex, float& offset, float& totalAdvance)
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.h ('k') | Source/platform/fonts/shaping/HarfBuzzShaperTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698