diff --git a/CHANGELOG.md b/CHANGELOG.md index c0254a25..518f6131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,11 @@ API turns the open cycle into a minor. also accepts a raw `ShapeOutline` mark for fully custom ticks. Adding a new design is one enum constant plus its vertex ring — the foundation for letting a caller choose which tick or arrow to render. +- **Bundled font: JetBrains Mono.** New `FontName.JETBRAINS_MONO` (`@since 1.7.0`) + joins the built-in `DefaultFonts` catalog with its Regular / Bold / Italic / + Bold-Italic faces (bundled from the OFL-1.1 release), so monospaced code and + data blocks render without a system-font install. Usable through any + `DocumentTextStyle.fontName(...)` and listed in the font showcase. ## v1.6.9 — 2026-06-03 diff --git a/src/main/java/com/demcha/compose/font/DefaultFonts.java b/src/main/java/com/demcha/compose/font/DefaultFonts.java index 403f59f6..9a8dda79 100644 --- a/src/main/java/com/demcha/compose/font/DefaultFonts.java +++ b/src/main/java/com/demcha/compose/font/DefaultFonts.java @@ -61,7 +61,8 @@ public class DefaultFonts { google(FontName.SARABUN, "sarabun", "Sarabun"), google(FontName.PROMPT, "prompt", "Prompt"), google(FontName.ANDIKA, "andika", "Andika"), - google(FontName.BAI_JAMJUREE, "baijamjuree", "BaiJamjuree")); + google(FontName.BAI_JAMJUREE, "baijamjuree", "BaiJamjuree"), + google(FontName.JETBRAINS_MONO, "jetbrainsmono", "JetBrainsMono")); private DefaultFonts() { } diff --git a/src/main/java/com/demcha/compose/font/FontName.java b/src/main/java/com/demcha/compose/font/FontName.java index 3e7c134d..d641228d 100644 --- a/src/main/java/com/demcha/compose/font/FontName.java +++ b/src/main/java/com/demcha/compose/font/FontName.java @@ -61,6 +61,7 @@ public final class FontName { public static final FontName PROMPT = of("Prompt"); public static final FontName ANDIKA = of("Andika"); public static final FontName BAI_JAMJUREE = of("Bai Jamjuree"); + public static final FontName JETBRAINS_MONO = of("JetBrains Mono"); private final String name; private final String normalizedName; diff --git a/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Bold.ttf b/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Bold.ttf new file mode 100644 index 00000000..8c93043d Binary files /dev/null and b/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Bold.ttf differ diff --git a/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-BoldItalic.ttf b/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-BoldItalic.ttf new file mode 100644 index 00000000..1ddf216d Binary files /dev/null and b/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-BoldItalic.ttf differ diff --git a/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Italic.ttf b/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Italic.ttf new file mode 100644 index 00000000..ccc9d6a5 Binary files /dev/null and b/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Italic.ttf differ diff --git a/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Regular.ttf b/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Regular.ttf new file mode 100644 index 00000000..dff66cc5 Binary files /dev/null and b/src/main/resources/fonts/google/jetbrainsmono/JetBrainsMono-Regular.ttf differ diff --git a/src/main/resources/fonts/google/jetbrainsmono/OFL.txt b/src/main/resources/fonts/google/jetbrainsmono/OFL.txt new file mode 100644 index 00000000..8bee4148 --- /dev/null +++ b/src/main/resources/fonts/google/jetbrainsmono/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +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 THE +COPYRIGHT HOLDER 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. diff --git a/src/test/java/com/demcha/compose/font/FontLibraryIntegrationTest.java b/src/test/java/com/demcha/compose/font/FontLibraryIntegrationTest.java index e8ec0e1f..317eaec4 100644 --- a/src/test/java/com/demcha/compose/font/FontLibraryIntegrationTest.java +++ b/src/test/java/com/demcha/compose/font/FontLibraryIntegrationTest.java @@ -19,7 +19,7 @@ void shouldExposeBundledGoogleFontsInEngineComposerHarness() throws Exception { try (EngineComposerHarness composer = com.demcha.compose.testsupport.EngineComposerHarness.pdf().create()) { assertThat(composer.availableFonts()) .contains(FontName.HELVETICA, FontName.LATO, FontName.IBM_PLEX_SERIF, FontName.ZILLA_SLAB, - FontName.KANIT, FontName.VOLKHOV, FontName.ANDIKA); + FontName.KANIT, FontName.VOLKHOV, FontName.ANDIKA, FontName.JETBRAINS_MONO); } try (PDDocument document = new PDDocument()) { @@ -28,6 +28,8 @@ void shouldExposeBundledGoogleFontsInEngineComposerHarness() throws Exception { assertThat(fonts.getFont(FontName.LATO, WordFont.class)).isPresent(); assertThat(fonts.getFont(FontName.KANIT, PdfFont.class)).isPresent(); assertThat(fonts.getFont(FontName.KANIT, WordFont.class)).isPresent(); + assertThat(fonts.getFont(FontName.JETBRAINS_MONO, PdfFont.class)).isPresent(); + assertThat(fonts.getFont(FontName.JETBRAINS_MONO, WordFont.class)).isPresent(); } } diff --git a/src/test/resources/layout-snapshots/fonts/available_fonts_preview.json b/src/test/resources/layout-snapshots/fonts/available_fonts_preview.json index a535dd86..be406334 100644 --- a/src/test/resources/layout-snapshots/fonts/available_fonts_preview.json +++ b/src/test/resources/layout-snapshots/fonts/available_fonts_preview.json @@ -22,15 +22,15 @@ "depth" : 1, "layer" : 1, "computedX" : 28.0, - "computedY" : -2711.974, + "computedY" : -2822.154, "placementX" : 28.0, - "placementY" : -2711.974, + "placementY" : -2822.154, "placementWidth" : 442.2, - "placementHeight" : 3525.864, + "placementHeight" : 3636.044, "startPage" : 0, "endPage" : 4, "contentWidth" : 442.2, - "contentHeight" : 3525.864, + "contentHeight" : 3636.044, "margin" : { "top" : 0.0, "right" : 0.0, @@ -5863,5 +5863,185 @@ "bottom" : 0.0, "left" : 0.0 } + }, { + "path" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]", + "entityName" : "FontSection_JetBrains Mono", + "entityKind" : "SectionNode", + "parentPath" : "AvailableFontsPreview[0]", + "childIndex" : 34, + "depth" : 2, + "layer" : 2, + "computedX" : 28.0, + "computedY" : 302.083, + "placementX" : 28.0, + "placementY" : 302.083, + "placementWidth" : 442.2, + "placementHeight" : 86.18, + "startPage" : 4, + "endPage" : 4, + "contentWidth" : 442.2, + "contentHeight" : 86.18, + "margin" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 8.0, + "left" : 0.0 + }, + "padding" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 0.0, + "left" : 0.0 + } + }, { + "path" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]/FontSection_JetBrains MonoTitle[0]", + "entityName" : "FontSection_JetBrains MonoTitle", + "entityKind" : "ParagraphNode", + "parentPath" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]", + "childIndex" : 0, + "depth" : 3, + "layer" : 3, + "computedX" : 28.0, + "computedY" : 377.163, + "placementX" : 28.0, + "placementY" : 377.163, + "placementWidth" : 90.012, + "placementHeight" : 11.1, + "startPage" : 4, + "endPage" : 4, + "contentWidth" : 90.012, + "contentHeight" : 11.1, + "margin" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 2.0, + "left" : 0.0 + }, + "padding" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 0.0, + "left" : 0.0 + } + }, { + "path" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]/ParagraphNode[1]", + "entityName" : null, + "entityKind" : "ParagraphNode", + "parentPath" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]", + "childIndex" : 1, + "depth" : 3, + "layer" : 3, + "computedX" : 28.0, + "computedY" : 358.643, + "placementX" : 28.0, + "placementY" : 358.643, + "placementWidth" : 415.8, + "placementHeight" : 14.52, + "startPage" : 4, + "endPage" : 4, + "contentWidth" : 415.8, + "contentHeight" : 14.52, + "margin" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 1.0, + "left" : 0.0 + }, + "padding" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 0.0, + "left" : 0.0 + } + }, { + "path" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]/ParagraphNode[2]", + "entityName" : null, + "entityKind" : "ParagraphNode", + "parentPath" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]", + "childIndex" : 2, + "depth" : 3, + "layer" : 3, + "computedX" : 28.0, + "computedY" : 341.123, + "placementX" : 28.0, + "placementY" : 341.123, + "placementWidth" : 396.0, + "placementHeight" : 14.52, + "startPage" : 4, + "endPage" : 4, + "contentWidth" : 396.0, + "contentHeight" : 14.52, + "margin" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 1.0, + "left" : 0.0 + }, + "padding" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 0.0, + "left" : 0.0 + } + }, { + "path" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]/ParagraphNode[3]", + "entityName" : null, + "entityKind" : "ParagraphNode", + "parentPath" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]", + "childIndex" : 3, + "depth" : 3, + "layer" : 3, + "computedX" : 28.0, + "computedY" : 323.603, + "placementX" : 28.0, + "placementY" : 323.603, + "placementWidth" : 409.2, + "placementHeight" : 14.52, + "startPage" : 4, + "endPage" : 4, + "contentWidth" : 409.2, + "contentHeight" : 14.52, + "margin" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 1.0, + "left" : 0.0 + }, + "padding" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 0.0, + "left" : 0.0 + } + }, { + "path" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]/ParagraphNode[4]", + "entityName" : null, + "entityKind" : "ParagraphNode", + "parentPath" : "AvailableFontsPreview[0]/FontSection_JetBrains Mono[34]", + "childIndex" : 4, + "depth" : 3, + "layer" : 3, + "computedX" : 28.0, + "computedY" : 306.083, + "placementX" : 28.0, + "placementY" : 306.083, + "placementWidth" : 442.2, + "placementHeight" : 14.52, + "startPage" : 4, + "endPage" : 4, + "contentWidth" : 442.2, + "contentHeight" : 14.52, + "margin" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 4.0, + "left" : 0.0 + }, + "padding" : { + "top" : 0.0, + "right" : 0.0, + "bottom" : 0.0, + "left" : 0.0 + } } ] }