fighting with fonts

This commit is contained in:
Ben Fry
2013-06-01 12:55:40 -04:00
parent b3c749dca5
commit 75406ef463
2 changed files with 27 additions and 25 deletions
Regular → Executable
+5 -5
View File
@@ -44,7 +44,7 @@ import processing.core.*;
* files and images, etc) that comes from that.
*/
public class Base {
// Added accessors for 0218 because the UpdateCheck class was not properly
// Added accessors for 0218 because the UpdateCheck class was not properly
// updating the values, because javac was inlining the static final values.
static private final int REVISION = 218;
/** This might be replaced by main() if there's a lib/version.txt file. */
@@ -53,8 +53,8 @@ public class Base {
// static private boolean RELEASE = false;
/** True if heavy debugging error/log messages are enabled */
static public boolean DEBUG = false;
// static public boolean DEBUG = true;
// static public boolean DEBUG = false;
static public boolean DEBUG = true;
static HashMap<Integer, String> platformNames =
new HashMap<Integer, String>();
@@ -1556,7 +1556,7 @@ public class Base {
static public int getRevision() {
return REVISION;
}
/**
* Return the version name, something like 1.5 or 2.0b8 or 0213 if it's not
@@ -1566,7 +1566,7 @@ public class Base {
return VERSION_NAME;
}
//...................................................................
+22 -20
View File
@@ -233,16 +233,16 @@ public class Toolkit {
}
return false;
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
// static Font monoFont;
// static Font plainFont;
// static Font boldFont;
//
//
//
//
// static public Font getMonoFont(int size) {
// if (monoFont == null) {
// try {
@@ -253,7 +253,7 @@ public class Toolkit {
// }
// return monoFont;
// }
//
//
//
// static public Font getPlainFont(int size) {
// if (plainFont == null) {
@@ -265,8 +265,8 @@ public class Toolkit {
// }
// return plainFont;
// }
//
//
//
//
// static public Font getBoldFont(int size) {
// if (boldFont == null) {
// try {
@@ -277,20 +277,21 @@ public class Toolkit {
// }
// return boldFont;
// }
static Font monoFont;
static Font monoBoldFont;
static Font sansFont;
static Font sansBoldFont;
static public Font getMonoFont(int size, int style) {
if (monoFont == null) {
try {
monoFont = createFont("SourceCodePro-Regular.otf", size);
monoBoldFont = createFont("SourceCodePro-Semibold.otf", size);
} catch (Exception e) {
Base.log("Could not load mono font", e);
monoFont = new Font("Monospaced", Font.PLAIN, size);
monoBoldFont = new Font("Monospaced", Font.BOLD, size);
}
@@ -310,11 +311,11 @@ public class Toolkit {
return monoFont.deriveFont((float) size);
}
}
// return style == Font.BOLD ?
// monoBoldFont.deriveFont((float) size) :
// monoFont.deriveFont((float) size);
// return style == Font.BOLD ?
// monoBoldFont.deriveFont((float) size) :
// monoFont.deriveFont((float) size);
}
static public Font getSansFont(int size, int style) {
if (sansFont == null) {
@@ -322,13 +323,14 @@ public class Toolkit {
sansFont = createFont("SourceSansPro-Regular.otf", size);
sansBoldFont = createFont("SourceSansPro-Semibold.otf", size);
} catch (Exception e) {
Base.log("Could not load sans font", e);
sansFont = new Font("Monospaced", Font.PLAIN, size);
sansBoldFont = new Font("Monospaced", Font.BOLD, size);
}
}
// System.out.println("deriving new font");
// return style == Font.BOLD ?
// sansBoldFont.deriveFont((float) size) :
// return style == Font.BOLD ?
// sansBoldFont.deriveFont((float) size) :
// sansFont.deriveFont((float) size);
if (style == Font.BOLD) {
if (size == sansBoldFont.getSize()) {
@@ -346,8 +348,8 @@ public class Toolkit {
}
}
}
static private Font createFont(String filename, int size) throws IOException, FontFormatException {
InputStream is = Base.getLibStream("fonts/" + filename);
BufferedInputStream input = new BufferedInputStream(is);