8324774: Add DejaVu web fonts

8327385: Add JavaDoc option to exclude web fonts from generated documentation

Reviewed-by: ihse, jjg
This commit is contained in:
Hannes Wallnöfer 2024-03-27 12:20:55 +00:00
parent 37a5a08378
commit d0a265039a
38 changed files with 546 additions and 13 deletions

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -105,7 +105,7 @@ define SetupInterimModule
Standard.java, \ Standard.java, \
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java \ EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java \
$($1.interim_EXTRA_FILES), \ $($1.interim_EXTRA_FILES), \
COPY := .gif .png .xml .css .svg .js .js.template .txt javax.tools.JavaCompilerTool, \ COPY := .gif .png .xml .css .svg .js .js.template .txt .woff .woff2 javax.tools.JavaCompilerTool, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \ BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
DISABLED_WARNINGS := module options, \ DISABLED_WARNINGS := module options, \
JAVAC_FLAGS := \ JAVAC_FLAGS := \

View File

@ -27,4 +27,4 @@
# -Werror and all lint warnings enabled. In particular, # -Werror and all lint warnings enabled. In particular,
# DISABLED_WARNINGS_java should not be augmented. # DISABLED_WARNINGS_java should not be augmented.
COPY += .xml .css .svg .js .js.template .png .txt COPY += .xml .css .svg .js .js.template .png .txt .woff .woff2

View File

@ -25,8 +25,11 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import java.io.BufferedReader;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.file.DirectoryStream; import java.nio.file.DirectoryStream;
@ -42,6 +45,8 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.function.Function; import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
import javax.lang.model.element.ModuleElement; import javax.lang.model.element.ModuleElement;
@ -303,9 +308,13 @@ public class HtmlDoclet extends AbstractDoclet {
w.buildPage(); w.buildPage();
} }
if (!options.noFonts()) {
copyFontResources();
}
// If a stylesheet file is not specified, copy the default stylesheet // If a stylesheet file is not specified, copy the default stylesheet
// and replace newline with platform-specific newline. // and replace newline with platform-specific newline.
if (options.stylesheetFile().length() == 0) { if (options.stylesheetFile().isEmpty()) {
copyResource(DocPaths.STYLESHEET, DocPaths.RESOURCE_FILES.resolve(DocPaths.STYLESHEET), true); copyResource(DocPaths.STYLESHEET, DocPaths.RESOURCE_FILES.resolve(DocPaths.STYLESHEET), true);
} }
copyResource(DocPaths.SCRIPT_JS_TEMPLATE, DocPaths.SCRIPT_FILES.resolve(DocPaths.SCRIPT_JS), true); copyResource(DocPaths.SCRIPT_JS_TEMPLATE, DocPaths.SCRIPT_FILES.resolve(DocPaths.SCRIPT_JS), true);
@ -453,6 +462,31 @@ public class HtmlDoclet extends AbstractDoclet {
} }
} }
private void copyFontResources() throws DocletException {
DocPath cssPath = DocPaths.FONTS.resolve(DocPaths.DEJAVU_CSS);
copyResource(cssPath, DocPaths.RESOURCE_FILES.resolve(cssPath), true);
try {
// Extract font file names from CSS file
URL cssURL = HtmlConfiguration.class.getResource(DocPaths.RESOURCES.resolve(cssPath).getPath());
Pattern pattern = Pattern.compile("DejaVu[-\\w]+\\.\\w+");
try (InputStream in = cssURL.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
String line;
while ((line = reader.readLine()) != null) {
Matcher m = pattern.matcher(line);
if (m.find()) {
DocPath fontPath = DocPaths.FONTS.resolve(m.group());
copyResource(fontPath, DocPaths.RESOURCE_FILES.resolve(fontPath), false);
}
}
}
} catch (IOException e) {
throw new ResourceIOException(cssPath, e);
}
}
private void copyFile(String filename, DocPath targetPath) throws DocFileIOException { private void copyFile(String filename, DocPath targetPath) throws DocFileIOException {
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;

View File

@ -0,0 +1,104 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
*/
/* DejaVu fonts v2.37 */
@font-face {
font-family: 'DejaVu Sans Mono';
src: url('DejaVuLGCSansMono.woff2') format('woff2'),
url('DejaVuLGCSansMono.woff') format('woff');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'DejaVu Sans Mono';
src: url('DejaVuLGCSansMono-Oblique.woff2') format('woff2'),
url('DejaVuLGCSansMono-Oblique.woff') format('woff');
font-weight: normal;
font-style: italic;
}
@font-face {
font-family: 'DejaVu Sans Mono';
src: url('DejaVuLGCSansMono-Bold.woff2') format('woff2'),
url('DejaVuLGCSansMono-Bold.woff') format('woff');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'DejaVu Sans Mono';
src: url('DejaVuLGCSansMono-BoldOblique.woff2') format('woff2'),
url('DejaVuLGCSansMono-BoldOblique.woff') format('woff');
font-weight: bold;
font-style: italic;
}
@font-face {
font-family: 'DejaVu Sans';
src: url('DejaVuLGCSans.woff2') format('woff2'),
url('DejaVuLGCSans.woff') format('woff');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'DejaVu Sans';
src: url('DejaVuLGCSans-Oblique.woff2') format('woff2'),
url('DejaVuLGCSans-Oblique.woff') format('woff');
font-weight: normal;
font-style: italic;
}
@font-face {
font-family: 'DejaVu Sans';
src: url('DejaVuLGCSans-Bold.woff2') format('woff2'),
url('DejaVuLGCSans-Bold.woff') format('woff');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'DejaVu Sans';
src: url('DejaVuLGCSans-BoldOblique.woff2') format('woff2'),
url('DejaVuLGCSans-BoldOblique.woff') format('woff');
font-weight: bold;
font-style: italic;
}
@font-face {
font-family: 'DejaVu Serif';
src: url('DejaVuLGCSerif.woff2') format('woff2'),
url('DejaVuLGCSerif.woff') format('woff');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'DejaVu Serif';
src: url('DejaVuLGCSerif-Italic.woff2') format('woff2'),
url('DejaVuLGCSerif-Italic.woff') format('woff');
font-weight: normal;
font-style: italic;
}
@font-face {
font-family: 'DejaVu Serif';
src: url('DejaVuLGCSerif-Bold.woff2') format('woff2'),
url('DejaVuLGCSerif-Bold.woff') format('woff');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'DejaVu Serif';
src: url('DejaVuLGCSerif-BoldItalic.woff2') format('woff2'),
url('DejaVuLGCSerif-BoldItalic.woff') format('woff');
font-weight: bold;
font-style: italic;
}

View File

@ -573,6 +573,9 @@ doclet.usage.nocomment.description=\
doclet.usage.nodeprecated.description=\ doclet.usage.nodeprecated.description=\
Do not include @deprecated information Do not include @deprecated information
doclet.usage.no-fonts.description=\
Do not include standard web fonts in generated documentation
doclet.usage.noqualifier.parameters=\ doclet.usage.noqualifier.parameters=\
<name1>,<name2>,... <name1>,<name2>,...
doclet.usage.noqualifier.description=\ doclet.usage.noqualifier.description=\

View File

@ -208,6 +208,13 @@ public abstract class BaseOptions {
*/ */
private boolean noDeprecated = false; private boolean noDeprecated = false;
/**
* Argument for command-line option {@code --no-fonts}.
* True if command-line option {@code --no-fonts} is used and font files
* should not be included in generated documentation. Default value is false.
*/
private boolean noFonts = false;
/** /**
* Argument for command-line option {@code --no-platform-links}. * Argument for command-line option {@code --no-platform-links}.
* True if command-line option "--no-platform-links" is used. Default value is * True if command-line option "--no-platform-links" is used. Default value is
@ -481,6 +488,14 @@ public abstract class BaseOptions {
} }
}, },
new Option(resources, "--no-fonts") {
@Override
public boolean process(String opt, List<String> args) {
noFonts = true;
return true;
}
},
new Option(resources, "-nosince") { new Option(resources, "-nosince") {
@Override @Override
public boolean process(String opt, List<String> args) { public boolean process(String opt, List<String> args) {
@ -889,6 +904,15 @@ public abstract class BaseOptions {
return noDeprecated; return noDeprecated;
} }
/**
* Argument for command-line option {@code --no-fonts}.
* True if command-line option {@code --no-fonts"} is used.
* Default value is false.
*/
public boolean noFonts() {
return noFonts;
}
/** /**
* Argument for command-line option {@code --no-platform-links}. * Argument for command-line option {@code --no-platform-links}.
* True if command-line option {@code --no-platform-links"} is used. * True if command-line option {@code --no-platform-links"} is used.

View File

@ -67,6 +67,12 @@ public class DocPaths {
/** The name of the file for all references to external specifications. */ /** The name of the file for all references to external specifications. */
public static final DocPath EXTERNAL_SPECS = DocPath.create("external-specs.html"); public static final DocPath EXTERNAL_SPECS = DocPath.create("external-specs.html");
/** The name of the sub-directory containing font resources. */
public static final DocPath FONTS = DocPath.create("fonts");
/** The name of the DejaVu web fonts CSS file. */
public static final DocPath DEJAVU_CSS = DocPath.create("dejavu.css");
/** The name of the image file showing a magnifying glass on the search box. */ /** The name of the image file showing a magnifying glass on the search box. */
public static final DocPath GLASS_IMG = DocPath.create("glass.png"); public static final DocPath GLASS_IMG = DocPath.create("glass.png");

View File

@ -0,0 +1,191 @@
## DejaVu fonts v2.37
### DejaVu License
<pre>
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
Bitstream Vera Fonts Copyright
------------------------------
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:
The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".
This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.
The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.
Arev Fonts Copyright
------------------------------
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:
The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.
The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".
This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.
The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.
TeX Gyre DJV Math
-----------------
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Math extensions done by B. Jackowski, P. Strzelczyk and P. Pianowski
(on behalf of TeX users groups) are in public domain.
Letters imported from Euler Fraktur from AMSfonts are (c) American
Mathematical Society (see below).
Bitstream Vera Fonts Copyright
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera
is a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation
files (the "Font Software"), to reproduce and distribute the Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute,
and/or sell copies of the Font Software, and to permit persons to whom
the Font Software is furnished to do so, subject to the following
conditions:
The above copyright and trademark notices and this permission notice
shall be
included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional
glyphs or characters may be added to the Fonts, only if the fonts are
renamed
to names not containing either the words "Bitstream" or the word "Vera".
This License becomes null and void to the extent applicable to Fonts or
Font Software
that has been modified and is distributed under the "Bitstream Vera"
names.
The Font Software may be sold as part of a larger software package but
no copy
of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL,
SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN
ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR
INABILITY TO USE
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the names of GNOME, the GNOME
Foundation,
and Bitstream Inc., shall not be used in advertising or otherwise to promote
the sale, use or other dealings in this Font Software without prior written
authorization from the GNOME Foundation or Bitstream Inc., respectively.
For further information, contact: fonts at gnome dot org.
AMSFonts (v. 2.2) copyright
The PostScript Type 1 implementation of the AMSFonts produced by and
previously distributed by Blue Sky Research and Y&Y, Inc. are now freely
available for general use. This has been accomplished through the
cooperation
of a consortium of scientific publishers with Blue Sky Research and Y&Y.
Members of this consortium include:
Elsevier Science IBM Corporation Society for Industrial and Applied
Mathematics (SIAM) Springer-Verlag American Mathematical Society (AMS)
In order to assure the authenticity of these fonts, copyright will be
held by
the American Mathematical Society. This is not meant to restrict in any way
the legitimate use of the fonts, such as (but not limited to) electronic
distribution of documents containing these fonts, inclusion of these fonts
into other public domain or commercial font collections or computer
applications, use of the outline data to create derivative fonts and/or
faces, etc. However, the AMS does require that the AMS copyright notice be
removed from any derivative versions of the fonts which have been altered in
any way. In addition, to ensure the fidelity of TeX documents using Computer
Modern fonts, Professor Donald Knuth, creator of the Computer Modern faces,
has requested that any alterations which yield different font metrics be
given a different name.
</pre>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8293177 * @bug 8293177 8324774
* @summary Verify version numbers in legal files * @summary Verify version numbers in legal files
* @library /test/lib * @library /test/lib
* @build jtreg.SkippedException * @build jtreg.SkippedException
@ -47,15 +47,16 @@ import jtreg.SkippedException;
public class CheckLibraryVersions { public class CheckLibraryVersions {
static class SourceDirNotFound extends Error {} static class SourceDirNotFound extends Error {}
// Regex pattern for library name and version in legal Markdown file // Regex pattern for library name and version in legal Markdown file
static final Pattern versionPattern = Pattern.compile("## ([\\w\\s]+) v(\\d+\\.\\d+\\.\\d+)"); static final Pattern versionPattern = Pattern.compile("## ([\\w\\s]+) v(\\d+(\\.\\d+){1,2})");
// Map of 3rd party libraries. The keys are the names of files in the legal directory, // Map of 3rd party libraries. The keys are the names of files in the legal directory,
// the values are lists of templates for library files with the following placeholders: // the values are lists of templates for library files with the following placeholders:
// %V is replaced with the version string // %V is replaced with the version string
// %M is replaced twice, once with an empty string and once with ".min" // %M is replaced twice, once with an empty string and once with ".min"
static final Map<String, List<String>> libraries = Map.of( static final Map<String, List<String>> libraries = Map.of(
"jquery.md", List.of("jquery-%V%M.js"), "jquery.md", List.of("jquery/jquery-%V%M.js"),
"jqueryUI.md", List.of("jquery-ui%M.js", "jquery-ui%M.css") "jqueryUI.md", List.of("jquery/jquery-ui%M.js", "jquery/jquery-ui%M.css"),
"dejavufonts.md", List.of("fonts/dejavu.css")
); );
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
@ -73,7 +74,7 @@ public class CheckLibraryVersions {
var legalDir = rootDir.resolve("src/jdk.javadoc/share/legal"); var legalDir = rootDir.resolve("src/jdk.javadoc/share/legal");
var scriptDir = rootDir.resolve("src/jdk.javadoc/share/classes") var scriptDir = rootDir.resolve("src/jdk.javadoc/share/classes")
.resolve("jdk/javadoc/internal/doclets/formats/html") .resolve("jdk/javadoc/internal/doclets/formats/html")
.resolve("resources/jquery"); .resolve("resources");
for (var legalFileName : libraries.keySet()) { for (var legalFileName : libraries.keySet()) {
var legalFile = legalDir.resolve(legalFileName); var legalFile = legalDir.resolve(legalFileName);

View File

@ -0,0 +1,120 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8324774 8327385
* @summary Add DejaVu web fonts
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
* @build toolbox.ToolBox javadoc.tester.*
* @run main TestFonts
*/
import java.io.IOException;
import java.nio.file.Path;
import javadoc.tester.JavadocTester;
import toolbox.ToolBox;
public class TestFonts extends JavadocTester {
public static void main(String... args) throws Exception {
var tester = new TestFonts();
tester.setup().runTests();
}
private final ToolBox tb = new ToolBox();
Path src;
TestFonts setup() throws IOException {
src = Path.of("src");
tb.writeJavaFiles(src, """
/**
* Simple dummy class.
*/
public class Dummy {}
""");
return this;
}
@Test
public void testFonts(Path base) throws Exception {
setUseDefaultOptions(false);
javadoc("-d", base.resolve("out").toString(),
src.resolve("Dummy.java").toString());
checkExit(Exit.OK);
checkOutput("resource-files/fonts/dejavu.css", true,
"""
/* DejaVu fonts v2.37 */""",
"""
@font-face {
font-family: 'DejaVu Sans Mono';
src: url('DejaVuLGCSansMono.woff2') format('woff2'),
url('DejaVuLGCSansMono.woff') format('woff');
font-weight: normal;
font-style: normal;
}""");
checkFiles(true,
"resource-files/fonts/DejaVuLGCSans-Bold.woff",
"resource-files/fonts/DejaVuLGCSans-Bold.woff2",
"resource-files/fonts/DejaVuLGCSans-BoldOblique.woff",
"resource-files/fonts/DejaVuLGCSans-BoldOblique.woff2",
"resource-files/fonts/DejaVuLGCSans-Oblique.woff",
"resource-files/fonts/DejaVuLGCSans-Oblique.woff2",
"resource-files/fonts/DejaVuLGCSans.woff",
"resource-files/fonts/DejaVuLGCSans.woff2",
"resource-files/fonts/DejaVuLGCSansMono-Bold.woff",
"resource-files/fonts/DejaVuLGCSansMono-Bold.woff2",
"resource-files/fonts/DejaVuLGCSansMono-BoldOblique.woff",
"resource-files/fonts/DejaVuLGCSansMono-BoldOblique.woff2",
"resource-files/fonts/DejaVuLGCSansMono-Oblique.woff",
"resource-files/fonts/DejaVuLGCSansMono-Oblique.woff2",
"resource-files/fonts/DejaVuLGCSansMono.woff",
"resource-files/fonts/DejaVuLGCSansMono.woff2",
"resource-files/fonts/DejaVuLGCSerif-Bold.woff",
"resource-files/fonts/DejaVuLGCSerif-Bold.woff2",
"resource-files/fonts/DejaVuLGCSerif-BoldItalic.woff",
"resource-files/fonts/DejaVuLGCSerif-BoldItalic.woff2",
"resource-files/fonts/DejaVuLGCSerif-Italic.woff",
"resource-files/fonts/DejaVuLGCSerif-Italic.woff2",
"resource-files/fonts/DejaVuLGCSerif.woff",
"resource-files/fonts/DejaVuLGCSerif.woff2");
}
@Test
public void testNoFontsOption(Path base) throws Exception {
setUseDefaultOptions(false);
javadoc("-d", base.resolve("out").toString(),
"--no-fonts",
src.resolve("Dummy.java").toString());
checkExit(Exit.OK);
checkFiles(true, "resource-files/copy.svg",
"resource-files/glass.png",
"resource-files/jquery-ui.min.css",
"resource-files/link.svg",
"resource-files/stylesheet.css",
"resource-files/x.png");
checkFiles(false, "resource-files/fonts");
}
}

View File

@ -168,6 +168,9 @@ public abstract class JavadocTester {
/** The output charset used in the most recent call of javadoc. */ /** The output charset used in the most recent call of javadoc. */
protected Charset charset = Charset.defaultCharset(); protected Charset charset = Charset.defaultCharset();
/** Default options used when running javadoc with the standard doclet. */
private final String[] defaultOptions = {"--no-fonts"};
/** The exit code of the most recent call of javadoc. */ /** The exit code of the most recent call of javadoc. */
private int exitCode; private int exitCode;
@ -249,6 +252,7 @@ public abstract class JavadocTester {
private boolean automaticCheckLinks = true; private boolean automaticCheckLinks = true;
private boolean automaticCheckUniqueOUT = true; private boolean automaticCheckUniqueOUT = true;
private boolean automaticCheckNoStacktrace = true; private boolean automaticCheckNoStacktrace = true;
private boolean useDefaultOptions = true;
private boolean useStandardStreams = false; private boolean useStandardStreams = false;
private StandardJavaFileManager fileManager = null; private StandardJavaFileManager fileManager = null;
@ -486,6 +490,7 @@ public abstract class JavadocTester {
String docencodingArg = null; String docencodingArg = null;
String encodingArg = null; String encodingArg = null;
boolean haveSourcePath = false; boolean haveSourcePath = false;
boolean hasDocletOption = false;
for (int i = 0; i < args.length - 2; i++) { for (int i = 0; i < args.length - 2; i++) {
switch (args[i]) { switch (args[i]) {
case "-d" -> outputDir = Path.of(args[++i]); case "-d" -> outputDir = Path.of(args[++i]);
@ -493,6 +498,7 @@ public abstract class JavadocTester {
case "-docencoding" -> docencodingArg = args[++i]; case "-docencoding" -> docencodingArg = args[++i];
case "-encoding" -> encodingArg = args[++i]; case "-encoding" -> encodingArg = args[++i];
case "-sourcepath", "--source-path", "--module-source-path" -> haveSourcePath = true; case "-sourcepath", "--source-path", "--module-source-path" -> haveSourcePath = true;
case "-doclet" -> hasDocletOption = true;
} }
} }
@ -514,6 +520,13 @@ public abstract class JavadocTester {
charset = Charset.defaultCharset(); charset = Charset.defaultCharset();
} }
// Use default options when running with standard doclet unless explicitly disabled
if (!hasDocletOption && useDefaultOptions) {
var newArgs = Arrays.copyOf(defaultOptions, defaultOptions.length + args.length);
System.arraycopy(args, 0, newArgs, defaultOptions.length, args.length);
args = newArgs;
}
// explicitly set the source path if none specified // explicitly set the source path if none specified
// to override the javadoc tool default to use the classpath // to override the javadoc tool default to use the classpath
if (!haveSourcePath) { if (!haveSourcePath) {
@ -619,6 +632,13 @@ public abstract class JavadocTester {
automaticCheckNoStacktrace = b; automaticCheckNoStacktrace = b;
} }
/**
* Sets whether to use the default options when running javadoc with the standard doclet.
*/
public void setUseDefaultOptions(boolean b) {
useDefaultOptions = b;
}
/** /**
* Sets whether to use standard output streams (stdout and stderr) * Sets whether to use standard output streams (stdout and stderr)
* instead of a single temporary stream. * instead of a single temporary stream.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,7 @@
/* /*
* @test * @test
* @bug 8273154 * @bug 8273154 8327385
* @summary Provide a JavadocTester method for non-overlapping, unordered output matching * @summary Provide a JavadocTester method for non-overlapping, unordered output matching
* @library /tools/lib/ ../lib * @library /tools/lib/ ../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool * @modules jdk.javadoc/jdk.javadoc.internal.tool
@ -424,6 +424,11 @@ public class TestJavadocTester extends JavadocTester {
"FAILED: out/p/C.html: m3() is not unique"); "FAILED: out/p/C.html: m3() is not unique");
} }
@Test
public void testDefaultOptions() {
checkFiles(false, "resource-files/fonts");
}
/** /**
* {@return a string with {@code /} replaced by the platform file separator} * {@return a string with {@code /} replaced by the platform file separator}
* *

View File

@ -66,7 +66,7 @@ public class CheckManPageOptions {
static final PrintStream out = System.err; static final PrintStream out = System.err;
List<String> MISSING_IN_MAN_PAGE = List.of(); List<String> MISSING_IN_MAN_PAGE = List.of("--no-fonts");
void run(String... args) throws Exception { void run(String... args) throws Exception {
var file = args.length == 0 ? findDefaultFile() : Path.of(args[0]); var file = args.length == 0 ? findDefaultFile() : Path.of(args[0]);

View File

@ -210,6 +210,31 @@ class APITest {
"resource-files/link.svg", "resource-files/link.svg",
"resource-files/stylesheet.css", "resource-files/stylesheet.css",
"resource-files/x.png", "resource-files/x.png",
"resource-files/fonts/dejavu.css",
"resource-files/fonts/DejaVuLGCSans-Bold.woff",
"resource-files/fonts/DejaVuLGCSans-Bold.woff2",
"resource-files/fonts/DejaVuLGCSans-BoldOblique.woff",
"resource-files/fonts/DejaVuLGCSans-BoldOblique.woff2",
"resource-files/fonts/DejaVuLGCSans-Oblique.woff",
"resource-files/fonts/DejaVuLGCSans-Oblique.woff2",
"resource-files/fonts/DejaVuLGCSans.woff",
"resource-files/fonts/DejaVuLGCSans.woff2",
"resource-files/fonts/DejaVuLGCSansMono-Bold.woff",
"resource-files/fonts/DejaVuLGCSansMono-Bold.woff2",
"resource-files/fonts/DejaVuLGCSansMono-BoldOblique.woff",
"resource-files/fonts/DejaVuLGCSansMono-BoldOblique.woff2",
"resource-files/fonts/DejaVuLGCSansMono-Oblique.woff",
"resource-files/fonts/DejaVuLGCSansMono-Oblique.woff2",
"resource-files/fonts/DejaVuLGCSansMono.woff",
"resource-files/fonts/DejaVuLGCSansMono.woff2",
"resource-files/fonts/DejaVuLGCSerif-Bold.woff",
"resource-files/fonts/DejaVuLGCSerif-Bold.woff2",
"resource-files/fonts/DejaVuLGCSerif-BoldItalic.woff",
"resource-files/fonts/DejaVuLGCSerif-BoldItalic.woff2",
"resource-files/fonts/DejaVuLGCSerif-Italic.woff",
"resource-files/fonts/DejaVuLGCSerif-Italic.woff2",
"resource-files/fonts/DejaVuLGCSerif.woff",
"resource-files/fonts/DejaVuLGCSerif.woff2",
"script-files/jquery-3.6.1.min.js", "script-files/jquery-3.6.1.min.js",
"script-files/jquery-ui.min.js", "script-files/jquery-ui.min.js",
"script-files/script.js", "script-files/script.js",