aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/font
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-02-23 14:51:06 +0100
committerSven Gothel <[email protected]>2014-02-23 14:51:06 +0100
commit3352601e0860584509adf2b76f993d03893ded4b (patch)
tree974fccc8c0eb2f5ad9d4ffd741dfc35869ed67b5 /src/jogl/classes/com/jogamp/graph/font
parentf51933f0ebe9ae030c26c066e59a728ce08b8559 (diff)
parentc67de337a8aaf52e36104c3f13e273aa19d21f1f (diff)
Merge branch 'master' into stash_glyphcache
Conflicts: make/scripts/tests.sh src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java src/jogl/classes/com/jogamp/graph/curve/Region.java src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java src/jogl/classes/com/jogamp/graph/font/Font.java src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java src/jogl/classes/jogamp/graph/curve/text/GlyphString.java src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/font')
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java39
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/FontFactory.java47
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/FontSet.java16
3 files changed, 58 insertions, 44 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index 97510bcd0..6c0041de9 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -30,16 +30,16 @@ package com.jogamp.graph.font;
import java.util.List;
import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.geom.AABBox;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Vertex.Factory;
+import com.jogamp.opengl.math.geom.AABBox;
/**
* Interface wrapper for font implementation.
- *
+ *
* TrueType Font Specification:
* http://developer.apple.com/fonts/ttrefman/rm06/Chap6.html
- *
+ *
* TrueType Font Table Introduction:
* http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08
*/
@@ -55,22 +55,22 @@ public interface Font {
public static final int NAME_VERSION = 5;
public static final int NAME_MANUFACTURER = 8;
public static final int NAME_DESIGNER = 9;
-
-
+
+
/**
* Metrics for font
- *
+ *
* Depending on the font's direction, horizontal or vertical,
* the following tables shall be used:
- *
+ *
* Vertical http://developer.apple.com/fonts/TTRefMan/RM06/Chap6vhea.html
* Horizontal http://developer.apple.com/fonts/TTRefMan/RM06/Chap6hhea.html
*/
- public interface Metrics {
+ public interface Metrics {
float getAscent(float pixelSize);
float getDescent(float pixelSize);
float getLineGap(float pixelSize);
- float getMaxExtend(float pixelSize);
+ float getMaxExtend(float pixelSize);
float getScale(float pixelSize);
AABBox getBBox(float pixelSize);
}
@@ -79,12 +79,12 @@ public interface Font {
* Glyph for font
*/
public interface Glyph {
- // reserved special glyph IDs
+ // reserved special glyph IDs
// http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08#ba57949e
public static final int ID_UNKNOWN = 0;
public static final int ID_CR = 2;
public static final int ID_SPACE = 3;
-
+
public Font getFont();
public char getSymbol();
public short getID();
@@ -97,24 +97,24 @@ public interface Font {
public String getName(int nameIndex);
public StringBuilder getName(StringBuilder string, int nameIndex);
-
+
/** Shall return the family and subfamily name, separated a dash.
* <p>{@link #getName(StringBuilder, int)} w/ {@link #NAME_FAMILY} and {@link #NAME_SUBFAMILY}</p>
* <p>Example: "{@code Ubuntu-Regular}"</p> */
public StringBuilder getFullFamilyName(StringBuilder buffer);
-
+
public StringBuilder getAllNames(StringBuilder string, String separator);
-
+
public float getAdvanceWidth(int i, float pixelSize);
public Metrics getMetrics();
public Glyph getGlyph(char symbol);
public int getNumGlyphs();
-
+
public float getStringWidth(CharSequence string, float pixelSize);
public float getStringHeight(CharSequence string, float pixelSize);
public AABBox getStringBounds(CharSequence string, float pixelSize);
-
- public boolean isPrintableChar( char c );
+
+ public boolean isPrintableChar( char c );
/**
* @param glyph source of the created OutlineShape
@@ -122,7 +122,7 @@ public interface Font {
* @return OutlineShape of the glyph
*/
public OutlineShape getOutlineShape(Glyph glyph, Factory<? extends Vertex> vertexFactory);
-
+
/**
* @param shapes optional storage of OutlineShapes passed by user, new shapes are appended
* @param string source of the created OutlineShapes
@@ -131,7 +131,8 @@ public interface Font {
* @return List of OutlineShapes, one OutlineShape per character
*/
public List<OutlineShape> getOutlineShapes(List<OutlineShape> shapes, CharSequence string, float pixelSize, Factory<? extends Vertex> vertexFactory);
-
+
/** Shall return {@link #getFullFamilyName()} */
+ @Override
public String toString();
} \ No newline at end of file
diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
index 33d487355..884662e6e 100644
--- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
+++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java
@@ -33,19 +33,29 @@ import java.net.URLConnection;
import com.jogamp.common.util.PropertyAccess;
import com.jogamp.common.util.ReflectionUtil;
-import com.jogamp.common.util.SecurityUtil;
import jogamp.graph.font.FontConstructor;
import jogamp.graph.font.JavaFontLoader;
import jogamp.graph.font.UbuntuFontLoader;
+/**
+ * The optional property <i>jogamp.graph.font.ctor</i>
+ * allows user to specify the {@link FontConstructor} implementation.
+ * <p>
+ * Default {@link FontConstructor} is {@link jogamp.graph.font.typecast.TypecastFontConstructor},
+ * i.e. using our internal <i>typecast</i> branch.
+ * </p>
+ */
public class FontFactory {
+ private static final String FontConstructorPropKey = "jogamp.graph.font.ctor";
+ private static final String DefaultFontConstructor = "jogamp.graph.font.typecast.TypecastFontConstructor";
+
/** 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 {
@@ -53,18 +63,18 @@ public class FontFactory {
* For example:
* "jogamp.graph.font.typecast.TypecastFontFactory" (default)
* "jogamp.graph.font.ttf.TTFFontImpl"
- */
- String fontImplName = PropertyAccess.getProperty("FontImpl", true, SecurityUtil.getCommonAccessControlContext(FontFactory.class));
+ */
+ String fontImplName = PropertyAccess.getProperty(FontConstructorPropKey, true);
if(null == fontImplName) {
- fontImplName = "jogamp.graph.font.typecast.TypecastFontConstructor";
+ fontImplName = DefaultFontConstructor;
}
fontConstr = (FontConstructor) ReflectionUtil.createInstance(fontImplName, FontFactory.class.getClassLoader());
}
-
+
public static final FontSet getDefault() {
return get(UBUNTU);
}
-
+
public static final FontSet get(int font) {
switch (font) {
case JAVA:
@@ -73,20 +83,23 @@ public class FontFactory {
return UbuntuFontLoader.get();
}
}
-
+
public static final Font get(File file) throws IOException {
return fontConstr.create(file);
}
public static final Font get(final URLConnection conn) throws IOException {
return fontConstr.create(conn);
- }
-
+ }
+
public static boolean isPrintableChar( char c ) {
- Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
- return (!Character.isISOControl(c)) &&
- c != 0 &&
- block != null &&
- block != Character.UnicodeBlock.SPECIALS;
- }
+ if( Character.isWhitespace(c) ) {
+ return true;
+ }
+ if( 0 == c || Character.isISOControl(c) ) {
+ return false;
+ }
+ final Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
+ return block != null && block != Character.UnicodeBlock.SPECIALS;
+ }
}
diff --git a/src/jogl/classes/com/jogamp/graph/font/FontSet.java b/src/jogl/classes/com/jogamp/graph/font/FontSet.java
index d376922ab..17b8b2136 100644
--- a/src/jogl/classes/com/jogamp/graph/font/FontSet.java
+++ b/src/jogl/classes/com/jogamp/graph/font/FontSet.java
@@ -34,29 +34,29 @@ public interface FontSet {
/** Font family REGULAR **/
public static final int FAMILY_REGULAR = 0;
-
+
/** Font family LIGHT **/
public static final int FAMILY_LIGHT = 1;
-
+
/** Font family MEDIUM **/
public static final int FAMILY_MEDIUM = 2;
-
+
/** Font family CONDENSED **/
public static final int FAMILY_CONDENSED = 3;
-
+
/** Font family MONO **/
public static final int FAMILY_MONOSPACED = 4;
-
+
/** SERIF style/family bit flag. Fallback to Sans Serif. */
public static final int STYLE_SERIF = 1 << 1;
-
+
/** BOLD style bit flag */
public static final int STYLE_BOLD = 1 << 2;
-
+
/** ITALIC style bit flag */
public static final int STYLE_ITALIC = 1 << 3;
Font getDefault() throws IOException ;
-
+
Font get(int family, int stylebits) throws IOException ;
}