@@ -238,47 +238,116 @@ static public boolean highResDisplay() {
238238 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
239239
240240
241+ // static Font monoFont;
242+ // static Font plainFont;
243+ // static Font boldFont;
244+ //
245+ //
246+ // static public Font getMonoFont(int size) {
247+ // if (monoFont == null) {
248+ // try {
249+ // monoFont = createFont("DroidSansMono.ttf", size);
250+ // } catch (Exception e) {
251+ // monoFont = new Font("Monospaced", Font.PLAIN, size);
252+ // }
253+ // }
254+ // return monoFont;
255+ // }
256+ //
257+ //
258+ // static public Font getPlainFont(int size) {
259+ // if (plainFont == null) {
260+ // try {
261+ // plainFont = createFont("DroidSans.ttf", size);
262+ // } catch (Exception e) {
263+ // plainFont = new Font("SansSerif", Font.PLAIN, size);
264+ // }
265+ // }
266+ // return plainFont;
267+ // }
268+ //
269+ //
270+ // static public Font getBoldFont(int size) {
271+ // if (boldFont == null) {
272+ // try {
273+ // boldFont = createFont("DroidSans-Bold.ttf", size);
274+ // } catch (Exception e) {
275+ // boldFont = new Font("SansSerif", Font.BOLD, size);
276+ // }
277+ // }
278+ // return boldFont;
279+ // }
280+
281+
241282 static Font monoFont ;
242- static Font plainFont ;
243- static Font boldFont ;
283+ static Font monoBoldFont ;
284+ static Font sansFont ;
285+ static Font sansBoldFont ;
244286
245287
246- static public Font getMonoFont (int size ) {
288+ static public Font getMonoFont (int size , int style ) {
247289 if (monoFont == null ) {
248290 try {
249- monoFont = createFont ("DroidSansMono.ttf" , size );
291+ monoFont = createFont ("SourceCodePro-Regular.otf" , size );
292+ monoBoldFont = createFont ("SourceCodePro-Semibold.otf" , size );
250293 } catch (Exception e ) {
251294 monoFont = new Font ("Monospaced" , Font .PLAIN , size );
295+ monoBoldFont = new Font ("Monospaced" , Font .BOLD , size );
296+ }
297+ }
298+ if (style == Font .BOLD ) {
299+ if (size == monoBoldFont .getSize ()) {
300+ return monoBoldFont ;
301+ } else {
302+ // System.out.println("deriving new font");
303+ return monoBoldFont .deriveFont ((float ) size );
304+ }
305+ } else {
306+ if (size == monoFont .getSize ()) {
307+ return monoFont ;
308+ } else {
309+ // System.out.println("deriving new font");
310+ return monoFont .deriveFont ((float ) size );
252311 }
253312 }
254- return monoFont ;
313+ // return style == Font.BOLD ?
314+ // monoBoldFont.deriveFont((float) size) :
315+ // monoFont.deriveFont((float) size);
255316 }
256317
257318
258- static public Font getPlainFont (int size ) {
259- if (plainFont == null ) {
319+ static public Font getSansFont (int size , int style ) {
320+ if (sansFont == null ) {
260321 try {
261- plainFont = createFont ("DroidSans.ttf" , size );
322+ sansFont = createFont ("SourceSansPro-Regular.otf" , size );
323+ sansBoldFont = createFont ("SourceSansPro-Semibold.otf" , size );
262324 } catch (Exception e ) {
263- plainFont = new Font ("SansSerif" , Font .PLAIN , size );
325+ sansFont = new Font ("Monospaced" , Font .PLAIN , size );
326+ sansBoldFont = new Font ("Monospaced" , Font .BOLD , size );
264327 }
265328 }
266- return plainFont ;
267- }
268-
269-
270- static public Font getBoldFont (int size ) {
271- if (boldFont == null ) {
272- try {
273- boldFont = createFont ("DroidSans-Bold.ttf" , size );
274- } catch (Exception e ) {
275- boldFont = new Font ("SansSerif" , Font .BOLD , size );
329+ // System.out.println("deriving new font");
330+ // return style == Font.BOLD ?
331+ // sansBoldFont.deriveFont((float) size) :
332+ // sansFont.deriveFont((float) size);
333+ if (style == Font .BOLD ) {
334+ if (size == sansBoldFont .getSize ()) {
335+ return sansBoldFont ;
336+ } else {
337+ // System.out.println("deriving new font");
338+ return sansBoldFont .deriveFont ((float ) size );
339+ }
340+ } else {
341+ if (size == sansFont .getSize ()) {
342+ return sansFont ;
343+ } else {
344+ // System.out.println("deriving new font");
345+ return sansFont .deriveFont ((float ) size );
276346 }
277347 }
278- return boldFont ;
279348 }
280-
281-
349+
350+
282351 static private Font createFont (String filename , int size ) throws IOException , FontFormatException {
283352 InputStream is = Base .getLibStream ("fonts/" + filename );
284353 BufferedInputStream input = new BufferedInputStream (is );
0 commit comments