diff options
author | Sven Gothel <[email protected]> | 2011-04-01 06:48:52 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-04-01 06:48:52 +0200 |
commit | 4b8bd5ec58cb2edfb51bd9ee930beb9c539a8a0b (patch) | |
tree | 5567f56606ea248707fe002015b90a9635250e91 /src/jogamp/graph/font/UbuntuFontLoader.java | |
parent | e8c69e69374b6650e37594ebf104602fb06b548b (diff) |
Final core and demo changes for jogl merge
Core:
- Region: Cleanup up constant names
- Renderer: Add getRenderType()
- TextRenderer: Add cache size limit
- JavaFontLoader: Add FIXME 'Add cache size to limit memory usage'
- UbuntuFontLoader: Add cache and FIXME 'Add cache size to limit memory usage'
- TypecastFont: Add FIXME 'Add cache size to limit memory usage ??'
Demos:
- Relocated and split (main/listener) for jogl merge
- Add 's' for screenshot
- Text:
- Add 'i' for live editing mode (until CR, backspace supported)
Diffstat (limited to 'src/jogamp/graph/font/UbuntuFontLoader.java')
-rw-r--r-- | src/jogamp/graph/font/UbuntuFontLoader.java | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/jogamp/graph/font/UbuntuFontLoader.java b/src/jogamp/graph/font/UbuntuFontLoader.java index 77d2cea03..e09ea85e5 100644 --- a/src/jogamp/graph/font/UbuntuFontLoader.java +++ b/src/jogamp/graph/font/UbuntuFontLoader.java @@ -27,6 +27,7 @@ */ package jogamp.graph.font; +import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontSet; import com.jogamp.graph.font.FontFactory; @@ -58,6 +59,9 @@ public class UbuntuFontLoader implements FontSet { private UbuntuFontLoader() { } + // FIXME: Add cache size to limit memory usage + static final IntObjectHashMap fontMap = new IntObjectHashMap(); + static boolean is(int bits, int bit) { return 0 != ( bits & bit ) ; } @@ -68,7 +72,10 @@ public class UbuntuFontLoader implements FontSet { public Font get(int family, int style) { - Font font = null; + Font font = (Font)fontMap.get( ( family << 8 ) | style ); + if (font != null) { + return font; + } switch (family) { case FAMILY_MONOSPACED: @@ -76,30 +83,30 @@ public class UbuntuFontLoader implements FontSet { case FAMILY_REGULAR: if( is(style, STYLE_BOLD) ) { if( is(style, STYLE_ITALIC) ) { - font = abspath(availableFontFileNames[3]); + font = abspath(availableFontFileNames[3], family, style); } else { - font = abspath(availableFontFileNames[2]); + font = abspath(availableFontFileNames[2], family, style); } } else if( is(style, STYLE_ITALIC) ) { - font = abspath(availableFontFileNames[1]); + font = abspath(availableFontFileNames[1], family, style); } else { - font = abspath(availableFontFileNames[0]); + font = abspath(availableFontFileNames[0], family, style); } break; case FAMILY_LIGHT: if( is(style, STYLE_ITALIC) ) { - font = abspath(availableFontFileNames[5]); + font = abspath(availableFontFileNames[5], family, style); } else { - font = abspath(availableFontFileNames[4]); + font = abspath(availableFontFileNames[4], family, style); } break; case FAMILY_MEDIUM: if( is(style, STYLE_ITALIC) ) { - font = abspath(availableFontFileNames[6]); + font = abspath(availableFontFileNames[6], family, style); } else { - font = abspath(availableFontFileNames[7]); + font = abspath(availableFontFileNames[7], family, style); } break; } @@ -110,6 +117,16 @@ public class UbuntuFontLoader implements FontSet { Font abspath(String fname) { return FontFactory.getFontConstr().create( Locator.getResource(UbuntuFontLoader.class, relPath+fname).getPath() ); + } + + Font abspath(String fname, int family, int style) { + final Font f = FontFactory.getFontConstr().create( + Locator.getResource(UbuntuFontLoader.class, relPath+fname).getPath() ); + if(null != f) { + fontMap.put( ( family << 8 ) | style, f ); + } + return f; } + } |