clean up default font handling, add more fallbacks to built-in fonts (fixes #4944)

This commit is contained in:
Ben Fry
2017-04-23 13:41:24 -04:00
parent 9dde0bd8c4
commit 530bec062c
6 changed files with 26 additions and 273 deletions

View File

@@ -635,25 +635,6 @@ public class Toolkit {
}
// someone needs to be slapped
//static KeyStroke closeWindowKeyStroke;
/**
* Return true if the key event was a Ctrl-W or an ESC,
* both indicators to close the window.
* Use as part of a keyPressed() event handler for frames.
*/
/*
static public boolean isCloseWindowEvent(KeyEvent e) {
if (closeWindowKeyStroke == null) {
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
closeWindowKeyStroke = KeyStroke.getKeyStroke('W', modifiers);
}
return ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
KeyStroke.getKeyStrokeForEvent(e).equals(closeWindowKeyStroke));
}
*/
/**
* Registers key events for a Ctrl-W and ESC with an ActionListener
* that will take care of disposing the window.
@@ -887,10 +868,6 @@ public class Toolkit {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
static final char GREEK_SMALL_LETTER_ALPHA = '\u03B1'; // α
static final char GREEK_CAPITAL_LETTER_OMEGA = '\u03A9'; // ω
// Gets the plain (not bold, not italic) version of each
static private List<Font> getMonoFontList() {
GraphicsEnvironment ge =
@@ -968,17 +945,12 @@ public class Toolkit {
monoFont = createFont("SourceCodePro-Regular.ttf", size);
monoBoldFont = createFont("SourceCodePro-Bold.ttf", size);
// additional language constraints
if ("el".equals(Language.getLanguage())) {
if (!monoFont.canDisplay(GREEK_SMALL_LETTER_ALPHA) ||
!monoFont.canDisplay(GREEK_CAPITAL_LETTER_OMEGA)) {
monoFont = createFont("AnonymousPro-Regular.ttf", size);
monoBoldFont = createFont("AnonymousPro-Bold.ttf", size);
}
}
// https://github.com/processing/processing/issues/2886
// https://github.com/processing/processing/issues/4944
String lang = Language.getLanguage();
if (Locale.CHINESE.getLanguage().equals(lang) ||
if ("el".equals(lang) ||
"ar".equals(lang) ||
Locale.CHINESE.getLanguage().equals(lang) ||
Locale.JAPANESE.getLanguage().equals(lang) ||
Locale.KOREAN.getLanguage().equals(lang)) {
sansFont = new Font("Monospaced", Font.PLAIN, size);
@@ -1018,42 +990,15 @@ public class Toolkit {
static public Font getSansFont(int size, int style) {
if (sansFont == null) {
try {
/*
// check for an installed version, because they cause nasty conflicts
// https://github.com/processing/processing/issues/4747
if (Platform.isWindows()) {
sansFont = new Font("Source Sans Pro", Font.PLAIN, size);
// the ps name will be Dialog.plain (or similar) if not installed
if (!sansFont.getPSName().startsWith("Source")) {
sansFont = null;
}
sansBoldFont = new Font("Source Sans Pro Semibold", Font.PLAIN, size);
if (!sansBoldFont.getPSName().startsWith("Source")) {
sansBoldFont = null;
}
}
if (sansFont == null) {
sansFont = createFont("SourceSansPro-Regular.ttf", size);
}
if (sansBoldFont == null) {
sansBoldFont = createFont("SourceSansPro-Semibold.ttf", size);
}
*/
sansFont = createFont("ProcessingSansPro-Regular.ttf", size);
sansBoldFont = createFont("ProcessingSansPro-Semibold.ttf", size);
// additional language constraints
if ("el".equals(Language.getLanguage())) {
if (!sansFont.canDisplay(GREEK_SMALL_LETTER_ALPHA) ||
!sansFont.canDisplay(GREEK_CAPITAL_LETTER_OMEGA)) {
sansFont = createFont("Carlito-Regular.ttf", size);
sansBoldFont = createFont("Carlito-Bold.ttf", size);
}
}
// https://github.com/processing/processing/issues/2886
// https://github.com/processing/processing/issues/4944
String lang = Language.getLanguage();
if (Locale.CHINESE.getLanguage().equals(lang) ||
if ("el".equals(lang) ||
"ar".equals(lang) ||
Locale.CHINESE.getLanguage().equals(lang) ||
Locale.JAPANESE.getLanguage().equals(lang) ||
Locale.KOREAN.getLanguage().equals(lang)) {
sansFont = new Font("SansSerif", Font.PLAIN, size);
@@ -1139,20 +1084,6 @@ public class Toolkit {
}
// /** Do not use or rely upon presence of this method: not approved as final API. */
// static public void debugOpacity(Component comp) {
// //Component parent = comp.getParent();
// while (comp != null) {
// //EditorConsole.systemOut.println("parent is " + parent + " " + parent.isOpaque());
// //EditorConsole.systemOut.println(parent.getClass().getName() + " " + (parent.isOpaque() ? "OPAQUE" : ""));
// System.out.println(comp.getClass().getName() + " " + (comp.isOpaque() ? "OPAQUE" : ""));
// comp = comp.getParent();
// }
// //EditorConsole.systemOut.println();
// System.out.println();
// }
static public int getMenuItemIndex(JMenu menu, JMenuItem item) {
int index = 0;
for (Component comp : menu.getMenuComponents()) {

View File

@@ -1,94 +0,0 @@
Copyright (c) 2009, Mark Simonson (http://www.ms-studio.com, mark@marksimonson.com),
with Reserved Font Name Anonymous Pro.
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:
http://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.

View File

@@ -1,95 +0,0 @@
Copyright (c) 2010-2013 by tyPoland Lukasz Dziedzic with Reserved Font Name "Carlito".
This Font Software is licensed under the SIL Open Font License,
Version 1.1 as shown below.
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.

View File

@@ -20,6 +20,8 @@ X https://github.com/processing/processing/issues/4936
X https://github.com/processing/processing/issues/5007
X get rid of error message when exporting sketches with the video library
X https://github.com/processing/processing/issues/4971
X use dialog font for processing.sans if using a non- or quirky Roman language
X make this a parameter of the language translation
jakub
X Fix preprocessing of code with double backslash in string or char literal
@@ -52,13 +54,6 @@ X https://github.com/processing/processing/pull/4970
X add Jump to Declaration
X https://github.com/processing/processing/pull/4707
X https://github.com/processing/processing/issues/4668
_ redo console handling to not use Timer, fixing freeze-up problems
_ https://github.com/processing/processing/pull/4935
_ https://github.com/processing/processing/issues/4825
_ Make the change detector not reload the sketch
_ https://github.com/processing/processing/pull/5021
_ https://github.com/processing/processing/issues/4713
X https://github.com/processing/processing/pull/4849
awaiting confirmation (fixed in 3.3)
X visual artifacts on Windows 10 when using menus
@@ -80,6 +75,22 @@ X amazing blurry editor window
X https://github.com/processing/processing/issues/4892
contrib
_ redo console handling to not use Timer, fixing freeze-up problems
_ https://github.com/processing/processing/pull/4935
_ https://github.com/processing/processing/issues/4825
_ Make the change detector not reload the sketch
_ https://github.com/processing/processing/pull/5021
_ https://github.com/processing/processing/issues/4713
X https://github.com/processing/processing/pull/4849
_ implement fallback fonts instead of giving up and using Dialog and Mono
_ https://github.com/processing/processing/issues/5023
_ "Required files could not be found" when trying to run from the .zip file
_ https://github.com/processing/processing/issues/5022
_ mode list does not update after changing sketchbook folder
_ already reported?
_ swap font smoothing for tab size?