[FOray-commit] SF.net SVN: foray:[12853] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2022-12-13 21:48:00
|
Revision: 12853
http://sourceforge.net/p/foray/code/12853
Author: victormote
Date: 2022-12-13 21:47:57 +0000 (Tue, 13 Dec 2022)
Log Message:
-----------
More cleanup of constants and utility code.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.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/SystemFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PdfTextPainter.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PsGraphics2D.java
trunk/foray/foray-mif/src/main/java/org/foray/mif/MifDocument.java
trunk/foray/foray-mif/src/main/java/org/foray/mif/MifFrame.java
trunk/foray/foray-mif/src/main/java/org/foray/mif/MifImportObject.java
trunk/foray/foray-mif/src/main/java/org/foray/mif/MifPgf.java
trunk/foray/foray-mif/src/main/java/org/foray/mif/MifTextRect.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/ByteUtils.java
trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java
Removed Paths:
-------------
trunk/foray/foray-common/src/main/java/org/foray/common/WellKnownConstants.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/Area4a.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -31,8 +31,8 @@
import org.axsl.area.Area;
import org.axsl.area.AreaTreeException;
import org.axsl.area.BlockLevelRa;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.font.FontUse;
import org.axsl.fotree.Fo;
import org.axsl.fotree.fo.BasicLink;
@@ -784,10 +784,10 @@
*/
public Rectangle2D.Float crPoints() {
return new Rectangle2D.Float(
- crOriginX() / FontConstants.MILLIPOINTS_PER_POINT,
- crOriginY() / FontConstants.MILLIPOINTS_PER_POINT,
- crIpd() / FontConstants.MILLIPOINTS_PER_POINT,
- crBpd() / FontConstants.MILLIPOINTS_PER_POINT);
+ crOriginX() / TypographicConstants.MILLIPOINTS_PER_POINT,
+ crOriginY() / TypographicConstants.MILLIPOINTS_PER_POINT,
+ crIpd() / TypographicConstants.MILLIPOINTS_PER_POINT,
+ crBpd() / TypographicConstants.MILLIPOINTS_PER_POINT);
}
/**
@@ -796,10 +796,10 @@
*/
public Rectangle2D.Float brPoints() {
return new Rectangle2D.Float(
- brOriginX() / FontConstants.MILLIPOINTS_PER_POINT,
- brOriginY() / FontConstants.MILLIPOINTS_PER_POINT,
- brIpd() / FontConstants.MILLIPOINTS_PER_POINT,
- brBpd() / FontConstants.MILLIPOINTS_PER_POINT);
+ brOriginX() / TypographicConstants.MILLIPOINTS_PER_POINT,
+ brOriginY() / TypographicConstants.MILLIPOINTS_PER_POINT,
+ brIpd() / TypographicConstants.MILLIPOINTS_PER_POINT,
+ brBpd() / TypographicConstants.MILLIPOINTS_PER_POINT);
}
/**
Deleted: trunk/foray/foray-common/src/main/java/org/foray/common/WellKnownConstants.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/WellKnownConstants.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/WellKnownConstants.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -1,199 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.common;
-
-import org.axsl.constants.PrimitiveConstants;
-import org.axsl.font.FontConstants;
-
-/**
- * Class containing well-known or commonly-used constants and conversions.
- */
-public final class WellKnownConstants {
-
- /**
- * Private constructor. This is a utility class, and should never be instantiated.
- */
- private WellKnownConstants() { }
-
- /**
- * Converts four unsigned bytes to a long.
- * (It must be converted to a long because the Java int is signed).
- * @param byte1 The high-order byte.
- * @param byte2 The second highest-order byte.
- * @param byte3 The third highest-order byte.
- * @param byte4 The low-order byte.
- * @return The long represented by the four bytes.
- */
- public static long unsignedBytesToLong(final byte byte1, final byte byte2,
- final byte byte3, final byte byte4) {
- final int int1 = unsignedByteToInt(byte1);
- final int int2 = unsignedByteToInt(byte2);
- final int int3 = unsignedByteToInt(byte3);
- final int int4 = unsignedByteToInt(byte4);
- return (int1 << PrimitiveConstants.SHIFT_3_BYTES)
- | (int2 << PrimitiveConstants.SHIFT_2_BYTES)
- | (int3 << PrimitiveConstants.SHIFT_1_BYTE)
- | int4;
- }
-
- /**
- * Converts one unsigned byte to its integer equivalent.
- * @param unsignedByte The byte to be converted.
- * @return The integer equivalent of {@code unsignedByte}.
- */
- public static int unsignedByteToInt(final byte unsignedByte) {
- final int converted = unsignedByte & PrimitiveConstants.MAX_8_BIT_UNSIGNED_INT;
- return converted;
- }
-
- /**
- * Converts four unsigned big-endian bytes from an array of bytes to a long.
- * (It must be converted to a long because the Java int is signed).
- * @param byteArray The array of bytes containing the bytes to be converted.
- * @param start The index to the first byte in the array to be converted.
- * This is the high-order byte of the 4 bytes. The second byte will be
- * indexed at start + 1, the third byte at start + 2, and the fourth byte
- * at start + 3.
- * @return The long represented by the four bytes.
- */
- public static long unsignedBytesToLongBE(final byte[] byteArray,
- final int start) {
- if (byteArray == null
- || start < 0
- || start + PrimitiveConstants.BYTES_PER_INT > byteArray.length) {
- /* Fails silently. */
- return 0;
- }
- int index = start;
- return unsignedBytesToLong(
- byteArray[index++],
- byteArray[index++],
- byteArray[index++],
- byteArray[index]);
- }
-
- /**
- * Converts four unsigned little-endian bytes from an array of bytes to a
- * long.
- * (It must be converted to a long because the Java int is signed).
- * @param byteArray The array of bytes containing the bytes to be converted.
- * @param start The index to the first byte in the array to be converted.
- * This is the low-order byte of the 4 bytes. The second byte will be
- * indexed at start + 1, the third byte at start + 2, and the fourth byte
- * (the high-order byte) at start + 3.
- * @return The long represented by the four bytes.
- */
- public static long unsignedBytesToLongLE(final byte[] byteArray,
- final int start) {
- if (byteArray == null
- || start < 0
- || start + PrimitiveConstants.BYTES_PER_INT > byteArray.length) {
- /* Fails silently. */
- return 0;
- }
- int index = start + PrimitiveConstants.BYTES_PER_INT - 1;
- return unsignedBytesToLong(
- byteArray[index--],
- byteArray[index--],
- byteArray[index--],
- byteArray[index]);
- }
-
- /**
- * Converts two unsigned bytes to an int.
- * (It must be converted to an int because the Java short is signed).
- * @param byte1 The high-order byte.
- * @param byte2 The low-order byte.
- * @return The int represented by the two bytes.
- */
- public static int unsignedBytesToInt(final byte byte1, final byte byte2) {
- return (int) unsignedBytesToLong((byte) 0, (byte) 0, byte1, byte2);
- }
-
- /**
- * Converts two unsigned big-endian bytes from an array of bytes to an int.
- * (It must be converted to an int because the Java short is signed).
- * @param byteArray The array of bytes containing the bytes to be converted.
- * @param start The index to the first byte in the array to be converted.
- * This is the high-order byte of the 2 bytes. The second byte (the
- * low-order byte) will be indexed at start + 1.
- * @return The int represented by the two bytes.
- */
- public static int unsignedBytesToIntBE(final byte[] byteArray,
- final int start) {
- if (byteArray == null
- || start < 0
- || start + PrimitiveConstants.BYTES_PER_SHORT > byteArray.length) {
- /* Fails silently. */
- return 0;
- }
- int index = start;
- return (int) unsignedBytesToLong(
- (byte) 0,
- (byte) 0,
- byteArray[index++],
- byteArray[index]);
- }
-
- /**
- * Converts two unsigned little-endian bytes from an array of bytes to an
- * int.
- * (It must be converted to an int because the Java short is signed).
- * @param byteArray The array of bytes containing the bytes to be converted.
- * @param start The index to the first byte in the array to be converted.
- * This is the low-order byte of the 4 bytes. The second byte (the
- * high-order byte) at start + 1.
- * @return The int represented by the two bytes.
- */
- public static int unsignedBytesToIntLE(final byte[] byteArray,
- final int start) {
- if (byteArray == null
- || start < 0
- || start + PrimitiveConstants.BYTES_PER_SHORT > byteArray.length) {
- /* Fails silently. */
- return 0;
- }
- int index = start + PrimitiveConstants.BYTES_PER_SHORT - 1;
- return (int) unsignedBytesToLong(
- (byte) 0,
- (byte) 0,
- byteArray[index--],
- byteArray[index]);
- }
-
- /**
- * Converts millipoints to points.
- * @param millipoints The millipoint value to be converted.
- * @return The points equivalent of {@code millipoints}.
- */
- public static float millipointsToPoints(final int millipoints) {
- return millipoints / (float) FontConstants.MILLIPOINTS_PER_POINT;
- }
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -30,8 +30,8 @@
import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.Kerning;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.ps.CharSet;
/**
@@ -220,11 +220,11 @@
return 0;
}
final int rawKerning = getKerning().kern(glyphIndex1, glyphIndex2);
- if (FontConstants.MILLIPOINTS_PER_POINT == this.getUnitsPerTextSpaceUnit()) {
+ if (TypographicConstants.MILLIPOINTS_PER_POINT == this.getUnitsPerTextSpaceUnit()) {
/* Avoid the potential loss of precision. */
return rawKerning;
}
- return Math.round(rawKerning * FontConstants.MILLIPOINTS_PER_POINT
+ return Math.round(rawKerning * TypographicConstants.MILLIPOINTS_PER_POINT
/ this.getUnitsPerTextSpaceUnit());
}
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 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -33,8 +33,8 @@
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
@@ -175,7 +175,7 @@
public int getAscender(final int fontSize) {
/* Since both size and ascender are in millipoints, divide by 1000
* to keep result in millipoints */
- final int value = fontSize * this.ascender / FontConstants.MILLIPOINTS_PER_POINT;
+ final int value = fontSize * this.ascender / TypographicConstants.MILLIPOINTS_PER_POINT;
return value;
}
@@ -183,7 +183,7 @@
public int getDescender(final int fontSize) {
/* Since both size and descender are in millipoints, divide by 1000
* to keep result in millipoints */
- return fontSize * this.descender / FontConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.descender / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
@@ -190,7 +190,7 @@
public int getCapHeight(final int fontSize) {
/* Since both size and capHeight are in millipoints, divide by 1000
* to keep result in millipoints */
- return fontSize * this.capHeight / FontConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.capHeight / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
@@ -197,7 +197,7 @@
public int getXheight(final int fontSize) {
/* Since both size and xHeight are in millipoints, divide by 1000
* to keep result in millipoints */
- return Math.round(fontSize * this.xHeight / FontConstants.MILLIPOINTS_PER_POINT);
+ return Math.round(fontSize * this.xHeight / TypographicConstants.MILLIPOINTS_PER_POINT);
}
/**
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 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -36,8 +36,8 @@
import org.foray.font.format.ttf.TrueTypeFont;
import org.foray.font.format.ttf.TtfSubSetFile;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
@@ -183,12 +183,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] / FontConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.getWidths()[glyphIndex] / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
public int widthUndefinedGlyph(final int fontSize) {
- return fontSize * this.getWidths()[0] / FontConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.getWidths()[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 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -38,8 +38,8 @@
import org.foray.font.format.type1.Type1Metrics;
import org.foray.font.format.type1.Type1MetricsParser;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.PsEncoding;
@@ -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] / FontConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.getWidths()[metricIndex] / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
public int widthUndefinedGlyph(final int fontSize) {
- return fontSize * this.getWidths()[0] / FontConstants.MILLIPOINTS_PER_POINT;
+ return fontSize * this.getWidths()[0] / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
@@ -370,12 +370,12 @@
@Override
public int underlineSize(final int fontSize) {
- return this.metricsFile.getUnderlineSize() * fontSize / FontConstants.MILLIPOINTS_PER_POINT;
+ return this.metricsFile.getUnderlineSize() * fontSize / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
public int underlinePosition(final int fontSize) {
- return this.metricsFile.getUnderlinePosition() * fontSize / FontConstants.MILLIPOINTS_PER_POINT;
+ return this.metricsFile.getUnderlinePosition() * fontSize / TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
@@ -395,7 +395,7 @@
@Override
public int getUnitsPerTextSpaceUnit() {
/* Type 1 fonts always use 1000 units per text-space unit. */
- return FontConstants.MILLIPOINTS_PER_POINT;
+ return TypographicConstants.MILLIPOINTS_PER_POINT;
}
@Override
@@ -418,12 +418,12 @@
@Override
public BoundingBox getGlyphBoundingBox(final int glyphIndex, final int fontSize) {
final BoundingBox raw = this.metricsFile.getGlyphBoundingBoxes()[glyphIndex];
- if (fontSize == FontConstants.MILLIPOINTS_PER_POINT) {
+ if (fontSize == TypographicConstants.MILLIPOINTS_PER_POINT) {
return raw;
}
final float[] scaled = new float[BoundingBox.QTY_ENTRIES];
for (int index = 0; index < BoundingBox.QTY_ENTRIES; index ++) {
- scaled[index] = raw.getCoordinateAsFloat(index) * fontSize / FontConstants.MILLIPOINTS_PER_POINT;
+ scaled[index] = raw.getCoordinateAsFloat(index) * fontSize / TypographicConstants.MILLIPOINTS_PER_POINT;
}
return BoundingBoxUtils.makeBoundingBox(scaled);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -29,7 +29,6 @@
package org.foray.font;
import org.foray.common.Environment;
-import org.foray.common.WellKnownConstants;
import org.foray.common.data.BoundingBoxUtils;
import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.FontParser;
@@ -36,7 +35,7 @@
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
@@ -125,13 +124,13 @@
// http://developer.java.sun.com/developer/bugParade/bugs/4399887.html
final int realAscent = fm.getAscent()
- (fm.getDescent() + fm.getLeading());
- return FontConstants.MILLIPOINTS_PER_POINT * realAscent;
+ return TypographicConstants.MILLIPOINTS_PER_POINT * realAscent;
}
@Override
public int getDescender(final int fontSize) {
final FontMetrics fm = getSizedFont(fontSize);
- return -1 * FontConstants.MILLIPOINTS_PER_POINT * fm.getDescent();
+ return -1 * TypographicConstants.MILLIPOINTS_PER_POINT * fm.getDescent();
}
@Override
@@ -147,7 +146,7 @@
getGraphics().getFontRenderContext());
final Rectangle2D rect = layout.getBounds();
final int xHeight = (int) rect.getHeight();
- return FontConstants.MILLIPOINTS_PER_POINT * xHeight;
+ return TypographicConstants.MILLIPOINTS_PER_POINT * xHeight;
}
@Override
@@ -161,7 +160,7 @@
ac[0] = (char) c;
double dWidth = fm.getStringBounds(ac, 0, 1, getGraphics()).getWidth()
- * FontConstants.MILLIPOINTS_PER_POINT;
+ * TypographicConstants.MILLIPOINTS_PER_POINT;
// The following was left in based on this comment from the past (may be
// vestigial)
@@ -344,7 +343,7 @@
* If so, returns it.
* If not, creates and caches new one with the new size.
*/
- final float s = WellKnownConstants.millipointsToPoints(fontSize);
+ final float s = fontSize / (float) TypographicConstants.MILLIPOINTS_PER_POINT;
/* Get local copies to make sure thread-safe. */
final FontMetrics lastFontMetrics = this.lastMetrics;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -31,8 +31,8 @@
import org.foray.font.Font4a;
import org.axsl.constants.NumericConstants;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.font.FontServer;
import org.axsl.ps.Encoding;
@@ -254,8 +254,8 @@
public float getSimulateSmallCaps() {
if (this.simulateSmallCaps == FontServer.SMALL_CAP_SIMULATION_NATIVE) {
final Font4a font = this.getRegisteredFont().getBestFont();
- this.simulateSmallCaps = font.getXheight(FontConstants.MILLIPOINTS_PER_POINT);
- this.simulateSmallCaps /= font.getAscender(FontConstants.MILLIPOINTS_PER_POINT);
+ this.simulateSmallCaps = font.getXheight(TypographicConstants.MILLIPOINTS_PER_POINT);
+ this.simulateSmallCaps /= font.getAscender(TypographicConstants.MILLIPOINTS_PER_POINT);
this.simulateSmallCaps *= NumericConstants.PERCENT_CONVERSION;
}
return this.simulateSmallCaps;
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 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -35,8 +35,8 @@
import org.foray.font.output.FontPdfUtilities;
import org.foray.primitive.BitUtils;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.Cmap;
@@ -535,7 +535,7 @@
final TtfTableHead headTable = this.getHeadTable();
final int unitsPerEm = headTable.unitsPerEm();
- final double result = ((float) fUnits) * FontConstants.MILLIPOINTS_PER_POINT / unitsPerEm;
+ final double result = ((float) fUnits) * TypographicConstants.MILLIPOINTS_PER_POINT / unitsPerEm;
final long roundedResult = Math.round(result);
/* This cast from a long to a short looks horrible, but should be safe. The results should almost always be in
* the range +/- 1500. Log an error if there is any truncation. */
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -33,7 +33,7 @@
package org.foray.graphic;
-import org.foray.common.WellKnownConstants;
+import org.foray.primitive.ByteUtils;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.constants.PrimitiveConstants;
@@ -354,10 +354,8 @@
final byte[] header = new byte[BmpGraphic.HEADERMAP_LENGTH];
getInputStream().read(header);
/* Little endian format. */
- this.pixelWidth = (int) WellKnownConstants.unsignedBytesToLongLE(header,
- BmpGraphic.WIDTH_OFFSET);
- this.pixelHeight = (int) WellKnownConstants.unsignedBytesToLongLE(header,
- BmpGraphic.HEIGHT_OFFSET);
+ this.pixelWidth = (int) ByteUtils.unsignedBytesToLongLE(header, BmpGraphic.WIDTH_OFFSET);
+ this.pixelHeight = (int) ByteUtils.unsignedBytesToLongLE(header, BmpGraphic.HEIGHT_OFFSET);
}
@Override
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -28,8 +28,8 @@
package org.foray.graphic;
-import org.foray.common.WellKnownConstants;
import org.foray.common.data.BoundingBoxUtils;
+import org.foray.primitive.ByteUtils;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.graphic.Graphic;
@@ -187,18 +187,12 @@
final byte[] fileStart = new byte[this.maxBytesToParseBasics()];
getInputStream().read(fileStart);
if (! this.isAscii) {
- this.psStart = (int) WellKnownConstants.unsignedBytesToLongBE(fileStart,
- EpsGraphic.PS_START_OFFSET);
- this.psLength = (int) WellKnownConstants.unsignedBytesToLongBE(fileStart,
- EpsGraphic.PS_LENGTH_OFFSET);
- this.wmfStart = (int) WellKnownConstants.unsignedBytesToLongBE(fileStart,
- EpsGraphic.WMF_START_OFFSET);
- this.wmfLength = (int) WellKnownConstants.unsignedBytesToLongBE(fileStart,
- EpsGraphic.WMF_LENGTH_OFFSET);
- this.tiffStart = (int) WellKnownConstants.unsignedBytesToLongBE(fileStart,
- EpsGraphic.TIFF_START_OFFSET);
- this.tiffLength = (int) WellKnownConstants.unsignedBytesToLongBE(fileStart,
- EpsGraphic.TIFF_LENGTH_OFFSET);
+ this.psStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.PS_START_OFFSET);
+ this.psLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.PS_LENGTH_OFFSET);
+ this.wmfStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.WMF_START_OFFSET);
+ this.wmfLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.WMF_LENGTH_OFFSET);
+ this.tiffStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.TIFF_START_OFFSET);
+ this.tiffLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.TIFF_LENGTH_OFFSET);
}
readBBox(fileStart);
if (this.bbox != null) {
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -28,7 +28,7 @@
package org.foray.graphic;
-import org.foray.common.WellKnownConstants;
+import org.foray.primitive.ByteUtils;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.constants.PrimitiveConstants;
@@ -208,12 +208,12 @@
icm.getGreens(greens);
icm.getBlues(blues);
for (int i = 0; i < icm.getMapSize(); i++) {
- final int alpha = WellKnownConstants.unsignedByteToInt(alphas[i]);
+ final int alpha = ByteUtils.unsignedByteToInt(alphas[i]);
if (alpha == 0) {
this.isTransparent = true;
- final int red = WellKnownConstants.unsignedByteToInt(reds[i]);
- final int green = WellKnownConstants.unsignedByteToInt(greens[i]);
- final int blue = WellKnownConstants.unsignedByteToInt(blues[i]);
+ final int red = ByteUtils.unsignedByteToInt(reds[i]);
+ final int green = ByteUtils.unsignedByteToInt(greens[i]);
+ final int blue = ByteUtils.unsignedByteToInt(blues[i]);
this.transparentColor = new Color(red, green, blue);
break;
}
@@ -241,10 +241,8 @@
final byte[] header = new byte[GifGraphic.GIF_BASICS_LENGTH];
getInputStream().read(header);
/* Little endian notation */
- this.pixelWidth = WellKnownConstants.unsignedBytesToIntLE(header,
- GifGraphic.PIXEL_WIDTH_OFFSET);
- this.pixelHeight = WellKnownConstants.unsignedBytesToIntLE(header,
- GifGraphic.PIXEL_HEIGHT_OFFSET);
+ this.pixelWidth = ByteUtils.unsignedBytesToIntLE(header, GifGraphic.PIXEL_WIDTH_OFFSET);
+ this.pixelHeight = ByteUtils.unsignedBytesToIntLE(header, GifGraphic.PIXEL_HEIGHT_OFFSET);
}
@Override
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -33,7 +33,6 @@
import org.foray.primitive.sequence.ByteArray;
import org.axsl.constants.TypographicConstants;
-import org.axsl.font.FontConstants;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.output.GraphicOutput;
import org.axsl.primitive.sequence.ByteSequence;
@@ -266,7 +265,7 @@
final int computedWidth = Math.round(
((float) pixelWidth / (float) pixelsPerInch)
* TypographicConstants.POINTS_PER_INCH
- * FontConstants.MILLIPOINTS_PER_POINT);
+ * TypographicConstants.MILLIPOINTS_PER_POINT);
return computedWidth;
}
@@ -298,7 +297,7 @@
final int computedHeight = Math.round(
((float) pixelHeight / (float) pixelsPerInch)
* TypographicConstants.POINTS_PER_INCH
- * FontConstants.MILLIPOINTS_PER_POINT);
+ * TypographicConstants.MILLIPOINTS_PER_POINT);
return computedHeight;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -35,7 +35,7 @@
package org.foray.graphic;
import org.foray.common.ColorSpaceCmyk;
-import org.foray.common.WellKnownConstants;
+import org.foray.primitive.ByteUtils;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.constants.PrimitiveConstants;
@@ -247,7 +247,7 @@
cont = processNextChunk(contentBytes, iccStream, index);
if (cont) {
index += 2;
- index += WellKnownConstants.unsignedBytesToIntBE(contentBytes, index);
+ index += ByteUtils.unsignedBytesToIntBE(contentBytes, index);
}
}
}
@@ -407,8 +407,7 @@
iccString, 0,
compareString.length());
if (compareString.equals(new String(iccString))) {
- final int chunkSize = WellKnownConstants.unsignedBytesToIntBE(contentBytes,
- index + 2);
+ final int chunkSize = ByteUtils.unsignedBytesToIntBE(contentBytes, index + 2);
iccStream.write(contentBytes, index + JpegGraphic.ICC_HEADER_SIZE,
chunkSize - JpegGraphic.ICC_HEADER_SIZE);
}
@@ -510,17 +509,14 @@
// index + 4 is the data precision (bits/sample).
// index + 5 & index + 6 are the image heigh, in pixels
// index + 7 & index + 8 are the image width, in pixels
- this.pixelHeight = WellKnownConstants.unsignedBytesToIntBE(readBuffer,
- index + JpegGraphic.HEIGHT_OFFSET);
- this.pixelWidth = WellKnownConstants.unsignedBytesToIntBE(readBuffer,
- index + JpegGraphic.WIDTH_OFFSET);
+ this.pixelHeight = ByteUtils.unsignedBytesToIntBE(readBuffer, index + JpegGraphic.HEIGHT_OFFSET);
+ this.pixelWidth = ByteUtils.unsignedBytesToIntBE(readBuffer, index + JpegGraphic.WIDTH_OFFSET);
break;
}
default: {
// Eat the segment marker and segment type bytes
index += 2;
- final int toSkip = WellKnownConstants.unsignedBytesToIntBE(readBuffer,
- index);
+ final int toSkip = ByteUtils.unsignedBytesToIntBE(readBuffer, index);
index += toSkip;
}
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -37,7 +37,6 @@
import org.axsl.constants.PrimitiveConstants;
import org.axsl.constants.TypographicConstants;
-import org.axsl.font.FontConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.primitive.sequence.ByteSequence;
@@ -354,7 +353,7 @@
return Math.round(this.pixelWidth()
/ this.xResolution
* TypographicConstants.POINTS_PER_INCH
- * FontConstants.MILLIPOINTS_PER_POINT);
+ * TypographicConstants.MILLIPOINTS_PER_POINT);
}
@Override
@@ -362,7 +361,7 @@
return Math.round(this.pixelHeight()
/ this.yResolution
* TypographicConstants.POINTS_PER_INCH
- * FontConstants.MILLIPOINTS_PER_POINT);
+ * TypographicConstants.MILLIPOINTS_PER_POINT);
}
@Override
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PdfTextPainter.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PdfTextPainter.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PdfTextPainter.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -33,10 +33,8 @@
package org.foray.graphic.batik;
-import org.foray.common.WellKnownConstants;
-
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.font.FontConsumer;
import org.axsl.font.FontContext;
import org.axsl.font.FontException;
@@ -281,9 +279,9 @@
final int letterSpacing = 0;
/* TODO: Pass the font options below instead of hard-coding them. */
final int width = fontToUse.width(txt, 0, txt.length(),
- awtFontSize * FontConstants.MILLIPOINTS_PER_POINT, letterSpacing, 0, FontContext.DEFAULT,
+ awtFontSize * TypographicConstants.MILLIPOINTS_PER_POINT, letterSpacing, 0, FontContext.DEFAULT,
this.orthography);
- final float advance = WellKnownConstants.millipointsToPoints(width);
+ final float advance = width / (float) TypographicConstants.MILLIPOINTS_PER_POINT;
float tx = 0;
if (anchor != null) {
switch (anchor.getType()) {
@@ -334,7 +332,7 @@
FontUtility.foFontFamily(this.fontFamily),
style, weight, Font.Variant.NORMAL,
org.axsl.font.Font.Stretch.NORMAL,
- fsize * FontConstants.MILLIPOINTS_PER_POINT,
+ fsize * TypographicConstants.MILLIPOINTS_PER_POINT,
' ');
if (font != null) {
/* TODO: Since PdfGraphics2D has moved to the foray-pdf project, this test can no longer be done.
@@ -355,7 +353,7 @@
weight,
Font.Variant.NORMAL,
org.axsl.font.Font.Stretch.NORMAL,
- fsize * FontConstants.MILLIPOINTS_PER_POINT,
+ fsize * TypographicConstants.MILLIPOINTS_PER_POINT,
' ');
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PsGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PsGraphics2D.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PsGraphics2D.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -40,7 +40,7 @@
import org.foray.primitive.StringUtils;
import org.axsl.constants.PrimitiveConstants;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
import org.axsl.graphic.Graphic;
import org.apache.xmlgraphics.java2d.AbstractGraphics2D;
@@ -313,7 +313,7 @@
final int qtyElements) {
final StringBuilder buffer = new StringBuilder();
for (int i = 0; i < qtyElements; i++) {
- buffer.append(PsUtil.doubleOut(FontConstants.MILLIPOINTS_PER_POINT * matrix[i]));
+ buffer.append(PsUtil.doubleOut(TypographicConstants.MILLIPOINTS_PER_POINT * matrix[i]));
buffer.append(StringUtils.SINGLE_SPACE);
}
return buffer.toString();
@@ -426,7 +426,7 @@
this.out.write("[");
for (int count = 0; count < da.length; count++) {
this.out.write(""
- + (FontConstants.MILLIPOINTS_PER_POINT
+ + (TypographicConstants.MILLIPOINTS_PER_POINT
* (int) da[count]));
if (count < da.length - 1) {
this.out.write(" ");
@@ -434,7 +434,7 @@
}
this.out.write("] ");
final float offset = bs.getDashPhase();
- this.out.write((FontConstants.MILLIPOINTS_PER_POINT
+ this.out.write((TypographicConstants.MILLIPOINTS_PER_POINT
* (int) offset) + " setdash");
}
final int ec = bs.getEndCap();
@@ -464,12 +464,12 @@
}
final float lw = bs.getLineWidth();
this.out.write(PsUtil.doubleOut(
- FontConstants.MILLIPOINTS_PER_POINT * lw)
+ TypographicConstants.MILLIPOINTS_PER_POINT * lw)
+ " setlinewidth");
final float ml = bs.getMiterLimit();
this.out.write(PsUtil.doubleOut(
- FontConstants.MILLIPOINTS_PER_POINT * ml)
+ TypographicConstants.MILLIPOINTS_PER_POINT * ml)
+ " setmiterlimit");
}
}
Modified: trunk/foray/foray-mif/src/main/java/org/foray/mif/MifDocument.java
===================================================================
--- trunk/foray/foray-mif/src/main/java/org/foray/mif/MifDocument.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-mif/src/main/java/org/foray/mif/MifDocument.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -28,7 +28,7 @@
package org.foray.mif;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
/**
* A MIF Document.
@@ -56,8 +56,8 @@
final StringBuilder mif = new StringBuilder();
mif.append(MifBook.EOL
+ "<Document " + MifBook.EOL
- + "<DPageSize " + this.width / FontConstants.MILLIPOINTS_PER_POINT
- + " " + this.height / FontConstants.MILLIPOINTS_PER_POINT + " >"
+ + "<DPageSize " + this.width / TypographicConstants.MILLIPOINTS_PER_POINT
+ + " " + this.height / TypographicConstants.MILLIPOINTS_PER_POINT + " >"
+ MifBook.EOL
+ ">");
return mif.toString();
Modified: trunk/foray/foray-mif/src/main/java/org/foray/mif/MifFrame.java
===================================================================
--- trunk/foray/foray-mif/src/main/java/org/foray/mif/MifFrame.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-mif/src/main/java/org/foray/mif/MifFrame.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -28,7 +28,7 @@
package org.foray.mif;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
import java.util.ArrayList;
import java.util.List;
@@ -109,10 +109,10 @@
+ MifBook.TAB + "<AnchorAlign Center>" + MifBook.EOL);
mif.append(MifBook.TAB + "<ShapeRect "
- + this.x / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.y / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.w / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.h / FontConstants.MILLIPOINTS_PER_POINT + " >");
+ + this.x / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.y / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.w / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.h / TypographicConstants.MILLIPOINTS_PER_POINT + " >");
for (int i = 0; i < this.content.size(); i++) {
mif.append(this.content.get(i).mifContent());
Modified: trunk/foray/foray-mif/src/main/java/org/foray/mif/MifImportObject.java
===================================================================
--- trunk/foray/foray-mif/src/main/java/org/foray/mif/MifImportObject.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-mif/src/main/java/org/foray/mif/MifImportObject.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -28,7 +28,7 @@
package org.foray.mif;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
/**
* A MIF Import Object.
@@ -95,10 +95,10 @@
mif.append(MifBook.TAB + "<ImportObFileDI " + "`<c\\>" + path + "'"
+ " >" + MifBook.EOL);
mif.append(MifBook.TAB + "<ShapeRect "
- + this.x / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.y / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.w / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.h / FontConstants.MILLIPOINTS_PER_POINT + " >"
+ + this.x / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.y / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.w / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.h / TypographicConstants.MILLIPOINTS_PER_POINT + " >"
+ MifBook.EOL);
mif.append("> #End ImportObj");
return mif.toString();
Modified: trunk/foray/foray-mif/src/main/java/org/foray/mif/MifPgf.java
===================================================================
--- trunk/foray/foray-mif/src/main/java/org/foray/mif/MifPgf.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-mif/src/main/java/org/foray/mif/MifPgf.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -28,7 +28,7 @@
package org.foray.mif;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
import java.util.ArrayList;
import java.util.List;
@@ -104,11 +104,10 @@
+ "<Pgf" + MifBook.EOL
+ "<PgfTag `Body'>" + MifBook.EOL
+ "<PgfLIndent "
- + this.pgf.getStartIndent()
- / FontConstants.MILLIPOINTS_PER_POINT
+ + this.pgf.getStartIndent() / TypographicConstants.MILLIPOINTS_PER_POINT
+ ">" + MifBook.EOL);
mif.append("<PgfRIndent "
- + this.pgf.getEndIndent() / FontConstants.MILLIPOINTS_PER_POINT
+ + this.pgf.getEndIndent() / TypographicConstants.MILLIPOINTS_PER_POINT
+ ">"
+ MifBook.EOL
+ ">");
Modified: trunk/foray/foray-mif/src/main/java/org/foray/mif/MifTextRect.java
===================================================================
--- trunk/foray/foray-mif/src/main/java/org/foray/mif/MifTextRect.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-mif/src/main/java/org/foray/mif/MifTextRect.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -28,7 +28,7 @@
package org.foray.mif;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
/**
* A MIF Text Rectangle.
@@ -114,15 +114,15 @@
+ "<TextRect" + MifBook.EOL
+ MifBook.TAB + "<ID " + this.textRectID + ">" + MifBook.EOL
+ MifBook.TAB + "<ShapeRect "
- + this.rx / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.ry / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.w / FontConstants.MILLIPOINTS_PER_POINT + " "
- + this.h / FontConstants.MILLIPOINTS_PER_POINT + ">");
+ + this.rx / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.ry / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.w / TypographicConstants.MILLIPOINTS_PER_POINT + " "
+ + this.h / TypographicConstants.MILLIPOINTS_PER_POINT + ">");
if (this.numCols > 1) {
mif.append(MifBook.EOL + "<TRNumColumns " + this.numCols + ">");
mif.append(MifBook.EOL + "<TRColumnGap "
- + this.colGap / FontConstants.MILLIPOINTS_PER_POINT + ">");
+ + this.colGap / TypographicConstants.MILLIPOINTS_PER_POINT + ">");
}
mif.append(MifBook.EOL + "> #End TextRect");
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -29,7 +29,6 @@
package org.foray.orthography;
import org.foray.common.MarkedIndexOutOfBoundsException;
-import org.foray.common.WellKnownConstants;
import org.foray.common.primitive.CharSequenceUtils;
import org.foray.common.primitive.UnicodeCharUtils;
import org.foray.common.primitive.XmlCharacterUtils;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/interact/annotation/PdfLink.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -35,7 +35,7 @@
import org.foray.pdf.structure.PdfTextString;
import org.foray.primitive.sequence.ByteArray;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
import org.axsl.primitive.sequence.ByteSequencePlus;
import java.awt.geom.Rectangle2D;
@@ -124,13 +124,13 @@
+ "/Type /Annot" + EOL
+ "/Subtype /Link" + EOL
+ "/Rect ["
- + getRectangle().getX() / FontConstants.MILLIPOINTS_PER_POINT
+ + getRectangle().getX() / TypographicConstants.MILLIPOINTS_PER_POINT
+ " "
- + getRectangle().getY() / FontConstants.MILLIPOINTS_PER_POINT
+ + getRectangle().getY() / TypographicConstants.MILLIPOINTS_PER_POINT
+ " "
- + (getRectangle().getX() + getRectangle().getWidth()) / FontConstants.MILLIPOINTS_PER_POINT
+ + (getRectangle().getX() + getRectangle().getWidth()) / TypographicConstants.MILLIPOINTS_PER_POINT
+ " "
- + (getRectangle().getY() - getRectangle().getHeight()) / FontConstants.MILLIPOINTS_PER_POINT
+ + (getRectangle().getY() - getRectangle().getHeight()) / TypographicConstants.MILLIPOINTS_PER_POINT
+ "]" + EOL);
buffer.append("/BS " + doc.getDefaultBorderStyle()
.pdfReference(doc) + EOL);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontDescriptor.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -33,8 +33,8 @@
import org.foray.pdf.type.PdfObject;
import org.foray.primitive.sequence.ByteArray;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
-import org.axsl.font.FontConstants;
import org.axsl.pdf.PdfException;
import org.axsl.primitive.sequence.ByteSequencePlus;
@@ -148,11 +148,11 @@
p.append(EOL + "/Flags ");
p.append(font.getFlags());
p.append(EOL + "/CapHeight ");
- p.append(font.getCapHeight(FontConstants.MILLIPOINTS_PER_POINT));
+ p.append(font.getCapHeight(TypographicConstants.MILLIPOINTS_PER_POINT));
p.append(EOL + "/Ascent ");
- p.append(font.getAscender(FontConstants.MILLIPOINTS_PER_POINT));
+ p.append(font.getAscender(TypographicConstants.MILLIPOINTS_PER_POINT));
p.append(EOL + "/Descent ");
- p.append(font.getDescender(FontConstants.MILLIPOINTS_PER_POINT));
+ p.append(font.getDescender(TypographicConstants.MILLIPOINTS_PER_POINT));
p.append(EOL + "/ItalicAngle ");
p.append(getItalicAngleFormatted());
p.append(EOL + "/StemV ");
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -42,7 +42,7 @@
import org.axsl.constants.NumericConstants;
import org.axsl.constants.PrimitiveConstants;
-import org.axsl.font.FontConstants;
+import org.axsl.constants.TypographicConstants;
import org.axsl.font.FontConsumer;
import org.axsl.font.FontUse;
import org.axsl.font.FontUtility;
@@ -717,7 +717,7 @@
fontStyle, fontWeight,
org.axsl.font.Font.Variant.NORMAL,
org.axsl.font.Font.Stretch.NORMAL,
- (int) (fontSize * FontConstants.MILLIPOINTS_PER_POINT),
+ (int) (fontSize * TypographicConstants.MILLIPOINTS_PER_POINT),
' ');
if (fontUse == null) {
fontUse = this.fontConsumer.selectFontFallback();
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/ByteUtils.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/ByteUtils.java 2022-12-13 21:13:16 UTC (rev 12852)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/ByteUtils.java 2022-12-13 21:47:57 UTC (rev 12853)
@@ -120,4 +120,150 @@
return (byte) HEX_CHARS.charAt(index);
}
+ /**
+ * Converts four unsigned bytes to a long.
+ * (It must be converted to a long because the Java int is signed).
+ * @param byte1 The high-order byte.
+ * @param byte2 The second highest-order byte.
+ * @param byte3 The third highest-order byte.
+ * @param byte4 The low-order byte.
+ * @return The long represented by the four bytes.
+ */
+ public static long unsignedBytesToLong(final byte byte1, final byte byte2,
+ final byte byte3, final byte byte4) {
+ final int int1 = unsignedByteToInt(byte1);
+ final int int2 = unsignedByteToInt(byte2);
+ final int int3 = unsignedByteToInt(byte3);
+ final int int4 = unsignedByteToInt(byte4);
+ return (int1 << PrimitiveConstants.SHIFT_3_BYTES)
+ | (int2 << PrimitiveConstants.SHIFT_2_BYTES)
+ | (int3 << PrimitiveConstants.SHIFT_1_BYTE)
+ | int4;
+ }
+
+ /**
+ * Converts one unsigned byte to its integer equivalent.
+ * @param unsignedByte The byte to be converted.
+ * @return The integer equivalent of {@code unsignedByte}.
+ */
+ public static int unsignedByteToInt(final byte unsignedByte) {
+ final int converted = unsignedByte & PrimitiveConstants.MAX_8_BIT_UNSIGNED_INT;
+ return converted;
+ }
+
+ /**
+ * Converts four unsigned big-endian bytes from an array of bytes to a long.
+ * (It must be converted to a long because the Java int is signed).
+ * @param byteArray The array of bytes containing the bytes to be converted.
+ * @param start The index to the first byte in the array to be converted.
+ * This is the high-order byte of the 4 bytes. The second byte will be
+ * indexed at start + 1, the third byte at start + 2, and the fourth byte
+ * at start + 3.
+ * @return The long represented by the four bytes.
+ */
+ public static long unsignedBytesToLongBE(final byte[] byteArray,
+ final int start) {
+ if (byteArray == null
+ || start < 0
+ || start + PrimitiveConstants.BYTES_PER_INT > byteArray.length) {
+ /* Fails silently. */
+ return 0;
+ }
+ int index = start;
+ return unsignedBytesToLong(
+ byteArray[index++],
+ byteArray[index++],
+ byteArray[index++],
+ byteArray[index]);
+ }
+
+ /**
+ * Converts four unsigned little-endian bytes from an array of bytes to a
+ * long.
+ * (It must be converted to a long because the Java int is signed).
+ * @param byteArray The array of bytes containing the bytes to be converted.
+ * @param start The index to the first byte in the array to be converted.
+ * This is the low-order byte of the 4 bytes. The second byte will be
+ * indexed at start + 1, the third byte at start + 2, and the fourth byte
+ * (the high-order byte) at start + 3.
+ * @return The long represented by the four bytes.
+ */
+ public static long unsignedBytesToLongLE(final byte[] byteArray,
+ final int start) {
+ if (byteArray == null
+ || start < 0
+ || start + PrimitiveConstants.BYTES_PER_INT > byteArray.length) {
+ /* Fails silently. */
+ return 0;
+ }
+ int index = start + PrimitiveConstants.BYTES_PER_INT - 1;
+ return unsignedBytesToLong(
+ byteArray[index--],
+ byteArray[index--],
+ byteArray[index--],
+ byteArray[index]);
+ }
+
+ /**
+ * Converts two unsigned bytes to an int.
+ * (It must be converted to an int because the Java short is signed).
+ * @param byte1 The high-order byte.
+ * @param byte2 The low-order byte.
+ * @return The int represented by the two bytes.
+ */
+ public static int unsignedBytesToInt(final byte byte1, final byte byte2) {
+ return (int) unsignedBytesToLong((byte) 0, (byte) 0, byte1, byte2);
+ }
+
+ /**
+ * Converts two unsigned big-endian bytes from an array of bytes to an int.
+ * (It must be converted to an int because the Java short is signed).
+ * @param byteArray The array of bytes containing the bytes to be converted.
+ * @param start The index to the first byte in the array to be converted.
+ * This is the high-order byte of the 2 bytes. The second byte (the
+ * low-order byte) will be indexed at start + 1.
+ * @return The int represented by the two bytes.
+ */
+ public static int unsignedBytesToIntBE(final byte[] byteArray,
+ final int start) {
+ if (byteArray == null
+ || start < 0
+ || start + PrimitiveConstants.BYTES_PER_SHORT > byteArray.length) {
+ /* Fails silently. */
+ return 0;
+ }
+ int index = start;
+ return (int) unsignedBytesToLong(
+ (byte) 0,
+ (byte) 0,
+ byteArray[index++],
+ byteArray[index]);
+ }
+
+ /**
+ * Converts two unsigned little-endian bytes from an array of bytes to an
+ * int.
+ * (It must be converted to an int because the Java short is signed).
+ * @param byteArray The array of bytes containing the bytes to be converted.
+ * @param start The index to the first byte in the array to be converted.
+ * This is the low-order byte of the 4 bytes. The second byte (the
+ * high-order byte) at start + 1.
+ * @return The int represented by the two bytes.
+ */
+ public static int unsignedBytesToIntLE(final byte[] byteArray,
+ final int start) {
+ if (byteArray == null
+ || start < 0
+ || star...
[truncated message content] |