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

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

Issue 986493002: Simplify text emphasis painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments Created 5 years, 9 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 | « Source/platform/fonts/shaping/Shaper.h ('k') | Source/platform/fonts/shaping/SimpleShaper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/shaping/Shaper.cpp
diff --git a/Source/platform/fonts/shaping/Shaper.cpp b/Source/platform/fonts/shaping/Shaper.cpp
index 6e97c922b7c138e75779fa51d2a4fc9c7b4f1d59..bee53773a6314f9c8b76b72f240db1fc15a222d6 100644
--- a/Source/platform/fonts/shaping/Shaper.cpp
+++ b/Source/platform/fonts/shaping/Shaper.cpp
@@ -31,11 +31,13 @@
#include "config.h"
#include "platform/fonts/shaping/Shaper.h"
+#include "platform/fonts/GlyphBuffer.h"
+#include "platform/fonts/GlyphPage.h"
#include "platform/text/TextRun.h"
namespace blink {
-Shaper::Shaper(const Font* font, const TextRun& run, ForTextEmphasisOrNot forTextEmphasis,
+Shaper::Shaper(const Font* font, const TextRun& run, const GlyphData* emphasisData,
HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds)
: m_font(font)
, m_run(run)
@@ -44,8 +46,32 @@ Shaper::Shaper(const Font* font, const TextRun& run, ForTextEmphasisOrNot forTex
, m_expansion(0)
, m_expansionPerOpportunity(0)
, m_isAfterExpansion(!run.allowsLeadingExpansion())
- , m_forTextEmphasis(forTextEmphasis)
+ , m_emphasisSubstitutionData(emphasisData)
{
+ if (emphasisData) {
+ ASSERT(emphasisData->fontData);
+ m_emphasisGlyphCenter = emphasisData->fontData->boundsForGlyph(emphasisData->glyph).center();
+ }
+}
+
+void Shaper::addEmphasisMark(GlyphBuffer* buffer, float midGlyphOffset) const
+{
+ ASSERT(buffer);
+ ASSERT(m_emphasisSubstitutionData);
+
+ const SimpleFontData* emphasisFontData = m_emphasisSubstitutionData->fontData;
+ ASSERT(emphasisFontData);
+
+ bool isVertical = emphasisFontData->platformData().orientation() == Vertical
+ && emphasisFontData->verticalData();
+
+ if (!isVertical) {
+ buffer->add(m_emphasisSubstitutionData->glyph, emphasisFontData,
+ midGlyphOffset - m_emphasisGlyphCenter.x());
+ } else {
+ buffer->add(m_emphasisSubstitutionData->glyph, emphasisFontData,
+ FloatPoint(-m_emphasisGlyphCenter.x(), midGlyphOffset - m_emphasisGlyphCenter.y()));
+ }
}
} // namespace blink
« no previous file with comments | « Source/platform/fonts/shaping/Shaper.h ('k') | Source/platform/fonts/shaping/SimpleShaper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698