Subversion Repositories svn.mios

Rev

Rev 213 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 213 Rev 628
Line 1... Line 1...
1
/*
1
/*
2
 * @(#)FontLoader.java  beta7   2006/04/23
2
 * @(#)FontLoader.java  beta8   2006/04/23
3
 *
3
 *
4
 * Copyright (C) 2006    Adam King (adamjking@optusnet.com.au)
4
 * Copyright (C) 2008    Adam King (adamjking@optusnet.com.au)
5
 *
5
 *
6
 * This application is free software; you can redistribute it and/or modify
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
9
 * (at your option) any later version.
Line 19... Line 19...
19
 */
19
 */
20
20
21
package org.midibox.utils.gui;
21
package org.midibox.utils.gui;
22
22
23
import java.awt.Font;
23
import java.awt.Font;
24
import java.net.URL;
-
 
25
import java.util.Hashtable;
24
import java.util.Hashtable;
26
25
27
public class FontLoader {
26
public class FontLoader {
28
27
29
    private static Hashtable fonts = new Hashtable();
28
    private static Hashtable fonts = new Hashtable();
Line 33... Line 32...
33
        Font font;
32
        Font font;
34
33
35
        if (fonts.containsKey(fontName + fontSize)) {
34
        if (fonts.containsKey(fontName + fontSize)) {
36
            font = (Font) fonts.get(fontName + fontSize);
35
            font = (Font) fonts.get(fontName + fontSize);
37
        } else {
36
        } else {
38
            //ClassLoader cl = ImageLoader.class.getClassLoader();
37
            ClassLoader cl = ImageLoader.class.getClassLoader();
-
 
38
39
            try {  
39
            try {
40
                /*
-
 
41
                font = Font.createFont(Font.TRUETYPE_FONT,
40
                font = Font.createFont(Font.TRUETYPE_FONT,
42
                        cl.getResourceAsStream("fonts/" + fontName))
41
                        cl.getResourceAsStream("fonts/" + fontName))
43
                        .deriveFont(fontSize);
42
                        .deriveFont(fontSize);
44
                */
-
 
45
                font = Font.createFont(Font.TRUETYPE_FONT,
-
 
46
                        FontLoader.class.getResourceAsStream("/fonts/" + fontName))
-
 
47
                        .deriveFont(fontSize);
-
 
48
               
-
 
49
                fonts.put(fontName + fontSize, font);
43
                fonts.put(fontName + fontSize, font);
50
            } catch (Exception e) {
44
            } catch (Exception e) {
51
                font = null;
45
                font = null;
52
            }
46
            }
53
        }
47
        }