Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
594 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
Roboto font | ||
=========== | ||
|
||
This sub-project contains fonts from the Roboto font family and bundles them | ||
into an easy-to-use and redistributable JAR. | ||
|
||
Font home page: https://fonts.google.com/specimen/Roboto | ||
|
||
GitHub project: https://github.com/googlefonts/roboto | ||
|
||
License: | ||
[Apache License, Version 2.0](src/main/resources/com/formdev/flatlaf/fonts/roboto/LICENSE.txt) | ||
|
||
|
||
How to install? | ||
--------------- | ||
|
||
Invoke the `install()` method once (e.g. in your `main()` method; on AWT | ||
thread): | ||
|
||
~~~java | ||
FlatRobotoFont.install(); | ||
~~~ | ||
|
||
|
||
How to use? | ||
----------- | ||
|
||
Use as default font: | ||
|
||
~~~java | ||
FlatLaf.setPreferredFontFamily( FlatRobotoFont.FAMILY ); | ||
FlatLaf.setPreferredLightFontFamily( FlatRobotoFont.FAMILY_LIGHT ); | ||
FlatLaf.setPreferredSemiboldFontFamily( FlatRobotoFont.FAMILY_SEMIBOLD ); | ||
~~~ | ||
|
||
Create fonts: | ||
|
||
~~~java | ||
// basic styles | ||
new Font( FlatRobotoFont.FAMILY, Font.PLAIN, 12 ); | ||
new Font( FlatRobotoFont.FAMILY, Font.ITALIC, 12 ); | ||
new Font( FlatRobotoFont.FAMILY, Font.BOLD, 12 ); | ||
new Font( FlatRobotoFont.FAMILY, Font.BOLD | Font.ITALIC, 12 ); | ||
|
||
// light | ||
new Font( FlatRobotoFont.FAMILY_LIGHT, Font.PLAIN, 12 ); | ||
new Font( FlatRobotoFont.FAMILY_LIGHT, Font.ITALIC, 12 ); | ||
|
||
// semibold | ||
new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.PLAIN, 12 ); | ||
new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.ITALIC, 12 ); | ||
~~~ | ||
|
||
|
||
Download | ||
-------- | ||
|
||
Not yet available. | ||
|
||
<!-- | ||
FlatLaf Fonts binaries are available on **Maven Central**. | ||
If you use Maven or Gradle, add a dependency with following coordinates to your | ||
build script: | ||
groupId: com.formdev | ||
artifactId: flatlaf-fonts-roboto | ||
version: (see button below) | ||
Otherwise download `flatlaf-fonts-roboto-<version>.jar` here: | ||
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.formdev/flatlaf-fonts-roboto/badge.svg?style=flat-square&color=007ec6)](https://maven-badges.herokuapp.com/maven-central/com.formdev/flatlaf-fonts-roboto) | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2022 FormDev Software GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// Version format: <font-version>[-<build-number>] | ||
// For maven compatibility, <font-version> should be in format <major>.<minor>[.<micro>]. | ||
// <build-number> is optional and should be incremented only if a new release is | ||
// necessary, but the <font-version> has not changed. | ||
version = "2.137" | ||
|
||
if( !rootProject.hasProperty( "release" ) ) | ||
version = version.toString() + "-SNAPSHOT" | ||
|
||
|
||
plugins { | ||
`java-library` | ||
`flatlaf-module-info` | ||
`flatlaf-publish` | ||
} | ||
|
||
dependencies { | ||
testImplementation( "org.junit.jupiter:junit-jupiter-api:5.7.2" ) | ||
testImplementation( "org.junit.jupiter:junit-jupiter-params" ) | ||
testRuntimeOnly( "org.junit.jupiter:junit-jupiter-engine" ) | ||
} | ||
|
||
java { | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
|
||
tasks { | ||
named<Jar>( "sourcesJar" ) { | ||
exclude( "**/*.ttf", "**/*.otf" ) | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
testLogging.exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL | ||
} | ||
|
||
withType<PublishToMavenRepository>().configureEach { | ||
onlyIf { !rootProject.hasProperty( "skipFonts" ) } | ||
} | ||
} | ||
|
||
flatlafPublish { | ||
artifactId = "flatlaf-fonts-roboto" | ||
name = "FlatLaf Roboto Fonts Pack" | ||
} |
150 changes: 150 additions & 0 deletions
150
...s/flatlaf-fonts-roboto/src/main/java/com/formdev/flatlaf/fonts/roboto/FlatRobotoFont.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
* Copyright 2022 FormDev Software GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.formdev.flatlaf.fonts.roboto; | ||
|
||
import java.awt.Font; | ||
import java.awt.FontFormatException; | ||
import java.awt.GraphicsEnvironment; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* The Roboto font family. | ||
* <p> | ||
* Font home page: <a href="https://fonts.google.com/specimen/Roboto">https://fonts.google.com/specimen/Roboto</a><br> | ||
* GitHub project: <a href="https://github.com/googlefonts/roboto">https://github.com/googlefonts/roboto</a> | ||
* <p> | ||
* To install the font, invoke following once (e.g. in your {@code main()} method; on AWT thread): | ||
* <pre>{@code | ||
* FlatRobotoFont.install(); | ||
* }</pre> | ||
* <p> | ||
* Use as default font: | ||
* <pre>{@code | ||
* FlatLaf.setPreferredFontFamily( FlatRobotoFont.FAMILY ); | ||
* FlatLaf.setPreferredLightFontFamily( FlatRobotoFont.FAMILY_LIGHT ); | ||
* FlatLaf.setPreferredSemiboldFontFamily( FlatRobotoFont.FAMILY_SEMIBOLD ); | ||
* }</pre> | ||
* <p> | ||
* Create fonts: | ||
* <pre>{@code | ||
* new Font( FlatRobotoFont.FAMILY, Font.PLAIN, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY, Font.ITALIC, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY, Font.BOLD, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY, Font.BOLD | Font.ITALIC, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY_LIGHT, Font.PLAIN, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY_LIGHT, Font.ITALIC, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.PLAIN, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.ITALIC, 12 ); | ||
* }</pre> | ||
* | ||
* @author Karl Tauber | ||
*/ | ||
public class FlatRobotoFont | ||
{ | ||
/** | ||
* Family name for basic styles (regular, italic and bold). | ||
* <p> | ||
* Usage: | ||
* <pre>{@code | ||
* new Font( FlatRobotoFont.FAMILY, Font.PLAIN, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY, Font.ITALIC, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY, Font.BOLD, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY, Font.BOLD | Font.ITALIC, 12 ); | ||
* }</pre> | ||
*/ | ||
public static final String FAMILY = "Roboto"; | ||
|
||
/** | ||
* Family name for light styles. | ||
* <p> | ||
* Usage: | ||
* <pre>{@code | ||
* new Font( FlatRobotoFont.FAMILY_LIGHT, Font.PLAIN, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY_LIGHT, Font.ITALIC, 12 ); | ||
* }</pre> | ||
*/ | ||
public static final String FAMILY_LIGHT = "Roboto Light"; | ||
|
||
/** | ||
* Family name for semibold styles. | ||
* <p> | ||
* Usage: | ||
* <pre>{@code | ||
* new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.PLAIN, 12 ); | ||
* new Font( FlatRobotoFont.FAMILY_SEMIBOLD, Font.ITALIC, 12 ); | ||
* }</pre> | ||
*/ | ||
public static final String FAMILY_SEMIBOLD = "Roboto Medium"; | ||
|
||
/** | ||
* Use for {@link #installStyle(String)} to install single font style. | ||
*/ | ||
public static final String | ||
// basic styles | ||
STYLE_REGULAR = "Roboto-Regular.ttf", | ||
STYLE_ITALIC = "Roboto-Italic.ttf", | ||
STYLE_BOLD = "Roboto-Bold.ttf", | ||
STYLE_BOLD_ITALIC = "Roboto-BoldItalic.ttf", | ||
|
||
// light | ||
STYLE_LIGHT = "Roboto-Light.ttf", | ||
STYLE_LIGHT_ITALIC = "Roboto-LightItalic.ttf", | ||
|
||
// semibold | ||
STYLE_SEMIBOLD = "Roboto-Medium.ttf", | ||
STYLE_SEMIBOLD_ITALIC = "Roboto-MediumItalic.ttf"; | ||
|
||
|
||
private FlatRobotoFont() {} | ||
|
||
/** | ||
* Creates and registers the fonts for all styles. | ||
*/ | ||
public static void install() { | ||
// basic styles | ||
installStyle( STYLE_REGULAR ); | ||
installStyle( STYLE_ITALIC ); | ||
installStyle( STYLE_BOLD ); | ||
installStyle( STYLE_BOLD_ITALIC ); | ||
|
||
// light | ||
installStyle( STYLE_LIGHT ); | ||
installStyle( STYLE_LIGHT_ITALIC ); | ||
|
||
// semibold | ||
installStyle( STYLE_SEMIBOLD ); | ||
installStyle( STYLE_SEMIBOLD_ITALIC ); | ||
} | ||
|
||
/** | ||
* Creates and registers the font for the given style. | ||
* See {@code STYLE_} constants. | ||
*/ | ||
public static boolean installStyle( String name ) { | ||
try( InputStream in = FlatRobotoFont.class.getResourceAsStream( name ) ) { | ||
Font font = Font.createFont( Font.TRUETYPE_FONT, in ); | ||
return GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont( font ); | ||
} catch( FontFormatException ex ) { | ||
ex.printStackTrace(); | ||
return false; | ||
} catch( IOException ex ) { | ||
ex.printStackTrace(); | ||
return false; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
flatlaf-fonts/flatlaf-fonts-roboto/src/main/module-info/module-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2022 FormDev Software GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @author Karl Tauber | ||
*/ | ||
module com.formdev.flatlaf.fonts.roboto { | ||
requires java.desktop; | ||
|
||
exports com.formdev.flatlaf.fonts.roboto; | ||
|
||
opens com.formdev.flatlaf.fonts.roboto; | ||
} |
Oops, something went wrong.