summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java43
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java58
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java22
3 files changed, 76 insertions, 47 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index 92d35768b..52ad4076d 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -88,7 +88,7 @@ public interface Font {
float getScale(final float pixelSize);
/**
* @param dest AABBox instance set to this metrics boundary w/ given pixelSize
- * @param pixelSize
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link Font#getPixelSize(float, float)}
* @param tmpV3 caller provided temporary 3-component vector
* @return the given and set AABBox 'dest'
*/
@@ -113,14 +113,25 @@ public interface Font {
public char getSymbol();
public short getID();
public AABBox getBBox();
+ /**
+ *
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link Font#getPixelSize(float, float)}
+ * @return
+ */
public float getScale(final float pixelSize);
/**
* @param dest AABBox instance set to this metrics boundary w/ given pixelSize
- * @param pixelSize
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link Font#getPixelSize(float, float)}
* @param tmpV3 caller provided temporary 3-component vector
* @return the given and set AABBox 'dest'
*/
public AABBox getBBox(final AABBox dest, final float pixelSize, float[] tmpV3);
+ /**
+ *
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link Font#getPixelSize(float, float)}
+ * @param useFrationalMetrics
+ * @return
+ */
public float getAdvance(final float pixelSize, boolean useFrationalMetrics);
public OutlineShape getShape();
public int hashCode();
@@ -153,13 +164,37 @@ public interface Font {
*/
public float getPixelSize(final float fontSize /* points per inch */, final float resolution);
+ /**
+ *
+ * @param glyphID
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
+ * @return
+ */
public float getAdvanceWidth(final int glyphID, final float pixelSize);
public Metrics getMetrics();
public Glyph getGlyph(final char symbol);
public int getNumGlyphs();
+ /**
+ *
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
+ * @return
+ */
public float getLineHeight(final float pixelSize);
+ /**
+ *
+ * @param string
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
+ * @return
+ */
public float getMetricWidth(final CharSequence string, final float pixelSize);
+ /**
+ *
+ * @param string
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
+ * @param tmp
+ * @return
+ */
public float getMetricHeight(final CharSequence string, final float pixelSize, final AABBox tmp);
/**
* Return the <i>layout</i> bounding box as computed by each glyph's metrics.
@@ -168,7 +203,7 @@ public interface Font {
* See {@link #getPointsBounds(AffineTransform, CharSequence, float, AffineTransform, AffineTransform)} for pixel correct results.
* </p>
* @param string string text
- * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
*/
public AABBox getMetricBounds(final CharSequence string, final float pixelSize);
@@ -176,7 +211,7 @@ public interface Font {
* Return the bounding box by taking each glyph's point-based bounding box into account.
* @param transform optional given transform
* @param string string text
- * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
* @param temp1 temporary AffineTransform storage, mandatory
* @param temp2 temporary AffineTransform storage, mandatory
*/
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
index 5bd49dce9..97570d605 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
@@ -32,8 +32,8 @@ import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.font.Font;
import com.jogamp.opengl.math.geom.AABBox;
-public class TypecastGlyph implements Font.Glyph {
- public static class Advance
+public final class TypecastGlyph implements Font.Glyph {
+ public static final class Advance
{
private final Font font;
private final float advance;
@@ -46,40 +46,42 @@ public class TypecastGlyph implements Font.Glyph {
size2advanceI.setKeyNotFoundValue(0);
}
- public void reset() {
+ public final void reset() {
size2advanceI.clear();
}
- public float getScale(final float pixelSize)
+ public final Font getFont() { return font; }
+
+ public final float getScale(final float pixelSize)
{
return this.font.getMetrics().getScale(pixelSize);
}
- public void add(final float advance, final float size)
+ public final void add(final float advance, final float size)
{
size2advanceI.put(Float.floatToIntBits(size), Float.floatToIntBits(advance));
}
- public float get(final float size, final boolean useFrationalMetrics)
+ public final float get(final float pixelSize, final boolean useFrationalMetrics)
{
- final int sI = Float.floatToIntBits(size);
+ final int sI = Float.floatToIntBits(pixelSize);
final int aI = size2advanceI.get(sI);
if( 0 != aI ) {
return Float.intBitsToFloat(aI);
}
final float a;
if ( useFrationalMetrics ) {
- a = this.advance * getScale(size);
+ a = this.advance * getScale(pixelSize);
} else {
- // a = Math.ceil(this.advance * getScale(size));
- a = Math.round(this.advance * getScale(size)); // TODO: check whether ceil should be used instead?
+ // a = Math.ceil(this.advance * getScale(pixelSize));
+ a = Math.round(this.advance * getScale(pixelSize)); // TODO: check whether ceil should be used instead?
}
size2advanceI.put(sI, Float.floatToIntBits(a));
return a;
}
@Override
- public String toString()
+ public final String toString()
{
return "\nAdvance:"+
"\n advance: "+this.advance+
@@ -87,7 +89,7 @@ public class TypecastGlyph implements Font.Glyph {
}
}
- public static class Metrics
+ public static final class Metrics
{
private final AABBox bbox;
private final Advance advance;
@@ -98,32 +100,34 @@ public class TypecastGlyph implements Font.Glyph {
this.advance = new Advance(font, advance);
}
- public void reset() {
+ public final void reset() {
advance.reset();
}
- public float getScale(final float pixelSize)
+ public final Font getFont() { return advance.getFont(); }
+
+ public final float getScale(final float pixelSize)
{
return this.advance.getScale(pixelSize);
}
- public AABBox getBBox()
+ public final AABBox getBBox()
{
return this.bbox;
}
- public void addAdvance(final float advance, final float size)
+ public final void addAdvance(final float advance, final float size)
{
this.advance.add(advance, size);
}
- public float getAdvance(final float size, final boolean useFrationalMetrics)
+ public final float getAdvance(final float pixelSize, final boolean useFrationalMetrics)
{
- return this.advance.get(size, useFrationalMetrics);
+ return this.advance.get(pixelSize, useFrationalMetrics);
}
@Override
- public String toString()
+ public final String toString()
{
return "\nMetrics:"+
"\n bbox: "+this.bbox+
@@ -134,31 +138,21 @@ public class TypecastGlyph implements Font.Glyph {
public static final short INVALID_ID = (short)((1 << 16) - 1);
public static final short MAX_ID = (short)((1 << 16) - 2);
- private final Font font;
private final char symbol;
private final OutlineShape shape; // in EM units
private final short id;
- private final int advance;
private final Metrics metrics;
protected TypecastGlyph(final Font font, final char symbol, final short id, final AABBox bbox, final int advance, final OutlineShape shape) {
- this.font = font;
this.symbol = symbol;
this.shape = shape;
this.id = id;
- this.advance = advance;
- this.metrics = new Metrics(this.font, bbox, this.advance);
+ this.metrics = new Metrics(font, bbox, advance);
}
- /**
- public void reset(Path2D path) {
- this.path = path;
- this.metrics.reset();
- } */
-
@Override
public final Font getFont() {
- return this.font;
+ return this.metrics.getFont();
}
@Override
@@ -211,7 +205,7 @@ public class TypecastGlyph implements Font.Glyph {
@Override
public final int hashCode() {
// 31 * x == (x << 5) - x
- final int hash = 31 + font.getName(Font.NAME_UNIQUNAME).hashCode();
+ final int hash = 31 + getFont().getName(Font.NAME_UNIQUNAME).hashCode();
return ((hash << 5) - hash) + id;
}
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java
index 7bfffd58c..8ed450326 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java
@@ -65,10 +65,10 @@ import com.jogamp.opengl.math.geom.AABBox;
* @version $Id: Glyph.java,v 1.3 2007-02-21 12:23:54 davidsch Exp $
* @author <a href="mailto:[email protected]">David Schweinsberg</a>, Sven Gothel
*/
-public class OTGlyph {
+public final class OTGlyph {
- protected short _leftSideBearing;
- protected int _advanceWidth;
+ private final short _leftSideBearing;
+ private final int _advanceWidth;
private Point[] _points;
AABBox _bbox;
@@ -102,33 +102,32 @@ public class OTGlyph {
}
}
- public void clearPointData() {
+ public final void clearPointData() {
_points = null;
}
- public AABBox getBBox() {
+ public final AABBox getBBox() {
return _bbox;
}
- public int getAdvanceWidth() {
+ public final int getAdvanceWidth() {
return _advanceWidth;
}
- public short getLeftSideBearing() {
+ public final short getLeftSideBearing() {
return _leftSideBearing;
}
- public Point getPoint(final int i) {
+ public final Point getPoint(final int i) {
return _points[i];
}
- public int getPointCount() {
+ public final int getPointCount() {
return null != _points ? _points.length : 0;
}
/**
* @param factor a 16.16 fixed value
- */
public void scale(final int factor) {
for (int i = 0; i < _points.length; i++) {
//points[i].x = ( points[i].x * factor ) >> 6;
@@ -139,11 +138,12 @@ public class OTGlyph {
_leftSideBearing = (short)(( _leftSideBearing * factor) >> 6);
_advanceWidth = (_advanceWidth * factor) >> 6;
}
+ */
/**
* Set the points of a glyph from the GlyphDescription
*/
- private void describe(final GlyphDescription gd) {
+ private final void describe(final GlyphDescription gd) {
int endPtIndex = 0;
_points = new Point[gd.getPointCount() /* + 2 */ ];
for (int i = 0; i < gd.getPointCount(); i++) {