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

Unified Diff: Source/core/rendering/InlineTextBox.cpp

Issue 147703002: Calculate Underline thickness from Font (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding Test cases in TestExpectations Created 6 years, 10 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/core/rendering/InlineTextBox.cpp
diff --git a/Source/core/rendering/InlineTextBox.cpp b/Source/core/rendering/InlineTextBox.cpp
index 063cb06b341189f36ebc98d5ad82e8954c3998a2..d36b8b4c49f6af4c5c4e2853ac0735c81c511ac1 100644
--- a/Source/core/rendering/InlineTextBox.cpp
+++ b/Source/core/rendering/InlineTextBox.cpp
@@ -1084,7 +1084,13 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint&
size_t shadowCount = shadowList ? shadowList->shadows().size() : 0;
// Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px.
// Using computedFontSize should take care of zoom as well.
- const float textDecorationThickness = std::max(1.f, styleToUse->computedFontSize() / 10.f);
+
+ // Update Underline thickness, in case we have Faulty Font Metrics calculating underline thickness by old method.
+ float textDecorationThickness = styleToUse->fontMetrics().underlineThickness();
+ int fontHeightInt = (int)(styleToUse->fontMetrics().floatHeight() + 0.5);
+ if ((textDecorationThickness == 0.f) || (textDecorationThickness >= (fontHeightInt >> 1)))
+ textDecorationThickness = std::max(1.f, styleToUse->computedFontSize() / 10.f);
+
context->setStrokeThickness(textDecorationThickness);
float extraOffset = 0;

Powered by Google App Engine
This is Rietveld 408576698