From 5f1eba22e0aeb10624c099477549c87cab420914 Mon Sep 17 00:00:00 2001 From: igt0 Date: Sat, 16 Sep 2017 16:50:17 -0300 Subject: [PATCH] bug 23104 - Add a default line height compensation Many fonts have issues with their vertical metrics. they are used to influence the height of ascenders and depth of descenders. Gecko uses it to calculate the line height (font height + ascender + descender), however because of that idiosyncratic behavior across multiple operating systems, it can be used to identify the user's OS. The solution proposed in the patch uses a default factor to be multiplied with the font size, simulating the concept of ascender and descender. This way all operating systems will have the same line height. --- layout/generic/ReflowInput.cpp | 6 +++++- modules/libpref/init/all.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index 42f4a24..8c7d5ce 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -46,7 +46,8 @@ enum eNormalLineHeightControl { eUninitialized = -1, eNoExternalLeading = 0, // does not include external leading eIncludeExternalLeading, // use whatever value font vendor provides - eCompensateLeading // compensate leading if leading provided by font vendor is not enough + eCompensateLeading, // compensate leading if leading provided by font vendor is not enough + eTorLeading }; static eNormalLineHeightControl sNormalLineHeightControl = eUninitialized; @@ -2778,6 +2779,9 @@ GetNormalLineHeight(nsFontMetrics* aFontMetrics) else normalLineHeight = emHeight+ internalLeading + externalLeading; break; + case eTorLeading: + normalLineHeight = NSToCoordRound(emHeight * NORMAL_LINE_HEIGHT_FACTOR); + break; default: //case eNoExternalLeading: normalLineHeight = emHeight + internalLeading; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 57fbe69..b0d14c5 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -247,7 +247,8 @@ pref("browser.display.force_inline_alttext", false); // true = force ALT text fo // 0 = no external leading, // 1 = use external leading only when font provides, // 2 = add extra leading both internal leading and external leading are zero -pref("browser.display.normal_lineheight_calc_control", 2); +// 3 = Add internal leading +pref("browser.display.normal_lineheight_calc_control", 3); // enable showing image placeholders while image is loading or when image is broken pref("browser.display.show_image_placeholders", true); // if browser.display.show_image_placeholders is true then this controls whether the loading image placeholder and border is shown or not -- 2.7.4