summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/graph/font/FontFactory.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-03-30 06:59:43 +0200
committerSven Gothel <[email protected]>2011-03-30 06:59:43 +0200
commit55356d999638491980a90cb2263b55c5d2e53e91 (patch)
tree711457c8b1bedcf1d71fd0ba0252155b2895ce7f /src/com/jogamp/graph/font/FontFactory.java
parent5f0293b84d0146d9e750ea7e75caaa101ae3b3c3 (diff)
Font Refactoring ; Misc Changes ; Demo/Test Update
Font Refactoring - Notion of distributed FontSet - FontFactory may produce FontSet and/or a Font by absolute ttf file path - Adding support for free Ubuntu fonts - Remove Vertex.Factory dependency for Font creation - Typecast Impl - Fix CmapTable selection - Fix horizontal spacing of space - Misc Changes - HwTextRenderer - Offer reshape for perspective and orthogonal view - Expose PMVMatrix, allowing user to setup their own view math. Demo Update - Dump font set a-zA-Z... - Dump 'lazy dog ..' text - Action: - s: toogle 'font set' - f: toggle fps - v: toggle v-sync - space: toggle font (ubuntu/java) - formated screenshot filename w/ font name Test Update: - add font set iteration
Diffstat (limited to 'src/com/jogamp/graph/font/FontFactory.java')
-rw-r--r--src/com/jogamp/graph/font/FontFactory.java60
1 files changed, 49 insertions, 11 deletions
diff --git a/src/com/jogamp/graph/font/FontFactory.java b/src/com/jogamp/graph/font/FontFactory.java
index b595413ba..1752a693c 100644
--- a/src/com/jogamp/graph/font/FontFactory.java
+++ b/src/com/jogamp/graph/font/FontFactory.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2011 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
@@ -27,16 +27,54 @@
*/
package com.jogamp.graph.font;
-import com.jogamp.graph.geom.Vertex;
+import java.security.AccessController;
-public interface FontFactory {
+import com.jogamp.common.util.ReflectionUtil;
- Font createFont(Vertex.Factory<? extends Vertex> factory,
- String[] families,
- String style,
- String variant,
- String weight);
+import jogamp.graph.font.FontConstructor;
+import jogamp.graph.font.JavaFontLoader;
+import jogamp.graph.font.UbuntuFontLoader;
+import jogamp.opengl.Debug;
- Font createFont(Vertex.Factory<? extends Vertex> factory,
- String name);
-} \ No newline at end of file
+public class FontFactory {
+ /** Ubuntu is the default font family */
+ public static final int UBUNTU = 0;
+
+ /** Java fonts are optional */
+ public static final int JAVA = 1;
+
+ private static final FontConstructor fontConstr;
+
+ static {
+ /**
+ * For example:
+ * "jogamp.graph.font.typecast.TypecastFontFactory" (default)
+ * "jogamp.graph.font.ttf.TTFFontImpl"
+ */
+ String fontImplName = Debug.getProperty("FontImpl", true, AccessController.getContext());
+ if(null == fontImplName) {
+ fontImplName = "jogamp.graph.font.typecast.TypecastFontConstructor";
+ }
+ fontConstr = (FontConstructor) ReflectionUtil.createInstance(fontImplName, FontFactory.class.getClassLoader());
+ }
+
+ public static final FontConstructor getFontConstr() { return fontConstr; }
+
+ public static final FontSet getDefault() {
+ return get(UBUNTU);
+ }
+
+ public static final FontSet get(int font) {
+ switch (font) {
+ case JAVA:
+ return JavaFontLoader.get();
+ default:
+ return UbuntuFontLoader.get();
+ }
+ }
+
+ public static final Font get(String path) {
+ return fontConstr.create(path);
+ }
+
+}