Changing the font in the generated JavaDocs

Nir Lisker nlisker at gmail.com
Sat Jul 20 20:37:18 UTC 2019


Hi Jon,

Thanks for the answer. Iv'e narrowed down the issue to the DejaVu font not
being loaded, so it falls back to Georgia. Inside the 'resources' directory
where the docs are generated there should be a 'fonts' directory with a
'dejavu.css' file. This exists in OpenJDK, but not in OpenJFX. I tried to
manually take that stylesheet and put it there, but then the webpage
generates errors about not finding the fonts:

Failed to load resource: net::ERR_FILE_NOT_FOUND
  DejaVuSans-webfont.woff:1
Failed to load resource: net::ERR_FILE_NOT_FOUND
DejaVuSans-Bold-webfont.woff:1
etc.

Maybe the task for generating the docs in OpenJFX, 'gradle javadoc', is
missing some resources.

I filed https://bugs.openjdk.java.net/browse/JDK-8227767. Is this something
you can help with?

- Nir

On Fri, Jul 19, 2019 at 5:37 PM Jonathan Gibbons <
jonathan.gibbons at oracle.com> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/javadoc-dev/attachments/20190720/cc2aa821/attachment.html>


More information about the javadoc-dev mailing list