RFR: JDK-8288671: Problematic fix for font boosting
Hannes Wallnöfer
hannesw at openjdk.org
Mon Jun 20 17:55:07 UTC 2022
Please review an important CSS-only fix for the output generated by JavaDoc.
Various mobile browsers have a feature called "font boosting" or "text inflation" to selectively increase the font size of parts of the page to make them easier to read. Since javadoc-generated pages have a `<meta name="viewport" content="width=device-width, initial-scale=1">` declaration that is not really needed, but especially Chrome on Android is very stubborn and insists on changing font sizes in an unpredictable way.
It seems like the only way to prevent Chrome/Android from doing this is to include a `min-height` CSS property. In JDK-8277420 we therefore included the CSS declaration shown below to avoid headers from changing font size when the copy-to-clipboard button is shown:
/* Disable font boosting */
h1, h2, h3, h4, h5, h6 {
max-height: 2em;
}
The idea was that a max-height of `2em` would be enough for how headers are displayed in our docs, but of course I didn't consider wrapped headers. In fact, the main header of the index page is often wrapped twice on small browsers/devices, resulting in the header overlapping with the first paragraph:

Font boosting also occurs in member signatures where some parts are displayed with bigger fonts than others. This is less obvious than the other cases, but it should also be fixed:

The proposed fix is to use a very high `max-height` value that is far beyond actual height values, and to include member signatures in the CSS selector.
This fixes the problems in the screenshots above in Chrome/Android as shown in the screenshots below. It does not have any effects in other browsers.

Fixed index page

Fixed member signature
-------------
Commit messages:
- JDK-8288671: Problematic fix for font boosting
Changes: https://git.openjdk.org/jdk19/pull/48/files
Webrev: https://webrevs.openjdk.org/?repo=jdk19&pr=48&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8288671
Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk19/pull/48.diff
Fetch: git fetch https://git.openjdk.org/jdk19 pull/48/head:pull/48
PR: https://git.openjdk.org/jdk19/pull/48
More information about the javadoc-dev
mailing list