[FOray-commit] SF.net SVN: foray:[13017] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2023-01-04 04:08:00
|
Revision: 13017
http://sourceforge.net/p/foray/code/13017
Author: victormote
Date: 2023-01-04 04:07:57 +0000 (Wed, 04 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Convert use of short[] to ShortSequence.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserAfm.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-Bold.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-BoldOblique.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-Oblique.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-Bold.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-BoldOblique.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-Oblique.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Symbol.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Bold.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-BoldItalic.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Italic.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Roman.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/ZapfDingbats.jbso
trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1MetricsParserAfmTests.java
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/eng.jbso
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/fin.jbso
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/hun.jbso
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/ita.jbso
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/mah.jbso
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/pol.jbso
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/por.jbso
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/rus.jbso
trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/spa.jbso
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -36,6 +36,7 @@
import org.foray.font.format.type1.Type1Font;
import org.foray.primitive.sequence.ByteArray;
import org.foray.primitive.sequence.IntArrayBuilder;
+import org.foray.primitive.sequence.ShortArrayBuilder;
import org.axsl.constants.NumericConstants;
import org.axsl.constants.PrimitiveConstants;
@@ -50,6 +51,7 @@
import org.axsl.orthography.Orthography;
import org.axsl.primitive.sequence.ByteSequence;
import org.axsl.primitive.sequence.IntSequence;
+import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.CharSet;
import org.axsl.ps.Encoding;
import org.axsl.unicode.block.Basic_Latin_Block;
@@ -440,7 +442,7 @@
}
@Override
- public short[] getWidths() {
+ public ShortSequence getWidths() {
final FreeStandingFont fsf = this.getFreeStandingFont();
if (fsf == null) {
return null;
@@ -457,7 +459,7 @@
final int firstIndex = encoding.getFirstIndex();
final int lastIndex = encoding.getLastIndex();
final int size = lastIndex - firstIndex + 1;
- final short[] widthsByFontIndex = new short[size];
+ final ShortArrayBuilder widthsByFontIndex = new ShortArrayBuilder(size);
for (int i = firstIndex; i <= lastIndex; i++) {
// Decode the character for this index
final int codePoint = encoding.decode(i);
@@ -467,11 +469,11 @@
continue;
}
// Find the width for that charSet index.
- final short width = fsf.getWidths()[charSetIndex];
+ final short width = fsf.getWidths().shortAt(charSetIndex);
// Set the current array element to that width
- widthsByFontIndex[i - firstIndex] = width;
+ widthsByFontIndex.setShortAt(i - firstIndex, width);
}
- return widthsByFontIndex;
+ return widthsByFontIndex.toImmutable();
}
/**
@@ -478,15 +480,15 @@
* Returns the width array for reencoded glyphs in a subsetted font.
* @return The width array for the reencoded glyphs.
*/
- private short[] getSubsetWidths() {
+ private ShortSequence getSubsetWidths() {
final Subset subset = getSubset();
- final short[] originalWidths = getFreeStandingFont().getWidths();
- final short[] tmpWidth = new short[subset.numGlyphsUsed()];
+ final ShortSequence originalWidths = getFreeStandingFont().getWidths();
+ final ShortArrayBuilder tmpWidth = new ShortArrayBuilder(subset.numGlyphsUsed());
for (int i = 0; i < subset.numGlyphsUsed(); i++) {
final int originalIndex = subset.decodeSubsetIndex(i);
- tmpWidth[i] = originalWidths[originalIndex];
+ tmpWidth.setShortAt(i, originalWidths.shortAt(originalIndex));
}
- return tmpWidth;
+ return tmpWidth.toImmutable();
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -36,6 +36,7 @@
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
import org.axsl.ps.Encoding;
@@ -103,9 +104,8 @@
/** The width that should be used for glyphs that have no width recorded. */
private int missingWidth = 0;
- /** The array of glyph widths for this font, expressed in text-space
- * units. */
- private short[] width = null;
+ /** The array of glyph widths for this font, expressed in text-space units. */
+ private ShortSequence width = null;
/** This font's internal encoding. */
private Encoding internalEncoding;
@@ -377,7 +377,7 @@
* Returns the widths of the glyphs in this font in an array.
* @return The widths of the glyphs in this font.
*/
- public short[] getWidths() {
+ public ShortSequence getWidths() {
return this.width;
}
@@ -442,7 +442,7 @@
* Set the widths for this font.
* @param widths The width array to set.
*/
- protected void setWidths(final short[] widths) {
+ protected void setWidths(final ShortSequence widths) {
this.width = widths;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -39,6 +39,7 @@
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
import org.slf4j.Logger;
@@ -126,13 +127,13 @@
this.setItalicAngle(this.ttf.getItalicAngle().floatValue());
this.setNumGlyphs(this.ttf.getNumGlyphs());
this.setInternalEncoding(this.ttf.getUnicodeCMap());
- final short[] widths = this.ttf.getWidths();
+ final ShortSequence widths = this.ttf.getWidths();
this.setWidths(widths);
/*
* The last entry hMetrics entry in the hmtx table holds the default
* width for the remaining glyphs in the font.
*/
- this.setMissingWidth(widths[widths.length - 1]);
+ this.setMissingWidth(widths.shortAt(widths.length() - 1));
this.setKerning(this.ttf.getKerning());
this.setPanose(this.ttf.getPanose());
@@ -183,12 +184,12 @@
}
/* Since the fontSize and width array are both in millipoints, must
* divide by 1000 to return a result in millipoints */
- return fontSize * this.getWidths()[glyphIndex] / TypographicConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.getWidths().shortAt(glyphIndex) / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
public int widthUndefinedGlyph(final int fontSize) {
- return fontSize * this.getWidths()[0] / TypographicConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.getWidths().shortAt(0) / TypographicConstants.MILLIPOINTS_PER_POINT;
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -271,12 +271,12 @@
public int width(final int metricIndex, final int fontSize) {
/* Since the fontSize and width array are both in millipoints, must
* divide by 1000 to return a result in millipoints */
- return fontSize * this.getWidths()[metricIndex] / TypographicConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.getWidths().shortAt(metricIndex) / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
public int widthUndefinedGlyph(final int fontSize) {
- return fontSize * this.getWidths()[0] / TypographicConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.getWidths().shortAt(0) / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
@@ -409,7 +409,7 @@
final int metricIndex =
this.metricsFile.getCharSet().getIndex(codePoint);
if (metricIndex < 0
- || metricIndex > this.getWidths().length) {
+ || metricIndex > this.getWidths().length()) {
return Integer.MIN_VALUE;
}
return metricIndex;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -34,9 +34,11 @@
import org.foray.font.format.Panose4a;
import org.foray.font.output.FontPdfUtilities;
import org.foray.primitive.BitUtils;
+import org.foray.primitive.sequence.ShortArrayBuilder;
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
+import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.Cmap;
@@ -685,12 +687,12 @@
* Return the widths of the glyphs in this font in an array.
* @return The widths of the glyphs in this font.
*/
- public short[] getWidths() {
- final short[] wx = new short[this.hmtxTable.numMtxEntries()];
- for (int i = 0; i < wx.length; i++) {
- wx[i] = convertFunitsToMillipoints(this.hmtxTable.getMtxEntry(i).getWidth());
+ public ShortSequence getWidths() {
+ final ShortArrayBuilder wx = new ShortArrayBuilder(this.hmtxTable.numMtxEntries());
+ for (int i = 0; i < wx.length(); i++) {
+ wx.setShortAt(i, convertFunitsToMillipoints(this.hmtxTable.getMtxEntry(i).getWidth()));
}
- return wx;
+ return wx.toImmutable();
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -32,7 +32,9 @@
import org.foray.font.format.Kerning;
import org.foray.font.output.FontPdfUtilities;
import org.foray.primitive.BitUtils;
+import org.foray.primitive.sequence.ShortArrayBuilder;
+import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
import org.axsl.ps.PsEncoding;
@@ -156,7 +158,8 @@
private float etmSlant;
/** The parsed extent table. */
- private short[] extentTable;
+ private ShortArrayBuilder extentTable;
+ /* TODO: Change this type to ShortSequence after cleaning up parsing. */
/** The parsed bounding boxes. */
private BoundingBox[] glyphBoundingBoxes;
@@ -491,7 +494,7 @@
* Returns the character widths for this font.
* @return The character widths for this font.
*/
- public short[] getCharWidths() {
+ public ShortSequence getCharWidths() {
return this.extentTable;
}
@@ -659,7 +662,7 @@
* Sets the extent table.
* @param extentTable The extent table to set.
*/
- public void setExtentTable(final short[] extentTable) {
+ public void setExtentTable(final ShortArrayBuilder extentTable) {
this.extentTable = extentTable;
}
@@ -667,7 +670,7 @@
* Returns the extent table.
* @return The extent table.
*/
- public short[] getExtentTable() {
+ public ShortArrayBuilder getExtentTable() {
return this.extentTable;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserAfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserAfm.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserAfm.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -33,6 +33,7 @@
import org.foray.font.FontServer4a;
import org.foray.font.format.Kerning;
import org.foray.primitive.sequence.IntArrayBuilder;
+import org.foray.primitive.sequence.ShortArrayBuilder;
import org.axsl.font.Font;
import org.axsl.font.FontException;
@@ -1041,7 +1042,8 @@
if (this.metrics.getCharSet() == null) {
this.codePoints = new int[this.qtyCharMetricsExpected];
}
- final short[] extentTable = new short[this.qtyCharMetricsExpected];
+ final ShortArrayBuilder extentTable = new ShortArrayBuilder(this.qtyCharMetricsExpected);
+ extentTable.setLength(this.qtyCharMetricsExpected);
this.metrics.setExtentTable(extentTable);
final BoundingBox[] glyphBoundingBoxes = new BoundingBox [this.qtyCharMetricsExpected];
this.metrics.setGlyphBoundingBoxes(glyphBoundingBoxes);
@@ -1073,7 +1075,7 @@
* @param psServer The PostScript server.
*/
private void createCharSet(final PsServer psServer) {
- final short[] extentTable = this.metrics.getExtentTable();
+ final ShortArrayBuilder extentTable = this.metrics.getExtentTable();
// Sort the char array and any related arrays
boolean anyChanges = true;
while (anyChanges) {
@@ -1085,9 +1087,7 @@
this.codePoints[i] = this.codePoints[i + 1];
this.codePoints[i + 1] = saveInt;
/* Also switch the same elements in the width array. */
- final short saveShort = extentTable[i];
- extentTable[i] = extentTable[i + 1];
- extentTable[i + 1] = saveShort;
+ extentTable.swap(i, i + 1);
anyChanges = true;
}
}
@@ -1458,13 +1458,13 @@
} else {
charIndex = this.metrics.getCharSet().getIndex(theChar);
}
- final short[] extentTable = this.metrics.getExtentTable();
+ final ShortArrayBuilder extentTable = this.metrics.getExtentTable();
if (charIndex < 0
- || charIndex > extentTable.length) {
+ || charIndex > extentTable.length()) {
throw new FontException("Cannot encode glyph name: " + this.glyphName + " at line: "
+ this.currentLineNumber);
}
- extentTable[charIndex] = this.charWidth;
+ extentTable.setShortAt(charIndex, this.charWidth);
this.metrics.getGlyphBoundingBoxes()[charIndex] = this.glyphBoundingBox;
if (this.glyphIndex > -1) {
/* Accumulate the information needed to create the internal
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -31,6 +31,7 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.FontServer4a;
import org.foray.font.format.Kerning;
+import org.foray.primitive.sequence.ShortArrayBuilder;
import org.axsl.constants.CharsetConstants;
import org.axsl.constants.PrimitiveConstants;
@@ -349,7 +350,7 @@
if (charSet == null) {
return;
}
- final short[] extentTable = new short[charSet.size()];
+ final ShortArrayBuilder extentTable = new ShortArrayBuilder(charSet.size());
this.metrics.setMinWidth(this.metrics.getMaxWidth());
for (int i = this.dfFirstChar; i <= this.dfLastChar; i++) {
final short width = (short) this.input.readUnsignedShortLoHi();
@@ -357,10 +358,10 @@
final int codePoint = internalEncoding.decode(encodedIndex);
final int charSetIndex = charSet.getIndex(codePoint);
if (charSetIndex < 0
- || charSetIndex >= extentTable.length) {
+ || charSetIndex >= extentTable.length()) {
continue;
}
- extentTable[charSetIndex] = width;
+ extentTable.setShortAt(charSetIndex, width);
if (width < this.metrics.getMinWidth()) {
this.metrics.setMinWidth(width);
}
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-Bold.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-BoldOblique.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-Oblique.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-Bold.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-BoldOblique.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-Oblique.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Symbol.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Bold.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-BoldItalic.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Italic.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Roman.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/ZapfDingbats.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1MetricsParserAfmTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1MetricsParserAfmTests.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1MetricsParserAfmTests.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -65,7 +65,7 @@
/* The WX records occupy rows 26 through 340 inclusive. Also, 315 agrees with the "StartCharMetrics 315" entry
* at line 25. */
- assertEquals(315, metrics.getExtentTable().length);
+ assertEquals(315, metrics.getExtentTable().length());
/* The KPX records occupy rows 344 through 2416 inclusive. Also, 2073 agrees with the "StartKernPairs 2073"
* entry at line 343. */
@@ -74,13 +74,13 @@
final CharSet charset = metrics.getCharSet();
assertEquals(315, charset.size());
/* Test the width of the space glyph. See line 26. */
- assertEquals(250, metrics.getCharWidths()[charset.getIndex(' ')]);
+ assertEquals(250, metrics.getCharWidths().shortAt(charset.getIndex(' ')));
/* Test the width of the "!" glyph. See line 27. */
- assertEquals(333, metrics.getCharWidths()[charset.getIndex('!')]);
+ assertEquals(333, metrics.getCharWidths().shortAt(charset.getIndex('!')));
/* Test the width of the i-macron glyph. See line 339. */
- assertEquals(278, metrics.getCharWidths()[charset.getIndex(0x012B)]);
+ assertEquals(278, metrics.getCharWidths().shortAt(charset.getIndex(0x012B)));
/* Test the width of the euro symbol glyph. See line 340. */
- assertEquals(500, metrics.getCharWidths()[charset.getIndex(0x20AC)]);
+ assertEquals(500, metrics.getCharWidths().shortAt(charset.getIndex(0x20AC)));
}
}
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/eng.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/fin.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/hun.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/ita.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/mah.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/pol.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/por.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/rus.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-orthography/src/main/resources/resources/org/foray/orthography/hyphPatterns/spa.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -41,6 +41,7 @@
import org.axsl.font.Font;
import org.axsl.font.FontUse;
import org.axsl.primitive.sequence.ByteSequencePlus;
+import org.axsl.primitive.sequence.ShortSequence;
/**
* Class representing a "character identifier" font. See PDF Reference, Second
@@ -182,7 +183,7 @@
* Returns the array of glyph widths for this font.
* @return The array of glyph widths for this font.
*/
- private short[] getCIDWidths() {
+ private ShortSequence getCIDWidths() {
if (! this.fsFont.getFont().isEmbeddable()) {
return null;
}
@@ -197,9 +198,9 @@
* entry.
* @return The String containing the /W entry.
*/
- public static String widthArrayToPDFString(final short[] widthArray) {
+ public static String widthArrayToPDFString(final ShortSequence widthArray) {
if (widthArray == null
- || widthArray.length == 0) {
+ || widthArray.length() == 0) {
return StringUtils.EMPTY_STRING;
}
final StringBuilder p = new StringBuilder();
@@ -206,15 +207,14 @@
p.append(EOL + "/W [");
int start = 0;
int end = 0;
- while (start < widthArray.length) {
- final int nextEqualRunStarts = findStartOfNextEqualRun(widthArray,
- start);
+ while (start < widthArray.length()) {
+ final int nextEqualRunStarts = findStartOfNextEqualRun(widthArray, start);
if (nextEqualRunStarts < 0) {
/*
* There are no more Equal Runs. Therefore, write the remaining
* items out as an Unequal Run.
*/
- end = widthArray.length - 1;
+ end = widthArray.length() - 1;
writeWidthArrayUnequalRun(p, widthArray, start, end);
} else if (nextEqualRunStarts == start) {
/*
@@ -229,8 +229,7 @@
*/
end = nextEqualRunStarts - 1;
writeWidthArrayUnequalRun(p, widthArray, start, end);
- end = writeWidthArrayEqualRun(p, widthArray,
- nextEqualRunStarts);
+ end = writeWidthArrayEqualRun(p, widthArray, nextEqualRunStarts);
}
start = end + 1;
}
@@ -245,11 +244,11 @@
* @param start The first element being written.
* @param end The last element being written.
*/
- private static void writeWidthArrayUnequalRun(final StringBuilder p,
- final short[] widthArray, final int start, final int end) {
+ private static void writeWidthArrayUnequalRun(final StringBuilder p, final ShortSequence widthArray,
+ final int start, final int end) {
p.append(" " + start + " [");
for (int i = start; i <= end; i++) {
- p.append(widthArray[i]);
+ p.append(widthArray.shortAt(i));
if (i < end) {
p.append(" ");
}
@@ -264,21 +263,20 @@
* @param start The first element being written.
* @return The index in {@code widthArray} to the last element written.
*/
- private static int writeWidthArrayEqualRun(final StringBuilder p,
- final short[] widthArray, final int start) {
+ private static int writeWidthArrayEqualRun(final StringBuilder p, final ShortSequence widthArray, final int start) {
// First, compute the end-point of the run.
int end = -1;
- for (int i = start; i < widthArray.length && end < 0; i++) {
- if (i + 1 >= widthArray.length) {
- end = widthArray.length - 1;
+ for (int i = start; i < widthArray.length() && end < 0; i++) {
+ if (i + 1 >= widthArray.length()) {
+ end = widthArray.length() - 1;
break;
}
- if (widthArray[i] != widthArray[i + 1]) {
+ if (widthArray.shortAt(i) != widthArray.shortAt(i + 1)) {
end = i;
}
}
// Now, write the entry
- p.append(" " + start + " " + end + " " + widthArray[start]);
+ p.append(" " + start + " " + end + " " + widthArray.shortAt(start));
return end;
}
@@ -291,12 +289,11 @@
* @return The index to the first array element that starts a run of 3 or
* more equal values in the array, or -1 if there is not one.
*/
- private static int findStartOfNextEqualRun(final short[] widthArray,
- final int start) {
+ private static int findStartOfNextEqualRun(final ShortSequence widthArray, final int start) {
int returnValue = -1;
- for (int i = start; i < widthArray.length - 2 && returnValue < 0; i++) {
- if ((widthArray[i] == widthArray[i + 1])
- && (widthArray[i] == widthArray[i + 2])) {
+ for (int i = start; i < widthArray.length() - 2 && returnValue < 0; i++) {
+ if ((widthArray.shortAt(i) == widthArray.shortAt(i + 1))
+ && (widthArray.shortAt(i) == widthArray.shortAt(i + 2))) {
returnValue = i;
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2023-01-04 03:26:37 UTC (rev 13016)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2023-01-04 04:07:57 UTC (rev 13017)
@@ -41,6 +41,7 @@
import org.axsl.orthography.Orthography;
import org.axsl.pdf.PdfFont;
import org.axsl.primitive.sequence.ByteSequencePlus;
+import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.Encoding;
import org.axsl.ps.PsEncoding;
@@ -253,7 +254,9 @@
return;
}
final PdfArray widthArray = new PdfArray();
- for (short aShort : this.fsFont.getWidths()) {
+ final ShortSequence widths = this.fsFont.getWidths();
+ for (int index = 0; index < widths.length(); index ++) {
+ final short aShort = widths.shortAt(index);
widthArray.add(aShort);
}
buffer.append("/Widths ");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|