Last change
on this file since 7401 was 7383, checked in by bastiK, 10 years ago |
applied #10301 - extend display of maxspeed nodes (patch by Klumbumbus)
Include Droid Sans font in the JOSM binary distribution.
This unifies the font rendering on different platforms and allows geometric constructions with text (as demonstrated for maxspeed). Both regular and bold style are available.
|
-
Property svn:eol-style
set to
native
|
File size:
1.2 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import java.awt.Font;
|
---|
5 | import java.awt.FontFormatException;
|
---|
6 | import java.awt.GraphicsEnvironment;
|
---|
7 | import java.io.IOException;
|
---|
8 | import java.io.InputStream;
|
---|
9 | import java.util.Arrays;
|
---|
10 | import java.util.Collection;
|
---|
11 | import java.util.Map;
|
---|
12 | import org.openstreetmap.josm.io.CachedFile;
|
---|
13 |
|
---|
14 | public class FontsManager {
|
---|
15 |
|
---|
16 | public static Map<String, Font> fonts;
|
---|
17 | public static Collection<String> includedFonts = Arrays.asList(
|
---|
18 | "DroidSans.ttf",
|
---|
19 | "DroidSans-Bold.ttf"
|
---|
20 | );
|
---|
21 |
|
---|
22 | public static void initialize() {
|
---|
23 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
---|
24 | for (String fontFile : includedFonts) {
|
---|
25 | String url = "resource://data/fonts/"+fontFile;
|
---|
26 | try (InputStream i = new CachedFile(url).getInputStream())
|
---|
27 | {
|
---|
28 | Font f = Font.createFont(Font.TRUETYPE_FONT, i);
|
---|
29 | if (f == null) {
|
---|
30 | throw new RuntimeException("unable to load font: "+fontFile);
|
---|
31 | }
|
---|
32 | ge.registerFont(f);
|
---|
33 | } catch (IOException | FontFormatException ex) {
|
---|
34 | throw new RuntimeException(ex);
|
---|
35 | }
|
---|
36 | }
|
---|
37 | }
|
---|
38 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.