aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-02-10 14:01:54 +0100
committerSven Gothel <[email protected]>2023-02-10 14:01:54 +0100
commitbe0d8cb42fa4c94233a7dd6d89a125ebb7bf2074 (patch)
tree5fb297b8555b550c5da179ebb79da489201969e4 /src/jogl/classes
parent6365b7e6bde5f2fc0bc55f19804acc0319eaf5a8 (diff)
Typecast: Kerning: Use 'int' to cover 'uint16' values; Detail KernSubtable and hold a KernSubtableFormat0 ref in KernTable
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java49
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java13
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java3
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java24
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java9
5 files changed, 88 insertions, 10 deletions
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java
index dcf02cb2b..1cc328ad2 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java
@@ -11,34 +11,59 @@ package jogamp.graph.font.typecast.ot.table;
import java.io.DataInput;
import java.io.IOException;
+import jogamp.graph.font.typecast.ot.Fixed;
+
/**
*
* @author <a href="mailto:[email protected]">David Schweinsberg</a>
* @version $Id: KernSubtable.java,v 1.1.1.1 2004-12-05 23:14:47 davidsch Exp $
*/
public abstract class KernSubtable {
+ private final int version;
+ private final int length;
+ private final int coverage;
/** Creates new KernSubtable */
- protected KernSubtable() {
+ protected KernSubtable(final int version, final int length, final int coverage) {
+ this.version = version;
+ this.length = length;
+ this.coverage = coverage;
}
+ /** Kern subtable version number */
+ public final int getVersion() { return version; }
+ /** Length of the subtable in bytes including the header */
+ public final int getLength() { return length; }
+ /** type of subtable information */
+ public final int getCoverage() { return coverage; }
+ /** Subtable format, i.e. 0 or 2 is supported here */
+ public final int getSubtableFormat() { return coverage >> 8; }
+ /** True if table is horizontal data, otherwise vertical */
+ public final boolean isHorizontal() { return 0 != ( coverage & 0b0001 ); }
+ /** True if table has kerning values, otherwise minimum values */
+ public final boolean areKerningValues() { return 0 == ( coverage & 0b0010 ); }
+ /** True if kerning is perpendicular to text flow, otherwise along with flow */
+ public final boolean isCrossstream() { return 0 != ( coverage & 0b0100 ); }
+ /** True if this table shall replace an accumulated value, otherwise keep */
+ public final boolean isOverride() { return 0 != ( coverage & 0b1000 ); }
+
public abstract int getKerningPairCount();
public abstract KerningPair getKerningPair(int i);
public static KernSubtable read(final DataInput di) throws IOException {
KernSubtable table = null;
- /* final int version = */ di.readUnsignedShort();
- /* final int length = */ di.readUnsignedShort();
+ final int version = di.readUnsignedShort();
+ final int length = di.readUnsignedShort();
final int coverage = di.readUnsignedShort();
final int format = coverage >> 8;
switch (format) {
case 0:
- table = new KernSubtableFormat0(di);
+ table = new KernSubtableFormat0(version, length, coverage, di);
break;
case 2:
- table = new KernSubtableFormat2(di);
+ table = new KernSubtableFormat2(version, length, coverage, di);
break;
default:
break;
@@ -46,4 +71,18 @@ public abstract class KernSubtable {
return table;
}
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("'kern' Sub-Table\n--------------------------")
+ .append("\n version: ").append(version)
+ .append("\n length: ").append(length)
+ .append("\n coverage: 0x").append(Integer.toHexString(coverage)).append("[")
+ .append("\n format: ").append(getSubtableFormat())
+ .append("\n horizontal: ").append(isHorizontal())
+ .append("\n kerningVal: ").append(areKerningValues())
+ .append("\n crossstream: ").append(isCrossstream())
+ .append("\n override: ").append(isOverride()).append("]");
+ return sb.toString();
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java
index 2d1acddd5..360aa94f7 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java
@@ -25,7 +25,8 @@ public class KernSubtableFormat0 extends KernSubtable {
private final KerningPair[] kerningPairs;
/** Creates new KernSubtableFormat0 */
- protected KernSubtableFormat0(final DataInput di) throws IOException {
+ protected KernSubtableFormat0(final int version, final int length, final int coverage, final DataInput di) throws IOException {
+ super(version, length, coverage);
nPairs = di.readUnsignedShort();
searchRange = di.readUnsignedShort();
entrySelector = di.readUnsignedShort();
@@ -41,6 +42,16 @@ public class KernSubtableFormat0 extends KernSubtable {
return nPairs;
}
+ public int getSearchRange() {
+ return searchRange;
+ }
+ public int getEntrySelector() {
+ return entrySelector;
+ }
+ public int getRangeShift() {
+ return rangeShift;
+ }
+
@Override
public KerningPair getKerningPair(final int i) {
return kerningPairs[i];
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java
index deb56c96d..79b8abc1b 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java
@@ -24,7 +24,8 @@ public class KernSubtableFormat2 extends KernSubtable {
private final int array;
/** Creates new KernSubtableFormat2 */
- protected KernSubtableFormat2(final DataInput di) throws IOException {
+ protected KernSubtableFormat2(final int version, final int length, final int coverage, final DataInput di) throws IOException {
+ super(version, length, coverage);
rowWidth = di.readUnsignedShort();
leftClassTable = di.readUnsignedShort();
rightClassTable = di.readUnsignedShort();
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java
index 6f1d682e1..bb29ceb89 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java
@@ -12,6 +12,8 @@ import java.io.DataInput;
import java.io.IOException;
/**
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kern.html
+ * https://learn.microsoft.com/en-us/typography/opentype/spec/kern
*
* @author <a href="mailto:[email protected]">David Schweinsberg</a>
* @version $Id: KernTable.java,v 1.1.1.1 2004-12-05 23:14:48 davidsch Exp $
@@ -22,6 +24,7 @@ public class KernTable implements Table {
private final int version;
private final int nTables;
private final KernSubtable[] tables;
+ private final KernSubtableFormat0 table0;
/** Creates new KernTable */
protected KernTable(final DirectoryEntry de, final DataInput di) throws IOException {
@@ -29,9 +32,14 @@ public class KernTable implements Table {
version = di.readUnsignedShort();
nTables = di.readUnsignedShort();
tables = new KernSubtable[nTables];
+ KernSubtableFormat0 _table0 = null;
for (int i = 0; i < nTables; i++) {
tables[i] = KernSubtable.read(di);
+ if( null == _table0 && 0 == tables[i].getSubtableFormat() ) {
+ _table0 = (KernSubtableFormat0)tables[i];
+ }
}
+ table0 = _table0;
}
public int getSubtableCount() {
@@ -42,6 +50,10 @@ public class KernTable implements Table {
return tables[i];
}
+ public KernSubtableFormat0 getSubtable0() {
+ return table0;
+ }
+
/** Get the table type, as a table directory value.
* @return The table type
*/
@@ -61,4 +73,16 @@ public class KernTable implements Table {
return de;
}
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("'kern' Table\n--------------------------")
+ .append("\n version: ").append(version)
+ .append("\n subtables: ").append(nTables);
+ for (int i = 0; i < nTables; i++) {
+ sb.append("\n ");
+ sb.append(tables[i].toString());
+ }
+ return sb.toString();
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java
index dd5d0ba06..84c5c2872 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java
@@ -18,9 +18,9 @@ import java.io.IOException;
*/
public class KerningPair {
- private final int left;
- private final int right;
- private final short value;
+ private final int left; // uint16
+ private final int right; // uint16
+ private final short value; // sint16 in FUnits
/** Creates new KerningPair */
protected KerningPair(final DataInput di) throws IOException {
@@ -29,14 +29,17 @@ public class KerningPair {
value = di.readShort();
}
+ /** left glyph index */
public int getLeft() {
return left;
}
+ /** right glyph index */
public int getRight() {
return right;
}
+ /** sint16 in FUnits between left and right glyph within a word */
public short getValue() {
return value;
}