aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/graph/font/FontFactory.java
diff options
context:
space:
mode:
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);
+ }
+
+}