Changing the font in the generated JavaDocs

Jonathan Gibbons jonathan.gibbons at oracle.com
Fri Jul 19 14:37:37 UTC 2019


Nir,

The only way to change the font is through the stylesheet(s).

If you don't want to edit the default stylesheet, you can specify 
additional stylesheets to be used on the command line. You can also 
replace the default stylesheet from the command line. Look for the 
--main-stylesheet and --add-stylesheet options.

$ /opt/jdk/11/bin/javadoc --help | grep style
     --add-stylesheet <file>
                   Additional stylesheet file for the generated 
documentation
     --main-stylesheet <file>, -stylesheetfile <file>
                   File to change style of the generated documentation

I'm not sure how detailed an answer you want with respect to 
OpenJDK-generated docs, but the high level answer is that it all happens 
in make/Docs.gmk.

The default stylesheet is in the source for the jdk.javadoc module:
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css

Here are the various lines related to the font-family:

     font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif;
     font-family:'DejaVu Sans Mono', monospace;
     font-family:'DejaVu Sans', Arial, Helvetica, sans-serif;
     font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif;

It's a minor code-style bug-ette that the first line has different 
whitespace. There should really only be 3 lines in that list, for serif, 
sans serif and monospace fonts.

-- Jon


On 7/16/19 6:21 PM, Nir Lisker wrote:
> Hi,
>
> I noticed that the font of the JDK docs is different than the ones we 
> get at OpenJFX. Compare 
> https://docs.oracle.com/en/java/javase/12/docs/api/index.html with 
> https://openjfx.io/javadoc/12/.
>
> I did not find a way to change the font except for messing with the 
> generated stylesheet (and there are a lot of definitions there). Is 
> there some flag I need to specify, or should I take the stylesheet 
> file from OpenJDK somewhere and replace ours? How do does OpenJDK 
> generate its docs?
>
> Thanks,
> Nir


More information about the javadoc-dev mailing list