| Index: third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
|
| diff --git a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
|
| index ba858b4b7453f5a7dd24d171424b035ca9e80fbc..beb0a4b793c2fc33c418bb1a119dc7e91f1602ce 100644
|
| --- a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
|
| +++ b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
|
| @@ -62,10 +62,12 @@ SimpleFontData::SimpleFontData(const FontPlatformData& platform_data,
|
| : max_char_width_(-1),
|
| avg_char_width_(-1),
|
| platform_data_(platform_data),
|
| - is_text_orientation_fallback_(is_text_orientation_fallback),
|
| vertical_data_(nullptr),
|
| + custom_font_data_(std::move(custom_data)),
|
| + is_text_orientation_fallback_(is_text_orientation_fallback),
|
| has_vertical_glyphs_(false),
|
| - custom_font_data_(std::move(custom_data)) {
|
| + visual_overflow_inflation_for_ascent_(0),
|
| + visual_overflow_inflation_for_descent_(0) {
|
| PlatformInit(subpixel_ascent_descent);
|
| PlatformGlyphInit();
|
| if (platform_data.IsVerticalAnyUpright() && !is_text_orientation_fallback) {
|
| @@ -78,9 +80,11 @@ SimpleFontData::SimpleFontData(const FontPlatformData& platform_data,
|
| SimpleFontData::SimpleFontData(const FontPlatformData& platform_data,
|
| PassRefPtr<OpenTypeVerticalData> vertical_data)
|
| : platform_data_(platform_data),
|
| - is_text_orientation_fallback_(false),
|
| vertical_data_(vertical_data),
|
| - has_vertical_glyphs_(false) {}
|
| + is_text_orientation_fallback_(false),
|
| + has_vertical_glyphs_(false),
|
| + visual_overflow_inflation_for_ascent_(0),
|
| + visual_overflow_inflation_for_descent_(0) {}
|
|
|
| void SimpleFontData::PlatformInit(bool subpixel_ascent_descent) {
|
| if (!platform_data_.size()) {
|
| @@ -134,30 +138,37 @@ void SimpleFontData::PlatformInit(bool subpixel_ascent_descent) {
|
| if (is_vdmx_valid) {
|
| ascent = vdmx_ascent;
|
| descent = -vdmx_descent;
|
| - } else {
|
| + } else if (subpixel_ascent_descent &&
|
| + (-metrics.fAscent < 3 ||
|
| + -metrics.fAscent + metrics.fDescent < 2)) {
|
| // For tiny fonts, the rounding of fAscent and fDescent results in equal
|
| // baseline for different types of text baselines (crbug.com/338908).
|
| // Please see CanvasRenderingContext2D::getFontBaseline for the heuristic.
|
| - if (subpixel_ascent_descent &&
|
| - (-metrics.fAscent < 3 || -metrics.fAscent + metrics.fDescent < 2)) {
|
| - ascent = -metrics.fAscent;
|
| - descent = metrics.fDescent;
|
| - } else {
|
| - ascent = SkScalarRoundToScalar(-metrics.fAscent);
|
| - descent = SkScalarRoundToScalar(metrics.fDescent);
|
| - }
|
| + ascent = -metrics.fAscent;
|
| + descent = metrics.fDescent;
|
| + } else {
|
| + ascent = SkScalarRoundToScalar(-metrics.fAscent);
|
| + descent = SkScalarRoundToScalar(metrics.fDescent);
|
| +
|
| + if (ascent < -metrics.fAscent)
|
| + visual_overflow_inflation_for_ascent_ = 1;
|
| + if (descent < metrics.fDescent) {
|
| + visual_overflow_inflation_for_descent_ = 1;
|
| #if OS(LINUX) || OS(ANDROID)
|
| - // When subpixel positioning is enabled, if the descent is rounded down, the
|
| - // descent part of the glyph may be truncated when displayed in a 'overflow:
|
| - // hidden' container. To avoid that, borrow 1 unit from the ascent when
|
| - // possible.
|
| - // FIXME: This can be removed if sub-pixel ascent/descent is supported.
|
| - if (PlatformData().GetFontRenderStyle().use_subpixel_positioning &&
|
| - descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) {
|
| - ++descent;
|
| - --ascent;
|
| - }
|
| + // When subpixel positioning is enabled, if the descent is rounded down,
|
| + // the descent part of the glyph may be truncated when displayed in a
|
| + // 'overflow: hidden' container. To avoid that, borrow 1 unit from the
|
| + // ascent when possible.
|
| + if (PlatformData().GetFontRenderStyle().use_subpixel_positioning &&
|
| + ascent >= 1) {
|
| + ++descent;
|
| + --ascent;
|
| + // We should inflate overflow 1 more pixel for ascent instead.
|
| + visual_overflow_inflation_for_descent_ = 0;
|
| + ++visual_overflow_inflation_for_ascent_;
|
| + }
|
| #endif
|
| + }
|
| }
|
|
|
| #if OS(MACOSX)
|
|
|