foray-commit Mailing List for FOray (Page 34)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2023-01-10 11:34:11
|
Revision: 13050
http://sourceforge.net/p/foray/code/13050
Author: victormote
Date: 2023-01-10 11:34:08 +0000 (Tue, 10 Jan 2023)
Log Message:
-----------
1. Remove requirement to have a Postscript server for parsing a TTF file. 2. Add test class of parsing of TTF file.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeCollectionLister.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/ttf/TtfOffsetTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableCmap.java
trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/OtfLookupGsubTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/TrueTypeCollectionParserTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/TrueTypeFontParserTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java
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-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -101,7 +101,7 @@
*/
public void parseFont() throws FontException, IOException {
final TrueTypeContainer ttfFile = (TrueTypeContainer)
- getRegisteredFont().createFontFileReader().createFontFile();
+ getRegisteredFont().createFontFileReader().parseFontFile();
final String fontName = getRegisteredFont().getTTCName();
try {
this.ttf = ttfFile.getTTFFont(fontName);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java 2023-01-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -317,7 +317,7 @@
this.successCount ++;
final FontContent fontFile;
try {
- fontFile = reader.createFontFile();
+ fontFile = reader.parseFontFile();
} catch (final FontException e) {
throw new IllegalStateException(e);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2023-01-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -213,7 +213,7 @@
* or null this is not a recognized font file format.
* @throws FontException For errors reading content.
*/
- public FontContent createFontFile() throws FontException {
+ public FontContent parseFontFile() throws FontException {
if (this.fontFileCreated == true) {
return this.fontFile;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeCollectionLister.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeCollectionLister.java 2023-01-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeCollectionLister.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -95,7 +95,7 @@
return;
}
- final FontContent fontFile = reader.createFontFile();
+ final FontContent fontFile = reader.parseFontFile();
if (! (fontFile instanceof TrueTypeCollection)) {
return;
}
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-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -29,7 +29,6 @@
package org.foray.font.format.ttf;
import org.foray.common.RandomAccessInput;
-import org.foray.font.format.FontParserClient;
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
import org.foray.font.output.FontPdfUtilities;
@@ -146,12 +145,11 @@
* Factory method that parses a font from random-access input.
* @param ttfTableDir The table directory from which this font should be created.
* @param raInput The input that should be parsed.
- * @param parserClient The client requesting the parsing.
* @return The newly-created {@link TrueTypeFont} instance.
* @throws IOException For I/O errors parsing the input.
*/
- public static TrueTypeFont parse(final TtfOffsetTable ttfTableDir, final RandomAccessInput raInput,
- final FontParserClient parserClient) throws IOException {
+ public static TrueTypeFont parse(final TtfOffsetTable ttfTableDir, final RandomAccessInput raInput)
+ throws IOException {
if (ttfTableDir.getTTFFont() != null) {
return ttfTableDir.getTTFFont();
}
@@ -175,8 +173,7 @@
/* Then the CMAP, so that glyph indexes can be computed. */
dirEntry = ttfTableDir.getTableDirectoryEntry("cmap");
- font.cmapTable = TtfTableCmap.parse(dirEntry, raInput, parserClient.getPsServer(),
- font.nameTable.getPostscriptName());
+ font.cmapTable = TtfTableCmap.parse(dirEntry, raInput, font.nameTable.getPostscriptName());
/* Read the Horizontal Header before the Horizontal Metrics. */
dirEntry = ttfTableDir.getTableDirectoryEntry("hhea");
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfOffsetTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfOffsetTable.java 2023-01-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfOffsetTable.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -132,8 +132,7 @@
if (this.ttfFont != null) {
return;
}
- this.ttfFont = TrueTypeFont.parse(this, this.getTTFFile().getReader().getRandomInput(),
- this.container.getReader().getFontParserClient());
+ this.ttfFont = TrueTypeFont.parse(this, this.getTTFFile().getReader().getRandomInput());
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableCmap.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableCmap.java 2023-01-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableCmap.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -29,11 +29,12 @@
package org.foray.font.format.ttf;
import org.foray.common.RandomAccessInput;
+import org.foray.ps.encode.Cmap04Ttf4a;
+import org.foray.ps.encode.Cmap12Ttf4a;
import org.axsl.ps.Cmap;
import org.axsl.ps.Cmap04Ttf;
import org.axsl.ps.Cmap12Ttf;
-import org.axsl.ps.PsServer;
import java.io.IOException;
@@ -85,13 +86,12 @@
* Currently only unicode cmaps are supported.
* @param dirEntry The parent table directory entry.
* @param raInput The input which is being parsed.
- * @param psServer The PostScript server.
* @param fontPostScriptName The PostScript name of this font.
* @return The parsed instance.
* @throws IOException For I/O Error.
*/
public static TtfTableCmap parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final PsServer psServer, final String fontPostScriptName) throws IOException {
+ final String fontPostScriptName) throws IOException {
raInput.seek(dirEntry.getOffset());
final TtfTableCmap cmap = new TtfTableCmap(dirEntry);
/* Skip table version. */
@@ -135,7 +135,7 @@
// getLogger().warn("No Unicode cmap table: " + this.ttfFont().getFontName());
// return;
// }
- cmap.unicodeCMap = parseCMap(dirEntry, raInput, offsetToParse, psServer, fontPostScriptName);
+ cmap.unicodeCMap = parseCMap(dirEntry, raInput, offsetToParse, fontPostScriptName);
return cmap;
}
@@ -144,13 +144,12 @@
* @param dirEntry The parent table directory entry.
* @param raInput The input which is being parsed.
* @param offsetToParse The offset of the table to be parsed.
- * @param psServer The PostScript server.
* @param fontPostScriptName The PostScript name of this font.
* @return The parsed Cmap4a instance.
* @throws IOException For I/O Error.
*/
private static Cmap parseCMap(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final long offsetToParse, final PsServer psServer, final String fontPostScriptName) throws IOException {
+ final long offsetToParse, final String fontPostScriptName) throws IOException {
int tableOffset = dirEntry.getOffset();
tableOffset += offsetToParse;
raInput.seek(tableOffset);
@@ -165,10 +164,10 @@
}
switch (formatHigh) {
case TtfTableCmap.CMAP_FORMAT_4: {
- return parseCMap04(raInput, psServer, fontPostScriptName);
+ return parseCMap04(raInput, fontPostScriptName);
}
case TtfTableCmap.CMAP_FORMAT_12: {
- return parseCMap12(raInput, psServer, fontPostScriptName);
+ return parseCMap12(raInput, fontPostScriptName);
}
}
return null;
@@ -177,13 +176,12 @@
/**
* Parse a Cmap4a format 4 table.
* @param raInput The input which is being parsed.
- * @param psServer The PostScript server.
* @param fontPostScriptName The PostScript name of this font.
* @return The parsed Cmap4a format 4 table.
* @throws IOException For I/O Error.
*/
- private static Cmap04Ttf parseCMap04(final RandomAccessInput raInput, final PsServer psServer,
- final String fontPostScriptName) throws IOException {
+ private static Cmap04Ttf parseCMap04(final RandomAccessInput raInput, final String fontPostScriptName)
+ throws IOException {
/* Format and Length have already been read. */
/* Skip version */
raInput.skipBytes(USHORT_BYTES);
@@ -223,7 +221,7 @@
// Parse the table entries and build a CMap4 from them.
final String encodingName = "internal-" + fontPostScriptName;
- final Cmap04Ttf cmap04 = psServer.createCmap04(encodingName, segCountX2 / 2);
+ final Cmap04Ttf cmap04 = new Cmap04Ttf4a(encodingName, segCountX2 / 2);
for (int i = 0; i < startCount.length; i++) {
if (rangeOffset[i] == 0) {
cmap04.addEntry(startCount[i],
@@ -254,16 +252,13 @@
/**
* Creates a Cmap4a12 instance by parsing the subtable contents.
* @param raInput The input which is being parsed.
- * @param psServer The PostScript server.
* @param fontPostScriptName The PostScript name of this font.
* @return A Cmap4a12 instance.
* @throws IOException If error reading file.
- * @see
- * <a href="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html">
- * The Apple doc for the cmap table</a>
+ * @see <a href="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html">The Apple doc for the cmap table</a>
*/
- private static Cmap12Ttf parseCMap12(final RandomAccessInput raInput, final PsServer psServer,
- final String fontPostScriptName) throws IOException {
+ private static Cmap12Ttf parseCMap12(final RandomAccessInput raInput, final String fontPostScriptName)
+ throws IOException {
/* Format and Length have already been read. */
/* Skip language. */
raInput.skipBytes(ULONG_BYTES);
@@ -270,7 +265,7 @@
final int nGroups = (int) raInput.readUnsignedInt();
final String encodingName = "internal-" + fontPostScriptName;
- final Cmap12Ttf cmap12 = psServer.createCmap12(encodingName, nGroups);
+ final Cmap12Ttf cmap12 = new Cmap12Ttf4a(encodingName, nGroups);
for (int i = 0; i < nGroups; i++) {
final int startCharCode = (int) raInput.readUnsignedInt();
Added: trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java (rev 0)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2023 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.font;
+
+import org.foray.font.format.FontContent;
+import org.foray.font.format.FontFileFormat;
+import org.foray.font.format.FontParser;
+import org.foray.font.format.ttf.TrueTypeFont;
+import org.foray.font.format.ttf.TrueTypeSingle;
+
+import org.axsl.font.Font;
+import org.axsl.font.FontException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.junit.jupiter.api.Test;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ * Tests of {@link FsTrueTypeFont}.
+ */
+public class FsTrueTypeFontTests {
+
+ /**
+ * Tests of {@link FsType1Font#width(int, int)}.
+ */
+ @Test
+ public void contentTest() throws IOException, FontException {
+ final FontParser parser = new FontParser(null, new FileInputStream(
+ "./src/test/resources/source-dejavu/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif.ttf"));
+ assertEquals(FontFileFormat.TTF_SINGLEFONT, parser.getFileFormat());
+ assertEquals(Font.Format.TRUETYPE, parser.getFontFormat());
+
+ final FontContent fontContent = parser.parseFontFile();
+ assertEquals(TrueTypeSingle.class, fontContent.getClass());
+ final TrueTypeSingle content = (TrueTypeSingle) fontContent;
+ assertEquals(1, content.getTTFFonts().length);
+ final TrueTypeFont font = content.getTTFFont("bogus");
+ assertNotNull(font);
+ assertEquals("DejaVu Serif", font.getFontName());
+
+ /* TODO: Add more assertions about the parsed font here. */
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/OtfLookupGsubTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/OtfLookupGsubTests.java 2023-01-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/OtfLookupGsubTests.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -79,7 +79,7 @@
final ByteSequenceParser bsp = new ByteSequenceParser(inputStream);
final FontParser parser = new FontParser(fontServer, bsp);
- final FontContent fontContent = parser.createFontFile();
+ final FontContent fontContent = parser.parseFontFile();
assertTrue(fontContent instanceof TrueTypeSingle);
final TrueTypeSingle ttfSingle = (TrueTypeSingle) fontContent;
OtfLookupGsubTests.ttfFont = ttfSingle.getTTFFont(null);
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/TrueTypeCollectionParserTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/TrueTypeCollectionParserTests.java 2023-01-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/TrueTypeCollectionParserTests.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -64,7 +64,7 @@
final ByteSequenceParser bsp = new ByteSequenceParser(inputStream);
final FontParser reader = new FontParser(fontServer, bsp);
- final FontContent fontContent = reader.createFontFile();
+ final FontContent fontContent = reader.parseFontFile();
assertTrue(fontContent instanceof TrueTypeCollection);
final TrueTypeCollection ttc = (TrueTypeCollection) fontContent;
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/TrueTypeFontParserTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/TrueTypeFontParserTests.java 2023-01-10 01:15:55 UTC (rev 13049)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/TrueTypeFontParserTests.java 2023-01-10 11:34:08 UTC (rev 13050)
@@ -106,7 +106,7 @@
final ByteSequenceParser bsp = new ByteSequenceParser(inputStream);
final FontParser parser = new FontParser(fontServer, bsp);
- final FontContent fontContent = parser.createFontFile();
+ final FontContent fontContent = parser.parseFontFile();
assertTrue(fontContent instanceof TrueTypeSingle);
final TrueTypeSingle ttfSingle = (TrueTypeSingle) fontContent;
final TrueTypeFont ttfFont = ttfSingle.getTTFFont(null);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-10 01:15:57
|
Revision: 13049
http://sourceforge.net/p/foray/code/13049
Author: victormote
Date: 2023-01-10 01:15:55 +0000 (Tue, 10 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Move MIME constants class to aXSL.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
Removed Paths:
-------------
trunk/foray/foray-common/src/main/java/org/foray/common/Mime.java
Deleted: trunk/foray/foray-common/src/main/java/org/foray/common/Mime.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/Mime.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/Mime.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -1,70 +0,0 @@
-/*
- * Copyright 2007 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;
-
-/**
- * An enumeration of some mime-types.
- */
-public enum Mime {
-
- /** The MIME type for PDF. */
- PDF("application/pdf"),
-
- /** The MIME type for PostScript. */
- POSTSCRIPT("application/postscript"),
-
- /** The (pseudo) MIME type for Java 2D output. */
- JAVA2D("java/java2d"),
-
- /** The MIME type for SVG. */
- SVG("image/svg+xml"),
-
- /** The (assumed) MIME type for MathML documents. */
- MATHML("text/mathml");
-
- /** The string used to designate this mime type. */
- private String mimeString;
-
- /**
- * Private Constructor.
- * @param mimeString The string used to designate this mime type.
- */
- Mime(final String mimeString) {
- this.mimeString = mimeString;
- }
-
- /**
- * Returns the string used to designate this mime type.
- * @return The string used to designate this mime type.
- */
- public String getMimeString() {
- return this.mimeString;
- }
-
-}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -28,8 +28,7 @@
package org.foray.graphic;
-import org.foray.common.Mime;
-
+import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.primitive.sequence.ByteSequence;
@@ -117,7 +116,7 @@
@Override
public String getMimeType() {
- return Mime.MATHML.getMimeString();
+ return MimeConstants.MIME_MATHML;
}
@Override
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -28,9 +28,9 @@
package org.foray.graphic;
-import org.foray.common.Mime;
import org.foray.graphic.batik.BatikUaAwt;
+import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.primitive.sequence.ByteSequence;
@@ -129,7 +129,7 @@
@Override
public String getMimeType() {
- return Mime.SVG.getMimeString();
+ return MimeConstants.MIME_SVG;
}
@Override
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -28,10 +28,10 @@
package org.foray.graphic.output;
-import org.foray.common.Mime;
import org.foray.graphic.Graphic4a;
import org.foray.graphic.SvgGraphic;
+import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
@@ -59,7 +59,7 @@
@Override
public String getMimeType() {
- return Mime.JAVA2D.getMimeString();
+ return MimeConstants.MIME_JAVA2D;
}
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -28,11 +28,11 @@
package org.foray.graphic.output;
-import org.foray.common.Mime;
import org.foray.graphic.Graphic4a;
import org.foray.graphic.MathGraphic4a;
import org.foray.graphic.SvgGraphic;
+import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
@@ -64,7 +64,7 @@
@Override
public String getMimeType() {
- return Mime.PDF.getMimeString();
+ return MimeConstants.MIME_PDF;
}
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -28,10 +28,10 @@
package org.foray.graphic.output;
-import org.foray.common.Mime;
import org.foray.graphic.Graphic4a;
import org.foray.graphic.SvgGraphic;
+import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
@@ -59,7 +59,7 @@
@Override
public String getMimeType() {
- return Mime.POSTSCRIPT.getMimeString();
+ return MimeConstants.MIME_POSTSCRIPT;
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -28,11 +28,11 @@
package org.foray.pdf.graphics;
-import org.foray.common.Mime;
import org.foray.common.data.BoundingBoxUtils;
import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.util.PdfGraphics2D;
+import org.axsl.constants.MimeConstants;
import org.axsl.font.FontConsumer;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.MathGraphic;
@@ -78,8 +78,7 @@
@Override
protected byte[] getPdfContent(final PdfDocument4a doc) throws GraphicException {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- final GraphicOutput graphicOutput = this.graphic.getGraphicOutput(
- Mime.PDF.getMimeString());
+ final GraphicOutput graphicOutput = this.graphic.getGraphicOutput(MimeConstants.MIME_PDF);
if (! (graphicOutput instanceof GraphicPdf)) {
throw new GraphicException("Unable to get PDF output helper for "
+ this.graphic.getUrl());
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -28,11 +28,11 @@
package org.foray.pdf.graphics;
-import org.foray.common.Mime;
import org.foray.common.data.BoundingBoxUtils;
import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.util.PdfGraphics2D;
+import org.axsl.constants.MimeConstants;
import org.axsl.font.FontConsumer;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.SvgGraphic;
@@ -78,8 +78,7 @@
@Override
protected byte[] getPdfContent(final PdfDocument4a doc) throws GraphicException {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- final GraphicOutput graphicOutput = this.graphic.getGraphicOutput(
- Mime.PDF.getMimeString());
+ final GraphicOutput graphicOutput = this.graphic.getGraphicOutput(MimeConstants.MIME_PDF);
if (! (graphicOutput instanceof GraphicPdf)) {
throw new GraphicException("Unable to get PDF output helper for "
+ this.graphic.getUrl());
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -39,10 +39,10 @@
package org.foray.render.awt;
-import org.foray.common.Mime;
import org.foray.common.url.UrlFactory;
import org.foray.render.Renderer4a;
+import org.axsl.constants.MimeConstants;
import org.axsl.constants.NumericConstants;
import org.axsl.font.FontSelectionConstraints;
import org.axsl.font.FontUse;
@@ -724,12 +724,12 @@
protected void renderSVGDocument(final SvgGraphic graphic,
final Rectangle2D.Float contentRectangle,
final Rectangle2D.Float clipRectangle) {
- if (! graphic.canMakeGraphicOutput(Mime.JAVA2D.getMimeString())) {
+ if (! graphic.canMakeGraphicOutput(MimeConstants.MIME_JAVA2D)) {
/* TODO: Consider logging/displaying a warning. */
return;
}
final GraphicJava2d output = (GraphicJava2d) graphic.getGraphicOutput(
- Mime.JAVA2D.getMimeString());
+ MimeConstants.MIME_JAVA2D);
try {
output.drawGraphic(this.graphics, contentRectangle);
} catch (final GraphicException e) {
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2023-01-10 00:35:10 UTC (rev 13048)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2023-01-10 01:15:55 UTC (rev 13049)
@@ -35,12 +35,12 @@
package org.foray.render.ps;
import org.foray.common.CharacterOutputStream;
-import org.foray.common.Mime;
import org.foray.common.data.BoundingBoxUtils;
import org.foray.primitive.StringUtils;
import org.foray.primitive.sequence.ByteArray;
import org.foray.render.PrintRenderer;
+import org.axsl.constants.MimeConstants;
import org.axsl.constants.PrimitiveConstants;
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
@@ -551,7 +551,7 @@
+ " translate");
this.write(sx * at.getScaleX() + " " + sy * at.getScaleY()
+ " scale");
- final String mime = Mime.POSTSCRIPT.getMimeString();
+ final String mime = MimeConstants.MIME_POSTSCRIPT;
if (svgGraphic.canMakeGraphicOutput(mime)) {
final GraphicPs graphicPs = (GraphicPs) svgGraphic.getGraphicOutput(
mime);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-10 00:35:13
|
Revision: 13048
http://sourceforge.net/p/foray/code/13048
Author: victormote
Date: 2023-01-10 00:35:10 +0000 (Tue, 10 Jan 2023)
Log Message:
-----------
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontFileFormat.java
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-09 20:34:34 UTC (rev 13047)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-10 00:35:10 UTC (rev 13048)
@@ -30,6 +30,7 @@
import org.foray.common.data.BoundingBoxUtils;
import org.foray.font.config.RegisteredFontContent;
+import org.foray.font.format.FontFileFormat;
import org.foray.font.format.FontParser;
import org.foray.font.format.type1.Type1Font;
import org.foray.font.format.type1.Type1FontParser;
@@ -92,10 +93,10 @@
return this.type1File;
}
final FontParser reader = getRegisteredFont().createFontFileReader();
- if (reader.getFileFormat() == FontParser.FILEFORMAT_TYPE1_PFB) {
+ if (reader.getFileFormat() == FontFileFormat.TYPE1_PFB) {
final Type1FontParser parser = new Type1FontParserPfb(getRegisteredFont().createFontFileReader());
this.type1File = parser.parse();
- } else if (reader.getFileFormat() == FontParser.FILEFORMAT_TYPE1_PFA) {
+ } else if (reader.getFileFormat() == FontFileFormat.TYPE1_PFA) {
final Type1FontParser parser = new Type1FontParserPfa(getRegisteredFont().createFontFileReader());
this.type1File = parser.parse();
} else {
Added: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontFileFormat.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/FontFileFormat.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontFileFormat.java 2023-01-10 00:35:10 UTC (rev 13048)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2023 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.font.format;
+
+/**
+ * Enumeration of supported font file formats.
+ */
+public enum FontFileFormat {
+
+ /** The file is in an unknown format. */
+ UNKNOWN,
+
+ /** The file is a Type 1 file in Postscript File ASCII (PFA) hexadecimal format. */
+ TYPE1_PFA,
+
+ /** The file is a Type 1 file in Postscript File Binary (PFB) (Microsoft) format. */
+ TYPE1_PFB,
+
+ /** The file is a Type 1 file in Macintosh format. */
+ TYPE1_MAC,
+
+ /** The file is a TrueType file containing only one TrueType font. */
+ TTF_SINGLEFONT,
+
+ /** The file is a TrueType collection. */
+ TTF_COLLECTION,
+
+ /** The file is an OpenType font in TrueType format. */
+ OTF_TRUETYPE,
+
+ /** The file is an OpenType font in CFF (Type 1) format. */
+ OTF_CFF;
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontFileFormat.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2023-01-09 20:34:34 UTC (rev 13047)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2023-01-10 00:35:10 UTC (rev 13048)
@@ -49,36 +49,6 @@
*/
public class FontParser {
- /** Consant indicating that the file is in an unknown format. */
- public static final byte FILEFORMAT_UNKNOWN = -1;
-
- /** Constant indicating that the file is a Type 1 file in PFA (hexadecimal)
- * format. PFA = [P]rinter (or [P]ostscript) [F]ile [A]SCII. */
- public static final byte FILEFORMAT_TYPE1_PFA = 1;
-
- /** Constant indicating that the file is a Type 1 file in PFB (Microsoft)
- * format. PFB = [P]rinter (or [P]ostscript) [F]ile [B]inary. */
- public static final byte FILEFORMAT_TYPE1_PFB = 2;
-
- /** Constant indicating that the file is a Type 1 file in Macintosh
- * format. */
- public static final byte FILEFORMAT_TYPE1_MAC = 3;
-
- /** Constant indicating that the file is a TrueType file containing only
- * one TrueType font. */
- public static final byte FILEFORMAT_TTF_SINGLEFONT = 11;
-
- /** Constant indicating that the file is a TrueType collection. */
- public static final byte FILEFORMAT_TTF_COLLECTION = 12;
-
- /** Constant indicating that the file is an OpenType font in TrueType
- * format. */
- public static final byte FILEFORMAT_OTF_TRUETYPE = 21;
-
- /** Constant indicating that the file is an OpenType font in CFF (Type 1)
- * format. */
- public static final byte FILEFORMAT_OTF_CFF = 22;
-
/** Constant for the header of a Type 1 file. */
private static final String TYPE_1_HEADER_1 = "%!PS-AdobeFont-1.0";
@@ -98,7 +68,7 @@
private Font.Format fontFormat;
/** Set to one of the FILEFORMAT constants. */
- private byte fileFormat = FontParser.FILEFORMAT_UNKNOWN;
+ private FontFileFormat fileFormat = FontFileFormat.UNKNOWN;
/** The font parser client. */
private FontParserClient parserClient;
@@ -160,7 +130,7 @@
|| tag.startsWith(FontParser.TYPE_1_HEADER_3)
|| tag.equals(FontParser.TYPE_1_HEADER_1)) {
this.fontFormat = Font.Format.TYPE1;
- this.fileFormat = FontParser.FILEFORMAT_TYPE1_PFA;
+ this.fileFormat = FontFileFormat.TYPE1_PFA;
return;
}
// Type1 Font (PC or PFB Format)
@@ -173,7 +143,7 @@
|| tag.startsWith(FontParser.TYPE_1_HEADER_3)
|| tag.equals(FontParser.TYPE_1_HEADER_1)) {
this.fontFormat = Font.Format.TYPE1;
- this.fileFormat = FontParser.FILEFORMAT_TYPE1_PFB;
+ this.fileFormat = FontFileFormat.TYPE1_PFB;
return;
}
}
@@ -182,7 +152,7 @@
sfntVersion = this.randomInput.readInt();
if (sfntVersion == TtfOffsetTable.TTF_FILE_SFNT_VERSION_1) {
this.fontFormat = Font.Format.TRUETYPE;
- this.fileFormat = FontParser.FILEFORMAT_TTF_SINGLEFONT;
+ this.fileFormat = FontFileFormat.TTF_SINGLEFONT;
return;
}
// TrueType Collection (multiple fonts)
@@ -190,7 +160,7 @@
tag = this.randomInput.readStringASCII(FontParser.TTF_HEADER.length());
if (tag.equals(FontParser.TTF_HEADER)) {
this.fontFormat = Font.Format.TRUETYPE;
- this.fileFormat = FontParser.FILEFORMAT_TTF_COLLECTION;
+ this.fileFormat = FontFileFormat.TTF_COLLECTION;
return;
}
// OpenType Font with CFF data
@@ -198,7 +168,7 @@
tag = this.randomInput.readStringASCII(FontParser.OPENTYPE_CFF_HEADER.length());
if (tag.equals(FontParser.OPENTYPE_CFF_HEADER)) {
this.fontFormat = Font.Format.OTF_CFF;
- this.fileFormat = FontParser.FILEFORMAT_OTF_CFF;
+ this.fileFormat = FontFileFormat.OTF_CFF;
return;
}
throw new FontException("Unsupported Font File Format: " + this.randomInput.getDescription());
@@ -216,7 +186,7 @@
* Returns the format of this font file.
* @return The format of this font file.
*/
- public byte getFileFormat() {
+ public FontFileFormat getFileFormat() {
return this.fileFormat;
}
@@ -249,27 +219,30 @@
}
this.fontFileCreated = true;
switch (this.fileFormat) {
- case FontParser.FILEFORMAT_TYPE1_PFA: {
+ case TYPE1_PFA: {
final Type1FontParser type1Parser = new Type1FontParserPfa(this);
this.fontFile = type1Parser.parse();
break;
}
- case FontParser.FILEFORMAT_TYPE1_PFB: {
+ case TYPE1_PFB: {
final Type1FontParser type1Parser = new Type1FontParserPfb(this);
this.fontFile = type1Parser.parse();
break;
}
- case FontParser.FILEFORMAT_TTF_SINGLEFONT:
- case FontParser.FILEFORMAT_OTF_TRUETYPE:
- case FontParser.FILEFORMAT_OTF_CFF: {
+ case TTF_SINGLEFONT:
+ case OTF_TRUETYPE:
+ case OTF_CFF: {
this.fontFile = new TrueTypeSingle(this);
break;
}
- case FontParser.FILEFORMAT_TTF_COLLECTION: {
+ case TTF_COLLECTION: {
this.fontFile = new TrueTypeCollection(this);
break;
}
+ default: {
+ throw new FontException("Unexpected font file format.");
}
+ }
return this.fontFile;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-09 20:34:37
|
Revision: 13047
http://sourceforge.net/p/foray/code/13047
Author: victormote
Date: 2023-01-09 20:34:34 +0000 (Mon, 09 Jan 2023)
Log Message:
-----------
Remove no-longer-needed wrapper classes for the embedded XML Documents.
Removed Paths:
-------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/ForeignXml.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/foreign/InstreamMathElement.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/foreign/InstreamSvgElement.java
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/ForeignXml.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/ForeignXml.java 2023-01-09 20:28:36 UTC (rev 13046)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/ForeignXml.java 2023-01-09 20:34:34 UTC (rev 13047)
@@ -1,168 +0,0 @@
-/*
- * Copyright 2004 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.fotree;
-
-import org.foray.fotree.fo.obj.InstreamForeignObject4a;
-
-import org.axsl.fotree.FoTreeException;
-import org.axsl.fotree.FoVisitor;
-
-import org.w3c.dom.Document;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * <p>Abstract base class for the root node of XML documents or document fragments that are wrapped inside of an
- * fo:instream-foreign-object.
- * Note that instances of this class are <em>not</em> the fo:instream-foreign-object itself, but rather its
- * content.</p>
- *
- * <p>Since the document represented by this object is by definition
- * <em>foreign,</em> no attempt is made to do anything with it other than
- * create a DOM document that can be used by the external application that
- * does know how to handle this content.
- * The primary example currently used is instream SVG, which is later passed
- * to Batik for it to process.</p>
- *
- * <p>Note that only the root element of the foreign XML is represented
- * directly in the FO Tree.
- * All other elements of the foreign XML are added to the DOM instance, which
- * is encapsulated in the ForeignXml instance.</p>
- *
- * @param <D> The type of XML document contained in this object.
- *
- * @see InstreamForeignObject4a
- */
-public abstract class ForeignXml<D extends Document> extends FoObj {
-
- /** The parent of this node. */
- private InstreamForeignObject4a parent;
-
- /**
- * Constructor.
- * @param parent The parent FoObj.
- */
- public ForeignXml(final InstreamForeignObject4a parent) {
- super(parent);
- this.parent = parent;
- }
-
- @Override
- protected void validateAncestry() throws FoTreeException {
- /* Ancestry validated at construction. */
- return;
- }
-
- @Override
- protected void validateProperties() throws FoTreeException {
- return;
- }
-
- @Override
- protected void validateDescendants() throws FoTreeException {
- this.validateEmptyContent();
- }
-
- @Override
- protected void setup() throws FoTreeException {
- return;
- }
-
- /**
- * Returns the DOM Document accumulated within this foreign XML.
- * @return The DOM Document.
- */
- public abstract D getDocument();
-
- @Override
- public String getName() {
- return "foreign-xml";
- }
-
- @Override
- public InstreamForeignObject4a getParent() {
- return this.parent;
- }
-
- @Override
- public List<FoObj> getChildren() {
- return Collections.emptyList();
- }
-
- @Override
- public void addChild(final FoObj child) throws FoTreeException {
- this.addChildToEmptyContentModel(child);
- }
-
- @Override
- public PropertyList getPropertyList() {
- return PropertyList.emptyPropertyList();
- }
-
- @Override
- public boolean isPcdataContent() {
- return false;
- }
-
- @Override
- protected void end() throws FoTreeException {
- }
-
- @Override
- public <T> T acceptVisitor(final FoVisitor<T> visitor) {
- return visitor.visit(this);
- }
-
- @Override
- public boolean isValid() {
- return this.getDocument() != null;
- }
-
- @Override
- public boolean canHaveMarkerChildren() {
- return false;
- }
-
- @Override
- public boolean canHavePcdataChildren() {
- return false;
- }
-
- @Override
- public boolean canHaveInlineChildren() {
- return false;
- }
-
- @Override
- public boolean canHaveBlockChildren() {
- return false;
- }
-
-}
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/foreign/InstreamMathElement.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/foreign/InstreamMathElement.java 2023-01-09 20:28:36 UTC (rev 13046)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/foreign/InstreamMathElement.java 2023-01-09 20:34:34 UTC (rev 13047)
@@ -1,66 +0,0 @@
-/*
- * Copyright 2004 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.fotree.foreign;
-
-import org.foray.fotree.ForeignXml;
-import org.foray.fotree.NamespaceNative;
-import org.foray.fotree.fo.obj.InstreamForeignObject4a;
-
-import org.w3c.dom.mathml.MathMLDocument;
-
-/**
- * The content of an instream Math (MathML) document.
- */
-public class InstreamMathElement extends ForeignXml<MathMLDocument> {
-
- /** The parsed instream document. */
- private MathMLDocument document;
-
- /**
- * Constructor.
- * @param parent The parent FoObj.
- * @param document The DOM document.
- */
- public InstreamMathElement(final InstreamForeignObject4a parent, final MathMLDocument document) {
- super(parent);
- this.document = document;
- }
-
- @Override
- public NamespaceNative getNamespace() {
- return null;
-// return NamespaceMath.getInstance();
- }
-
- @Override
- public MathMLDocument getDocument() {
- return this.document;
- }
-
-}
Deleted: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/foreign/InstreamSvgElement.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/foreign/InstreamSvgElement.java 2023-01-09 20:28:36 UTC (rev 13046)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/foreign/InstreamSvgElement.java 2023-01-09 20:34:34 UTC (rev 13047)
@@ -1,66 +0,0 @@
-/*
- * Copyright 2004 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.fotree.foreign;
-
-import org.foray.fotree.ForeignXml;
-import org.foray.fotree.NamespaceNative;
-import org.foray.fotree.fo.obj.InstreamForeignObject4a;
-
-import org.w3c.dom.svg.SVGDocument;
-
-/**
- * The content of an inline SVG document.
- */
-public class InstreamSvgElement extends ForeignXml<SVGDocument> {
-
- /** The parsed instream document. */
- private SVGDocument document;
-
- /**
- * Constructor.
- * @param parent The parent FoObj.
- * @param document The DOM document.
- */
- public InstreamSvgElement(final InstreamForeignObject4a parent, final SVGDocument document) {
- super(parent);
- this.document = document;
- }
-
- @Override
- public NamespaceNative getNamespace() {
- return null;
-// return NamespaceSvg.getInstance();
- }
-
- @Override
- public SVGDocument getDocument() {
- return this.document;
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-09 20:28:39
|
Revision: 13046
http://sourceforge.net/p/foray/code/13046
Author: victormote
Date: 2023-01-09 20:28:36 +0000 (Mon, 09 Jan 2023)
Log Message:
-----------
Embed the DOM document directly into the InstreamForeignObject instance instead of wrapping it in ForeignXml, which adds no value.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2023-01-09 20:17:52 UTC (rev 13045)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2023-01-09 20:28:36 UTC (rev 13046)
@@ -35,8 +35,6 @@
import org.foray.fotree.fo.obj.InstreamForeignObject4a;
import org.foray.fotree.fo.obj.PageSequence4a;
import org.foray.fotree.fo.obj.Root4a;
-import org.foray.fotree.foreign.InstreamMathElement;
-import org.foray.fotree.foreign.InstreamSvgElement;
import org.foray.primitive.StringUtils;
import org.foray.xml.Sax2DomParser;
import org.foray.xml.SaxParser;
@@ -385,18 +383,14 @@
&& "instream-foreign-object".equals(localName)) {
final InstreamForeignObject4a parent = (InstreamForeignObject4a) this.currentFObj;
- ForeignXml<? extends Document> foreignXml = null;
-
if (this.foreignDocument instanceof SVGDocument) {
- foreignXml = new InstreamSvgElement(parent, (SVGDocument) this.foreignDocument);
} else if (this.foreignDocument instanceof MathMLDocument) {
- foreignXml = new InstreamMathElement(parent, (MathMLDocument) this.foreignDocument);
} else {
throw new IllegalStateException(
"Unexpected document type:" + this.foreignDocument.getClass().getName());
}
- parent.setForeignXml(foreignXml);
+ parent.setForeignXml(this.foreignDocument);
this.proxyParser = null;
this.foreignDocument = null;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2023-01-09 20:17:52 UTC (rev 13045)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2023-01-09 20:28:36 UTC (rev 13046)
@@ -29,7 +29,6 @@
package org.foray.fotree.fo.obj;
import org.foray.fotree.FoObj;
-import org.foray.fotree.ForeignXml;
import org.foray.fotree.NamespaceNative;
import org.foray.fotree.PropertyList;
import org.foray.fotree.fo.NamespaceFo;
@@ -56,7 +55,7 @@
private FoObj parent;
/** The attached foreign XML. */
- private ForeignXml<? extends Document> foreignXml;
+ private Document foreignXml;
/**
* Constructor.
@@ -170,7 +169,7 @@
@Override
public Document getXmlDocument() {
- return this.foreignXml.getDocument();
+ return this.foreignXml;
}
/**
@@ -177,7 +176,7 @@
* Sets the foreign XML.
* @param foreignXml The foreign XML to set.
*/
- public void setForeignXml(final ForeignXml<? extends Document> foreignXml) {
+ public void setForeignXml(final Document foreignXml) {
this.foreignXml = foreignXml;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-09 20:17:54
|
Revision: 13045
http://sourceforge.net/p/foray/code/13045
Author: victormote
Date: 2023-01-09 20:17:52 +0000 (Mon, 09 Jan 2023)
Log Message:
-----------
Remove no-longer needed event mechanism for triggering the end of parsing for instream-foreign-object.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
trunk/foray/foray-xml/src/main/java/org/foray/xml/Sax2DomParser.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2023-01-09 20:06:04 UTC (rev 13044)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2023-01-09 20:17:52 UTC (rev 13045)
@@ -74,8 +74,7 @@
/**
* SAX Handler that builds the formatting object tree.
*/
-public class FoTreeParser4a extends SaxParser<FoTree4a> implements FoTreeParser, Namespace.ErrorHandler,
- Sax2DomParser.Listener {
+public class FoTreeParser4a extends SaxParser<FoTree4a> implements FoTreeParser, Namespace.ErrorHandler {
/** The initial size of the text buffer for accumulating text. */
private static final int INITIAL_TEXT_BUFFER_SIZE = 4096;
@@ -295,7 +294,6 @@
final NamespaceForeign foreignNamespace = (NamespaceForeign) namespace;
this.foreignDocument = foreignNamespace.createDomDocument();
this.proxyParser = foreignNamespace.createSaxParser(this.foreignDocument);
- this.proxyParser.setListener(this);
this.proxyParser.startElement(namespaceURI, localName, rawName, attlist);
return;
} else {
@@ -377,7 +375,10 @@
@Override
public void endElement(final String uri, final String localName, final String rawName) throws SAXException {
- /* Check the actual uri and local name passed instead of this.currentFObj, because this.currentFObj will always
+
+ /* First, see if this is ending an instream-foreign-object element.
+ * We need to check that before allowing the proxy parser to parse (see next code block).
+ * Check the actual uri and local name passed instead of this.currentFObj, because this.currentFObj will always
* be an instance of InstreamForeignObject while the contents are being parsed. We only want to hit this code
* block when we are actually ending the instream-foreign-object element. */
if (XmlConstants.XSLFO_NS_URI.equals(uri)
@@ -403,10 +404,7 @@
if (this.proxyParser != null) {
// If inside foreign XML, let the ForeignXml instance handle it.
this.proxyParser.endElement(uri, localName, rawName);
- // It may have disactivated the foreign XML, so check again.
- if (this.proxyParser != null) {
- return;
- }
+ return;
}
try {
@@ -507,10 +505,6 @@
}
}
- @Override
- public void rootElementEnded() {
- }
-
/**
* Return the "parent" FO Tree server.
* @return The FO Tree server.
Modified: trunk/foray/foray-xml/src/main/java/org/foray/xml/Sax2DomParser.java
===================================================================
--- trunk/foray/foray-xml/src/main/java/org/foray/xml/Sax2DomParser.java 2023-01-09 20:06:04 UTC (rev 13044)
+++ trunk/foray/foray-xml/src/main/java/org/foray/xml/Sax2DomParser.java 2023-01-09 20:17:52 UTC (rev 13045)
@@ -50,20 +50,6 @@
*/
public class Sax2DomParser extends SaxParser<Document> {
- /**
- * An object who wants to be notified of events as the document is processed.
- */
- public interface Listener {
-
- /**
- * The listener is notified if the root element of the document being parsed by this document has ended.
- * This is useful in cases where XML content from a different namespace is being parsed.
- * Since the foreign elements are embedded into the main document, {@link #startDocument()} and
- * {@link #endDocument()} will not be triggered, so something is needed to send control back to the main parser.
- */
- void rootElementEnded();
- }
-
/** The DOM {@link Document} being parsed. */
private Document domDocument;
@@ -70,9 +56,6 @@
/** Tracks which element in the DOM is currently being parsed. */
private transient Element currentElement;
- /** An object listening to events fired by this class. */
- private Listener listener;
-
/**
* No-args constructor.
* An instance of {@link Document} will be created by this parser.
@@ -173,26 +156,11 @@
this.currentElement.appendChild(text);
// Reuse the builder.
}
- // If this is the end of the root element, clean up and turn control
- // back over to the FoTreeBuilder.
- if (this.currentElement == this.domDocument.getDocumentElement()) {
- this.currentElement.normalize();
- if (this.listener != null) {
- listener.rootElementEnded();
- }
- return;
+ // Go back up the tree one level.
+ final Node parent = this.currentElement.getParentNode();
+ if (parent instanceof Element) {
+ this.currentElement = (Element) parent;
}
- // Otherwise go back up the tree one level.
- final Node parent = this.currentElement.getParentNode();
- this.currentElement = (Element) parent;
}
- /**
- * Sets the listener for this parser.
- * @param listener The listener.
- */
- public void setListener(final Listener listener) {
- this.listener = listener;
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-09 20:06:07
|
Revision: 13044
http://sourceforge.net/p/foray/code/13044
Author: victormote
Date: 2023-01-09 20:06:04 +0000 (Mon, 09 Jan 2023)
Log Message:
-----------
Move trigger ending the parse of the instream-foreign-object from the proxy parser to the main parser.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2023-01-09 04:04:34 UTC (rev 13043)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2023-01-09 20:06:04 UTC (rev 13044)
@@ -41,6 +41,7 @@
import org.foray.xml.Sax2DomParser;
import org.foray.xml.SaxParser;
+import org.axsl.constants.XmlConstants;
import org.axsl.fotree.FoTreeEvent;
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.FoTreeListener;
@@ -376,6 +377,29 @@
@Override
public void endElement(final String uri, final String localName, final String rawName) throws SAXException {
+ /* Check the actual uri and local name passed instead of this.currentFObj, because this.currentFObj will always
+ * be an instance of InstreamForeignObject while the contents are being parsed. We only want to hit this code
+ * block when we are actually ending the instream-foreign-object element. */
+ if (XmlConstants.XSLFO_NS_URI.equals(uri)
+ && "instream-foreign-object".equals(localName)) {
+ final InstreamForeignObject4a parent = (InstreamForeignObject4a) this.currentFObj;
+
+ ForeignXml<? extends Document> foreignXml = null;
+
+ if (this.foreignDocument instanceof SVGDocument) {
+ foreignXml = new InstreamSvgElement(parent, (SVGDocument) this.foreignDocument);
+ } else if (this.foreignDocument instanceof MathMLDocument) {
+ foreignXml = new InstreamMathElement(parent, (MathMLDocument) this.foreignDocument);
+ } else {
+ throw new IllegalStateException(
+ "Unexpected document type:" + this.foreignDocument.getClass().getName());
+ }
+
+ parent.setForeignXml(foreignXml);
+ this.proxyParser = null;
+ this.foreignDocument = null;
+ }
+
if (this.proxyParser != null) {
// If inside foreign XML, let the ForeignXml instance handle it.
this.proxyParser.endElement(uri, localName, rawName);
@@ -384,6 +408,7 @@
return;
}
}
+
try {
finalizeText();
this.currentFObj.end();
@@ -484,21 +509,6 @@
@Override
public void rootElementEnded() {
- ForeignXml<? extends Document> foreignXml = null;
- final InstreamForeignObject4a parent = (InstreamForeignObject4a) this.currentFObj;
-
- if (this.foreignDocument instanceof SVGDocument) {
- foreignXml = new InstreamSvgElement(parent, (SVGDocument) this.foreignDocument);
- } else if (this.foreignDocument instanceof MathMLDocument) {
- foreignXml = new InstreamMathElement(parent, (MathMLDocument) this.foreignDocument);
- } else {
- throw new IllegalStateException("Unexpected document type:" + this.foreignDocument.getClass().getName());
- }
-
- parent.setForeignXml(foreignXml);
- this.currentFObj = foreignXml;
- this.proxyParser = null;
- this.foreignDocument = null;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-09 04:04:37
|
Revision: 13043
http://sourceforge.net/p/foray/code/13043
Author: victormote
Date: 2023-01-09 04:04:34 +0000 (Mon, 09 Jan 2023)
Log Message:
-----------
Move FO Tree document tests to foray-fotree.
Added Paths:
-----------
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/AbstractFoTreeTest.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/CommonFontPropertiesTests.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InlineLevelFoTests.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InvalidXmlTests.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/package-info.java
Removed Paths:
-------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/
Copied: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/AbstractFoTreeTest.java (from rev 13036, trunk/foray/foray-app/src/test/java/org/foray/app/fo/AbstractFoTreeTest.java)
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/AbstractFoTreeTest.java (rev 0)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/AbstractFoTreeTest.java 2023-01-09 04:04:34 UTC (rev 13043)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2007 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.fotree.doc;
+
+import org.foray.fotree.FoObj;
+import org.foray.fotree.FoTree4a;
+import org.foray.fotree.FoTreeParser4a;
+import org.foray.fotree.FoTreeServer4a;
+import org.foray.fotree.fo.obj.Flow4a;
+import org.foray.fotree.fo.obj.PageSequence4a;
+import org.foray.fotree.fo.obj.Root4a;
+
+import org.axsl.fotree.FoTreeException;
+import org.axsl.fotree.text.FoOrthographyServer;
+
+import org.xml.sax.InputSource;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.mockito.Mockito;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Collections;
+
+/**
+ * Abstract superclass for test classes testing FO Tree content.
+ */
+public abstract class AbstractFoTreeTest {
+
+ /** Boilerplate bare-minimum start of an XSL-FO document. Used by subclasses to create a full document for
+ * testing. */
+ protected static final String DOCUMENT_PROLOG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xml:lang=\"eng-US\">\n"
+ + "<fo:layout-master-set>\n"
+ + " <fo:simple-page-master\n"
+ + " master-name=\"simplePM\"\n"
+ + " page-height=\"25cm\"\n"
+ + " page-width=\"20cm\"\n"
+ + " margin-top=\"1cm\"\n"
+ + " margin-bottom=\"1cm\"\n"
+ + " margin-left=\"1.5cm\"\n"
+ + " margin-right=\"1.5cm\">\n"
+ + " <fo:region-before extent=\"2.5cm\"/>\n"
+ + " <fo:region-body margin-top=\"3cm\" margin-bottom=\"3cm\"/>\n"
+ + " <fo:region-after extent=\"2.5cm\"/>\n"
+ + " </fo:simple-page-master>\n"
+ + "</fo:layout-master-set>\n"
+ + "\n"
+ + "<fo:page-sequence master-reference=\"simplePM\">\n";
+
+
+ /** Boilerplate bare-minimum end of an XSL-FO document. Used by subclasses to create a full document for
+ * testing. */
+ protected static final String DOCUMENT_EPILOG =
+ "</fo:page-sequence>\n"
+ + "</fo:root>\n";
+
+ /**
+ * Parses an XSL-FO document using a {@link FoTreeParser4a} instance and the
+ * {@link FoTreeParser4a.TextStrategy#CHARACTER} strategy.
+ * These tests are focused on whether the tree has the correct objects and properties, so the we don't care much
+ * about having an orthography.
+ * @param document The document to be parsed.
+ * @return The newly-parsed tree.
+ * @throws FoTreeException For errors parsing the document.
+ */
+ protected FoTree4a parseDocument(final String document) throws FoTreeException {
+ final Reader reader = new StringReader(document);
+ final InputSource inputSource = new InputSource(reader);
+
+ final FoOrthographyServer orthographyServer = Mockito.mock(FoOrthographyServer.class);
+ final FoTreeServer4a treeServer = new FoTreeServer4a(orthographyServer, Collections.emptyList());
+ final FoTreeParser4a parser = new FoTreeParser4a(treeServer, null);
+ parser.setTextStrategy(FoTreeParser4a.TextStrategy.CHARACTER);
+
+ parser.parseFoTree(inputSource);
+ return parser.getFoTree();
+ }
+
+ /**
+ * Returns the first flow item in a given fo tree.
+ * @param foTree The fo tree whose first flow is needed.
+ * @return The first flow in {@code foTree}.
+ */
+ protected Flow4a getFlow(final FoTree4a foTree) {
+ final Root4a root = foTree.getRootFo();
+ FoObj node = root.formattingObjectChildAt(1);
+ assertTrue(node instanceof PageSequence4a);
+ final PageSequence4a sequence = (PageSequence4a) node;
+ node = sequence.formattingObjectChildAt(0);
+ assertTrue(node instanceof Flow4a);
+ final Flow4a flow = (Flow4a) node;
+ return flow;
+ }
+
+}
Copied: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/CommonFontPropertiesTests.java (from rev 13039, trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java)
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/CommonFontPropertiesTests.java (rev 0)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/CommonFontPropertiesTests.java 2023-01-09 04:04:34 UTC (rev 13043)
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2007 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.fotree.doc;
+
+import org.foray.fotree.FoObj;
+import org.foray.fotree.FoTree4a;
+import org.foray.fotree.fo.obj.Block4a;
+import org.foray.fotree.fo.obj.Flow4a;
+
+import org.axsl.fotree.FoContext;
+import org.axsl.fotree.FoTreeException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import java.util.List;
+
+/**
+ * Tests of various font properties at the FO Tree level.
+ */
+public class CommonFontPropertiesTests extends AbstractFoTreeTest {
+
+ /**
+ * Tests of font-family="something".
+ * @throws ForayException For errors creating the FO Tree.
+ */
+ @Test
+ public void fontFamilyTest_001() throws FoTreeException {
+ final String document =
+DOCUMENT_PROLOG
++ "<fo:flow flow-name=\"xsl-region-body\">\n"
++ " <fo:block>The default font.</fo:block>\n"
++ " <fo:block font-family=\"Base14-Courier\">font-family: Base14-Courier.</fo:block>\n"
++ "</fo:flow>\n"
++ DOCUMENT_EPILOG;
+
+ final FoTree4a foTree = parseDocument(document);
+ final Flow4a flow = getFlow(foTree);
+
+ FoObj node = flow.formattingObjectChildAt(0);
+ assertTrue(node instanceof Block4a);
+ Block4a block = (Block4a) node;
+ List<String> fontFamilies = block.traitFontFamily(null);
+ assertEquals(1, fontFamilies.size());
+ /* The default font-family is "serif". */
+ assertEquals("serif", fontFamilies.get(0));
+
+ node = flow.formattingObjectChildAt(1);
+ assertTrue(node instanceof Block4a);
+ block = (Block4a) node;
+ fontFamilies = block.traitFontFamily(null);
+ assertEquals(1, fontFamilies.size());
+ assertEquals("Base14-Courier", fontFamilies.get(0));
+ }
+
+ /**
+ * Tests of font-size="something" and font-size-adjust="something".
+ * @throws FoTreeException For errors creating the FO Tree.
+ */
+ @Test
+ public void fontSizeTest_001() throws FoTreeException {
+ final String document =
+DOCUMENT_PROLOG
++ "<fo:flow flow-name=\"xsl-region-body\">\n"
++ " <fo:block>This block is the default font size and default font.</fo:block>\n"
++ " <fo:block font-family=\"Courier\" font-size=\"8pt\">This block is Courier, 8 points.</fo:block>\n"
++ " <fo:block font-family=\"Base14-Courier\" font-size=\"10pt\" font-size-adjust=\".6\">This block is \n"
++ " Base14-Courier, font-size=\"10 points\", and font-size-adjust=\".6\". Since the x-height for Courier is "
++ " 426, the actual font-size for this block should be</fo:block>\n"
++ "</fo:flow>\n"
++ DOCUMENT_EPILOG;
+
+ final FoTree4a foTree = parseDocument(document);
+ final Flow4a flow = getFlow(foTree);
+
+ /* First block. Default size. */
+ FoObj node = flow.formattingObjectChildAt(0);
+ assertTrue(node instanceof Block4a);
+ Block4a block = (Block4a) node;
+ /* The default font size is 12 points. */
+ assertEquals(12000, block.traitFontSize(null));
+
+ /* Second block. The font-size is 8 pts. */
+ node = flow.formattingObjectChildAt(1);
+ assertTrue(node instanceof Block4a);
+ block = (Block4a) node;
+ assertEquals(8000, block.traitFontSize(null));
+
+ /* Third block. The font-size is 10 points with font-size-adjust = .6. */
+ node = flow.formattingObjectChildAt(2);
+ assertTrue(node instanceof Block4a);
+ block = (Block4a) node;
+
+ /* The nominal font-size is 10 pts. */
+ assertEquals(10000, block.traitFontSize(null));
+
+ /* The font-size-adjust is .6. */
+ assertEquals(.6, block.traitFontSizeAdjust(null).doubleValue(), .001);
+
+ final FoContext context = Mockito.mock(FoContext.class);
+ /* If the font for this block resolved to Base14-Courier, the x-height is 426.
+ * Therefore the x-height at 10 points = 426 x 10 = 4260. */
+ Mockito.when(context.fontXheight(10000)).thenReturn(4260);
+
+ /* Actual font size computation, using a basis factor of 1000.
+ * 600 / 426 * 10000 = 14085. */
+ assertEquals(14085, block.traitFontSizeActual(context));
+ }
+
+}
Copied: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InlineLevelFoTests.java (from rev 13040, trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestGraphic.java)
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InlineLevelFoTests.java (rev 0)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InlineLevelFoTests.java 2023-01-09 04:04:34 UTC (rev 13043)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2007 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.fotree.doc;
+
+import org.foray.fotree.FoObj;
+import org.foray.fotree.FoTree4a;
+import org.foray.fotree.fo.obj.Block4a;
+import org.foray.fotree.fo.obj.Flow4a;
+import org.foray.fotree.fo.obj.InstreamForeignObject4a;
+
+import org.axsl.fotree.FoContext;
+import org.axsl.fotree.FoTreeException;
+
+import org.apache.batik.anim.dom.SVGOMDocument;
+import org.w3c.dom.Document;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+/**
+ * Tests of various graphic capabilities at the FO Tree level.
+ */
+public class InlineLevelFoTests extends AbstractFoTreeTest {
+
+ /**
+ * Test of an fo:instream-foreign-object with a simple SVG in it.
+ * @throws FoTreeException For errors creating the FO Tree.
+ */
+ @Test
+ public void graphicTest_001() throws FoTreeException {
+ final String document =
+DOCUMENT_PROLOG
++ "<fo:flow flow-name=\"xsl-region-body\">\n"
++ " <fo:block>The following block contains an inline SVG wrapped in a fo:foreign-xml object.</fo:block>\n"
++ " <fo:block><fo:instream-foreign-object>\n"
++ "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\"\n"
++ " xml:space=\"preserve\">\n"
++ " <g style=\"fill:red; stroke:#000000\">\n"
++ " <rect x=\"0\" y=\"0\" width=\"15\" height=\"15\"/>\n"
++ " <rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ " </g>\n"
++ "</svg></fo:instream-foreign-object>\n"
++ " </fo:block>\n"
++ "</fo:flow>\n"
++ DOCUMENT_EPILOG;
+
+ final FoTree4a foTree = parseDocument(document);
+ final Flow4a flow = getFlow(foTree);
+
+ /* The second child should be a block ... */
+ FoObj node = flow.formattingObjectChildAt(1);
+ assertTrue(node instanceof Block4a);
+ final Block4a block = (Block4a) node;
+
+ /* ... which contains an InstreamForeignObject ... */
+ node = block.formattingObjectChildAt(0);
+ assertEquals(InstreamForeignObject4a.class, node.getClass());
+ final InstreamForeignObject4a ifo = (InstreamForeignObject4a) node;
+
+ /* ... which contains an SVGElement ... */
+ final Document domDocument = ifo.getXmlDocument();
+ assertNotNull(domDocument);
+ assertEquals(SVGOMDocument.class, domDocument.getClass());
+
+ /* ... for which we can find the width and height. */
+
+ /* The pixel width is 20. At the default screen resolution of 96 dpi,
+ * the millipoints are (20 / 96) * 72000 = 15000. */
+ final FoContext context = Mockito.mock(FoContext.class);
+ Mockito.when(context.getIntrinsicWidth(ifo)).thenReturn(15_000);
+ Mockito.when(context.getIntrinsicHeight(ifo)).thenReturn(15_000);
+ assertEquals(15_000, ifo.getIntrinsicWidth(context));
+ assertEquals(15_000, ifo.getIntrinsicHeight(context));
+ }
+
+}
Copied: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InvalidXmlTests.java (from rev 13042, trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java)
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InvalidXmlTests.java (rev 0)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InvalidXmlTests.java 2023-01-09 04:04:34 UTC (rev 13043)
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2007 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.fotree.doc;
+
+import org.axsl.fotree.FoTreeException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for parsing invalid XML in FO input.
+ */
+public class InvalidXmlTests extends AbstractFoTreeTest {
+
+ /**
+ * Test of an invalid XML document.
+ */
+ @Test
+ public void invalidXmlTest_001() {
+ final String document =
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
++ "fegsdfgdsgfsdgf\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals("org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Content is not allowed in "
+ + "prolog.", exception.getMessage());
+ }
+
+ /**
+ * Test of FO document that does not specify the namespace.
+ */
+ @Test
+ public void invalidXmlTest_002() {
+ final String document =
+"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
++ "<fo:root>\n"
++ "<fo:page-sequence>\n"
++ "<fo:root>\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals("org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 10; The prefix \"fo\" for element "
+ + "\"fo:root\" is not bound.", exception.getMessage());
+ }
+
+ /**
+ * Test of document with an unregistered namespace.
+ */
+ @Test
+ public void unregisteredNamespaceTest_001() {
+ final String document =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
++ "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xml:lang=\"eng-US\">\n"
++ " <fo:layout-master-set>\n"
++ " <fo:simple-page-master\n"
++ " margin-right=\"1.5cm\"\n"
++ " margin-left=\"1.5cm\"\n"
++ " margin-bottom=\"2cm\"\n"
++ " margin-top=\"1cm\"\n"
++ " page-width=\"21cm\"\n"
++ " page-height=\"29.7cm\"\n"
++ " master-name=\"first\">\n"
++ " <fo:region-before extent=\"1cm\"/>\n"
++ " <fo:region-body margin-top=\"1cm\"/>\n"
++ " <fo:region-after extent=\"1.5cm\"/>\n"
++ " </fo:simple-page-master>\n"
++ " </fo:layout-master-set>\n"
++ "\n"
++ " <fo:page-sequence master-reference=\"first\">\n"
++ " <fo:flow flow-name=\"xsl-region-body\">\n"
++ "\n"
++ " <fo:block space-before.optimum=\"3pt\" space-after.optimum=\"15pt\">\n"
++ " The Counter Extension\n"
++ " </fo:block>\n"
++ "\n"
++ " <fo:block space-before.optimum=\"3pt\" space-after.optimum=\"20pt\">\n"
++ "\n"
++ "<fo:instream-foreign-object>\n"
++ "<fake xmlns=\"http://www.foo.com/fake\">\n"
++ "<a>\n"
++ "</a>\n"
++ "</fake>\n"
++ "</fo:instream-foreign-object>\n"
++ " </fo:block>\n"
++ " </fo:flow>\n"
++ " </fo:page-sequence>\n"
++ "</fo:root>\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals("org.xml.sax.SAXException: Unregistered namespace: http://www.foo.com/fake: (28:39)",
+ exception.getMessage());
+ }
+
+ /**
+ * Test of document with an unregistered namespace inside some foreign xml.
+ */
+ @Test
+ public void unregisteredNamespaceTest_002() {
+ final String document =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
++ "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xml:lang=\"eng-US\">\n"
++ " <fo:layout-master-set>\n"
++ " <fo:simple-page-master\n"
++ " margin-right=\"1.5cm\"\n"
++ " margin-left=\"1.5cm\"\n"
++ " margin-bottom=\"2cm\"\n"
++ " margin-top=\"1cm\"\n"
++ " page-width=\"21cm\"\n"
++ " page-height=\"29.7cm\"\n"
++ " master-name=\"first\">\n"
++ " <fo:region-before extent=\"1cm\"/>\n"
++ " <fo:region-body margin-top=\"1cm\"/>\n"
++ " <fo:region-after extent=\"1.5cm\"/>\n"
++ " </fo:simple-page-master>\n"
++ " </fo:layout-master-set>\n"
++ "\n"
++ " <fo:page-sequence master-reference=\"first\">\n"
++ " <fo:static-content flow-name=\"xsl-region-before\">\n"
++ " <fo:block line-height=\"14pt\" font-size=\"10pt\"\n"
++ " text-align=\"end\">Embedding SVG examples</fo:block>\n"
++ " </fo:static-content>\n"
++ " <fo:static-content flow-name=\"xsl-region-after\">\n"
++ " <fo:block line-height=\"14pt\" font-size=\"10pt\"\n"
++ " text-align=\"end\">Page <fo:page-number/></fo:block>\n"
++ " </fo:static-content>\n"
++ "\n"
++ " <fo:flow flow-name=\"xsl-region-body\">\n"
++ "\n"
++ " <fo:block text-align=\"center\" font-weight=\"bold\" font-size=\"14pt\" space-before.optimum=\"3pt\" "
++ "space-after.optimum=\"15pt\">\n"
++ " Embedding SVG\n"
++ " </fo:block>\n"
++ "\n"
++ " <fo:block space-before.optimum=\"3pt\" space-after.optimum=\"20pt\">\n"
++ "<fo:instream-foreign-object>\n"
++ "<foo xmlns=\"http://www.foo.com\" width=\"20\" height=\"20\">\n"
++ " <g style=\"fill:red; stroke:#000000\">\n"
++ " <rect x=\"0\" y=\"0\" width=\"15\" height=\"15\"/>\n"
++ " <rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ " </g>\n"
++ "</foo>\n"
++ "</fo:instream-foreign-object>\n"
++ " </fo:block>\n"
++ "\n"
++ " <fo:block space-before.optimum=\"5pt\">\n"
++ "<fo:instream-foreign-object xmlns:svg=\"http://www.w3.org/2000/svg\">\n"
++ "<svg:svg width=\"20\" height=\"20\">\n"
++ " <svg:g style=\"fill:red; stroke:#000000\">\n"
++ " <svg:rect x=\"0\" y=\"0\" width=\"15\" height=\"15\"/>\n"
++ " <svg:rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ " </svg:g>\n"
++ "</svg:svg>\n"
++ "</fo:instream-foreign-object>\n"
++ " </fo:block>\n"
++ "\n"
++ "<foo xmlns=\"http://www.foo.com\" width=\"20\" height=\"20\">\n"
++ " <g style=\"fill:red; stroke:#000000\">\n"
++ " <rect x=\"0\" y=\"0\" width=\"15\" height=\"15\"/>\n"
++ " <rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ " </g>\n"
++ "</foo>\n"
++ "\n"
++ "<foo width=\"20\" height=\"20\">\n"
++ " <rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ "</foo>\n"
++ "\n"
++ "<fo:foo width=\"20\" height=\"20\">\n"
++ " <fo:rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ "</fo:foo>\n"
++ " </fo:flow>\n"
++ " </fo:page-sequence>\n"
++ "</fo:root>\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals("org.xml.sax.SAXException: Unregistered namespace: http://www.foo.com: (36:56)",
+ exception.getMessage());
+ }
+
+ /**
+ * Test FO document that has no root element.
+ */
+ @Test
+ public void invalidFoTest_001() {
+ final String document =
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
++ " <fo:layout-master-set xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n"
++ " <fo:simple-page-master master-name=\"first\"\n"
++ " page-height=\"29.7cm\" page-width=\"21cm\"\n"
++ " margin-top=\"1cm\"\n"
++ " margin-bottom=\"2cm\"\n"
++ " margin-left=\"2.5cm\"\n"
++ " margin-right=\"2.5cm\">\n"
++ " <fo:region-body margin-top=\"3cm\"/>\n"
++ " <fo:region-before extent=\"3cm\"/>\n"
++ " <fo:region-after extent=\"1.5cm\"/>\n"
++ " </fo:simple-page-master>\n"
++ " </fo:layout-master-set>\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals(
+ "org.xml.sax.SAXException: The first element parsed must be: {http://www.w3.org/1999/XSL/Format}root",
+ exception.getMessage());
+ }
+
+}
Added: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/package-info.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/package-info.java (rev 0)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/package-info.java 2023-01-09 04:04:34 UTC (rev 13043)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2023 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$
+ */
+
+/**
+ * Document-level tests of a parsed FO Tree.
+ */
+package org.foray.fotree.doc;
Property changes on: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 23:48:37
|
Revision: 13042
http://sourceforge.net/p/foray/code/13042
Author: victormote
Date: 2023-01-08 23:48:35 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
Pull test document into the test class.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java
Removed Paths:
-------------
trunk/foray/foray-00-master/dist/resource/test/fo/invalid-fo-001.fo
trunk/foray/foray-00-master/dist/resource/test/fo/invalid-ns-001.fo
trunk/foray/foray-00-master/dist/resource/test/fo/invalid-ns-002.fo
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/invalid-fo-001.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/invalid-fo-001.fo 2023-01-08 23:03:54 UTC (rev 13041)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/invalid-fo-001.fo 2023-01-08 23:48:35 UTC (rev 13042)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
- <!-- defines page layout -->
- <fo:layout-master-set xmlns:fo="http://www.w3.org/1999/XSL/Format">
- <fo:simple-page-master master-name="first"
- page-height="29.7cm" page-width="21cm"
- margin-top="1cm"
- margin-bottom="2cm"
- margin-left="2.5cm"
- margin-right="2.5cm">
- <fo:region-body margin-top="3cm"/>
- <fo:region-before extent="3cm"/>
- <fo:region-after extent="1.5cm"/>
- </fo:simple-page-master>
- </fo:layout-master-set>
-
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/invalid-ns-001.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/invalid-ns-001.fo 2023-01-08 23:03:54 UTC (rev 13041)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/invalid-ns-001.fo 2023-01-08 23:48:35 UTC (rev 13042)
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:lang="eng-US">
- <fo:layout-master-set>
- <fo:simple-page-master
- margin-right="1.5cm"
- margin-left="1.5cm"
- margin-bottom="2cm"
- margin-top="1cm"
- page-width="21cm"
- page-height="29.7cm"
- master-name="first">
- <fo:region-before extent="1cm"/>
- <fo:region-body margin-top="1cm"/>
- <fo:region-after extent="1.5cm"/>
- </fo:simple-page-master>
- </fo:layout-master-set>
-
- <fo:page-sequence master-reference="first">
- <fo:flow flow-name="xsl-region-body">
-
- <fo:block space-before.optimum="3pt" space-after.optimum="15pt">
- The Counter Extension
- </fo:block>
-
- <fo:block space-before.optimum="3pt" space-after.optimum="20pt">
-
-<fo:instream-foreign-object>
-<fake xmlns="http://www.foo.com/fake">
-<a>
-</a>
-</fake>
-</fo:instream-foreign-object>
- </fo:block>
- </fo:flow>
- </fo:page-sequence>
-</fo:root>
-
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/invalid-ns-002.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/invalid-ns-002.fo 2023-01-08 23:03:54 UTC (rev 13041)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/invalid-ns-002.fo 2023-01-08 23:48:35 UTC (rev 13042)
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:lang="eng-US">
- <fo:layout-master-set>
- <fo:simple-page-master
- margin-right="1.5cm"
- margin-left="1.5cm"
- margin-bottom="2cm"
- margin-top="1cm"
- page-width="21cm"
- page-height="29.7cm"
- master-name="first">
- <fo:region-before extent="1cm"/>
- <fo:region-body margin-top="1cm"/>
- <fo:region-after extent="1.5cm"/>
- </fo:simple-page-master>
- </fo:layout-master-set>
-
- <fo:page-sequence master-reference="first">
- <fo:static-content flow-name="xsl-region-before">
- <fo:block line-height="14pt" font-size="10pt"
- text-align="end">Embedding SVG examples</fo:block>
- </fo:static-content>
- <fo:static-content flow-name="xsl-region-after">
- <fo:block line-height="14pt" font-size="10pt"
- text-align="end">Page <fo:page-number/></fo:block>
- </fo:static-content>
-
- <fo:flow flow-name="xsl-region-body">
-
- <fo:block text-align="center" font-weight="bold" font-size="14pt" space-before.optimum="3pt" space-after.optimum="15pt">
- Embedding SVG
- </fo:block>
-
- <fo:block space-before.optimum="3pt" space-after.optimum="20pt">
-<fo:instream-foreign-object>
-<foo xmlns="http://www.foo.com" width="20" height="20">
- <g style="fill:red; stroke:#000000">
- <rect x="0" y="0" width="15" height="15"/>
- <rect x="5" y="5" width="15" height="15"/>
- </g>
-</foo>
-</fo:instream-foreign-object>
- </fo:block>
-
- <fo:block space-before.optimum="5pt">
-<fo:instream-foreign-object xmlns:svg="http://www.w3.org/2000/svg">
-<svg:svg width="20" height="20">
- <svg:g style="fill:red; stroke:#000000">
- <svg:rect x="0" y="0" width="15" height="15"/>
- <svg:rect x="5" y="5" width="15" height="15"/>
- </svg:g>
-</svg:svg>
-</fo:instream-foreign-object>
- </fo:block>
-
-<foo xmlns="http://www.foo.com" width="20" height="20">
- <g style="fill:red; stroke:#000000">
- <rect x="0" y="0" width="15" height="15"/>
- <rect x="5" y="5" width="15" height="15"/>
- </g>
-</foo>
-
-<foo width="20" height="20">
- <rect x="5" y="5" width="15" height="15"/>
-</foo>
-
-<fo:foo width="20" height="20">
- <fo:rect x="5" y="5" width="15" height="15"/>
-</fo:foo>
- </fo:flow>
- </fo:page-sequence>
-</fo:root>
-
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java 2023-01-08 23:03:54 UTC (rev 13041)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java 2023-01-08 23:48:35 UTC (rev 13042)
@@ -28,13 +28,10 @@
package org.foray.app.fo;
-import org.foray.app.FoDocumentReader;
-
import org.axsl.fotree.FoTreeException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
/**
@@ -77,45 +74,168 @@
}
/**
- * Test of fo/invalid-ns-001.fo, which contains an unregistered namespace.
+ * Test of document with an unregistered namespace.
*/
@Test
- public void testNamespace001() {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- try {
- reader.buildFoTree("fo/invalid-ns-001.fo");
- fail("Expected ForayException indicating an unregistered namespace.");
- } catch (final FoTreeException e) {
- /* Do nothing. This is the expected case. */
- }
+ public void unregisteredNamespaceTest_001() {
+ final String document =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
++ "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xml:lang=\"eng-US\">\n"
++ " <fo:layout-master-set>\n"
++ " <fo:simple-page-master\n"
++ " margin-right=\"1.5cm\"\n"
++ " margin-left=\"1.5cm\"\n"
++ " margin-bottom=\"2cm\"\n"
++ " margin-top=\"1cm\"\n"
++ " page-width=\"21cm\"\n"
++ " page-height=\"29.7cm\"\n"
++ " master-name=\"first\">\n"
++ " <fo:region-before extent=\"1cm\"/>\n"
++ " <fo:region-body margin-top=\"1cm\"/>\n"
++ " <fo:region-after extent=\"1.5cm\"/>\n"
++ " </fo:simple-page-master>\n"
++ " </fo:layout-master-set>\n"
++ "\n"
++ " <fo:page-sequence master-reference=\"first\">\n"
++ " <fo:flow flow-name=\"xsl-region-body\">\n"
++ "\n"
++ " <fo:block space-before.optimum=\"3pt\" space-after.optimum=\"15pt\">\n"
++ " The Counter Extension\n"
++ " </fo:block>\n"
++ "\n"
++ " <fo:block space-before.optimum=\"3pt\" space-after.optimum=\"20pt\">\n"
++ "\n"
++ "<fo:instream-foreign-object>\n"
++ "<fake xmlns=\"http://www.foo.com/fake\">\n"
++ "<a>\n"
++ "</a>\n"
++ "</fake>\n"
++ "</fo:instream-foreign-object>\n"
++ " </fo:block>\n"
++ " </fo:flow>\n"
++ " </fo:page-sequence>\n"
++ "</fo:root>\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals("org.xml.sax.SAXException: Unregistered namespace: http://www.foo.com/fake: (28:39)",
+ exception.getMessage());
}
/**
- * Test of fo/invalid-ns-002.fo, which contains an unregistered namespace inside some foreign xml.
+ * Test of document with an unregistered namespace inside some foreign xml.
*/
@Test
- public void testNamespace002() {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- try {
- reader.buildFoTree("fo/invalid-ns-002.fo");
- fail("Expected ForayException indicating an unregistered namespace.");
- } catch (final FoTreeException e) {
- /* Do nothing. This is the expected case. */
- }
+ public void unregisteredNamespaceTest_002() {
+ final String document =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
++ "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xml:lang=\"eng-US\">\n"
++ " <fo:layout-master-set>\n"
++ " <fo:simple-page-master\n"
++ " margin-right=\"1.5cm\"\n"
++ " margin-left=\"1.5cm\"\n"
++ " margin-bottom=\"2cm\"\n"
++ " margin-top=\"1cm\"\n"
++ " page-width=\"21cm\"\n"
++ " page-height=\"29.7cm\"\n"
++ " master-name=\"first\">\n"
++ " <fo:region-before extent=\"1cm\"/>\n"
++ " <fo:region-body margin-top=\"1cm\"/>\n"
++ " <fo:region-after extent=\"1.5cm\"/>\n"
++ " </fo:simple-page-master>\n"
++ " </fo:layout-master-set>\n"
++ "\n"
++ " <fo:page-sequence master-reference=\"first\">\n"
++ " <fo:static-content flow-name=\"xsl-region-before\">\n"
++ " <fo:block line-height=\"14pt\" font-size=\"10pt\"\n"
++ " text-align=\"end\">Embedding SVG examples</fo:block>\n"
++ " </fo:static-content>\n"
++ " <fo:static-content flow-name=\"xsl-region-after\">\n"
++ " <fo:block line-height=\"14pt\" font-size=\"10pt\"\n"
++ " text-align=\"end\">Page <fo:page-number/></fo:block>\n"
++ " </fo:static-content>\n"
++ "\n"
++ " <fo:flow flow-name=\"xsl-region-body\">\n"
++ "\n"
++ " <fo:block text-align=\"center\" font-weight=\"bold\" font-size=\"14pt\" space-before.optimum=\"3pt\" "
++ "space-after.optimum=\"15pt\">\n"
++ " Embedding SVG\n"
++ " </fo:block>\n"
++ "\n"
++ " <fo:block space-before.optimum=\"3pt\" space-after.optimum=\"20pt\">\n"
++ "<fo:instream-foreign-object>\n"
++ "<foo xmlns=\"http://www.foo.com\" width=\"20\" height=\"20\">\n"
++ " <g style=\"fill:red; stroke:#000000\">\n"
++ " <rect x=\"0\" y=\"0\" width=\"15\" height=\"15\"/>\n"
++ " <rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ " </g>\n"
++ "</foo>\n"
++ "</fo:instream-foreign-object>\n"
++ " </fo:block>\n"
++ "\n"
++ " <fo:block space-before.optimum=\"5pt\">\n"
++ "<fo:instream-foreign-object xmlns:svg=\"http://www.w3.org/2000/svg\">\n"
++ "<svg:svg width=\"20\" height=\"20\">\n"
++ " <svg:g style=\"fill:red; stroke:#000000\">\n"
++ " <svg:rect x=\"0\" y=\"0\" width=\"15\" height=\"15\"/>\n"
++ " <svg:rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ " </svg:g>\n"
++ "</svg:svg>\n"
++ "</fo:instream-foreign-object>\n"
++ " </fo:block>\n"
++ "\n"
++ "<foo xmlns=\"http://www.foo.com\" width=\"20\" height=\"20\">\n"
++ " <g style=\"fill:red; stroke:#000000\">\n"
++ " <rect x=\"0\" y=\"0\" width=\"15\" height=\"15\"/>\n"
++ " <rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ " </g>\n"
++ "</foo>\n"
++ "\n"
++ "<foo width=\"20\" height=\"20\">\n"
++ " <rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ "</foo>\n"
++ "\n"
++ "<fo:foo width=\"20\" height=\"20\">\n"
++ " <fo:rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ "</fo:foo>\n"
++ " </fo:flow>\n"
++ " </fo:page-sequence>\n"
++ "</fo:root>\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals("org.xml.sax.SAXException: Unregistered namespace: http://www.foo.com: (36:56)",
+ exception.getMessage());
}
/**
- * Test of fo/invalid-fo-001.fo, which has no root element.
+ * Test FO document that has no root element.
*/
@Test
- public void testFo001() {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- try {
- reader.buildFoTree("fo/invalid-fo-001.fo");
- fail("Expected ForayException indicating that the root element is missing.");
- } catch (final FoTreeException e) {
- /* Do nothing. This is the expected case. */
- }
+ public void invalidFoTest_001() {
+ final String document =
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
++ " <fo:layout-master-set xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n"
++ " <fo:simple-page-master master-name=\"first\"\n"
++ " page-height=\"29.7cm\" page-width=\"21cm\"\n"
++ " margin-top=\"1cm\"\n"
++ " margin-bottom=\"2cm\"\n"
++ " margin-left=\"2.5cm\"\n"
++ " margin-right=\"2.5cm\">\n"
++ " <fo:region-body margin-top=\"3cm\"/>\n"
++ " <fo:region-before extent=\"3cm\"/>\n"
++ " <fo:region-after extent=\"1.5cm\"/>\n"
++ " </fo:simple-page-master>\n"
++ " </fo:layout-master-set>\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals(
+ "org.xml.sax.SAXException: The first element parsed must be: {http://www.w3.org/1999/XSL/Format}root",
+ exception.getMessage());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 23:03:57
|
Revision: 13041
http://sourceforge.net/p/foray/code/13041
Author: victormote
Date: 2023-01-08 23:03:54 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
Pull test document into the test class.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java
Removed Paths:
-------------
trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-001.fo
trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-002.fo
trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-003.fo
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-001.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-001.fo 2023-01-08 22:35:42 UTC (rev 13040)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-001.fo 2023-01-08 23:03:54 UTC (rev 13041)
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-fegsdfgdsgfsdgf
-
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-002.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-002.fo 2023-01-08 22:35:42 UTC (rev 13040)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-002.fo 2023-01-08 23:03:54 UTC (rev 13041)
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<fo:root>
-<fo:page-sequence>
-<fo:root>
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-003.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-003.fo 2023-01-08 22:35:42 UTC (rev 13040)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/invalid-xml-003.fo 2023-01-08 23:03:54 UTC (rev 13041)
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-fegsdfgdsgfsdgf
-
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:lang="eng-US">
-
- <!-- defines page layout -->
- <fo:layout-master-set>
- <fo:simple-page-master master-name="first"
- page-height="29.7cm" page-width="21cm"
- margin-top="1cm"
- margin-bottom="2cm"
- margin-left="2.5cm"
- margin-right="2.5cm">
- <fo:region-body margin-top="3cm"/>
- <fo:region-before extent="3cm"/>
- <fo:region-after extent="1.5cm"/>
- </fo:simple-page-master>
- </fo:layout-master-set>
- <!-- end: defines page layout -->
-
- <!-- actual layout -->
- <fo:page-sequence master-reference="first">
-
- <!-- text body -->
- <fo:flow flow-name="xsl-region-body">
-
- <!-- Normal text -->
- <fo:block text-align="center">0. Normal text without link
- </fo:block>
-</fo:flow>
-</fo:page-sequence>
-</fo:root>
-
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java 2023-01-08 22:35:42 UTC (rev 13040)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestInvalidXml.java 2023-01-08 23:03:54 UTC (rev 13041)
@@ -32,6 +32,8 @@
import org.axsl.fotree.FoTreeException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
@@ -38,48 +40,40 @@
/**
* Tests for parsing invalid XML in FO input.
*/
-public class TestInvalidXml {
+public class TestInvalidXml extends AbstractFoTreeTest {
/**
- * Test of fo/invalid-xml-001.fo.
+ * Test of an invalid XML document.
*/
@Test
- public void testXml001() {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- try {
- reader.buildFoTree("fo/invalid-xml-001.fo");
- fail("Expected ForayException indicating invalid XML content.");
- } catch (final FoTreeException e) {
- /* Do nothing. This is the expected case. */
- }
+ public void invalidXmlTest_001() {
+ final String document =
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
++ "fegsdfgdsgfsdgf\n";
+
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals("org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Content is not allowed in "
+ + "prolog.", exception.getMessage());
}
/**
- * Test of fo/invalid-xml-002.fo.
+ * Test of FO document that does not specify the namespace.
*/
@Test
- public void testXml002() {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- try {
- reader.buildFoTree("fo/invalid-xml-002.fo");
- fail("Expected ForayException indicating invalid XML content.");
- } catch (final FoTreeException e) {
- /* Do nothing. This is the expected case. */
- }
- }
+ public void invalidXmlTest_002() {
+ final String document =
+"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
++ "<fo:root>\n"
++ "<fo:page-sequence>\n"
++ "<fo:root>\n";
- /**
- * Test of fo/invalid-xml-003.fo.
- */
- @Test
- public void testXml003() {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- try {
- reader.buildFoTree("fo/invalid-xml-003.fo");
- fail("Expected ForayException indicating invalid XML content.");
- } catch (final FoTreeException e) {
- /* Do nothing. This is the expected case. */
- }
+ final FoTreeException exception = assertThrows(FoTreeException.class, () -> {
+ parseDocument(document);
+ });
+ assertEquals("org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 10; The prefix \"fo\" for element "
+ + "\"fo:root\" is not bound.", exception.getMessage());
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 22:35:45
|
Revision: 13040
http://sourceforge.net/p/foray/code/13040
Author: victormote
Date: 2023-01-08 22:35:42 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
Pull test document into the test class.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestGraphic.java
Removed Paths:
-------------
trunk/foray/foray-00-master/dist/resource/test/fo/graphic-001.fo
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/graphic-001.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/graphic-001.fo 2023-01-08 21:56:31 UTC (rev 13039)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/graphic-001.fo 2023-01-08 22:35:42 UTC (rev 13040)
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:lang="eng-US">
-
-<fo:layout-master-set>
- <fo:simple-page-master
- master-name="simple"
- page-height="11in"
- page-width="8.5in"
- margin-top="1in"
- margin-bottom="1in"
- margin-left="1in"
- margin-right="1in">
- <fo:region-body/>
- </fo:simple-page-master>
-</fo:layout-master-set>
-
-<fo:page-sequence master-reference="simple">
-<fo:flow flow-name="xsl-region-body">
-
-<fo:block>The following block contains an inline SVG wrapped in a
-fo:foreign-xml object.</fo:block>
-
-<fo:block><fo:instream-foreign-object>
-
-<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"
- xml:space="preserve">
- <g style="fill:red; stroke:#000000">
- <rect x="0" y="0" width="15" height="15"/>
- <rect x="5" y="5" width="15" height="15"/>
- </g>
-</svg>
-
-</fo:instream-foreign-object></fo:block>
-
-</fo:flow>
-</fo:page-sequence>
-</fo:root>
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestGraphic.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestGraphic.java 2023-01-08 21:56:31 UTC (rev 13039)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestGraphic.java 2023-01-08 22:35:42 UTC (rev 13040)
@@ -28,17 +28,23 @@
package org.foray.app.fo;
-import org.foray.app.FoDocumentReader;
import org.foray.fotree.FoObj;
import org.foray.fotree.FoTree4a;
import org.foray.fotree.fo.obj.Block4a;
import org.foray.fotree.fo.obj.Flow4a;
import org.foray.fotree.fo.obj.InstreamForeignObject4a;
-import org.foray.fotree.foreign.InstreamSvgElement;
+import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoTreeException;
+import org.apache.batik.anim.dom.SVGOMDocument;
+import org.w3c.dom.Document;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
/**
* Tests of various graphic capabilities at the FO Tree level.
@@ -46,15 +52,30 @@
public class TestGraphic extends AbstractFoTreeTest {
/**
- * Test of fo/graphic-001.fo.
- * This file contains an fo:instream-foreign-object with a simple SVG in it.
+ * Test of an fo:instream-foreign-object with a simple SVG in it.
* @throws FoTreeException For errors creating the FO Tree.
*/
- public void testGraphic001() throws FoTreeException {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- final FoTree4a foTree = reader.buildFoTree("fo/graphic-001.fo");
- final Flow4a flow = this.getFlow(foTree);
+ @Test
+ public void graphicTest_001() throws FoTreeException {
+ final String document =
+DOCUMENT_PROLOG
++ "<fo:flow flow-name=\"xsl-region-body\">\n"
++ " <fo:block>The following block contains an inline SVG wrapped in a fo:foreign-xml object.</fo:block>\n"
++ " <fo:block><fo:instream-foreign-object>\n"
++ "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\"\n"
++ " xml:space=\"preserve\">\n"
++ " <g style=\"fill:red; stroke:#000000\">\n"
++ " <rect x=\"0\" y=\"0\" width=\"15\" height=\"15\"/>\n"
++ " <rect x=\"5\" y=\"5\" width=\"15\" height=\"15\"/>\n"
++ " </g>\n"
++ "</svg></fo:instream-foreign-object>\n"
++ " </fo:block>\n"
++ "</fo:flow>\n"
++ DOCUMENT_EPILOG;
+ final FoTree4a foTree = parseDocument(document);
+ final Flow4a flow = getFlow(foTree);
+
/* The second child should be a block ... */
FoObj node = flow.formattingObjectChildAt(1);
assertTrue(node instanceof Block4a);
@@ -62,20 +83,23 @@
/* ... which contains an InstreamForeignObject ... */
node = block.formattingObjectChildAt(0);
- assertTrue(node instanceof InstreamForeignObject4a);
+ assertEquals(InstreamForeignObject4a.class, node.getClass());
final InstreamForeignObject4a ifo = (InstreamForeignObject4a) node;
/* ... which contains an SVGElement ... */
- node = ifo.formattingObjectChildAt(0);
- assertTrue(node instanceof InstreamSvgElement);
-// final InstreamSvgElement svgElement = (InstreamSvgElement) node;
+ final Document domDocument = ifo.getXmlDocument();
+ assertNotNull(domDocument);
+ assertEquals(SVGOMDocument.class, domDocument.getClass());
-// /* ... for which we can find the width and height. */
-//
-// /* The pixel width is 20. At the default screen resolution of 96 dpi,
-// * the millipoints are (20 / 96) * 72000 = 15000. */
-// assertEquals(15000, svgElement.intrinsicContentWidth());
-// assertEquals(15000, svgElement.intrinsicContentHeight());
+ /* ... for which we can find the width and height. */
+
+ /* The pixel width is 20. At the default screen resolution of 96 dpi,
+ * the millipoints are (20 / 96) * 72000 = 15000. */
+ final FoContext context = Mockito.mock(FoContext.class);
+ Mockito.when(context.getIntrinsicWidth(ifo)).thenReturn(15_000);
+ Mockito.when(context.getIntrinsicHeight(ifo)).thenReturn(15_000);
+ assertEquals(15_000, ifo.getIntrinsicWidth(context));
+ assertEquals(15_000, ifo.getIntrinsicHeight(context));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 21:56:34
|
Revision: 13039
http://sourceforge.net/p/foray/code/13039
Author: victormote
Date: 2023-01-08 21:56:31 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
1. Remove no-longer-needed test documents. 2. Rename methods for consistency.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
Removed Paths:
-------------
trunk/foray/foray-00-master/dist/resource/test/fo/font-family-001.fo
trunk/foray/foray-00-master/dist/resource/test/fo/font-size-001.fo
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/font-family-001.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/font-family-001.fo 2023-01-08 21:41:45 UTC (rev 13038)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/font-family-001.fo 2023-01-08 21:56:31 UTC (rev 13039)
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:lang="eng-US">
-<fo:layout-master-set>
- <fo:simple-page-master
- master-name="simplePM"
- page-height="25cm"
- page-width="20cm"
- margin-top="1cm"
- margin-bottom="1cm"
- margin-left="1.5cm"
- margin-right="1.5cm">
- <fo:region-before extent="2.5cm"/>
- <fo:region-body margin-top="3cm" margin-bottom="3cm"/>
- <fo:region-after extent="2.5cm"/>
- </fo:simple-page-master>
-</fo:layout-master-set>
-
-<fo:page-sequence master-reference="simplePM">
-<fo:flow flow-name="xsl-region-body">
-
-<fo:block>The default font.</fo:block>
-<fo:block
- font-family="Base14-Courier">font-family: Base14-Courier.</fo:block>
-
-
-</fo:flow>
-</fo:page-sequence>
-</fo:root>
Deleted: trunk/foray/foray-00-master/dist/resource/test/fo/font-size-001.fo
===================================================================
--- trunk/foray/foray-00-master/dist/resource/test/fo/font-size-001.fo 2023-01-08 21:41:45 UTC (rev 13038)
+++ trunk/foray/foray-00-master/dist/resource/test/fo/font-size-001.fo 2023-01-08 21:56:31 UTC (rev 13039)
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:lang="eng-US">
-
-<fo:layout-master-set>
- <fo:simple-page-master
- master-name="simplePM"
- page-height="25cm"
- page-width="20cm"
- margin-top="1cm"
- margin-bottom="1cm"
- margin-left="1.5cm"
- margin-right="1.5cm">
- <fo:region-before extent="2.5cm"/>
- <fo:region-body margin-top="3cm" margin-bottom="3cm"/>
- <fo:region-after extent="2.5cm"/>
- </fo:simple-page-master>
-</fo:layout-master-set>
-
-<fo:page-sequence master-reference="simplePM">
-<fo:flow
- flow-name="xsl-region-body">
-
-<fo:block>This block is the default font size and default font.</fo:block>
-
-<fo:block
- font-family="Courier"
- font-size="8pt">This block is Courier, 8 points.</fo:block>
-
-<fo:block font-family="Base14-Courier" font-size="10pt"
- font-size-adjust=".6">This block is Base14-Courier, font-size="10 points",
-and font-size-adjust=".6". Since the x-height for Courier is 426, the actual
-font-size for this block should be</fo:block>
-
-
-</fo:flow>
-</fo:page-sequence>
-</fo:root>
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 21:41:45 UTC (rev 13038)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 21:56:31 UTC (rev 13039)
@@ -50,11 +50,11 @@
public class TestFont extends AbstractFoTreeTest {
/**
- * Test of fo/font-family-001.fo.
+ * Tests of font-family="something".
* @throws ForayException For errors creating the FO Tree.
*/
@Test
- public void testFontFamily001() throws FoTreeException {
+ public void fontFamilyTest_001() throws FoTreeException {
final String document =
DOCUMENT_PROLOG
+ "<fo:flow flow-name=\"xsl-region-body\">\n"
@@ -83,11 +83,11 @@
}
/**
- * Test of fo/font-size-001.fo.
+ * Tests of font-size="something" and font-size-adjust="something".
* @throws FoTreeException For errors creating the FO Tree.
*/
@Test
- public void testFontSize001() throws FoTreeException {
+ public void fontSizeTest_001() throws FoTreeException {
final String document =
DOCUMENT_PROLOG
+ "<fo:flow flow-name=\"xsl-region-body\">\n"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 21:41:48
|
Revision: 13038
http://sourceforge.net/p/foray/code/13038
Author: victormote
Date: 2023-01-08 21:41:45 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
Reactivate assertion after setting up correct context.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 21:17:11 UTC (rev 13037)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 21:41:45 UTC (rev 13038)
@@ -34,11 +34,13 @@
import org.foray.fotree.fo.obj.Block4a;
import org.foray.fotree.fo.obj.Flow4a;
+import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoTreeException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
import java.util.List;
@@ -100,35 +102,38 @@
final FoTree4a foTree = parseDocument(document);
final Flow4a flow = getFlow(foTree);
+ /* First block. Default size. */
FoObj node = flow.formattingObjectChildAt(0);
assertTrue(node instanceof Block4a);
Block4a block = (Block4a) node;
- int fontSize = block.traitFontSize(null);
/* The default font size is 12 points. */
- assertEquals(12000, fontSize);
+ assertEquals(12000, block.traitFontSize(null));
+ /* Second block. The font-size is 8 pts. */
node = flow.formattingObjectChildAt(1);
assertTrue(node instanceof Block4a);
block = (Block4a) node;
- fontSize = block.traitFontSize(null);
- assertEquals(8000, fontSize);
+ assertEquals(8000, block.traitFontSize(null));
+ /* Third block. The font-size is 10 points with font-size-adjust = .6. */
node = flow.formattingObjectChildAt(2);
assertTrue(node instanceof Block4a);
block = (Block4a) node;
-// final Font font = node.getPrimaryFont(null).getFont();
-// assertEquals("Courier", font.getFamilyName());
-// assertEquals(426, font.getXheight(1000));
- final int nominalFontSize = block.traitFontSize(null);
+
/* The nominal font-size is 10 pts. */
- assertEquals(10000, nominalFontSize);
+ assertEquals(10000, block.traitFontSize(null));
+
/* The font-size-adjust is .6. */
- final Number fontSizeAdjust = block.traitFontSizeAdjust(null);
- assertEquals(.6, fontSizeAdjust.doubleValue(), .001);
+ assertEquals(.6, block.traitFontSizeAdjust(null).doubleValue(), .001);
+
+ final FoContext context = Mockito.mock(FoContext.class);
+ /* If the font for this block resolved to Base14-Courier, the x-height is 426.
+ * Therefore the x-height at 10 points = 426 x 10 = 4260. */
+ Mockito.when(context.fontXheight(10000)).thenReturn(4260);
+
/* Actual font size computation, using a basis factor of 1000.
* 600 / 426 * 10000 = 14085. */
-// fontSize = block.traitFontSizeActual(null, font);
-// assertEquals(14085, fontSize);
+ assertEquals(14085, block.traitFontSizeActual(context));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 21:17:14
|
Revision: 13037
http://sourceforge.net/p/foray/code/13037
Author: victormote
Date: 2023-01-08 21:17:11 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
Pull test document into the test class.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 21:07:21 UTC (rev 13036)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 21:17:11 UTC (rev 13037)
@@ -28,7 +28,6 @@
package org.foray.app.fo;
-import org.foray.app.FoDocumentReader;
import org.foray.core.ForayException;
import org.foray.fotree.FoObj;
import org.foray.fotree.FoTree4a;
@@ -55,12 +54,12 @@
@Test
public void testFontFamily001() throws FoTreeException {
final String document =
- DOCUMENT_PROLOG
- + "<fo:flow flow-name=\"xsl-region-body\">\n"
- + " <fo:block>The default font.</fo:block>\n"
- + " <fo:block font-family=\"Base14-Courier\">font-family: Base14-Courier.</fo:block>\n"
- + "</fo:flow>\n"
- + DOCUMENT_EPILOG;
+DOCUMENT_PROLOG
++ "<fo:flow flow-name=\"xsl-region-body\">\n"
++ " <fo:block>The default font.</fo:block>\n"
++ " <fo:block font-family=\"Base14-Courier\">font-family: Base14-Courier.</fo:block>\n"
++ "</fo:flow>\n"
++ DOCUMENT_EPILOG;
final FoTree4a foTree = parseDocument(document);
final Flow4a flow = getFlow(foTree);
@@ -87,10 +86,20 @@
*/
@Test
public void testFontSize001() throws FoTreeException {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- final FoTree4a foTree = reader.buildFoTree("fo/font-size-001.fo");
- final Flow4a flow = this.getFlow(foTree);
+ final String document =
+DOCUMENT_PROLOG
++ "<fo:flow flow-name=\"xsl-region-body\">\n"
++ " <fo:block>This block is the default font size and default font.</fo:block>\n"
++ " <fo:block font-family=\"Courier\" font-size=\"8pt\">This block is Courier, 8 points.</fo:block>\n"
++ " <fo:block font-family=\"Base14-Courier\" font-size=\"10pt\" font-size-adjust=\".6\">This block is \n"
++ " Base14-Courier, font-size=\"10 points\", and font-size-adjust=\".6\". Since the x-height for Courier is "
++ " 426, the actual font-size for this block should be</fo:block>\n"
++ "</fo:flow>\n"
++ DOCUMENT_EPILOG;
+ final FoTree4a foTree = parseDocument(document);
+ final Flow4a flow = getFlow(foTree);
+
FoObj node = flow.formattingObjectChildAt(0);
assertTrue(node instanceof Block4a);
Block4a block = (Block4a) node;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 21:07:23
|
Revision: 13036
http://sourceforge.net/p/foray/code/13036
Author: victormote
Date: 2023-01-08 21:07:21 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
Split chunks of testing code into superclass, for reuse.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/AbstractFoTreeTest.java
trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/AbstractFoTreeTest.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/AbstractFoTreeTest.java 2023-01-08 20:28:17 UTC (rev 13035)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/AbstractFoTreeTest.java 2023-01-08 21:07:21 UTC (rev 13036)
@@ -30,18 +30,81 @@
import org.foray.fotree.FoObj;
import org.foray.fotree.FoTree4a;
+import org.foray.fotree.FoTreeParser4a;
+import org.foray.fotree.FoTreeServer4a;
import org.foray.fotree.fo.obj.Flow4a;
import org.foray.fotree.fo.obj.PageSequence4a;
import org.foray.fotree.fo.obj.Root4a;
+import org.axsl.fotree.FoTreeException;
+import org.axsl.fotree.text.FoOrthographyServer;
+
+import org.xml.sax.InputSource;
+
import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.mockito.Mockito;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Collections;
+
/**
* Abstract superclass for test classes testing FO Tree content.
*/
public abstract class AbstractFoTreeTest {
+ /** Boilerplate bare-minimum start of an XSL-FO document. Used by subclasses to create a full document for
+ * testing. */
+ protected static final String DOCUMENT_PROLOG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xml:lang=\"eng-US\">\n"
+ + "<fo:layout-master-set>\n"
+ + " <fo:simple-page-master\n"
+ + " master-name=\"simplePM\"\n"
+ + " page-height=\"25cm\"\n"
+ + " page-width=\"20cm\"\n"
+ + " margin-top=\"1cm\"\n"
+ + " margin-bottom=\"1cm\"\n"
+ + " margin-left=\"1.5cm\"\n"
+ + " margin-right=\"1.5cm\">\n"
+ + " <fo:region-before extent=\"2.5cm\"/>\n"
+ + " <fo:region-body margin-top=\"3cm\" margin-bottom=\"3cm\"/>\n"
+ + " <fo:region-after extent=\"2.5cm\"/>\n"
+ + " </fo:simple-page-master>\n"
+ + "</fo:layout-master-set>\n"
+ + "\n"
+ + "<fo:page-sequence master-reference=\"simplePM\">\n";
+
+
+ /** Boilerplate bare-minimum end of an XSL-FO document. Used by subclasses to create a full document for
+ * testing. */
+ protected static final String DOCUMENT_EPILOG =
+ "</fo:page-sequence>\n"
+ + "</fo:root>\n";
+
/**
+ * Parses an XSL-FO document using a {@link FoTreeParser4a} instance and the
+ * {@link FoTreeParser4a.TextStrategy#CHARACTER} strategy.
+ * These tests are focused on whether the tree has the correct objects and properties, so the we don't care much
+ * about having an orthography.
+ * @param document The document to be parsed.
+ * @return The newly-parsed tree.
+ * @throws FoTreeException For errors parsing the document.
+ */
+ protected FoTree4a parseDocument(final String document) throws FoTreeException {
+ final Reader reader = new StringReader(document);
+ final InputSource inputSource = new InputSource(reader);
+
+ final FoOrthographyServer orthographyServer = Mockito.mock(FoOrthographyServer.class);
+ final FoTreeServer4a treeServer = new FoTreeServer4a(orthographyServer, Collections.emptyList());
+ final FoTreeParser4a parser = new FoTreeParser4a(treeServer, null);
+ parser.setTextStrategy(FoTreeParser4a.TextStrategy.CHARACTER);
+
+ parser.parseFoTree(inputSource);
+ return parser.getFoTree();
+ }
+
+ /**
* Returns the first flow item in a given fo tree.
* @param foTree The fo tree whose first flow is needed.
* @return The first flow in {@code foTree}.
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 20:28:17 UTC (rev 13035)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 21:07:21 UTC (rev 13036)
@@ -32,24 +32,15 @@
import org.foray.core.ForayException;
import org.foray.fotree.FoObj;
import org.foray.fotree.FoTree4a;
-import org.foray.fotree.FoTreeParser4a;
-import org.foray.fotree.FoTreeServer4a;
import org.foray.fotree.fo.obj.Block4a;
import org.foray.fotree.fo.obj.Flow4a;
import org.axsl.fotree.FoTreeException;
-import org.axsl.fotree.text.FoOrthographyServer;
-import org.xml.sax.InputSource;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Collections;
import java.util.List;
/**
@@ -57,36 +48,6 @@
*/
public class TestFont extends AbstractFoTreeTest {
- /** A test document. */
- private static final String DOCUMENT =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xml:lang=\"eng-US\">\n"
- + "<fo:layout-master-set>\n"
- + " <fo:simple-page-master\n"
- + " master-name=\"simplePM\"\n"
- + " page-height=\"25cm\"\n"
- + " page-width=\"20cm\"\n"
- + " margin-top=\"1cm\"\n"
- + " margin-bottom=\"1cm\"\n"
- + " margin-left=\"1.5cm\"\n"
- + " margin-right=\"1.5cm\">\n"
- + " <fo:region-before extent=\"2.5cm\"/>\n"
- + " <fo:region-body margin-top=\"3cm\" margin-bottom=\"3cm\"/>\n"
- + " <fo:region-after extent=\"2.5cm\"/>\n"
- + " </fo:simple-page-master>\n"
- + "</fo:layout-master-set>\n"
- + "\n"
- + "<fo:page-sequence master-reference=\"simplePM\">\n"
- + "<fo:flow flow-name=\"xsl-region-body\">\n"
- + "\n"
- + "<fo:block>The default font.</fo:block>\n"
- + "<fo:block font-family=\"Base14-Courier\">font-family: Base14-Courier.</fo:block>\n"
- + "\n"
- + "</fo:flow>\n"
- + "</fo:page-sequence>\n"
- + "</fo:root>\n"
- + "";
-
/**
* Test of fo/font-family-001.fo.
* @throws ForayException For errors creating the FO Tree.
@@ -93,16 +54,15 @@
*/
@Test
public void testFontFamily001() throws FoTreeException {
- final Reader reader = new StringReader(DOCUMENT);
- final InputSource inputSource = new InputSource(reader);
+ final String document =
+ DOCUMENT_PROLOG
+ + "<fo:flow flow-name=\"xsl-region-body\">\n"
+ + " <fo:block>The default font.</fo:block>\n"
+ + " <fo:block font-family=\"Base14-Courier\">font-family: Base14-Courier.</fo:block>\n"
+ + "</fo:flow>\n"
+ + DOCUMENT_EPILOG;
- final FoOrthographyServer orthographyServer = Mockito.mock(FoOrthographyServer.class);
- final FoTreeServer4a treeServer = new FoTreeServer4a(orthographyServer, Collections.emptyList());
- final FoTreeParser4a parser = new FoTreeParser4a(treeServer, null);
- parser.setTextStrategy(FoTreeParser4a.TextStrategy.CHARACTER);
-
- parser.parseFoTree(inputSource);
- final FoTree4a foTree = parser.getFoTree();
+ final FoTree4a foTree = parseDocument(document);
final Flow4a flow = getFlow(foTree);
FoObj node = flow.formattingObjectChildAt(0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 20:28:19
|
Revision: 13035
http://sourceforge.net/p/foray/code/13035
Author: victormote
Date: 2023-01-08 20:28:17 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
1. Pull test document into the class. 2. Remove dependency on FoDocumentReader.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 20:27:19 UTC (rev 13034)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/TestFont.java 2023-01-08 20:28:17 UTC (rev 13035)
@@ -32,15 +32,24 @@
import org.foray.core.ForayException;
import org.foray.fotree.FoObj;
import org.foray.fotree.FoTree4a;
+import org.foray.fotree.FoTreeParser4a;
+import org.foray.fotree.FoTreeServer4a;
import org.foray.fotree.fo.obj.Block4a;
import org.foray.fotree.fo.obj.Flow4a;
import org.axsl.fotree.FoTreeException;
+import org.axsl.fotree.text.FoOrthographyServer;
+import org.xml.sax.InputSource;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Collections;
import java.util.List;
/**
@@ -48,6 +57,36 @@
*/
public class TestFont extends AbstractFoTreeTest {
+ /** A test document. */
+ private static final String DOCUMENT =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xml:lang=\"eng-US\">\n"
+ + "<fo:layout-master-set>\n"
+ + " <fo:simple-page-master\n"
+ + " master-name=\"simplePM\"\n"
+ + " page-height=\"25cm\"\n"
+ + " page-width=\"20cm\"\n"
+ + " margin-top=\"1cm\"\n"
+ + " margin-bottom=\"1cm\"\n"
+ + " margin-left=\"1.5cm\"\n"
+ + " margin-right=\"1.5cm\">\n"
+ + " <fo:region-before extent=\"2.5cm\"/>\n"
+ + " <fo:region-body margin-top=\"3cm\" margin-bottom=\"3cm\"/>\n"
+ + " <fo:region-after extent=\"2.5cm\"/>\n"
+ + " </fo:simple-page-master>\n"
+ + "</fo:layout-master-set>\n"
+ + "\n"
+ + "<fo:page-sequence master-reference=\"simplePM\">\n"
+ + "<fo:flow flow-name=\"xsl-region-body\">\n"
+ + "\n"
+ + "<fo:block>The default font.</fo:block>\n"
+ + "<fo:block font-family=\"Base14-Courier\">font-family: Base14-Courier.</fo:block>\n"
+ + "\n"
+ + "</fo:flow>\n"
+ + "</fo:page-sequence>\n"
+ + "</fo:root>\n"
+ + "";
+
/**
* Test of fo/font-family-001.fo.
* @throws ForayException For errors creating the FO Tree.
@@ -54,10 +93,18 @@
*/
@Test
public void testFontFamily001() throws FoTreeException {
- final FoDocumentReader reader = FoDocumentReader.getInstance();
- final FoTree4a foTree = reader.buildFoTree("fo/font-family-001.fo");
- final Flow4a flow = this.getFlow(foTree);
+ final Reader reader = new StringReader(DOCUMENT);
+ final InputSource inputSource = new InputSource(reader);
+ final FoOrthographyServer orthographyServer = Mockito.mock(FoOrthographyServer.class);
+ final FoTreeServer4a treeServer = new FoTreeServer4a(orthographyServer, Collections.emptyList());
+ final FoTreeParser4a parser = new FoTreeParser4a(treeServer, null);
+ parser.setTextStrategy(FoTreeParser4a.TextStrategy.CHARACTER);
+
+ parser.parseFoTree(inputSource);
+ final FoTree4a foTree = parser.getFoTree();
+ final Flow4a flow = getFlow(foTree);
+
FoObj node = flow.formattingObjectChildAt(0);
assertTrue(node instanceof Block4a);
Block4a block = (Block4a) node;
@@ -72,9 +119,6 @@
fontFamilies = block.traitFontFamily(null);
assertEquals(1, fontFamilies.size());
assertEquals("Base14-Courier", fontFamilies.get(0));
-
-// final Font font = block.getPrimaryFont(null).getFont();
-// assertEquals("Courier", font.getFontName());
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 20:27:22
|
Revision: 13034
http://sourceforge.net/p/foray/code/13034
Author: victormote
Date: 2023-01-08 20:27:19 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
Add ability to configure the text strategy at runtime.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2023-01-08 15:28:43 UTC (rev 13033)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2023-01-08 20:27:19 UTC (rev 13034)
@@ -82,7 +82,7 @@
/**
* Enumeration of strategies to use for handling text.
*/
- private enum TextStrategy {
+ public enum TextStrategy {
/** Store text in a collection of characters. */
CHARACTER,
@@ -117,7 +117,8 @@
private StringBuilder textBuffer = new StringBuilder(INITIAL_TEXT_BUFFER_SIZE);
/* TODO: This should possibly be configurable. */
- /** The strategy to use for storing text. */
+ /** The strategy to use for storing text. Defaults to {@link TextStrategy#WORD}, but can be changed by
+ * {@link #setTextStrategy(TextStrategy)}. */
private TextStrategy textStrategy = TextStrategy.WORD;
/** Map whose key is a {@link Namespace} instance, and whose value is the set of elements that were parsed in that
@@ -537,4 +538,12 @@
return this.resourceSearchPath;
}
+ /**
+ * Sets the text strategy to be used by this parser.
+ * @param textStrategy The textStrategy to set.
+ */
+ public void setTextStrategy(final TextStrategy textStrategy) {
+ this.textStrategy = textStrategy;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-08 15:28:45
|
Revision: 13033
http://sourceforge.net/p/foray/code/13033
Author: victormote
Date: 2023-01-08 15:28:43 +0000 (Sun, 08 Jan 2023)
Log Message:
-----------
Upgrade Unicode parser to work with Block naming scheme.
Modified Paths:
--------------
trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Block.java
trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Blocks.java
trunk/foray/foray-unicode/src/main/java/org/foray/unicode/UnicodeParser.java
Modified: trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Block.java
===================================================================
--- trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Block.java 2023-01-07 22:58:19 UTC (rev 13032)
+++ trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Block.java 2023-01-08 15:28:43 UTC (rev 13033)
@@ -40,6 +40,9 @@
/** The name of the code block. */
private String name;
+ /** The first code point in the block, expressed as hex digits, for example "0A80" for Gujarati. */
+ private String startAsString;
+
/** The first code point in the block. */
private int start;
@@ -52,11 +55,13 @@
/**
* Constructor.
* @param name The name of this block.
+ * @param startAsString The first code point in the block, expressed as hex digits, for example "0A80" for Gujarati.
* @param start The first code point value in this block.
* @param end The last code point value in this block.
*/
- public Block(final String name, final int start, final int end) {
+ public Block(final String name, final String startAsString, final int start, final int end) {
this.name = name;
+ this.startAsString = startAsString;
this.start = start;
this.end = end;
}
@@ -70,6 +75,14 @@
}
/**
+ * Returns the first code point in the block, expressed as hex digits, for example "0A80" for Gujarati.
+ * @return The first code point in the block, expressed as hex digits, for example "0A80" for Gujarati.
+ */
+ public String getStartAsString() {
+ return this.startAsString;
+ }
+
+ /**
* Returns the first code point in the block.
* @return The first code point in the block.
*/
Modified: trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Blocks.java
===================================================================
--- trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Blocks.java 2023-01-07 22:58:19 UTC (rev 13032)
+++ trunk/foray/foray-unicode/src/main/java/org/foray/unicode/Blocks.java 2023-01-08 15:28:43 UTC (rev 13033)
@@ -38,7 +38,7 @@
/** The "No_Block" block specified in the Unicode standard, to be used when a code point has not been assigned to
* a code block. */
- public static final Block NO_BLOCK = new Block("No_Block", -1, -1);
+ public static final Block NO_BLOCK = new Block("No_Block", "", -1, -1);
/** Map whose key is the normalized block name, and whose value is the block. */
private Map<String, Block> namesMap = new HashMap<String, Block>();
Modified: trunk/foray/foray-unicode/src/main/java/org/foray/unicode/UnicodeParser.java
===================================================================
--- trunk/foray/foray-unicode/src/main/java/org/foray/unicode/UnicodeParser.java 2023-01-07 22:58:19 UTC (rev 13032)
+++ trunk/foray/foray-unicode/src/main/java/org/foray/unicode/UnicodeParser.java 2023-01-08 15:28:43 UTC (rev 13033)
@@ -38,6 +38,7 @@
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
+import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
@@ -116,7 +117,14 @@
outDir.mkdir();
outDir = new File(outDir, "block/");
outDir.mkdir();
- final String className = block.getJavaName() + "_Block";
+ final String className;
+ if (block.getStart() < Character.MAX_VALUE) {
+ /* Only use four hex characters for the basic plane. */
+ className = "U" + block.getStartAsString() + "_" + block.getJavaName();
+ } else {
+ /* Keep the blocks with more than four hex characters sorted by prepending "X" instead of "U". */
+ className = "X" + block.getStartAsString() + "_" + block.getJavaName();
+ }
final File outFile = new File(outDir, className + ".java");
final String eol = System.lineSeparator();
try (Writer writer = new FileWriter(outFile)) {
@@ -139,8 +147,8 @@
writer.write(" */");
writer.write(eol);
writer.write("public final class ");
- writer.write(block.getJavaName());
- writer.write("_Block {");
+ writer.write(className);
+ writer.write(" {");
writer.write(eol);
writer.write(eol);
writer.write(" /*");
@@ -201,7 +209,7 @@
/* The file footer. */
writer.write(eol);
- writer.write(" /*");
+ writer.write(" /**");
writer.write(eol);
writer.write(" * Private constructor. This is a utility class and should never be instantiated.");
writer.write(eol);
@@ -278,10 +286,12 @@
final String name = split1[1];
final String[] split2 = range.split("\\.\\.");
- final int start = Integer.parseInt(split2[0], 16);
- final int end = Integer.parseInt(split2[1], 16);
+ final String startAsString = split2[0];
+ final String endAsString = split2[1];
+ final int start = Integer.parseInt(startAsString, 16);
+ final int end = Integer.parseInt(endAsString, 16);
- return new Block(name, start, end);
+ return new Block(name, startAsString, start, end);
}
/**
@@ -293,7 +303,9 @@
final StringBuilder builder = new StringBuilder();
builder.append("/*");
builder.append(eol);
- builder.append(" * Copyright 2021 The aXSL Project.");
+ builder.append(" * Copyright ");
+ builder.append(LocalDate.now().getYear());
+ builder.append(" The aXSL Project.");
builder.append(eol);
builder.append(" * http://www.axsl.org");
builder.append(eol);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-07 22:58:21
|
Revision: 13032
http://sourceforge.net/p/foray/code/13032
Author: victormote
Date: 2023-01-07 22:58:19 +0000 (Sat, 07 Jan 2023)
Log Message:
-----------
Move kerning test to FsType1FontTests.
Modified Paths:
--------------
trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2023-01-07 22:51:56 UTC (rev 13031)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2023-01-07 22:58:19 UTC (rev 13032)
@@ -32,8 +32,6 @@
import org.axsl.font.FontException;
import org.axsl.font.zzz.FontContextMdo;
-import org.axsl.ps.Encoding;
-import org.axsl.unicode.block.U0080_Latin_1_Supplement;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -45,34 +43,6 @@
public class Font4aTests {
/**
- * Ensures that we can read the serialized metrics information for the
- * Base-14 fonts, and some basic testing of that data.
- * @throws FontException For font system errors.
- */
- @Test
- public void testBase14() throws FontException {
- final FontServer4a server = FontServer4aTests.getServer();
- assertNotNull(server);
- final RegisteredFontContent rf = server.getRegisteredFont("Base14-Times");
- assertNotNull(rf);
- final FsType1Font fsf = (FsType1Font) rf.getFreeStandingFont();
- assertNotNull(fsf);
- final Encoding encoding = fsf.getInternalEncoding();
- assertNotNull(encoding);
-
- /* Line 265 of Times-Roman.afm shows the width of A-dieresis to be 722. */
- assertEquals(722, fsf.width(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS, 1000));
- /* Line 321 of Times-Roman.afm shows the width of (O-tilde to be 722. */
- assertEquals(722, fsf.width(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_O_WITH_TILDE, 1000));
-
- /* TODO: Move this test to FSType1FontTests. */
- /* Get the kerning value for an A-dieresis and an O-tilde, found at line 519 of the AFM for Times-Roman. */
- final int kernValue = fsf.kern(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS,
- U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_O_WITH_TILDE);
- assertEquals(-55, kernValue);
- }
-
- /**
* Functional test of getting the glyph widths and kerning for a String.
* @throws FontException For font system errors.
*/
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java 2023-01-07 22:51:56 UTC (rev 13031)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java 2023-01-07 22:58:19 UTC (rev 13032)
@@ -32,6 +32,8 @@
import org.axsl.font.FontException;
import org.axsl.font.zzz.FontContextMdo;
+import org.axsl.ps.Encoding;
+import org.axsl.unicode.block.U0080_Latin_1_Supplement;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -80,4 +82,30 @@
assertEquals(7_200, fsf.width(0x2211, 12000));
}
+ /**
+ * Test of {@link FsType1Font#kern(int, int)}.
+ * @throws FontException For font system errors.
+ */
+ @Test
+ public void kernTest() throws FontException {
+ final FontServer4a server = FontServer4aTests.getServer();
+ assertNotNull(server);
+ final RegisteredFontContent rf = server.getRegisteredFont("Base14-Times");
+ assertNotNull(rf);
+ final FsType1Font fsf = (FsType1Font) rf.getFreeStandingFont();
+ assertNotNull(fsf);
+ final Encoding encoding = fsf.getInternalEncoding();
+ assertNotNull(encoding);
+
+ /* Line 265 of Times-Roman.afm shows the width of A-dieresis to be 722. */
+ assertEquals(722, fsf.width(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS, 1000));
+ /* Line 321 of Times-Roman.afm shows the width of (O-tilde to be 722. */
+ assertEquals(722, fsf.width(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_O_WITH_TILDE, 1000));
+
+ /* Get the kerning value for an A-dieresis and an O-tilde, found at line 519 of the AFM for Times-Roman. */
+ final int kernValue = fsf.kern(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS,
+ U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_O_WITH_TILDE);
+ assertEquals(-55, kernValue);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-07 22:51:59
|
Revision: 13031
http://sourceforge.net/p/foray/code/13031
Author: victormote
Date: 2023-01-07 22:51:56 +0000 (Sat, 07 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Fix bug related to word-spacing computation.
Modified Paths:
--------------
trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2023-01-07 22:38:25 UTC (rev 13030)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2023-01-07 22:51:56 UTC (rev 13031)
@@ -120,8 +120,8 @@
* Number of word spaces = 2.
* Total word spacing = 600.
* Total space (kerning on) = 90,780 + 600 = 91,380. */
-// assertEquals(91380, font.width(
-// testString, 0, testString.length(), 12000, 0, 300, fontOptionsWithKerning, null));
+ assertEquals(91380, font.width(
+ testString, 0, testString.length(), 12000, 0, 300, fontOptionsWithKerning, null));
/* Test with letter spacing.
* Letter spacing = 5.
@@ -133,8 +133,8 @@
/* Test with both word spacing and letter spacing, using same parameters as above.
* Total space (kerning on) = 90,780 + 600 + 80 = 91,460. */
-// assertEquals(91460, font.width(
-// testString, 0, testString.length(), 12000, 5, 300, fontOptionsWithKerning, null));
+ assertEquals(91460, font.width(
+ testString, 0, testString.length(), 12000, 5, 300, fontOptionsWithKerning, null));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-07 22:38:27
|
Revision: 13030
http://sourceforge.net/p/foray/code/13030
Author: victormote
Date: 2023-01-07 22:38:25 +0000 (Sat, 07 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Change semantic of parameters to kern(int, int) method from glyph indexes to code points.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/Kerning.java
trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentTests.java
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 2023-01-07 18:04:34 UTC (rev 13029)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-07 22:38:25 UTC (rev 13030)
@@ -217,11 +217,13 @@
public abstract boolean kerningActive();
@Override
- public int kern(final int glyphIndex1, final int glyphIndex2) {
+ public int kern(final int codePoint1, final int codePoint2) {
if (getKerning() == null) {
return 0;
}
- final int rawKerning = getKerning().kern(glyphIndex1, glyphIndex2);
+ final int metricIndex1 = this.metricIndex(codePoint1);
+ final int metricIndex2 = this.metricIndex(codePoint2);
+ final int rawKerning = getKerning().kern(metricIndex1, metricIndex2);
if (TypographicConstants.MILLIPOINTS_PER_POINT == this.getUnitsPerTextSpaceUnit()) {
/* Avoid the potential loss of precision. */
return rawKerning;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/Kerning.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/Kerning.java 2023-01-07 18:04:34 UTC (rev 13029)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/Kerning.java 2023-01-07 22:38:25 UTC (rev 13030)
@@ -154,18 +154,18 @@
/**
* Computes the kerning needed between two glyphs in this font.
* Note that this method silently returns zero if the Kerning instance is not locked (see {@link #lock()}.
- * @param glyphIndex1 The glyph index of the first (left in a left-to-right system) glyph.
- * @param glyphIndex2 The glyph index of the second (right in left-to-right system) glyph.
+ * @param codePoint1 The code point of the first (left in a left-to-right system) glyph.
+ * @param codePoint2 The code point of the second (right in left-to-right system) glyph.
* @return The distance in raw font units (millipoints for Type 1 fonts) of the kerning.
* A positive amount means that the characters should be moved farther apart, and a negative amount means that they
* should be moved closer together.
*/
- public int kern(final int glyphIndex1, final int glyphIndex2) {
+ public int kern(final int codePoint1, final int codePoint2) {
if (! this.isLocked) {
return 0;
}
int index = 0;
- index = indexOfKerningPair(glyphIndex1, glyphIndex2);
+ index = indexOfKerningPair(codePoint1, codePoint2);
if (index < 0) {
return 0;
}
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2023-01-07 18:04:34 UTC (rev 13029)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2023-01-07 22:38:25 UTC (rev 13030)
@@ -37,7 +37,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -66,10 +65,11 @@
/* Line 321 of Times-Roman.afm shows the width of (O-tilde to be 722. */
assertEquals(722, fsf.width(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_O_WITH_TILDE, 1000));
- /* TODO: Change kern method to use codePoint. TODO: Move this test to FSType1FontTests. */
+ /* TODO: Move this test to FSType1FontTests. */
/* Get the kerning value for an A-dieresis and an O-tilde, found at line 519 of the AFM for Times-Roman. */
-// final int kernValue = fsf.kern(metricIndex1, metricIndex2);
-// assertEquals(-55, kernValue);
+ final int kernValue = fsf.kern(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS,
+ U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_O_WITH_TILDE);
+ assertEquals(-55, kernValue);
}
/**
@@ -77,7 +77,6 @@
* @throws FontException For font system errors.
*/
@Test
- @Disabled("Method kern() needs to be adjusted to take code points instead of glyph indexes.")
public void testWidth() throws FontException {
final FontContextMdo fontOptionsWithKerning = new FontContextMdo();
fontOptionsWithKerning.setKerning(true);
@@ -121,8 +120,8 @@
* Number of word spaces = 2.
* Total word spacing = 600.
* Total space (kerning on) = 90,780 + 600 = 91,380. */
- assertEquals(91380, font.width(
- testString, 0, testString.length(), 12000, 0, 300, fontOptionsWithKerning, null));
+// assertEquals(91380, font.width(
+// testString, 0, testString.length(), 12000, 0, 300, fontOptionsWithKerning, null));
/* Test with letter spacing.
* Letter spacing = 5.
@@ -134,8 +133,8 @@
/* Test with both word spacing and letter spacing, using same parameters as above.
* Total space (kerning on) = 90,780 + 600 + 80 = 91,460. */
- assertEquals(91460, font.width(
- testString, 0, testString.length(), 12000, 5, 300, fontOptionsWithKerning, null));
+// assertEquals(91460, font.width(
+// testString, 0, testString.length(), 12000, 5, 300, fontOptionsWithKerning, null));
}
}
Modified: trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentTests.java
===================================================================
--- trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentTests.java 2023-01-07 18:04:34 UTC (rev 13029)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentTests.java 2023-01-07 22:38:25 UTC (rev 13030)
@@ -57,6 +57,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
@@ -103,9 +104,12 @@
final PdfFont pdfFont = doc.getPdfFont(fontUse);
contentStream.setFont(pdfFont, 12);
+ /* Turn kerning off for this basic test. */
+ final FontContext fontContext = Mockito.mock(FontContext.class);
+ Mockito.when(fontContext.isKerning()).thenReturn(false);
contentStream.setCursor(36, heightPoints - 36);
contentStream.openTextObject();
- contentStream.drawText("Hello World!", FontContext.DEFAULT, null);
+ contentStream.drawText("Hello World!", fontContext, null);
contentStream.closeTextObject();
contentStream.close();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-07 18:04:36
|
Revision: 13029
http://sourceforge.net/p/foray/code/13029
Author: victormote
Date: 2023-01-07 18:04:34 +0000 (Sat, 07 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed method FontUse.width(int, int).
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java
trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreaker.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java 2023-01-07 17:52:08 UTC (rev 13028)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LeaderArea.java 2023-01-07 18:04:34 UTC (rev 13029)
@@ -486,7 +486,7 @@
public int getCharWidth(final int c) {
final FontUse fontUse = traitNominalFont();
fontUse.registerCharUsed(c);
- return fontUse.width(c, traitFontSize()) + this.traitGeneratedBy().traitLetterSpacingOpt(this);
+ return fontUse.getFont().width(c, traitFontSize()) + this.traitGeneratedBy().traitLetterSpacingOpt(this);
}
@Override
Modified: trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java
===================================================================
--- trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2023-01-07 17:52:08 UTC (rev 13028)
+++ trunk/foray/foray-content/src/main/java/org/foray/content/PageReferenceContent.java 2023-01-07 18:04:34 UTC (rev 13029)
@@ -69,7 +69,7 @@
/* TODO: Fix this method after we add the context to this class. */
final CommonFontPa asText = (CommonFontPa) this.content;
final int fontSize = asText.traitFontSize(null);
- final int zeroWidth = getFontUse().width('0', fontSize);
+ final int zeroWidth = getFontUse().getFont().width('0', fontSize);
// This is an estimate for purposes of layout.
return zeroWidth * QTY_PLACEHOLDER_DIGITS;
}
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-07 17:52:08 UTC (rev 13028)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2023-01-07 18:04:34 UTC (rev 13029)
@@ -191,15 +191,6 @@
}
@Override
- public int width(final int codePoint, final int fontSize) {
- final int metricIndex = getFont().metricIndex(codePoint);
- if (metricIndex < 0) {
- return getFont().widthUndefinedGlyph(fontSize);
- }
- return this.getFont().width(metricIndex, fontSize);
- }
-
- @Override
public Font.Weight nextBolderWeight() {
final RegisteredFont desc =
this.registeredFontDesc.nextBolderFont();
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java 2023-01-07 17:52:08 UTC (rev 13028)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java 2023-01-07 18:04:34 UTC (rev 13029)
@@ -98,7 +98,7 @@
@Override
public int getHyphenCharacterWidth() {
- return this.fontUse.width(this.hyphenationCharacter, this.fontSize);
+ return this.fontUse.getFont().width(this.hyphenationCharacter, this.fontSize);
}
}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreaker.java 2023-01-07 17:52:08 UTC (rev 13028)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/LineBreaker.java 2023-01-07 18:04:34 UTC (rev 13029)
@@ -93,7 +93,7 @@
codePointToUse = java.lang.Character.toUpperCase((char) codePoint);
}
fontUse.registerCharUsed(codePointToUse);
- return fontUse.width(codePointToUse, fontSize) + lineText.inlineLetterSpacingOptimum();
+ return fontUse.getFont().width(codePointToUse, fontSize) + lineText.inlineLetterSpacingOptimum();
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-07 17:52:11
|
Revision: 13028
http://sourceforge.net/p/foray/code/13028
Author: victormote
Date: 2023-01-07 17:52:08 +0000 (Sat, 07 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Change the semantic of the first parameter of Font.width(int, int) from "metric index" to "code point."
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.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/test/java/org/foray/font/Font4aTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java
trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java
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 2023-01-07 15:33:40 UTC (rev 13027)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-07 17:52:08 UTC (rev 13028)
@@ -131,8 +131,8 @@
}
@Override
- public int widthEstimate(final int c, final int fontSize) {
- switch (c) {
+ public int widthEstimate(final int codePoint, final int fontSize) {
+ switch (codePoint) {
case U0000_Basic_Latin.CONTROL_CHARACTER_TABULATION: // horizontal tab
case U0000_Basic_Latin.CONTROL_LINE_FEED:
case U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN:
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-07 15:33:40 UTC (rev 13027)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2023-01-07 17:52:08 UTC (rev 13028)
@@ -177,8 +177,8 @@
}
@Override
- public int width(final int c, final int fontSize) {
- final int glyphIndex = this.getInternalEncoding().encode(c);
+ public int width(final int codePoint, final int fontSize) {
+ final int glyphIndex = this.getInternalEncoding().encode(codePoint);
if (glyphIndex < 0) {
return Integer.MIN_VALUE;
}
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-07 15:33:40 UTC (rev 13027)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2023-01-07 17:52:08 UTC (rev 13028)
@@ -268,7 +268,11 @@
}
@Override
- public int width(final int metricIndex, final int fontSize) {
+ public int width(final int codePoint, final int fontSize) {
+ final int metricIndex = this.metricIndex(codePoint);
+ if (metricIndex < 0) {
+ return this.widthEstimate(codePoint, 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().shortAt(metricIndex) / TypographicConstants.MILLIPOINTS_PER_POINT;
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 2023-01-07 15:33:40 UTC (rev 13027)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2023-01-07 17:52:08 UTC (rev 13028)
@@ -150,7 +150,7 @@
}
@Override
- public int width(final int c, final int size) {
+ public int width(final int codePoint, final int size) {
final FontMetrics fm = getSizedFont(size);
// Nov 18, 2002, aml/rlc
@@ -157,7 +157,7 @@
// measure character width using getStringBounds for better results
final char[] ac = new char [1];
- ac[0] = (char) c;
+ ac[0] = (char) codePoint;
double dWidth = fm.getStringBounds(ac, 0, 1, getGraphics()).getWidth()
* TypographicConstants.MILLIPOINTS_PER_POINT;
@@ -169,7 +169,7 @@
// space is rendered larger than given by
// the FontMetrics object
- if (c == ' ') {
+ if (codePoint == ' ') {
dWidth = dWidth * SystemFont.SPACE_SIZE_CONVERSION;
}
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2023-01-07 15:33:40 UTC (rev 13027)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2023-01-07 17:52:08 UTC (rev 13028)
@@ -32,11 +32,12 @@
import org.axsl.font.FontException;
import org.axsl.font.zzz.FontContextMdo;
-import org.axsl.ps.CharSet;
import org.axsl.ps.Encoding;
+import org.axsl.unicode.block.U0080_Latin_1_Supplement;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -59,18 +60,16 @@
assertNotNull(fsf);
final Encoding encoding = fsf.getInternalEncoding();
assertNotNull(encoding);
- final CharSet charSet = fsf.getCharSet();
- final int metricIndex1 = charSet.getIndex(0xC4);
/* Line 265 of Times-Roman.afm shows the width of A-dieresis to be 722. */
- assertEquals(722, fsf.width(metricIndex1, 1000));
- final int metricIndex2 = charSet.getIndex(0xD5);
+ assertEquals(722, fsf.width(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS, 1000));
/* Line 321 of Times-Roman.afm shows the width of (O-tilde to be 722. */
- assertEquals(722, fsf.width(metricIndex2, 1000));
+ assertEquals(722, fsf.width(U0080_Latin_1_Supplement.LATIN_CAPITAL_LETTER_O_WITH_TILDE, 1000));
+ /* TODO: Change kern method to use codePoint. TODO: Move this test to FSType1FontTests. */
/* Get the kerning value for an A-dieresis and an O-tilde, found at line 519 of the AFM for Times-Roman. */
- final int kernValue = fsf.kern(metricIndex1, metricIndex2);
- assertEquals(-55, kernValue);
+// final int kernValue = fsf.kern(metricIndex1, metricIndex2);
+// assertEquals(-55, kernValue);
}
/**
@@ -78,6 +77,7 @@
* @throws FontException For font system errors.
*/
@Test
+ @Disabled("Method kern() needs to be adjusted to take code points instead of glyph indexes.")
public void testWidth() throws FontException {
final FontContextMdo fontOptionsWithKerning = new FontContextMdo();
fontOptionsWithKerning.setKerning(true);
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java 2023-01-07 15:33:40 UTC (rev 13027)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java 2023-01-07 17:52:08 UTC (rev 13028)
@@ -35,7 +35,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -47,7 +46,6 @@
* Tests of {@link FsType1Font#width(int, int)}.
*/
@Test
- @Disabled("Activate as part of the width refactoring. ")
public void widthTest() throws FontException {
final FontContextMdo fontOptionsWithKerning = new FontContextMdo();
fontOptionsWithKerning.setKerning(true);
Modified: trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java
===================================================================
--- trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java 2023-01-07 15:33:40 UTC (rev 13027)
+++ trunk/foray/foray-linebreak/src/test/java/org/foray/linebreak/KpContext4a.java 2023-01-07 17:52:08 UTC (rev 13028)
@@ -81,7 +81,7 @@
public int getIdealWidth(final KpLeaf leaf) {
if (leaf instanceof CharSequence) {
final CharSequence chars = (CharSequence) leaf;
- return this.fontUse.getFont().width(chars, 0, chars.length(), fontSize, 0, 0, fontContext, orthography);
+ return this.fontUse.getFont().width(chars, fontSize, fontContext, orthography);
}
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-07 15:33:44
|
Revision: 13027
http://sourceforge.net/p/foray/code/13027
Author: victormote
Date: 2023-01-07 15:33:40 +0000 (Sat, 07 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Rename Unicode block classes to include their starting code point.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java
trunk/foray/foray-common/src/main/java/org/foray/common/data/ByteSequenceTokenizer.java
trunk/foray/foray-common/src/main/java/org/foray/common/i18n/Script4a.java
trunk/foray/foray-common/src/test/java/org/foray/common/data/ByteSequenceTokenizerTests.java
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParserPfa.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoRefinedText4aTests.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Lexer4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java
trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/CharacterUtils.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextArea.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -40,7 +40,7 @@
import org.axsl.galley.GlyphAreaSequenceG5;
import org.axsl.galley.render.GalleyVisitor;
import org.axsl.galley.render.GalleyVisitorException;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import org.axsl.value.WhiteSpaceTreatment;
import java.awt.Color;
@@ -216,7 +216,7 @@
for (int i = start; i < start + size; i++) {
final char c = chars.charAt(i);
if (! XmlCharacterUtils.isXMLWhitespace(c)
- || c == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ || c == U0000_Basic_Latin.CONTROL_LINE_FEED) {
return count;
}
count ++;
@@ -260,7 +260,7 @@
for (int i = start + size - 1; i >= start; i--) {
final char c = chars.charAt(i);
if (! XmlCharacterUtils.isXMLWhitespace(c)
- || c == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ || c == U0000_Basic_Latin.CONTROL_LINE_FEED) {
return count;
}
count ++;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TextAreaCharacters.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -32,7 +32,7 @@
import org.foray.common.CharSequenceSubset;
import org.axsl.fotree.fo.FoTextCharacters;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import java.io.Serializable;
@@ -223,7 +223,7 @@
return false;
}
final int lastCharIndex = rawText.length() - 1;
- if (rawText.charAt(lastCharIndex) == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (rawText.charAt(lastCharIndex) == U0000_Basic_Latin.CONTROL_LINE_FEED) {
return true;
}
return false;
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/data/ByteSequenceTokenizer.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/data/ByteSequenceTokenizer.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/data/ByteSequenceTokenizer.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -33,7 +33,7 @@
import org.axsl.primitive.sequence.ByteSequence;
import org.axsl.primitive.sequence.ByteSequencePlus;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import java.util.ArrayList;
import java.util.List;
@@ -59,12 +59,12 @@
* The standard set of whitespace characters.
*/
private static final ByteArray WHITESPACE = new ByteArray(
- (byte) Basic_Latin_Block.CONTROL_NULL,
- (byte) Basic_Latin_Block.CONTROL_CHARACTER_TABULATION,
- (byte) Basic_Latin_Block.CONTROL_LINE_FEED,
- (byte) Basic_Latin_Block.CONTROL_FORM_FEED,
- (byte) Basic_Latin_Block.CONTROL_CARRIAGE_RETURN,
- (byte) Basic_Latin_Block.SPACE);
+ (byte) U0000_Basic_Latin.CONTROL_NULL,
+ (byte) U0000_Basic_Latin.CONTROL_CHARACTER_TABULATION,
+ (byte) U0000_Basic_Latin.CONTROL_LINE_FEED,
+ (byte) U0000_Basic_Latin.CONTROL_FORM_FEED,
+ (byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN,
+ (byte) U0000_Basic_Latin.SPACE);
/** The default tokenizer configuration. Using it will return non-whitespace as tokens. */
private static final ByteSequenceTokenizerConfig DEFAULT_TOKENIZER_CONFIG =
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/i18n/Script4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/i18n/Script4a.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/i18n/Script4a.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -30,7 +30,7 @@
package org.foray.common.i18n;
import org.axsl.i18n.Script;
-import org.axsl.unicode.block.General_Punctuation_Block;
+import org.axsl.unicode.block.U2000_General_Punctuation;
import com.ibm.icu.lang.UScript;
@@ -75,7 +75,7 @@
* @see "XSL Recommendation 1.1, Section 1.2.1."
* @see "XSL Recommendation 1.1, Section 7.10.5."
*/
- private static final String DEFAULT_HYPHENATION_CHAR = Character.toString(General_Punctuation_Block.HYPHEN);
+ private static final String DEFAULT_HYPHENATION_CHAR = Character.toString(U2000_General_Punctuation.HYPHEN);
/** The alpha code map. */
private static Map<String, Script4a> mapAlpha = new HashMap<String, Script4a>(INITIAL_CAPACITY);
Modified: trunk/foray/foray-common/src/test/java/org/foray/common/data/ByteSequenceTokenizerTests.java
===================================================================
--- trunk/foray/foray-common/src/test/java/org/foray/common/data/ByteSequenceTokenizerTests.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-common/src/test/java/org/foray/common/data/ByteSequenceTokenizerTests.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.ByteArray;
import org.axsl.primitive.sequence.ByteSequence;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -57,12 +57,12 @@
/** Whitespace characters that should be treated as non-returnable delimiters for these tests. */
private static final ByteArray WHITESPACE = new ByteArray(
- (byte) Basic_Latin_Block.CONTROL_NULL,
- (byte) Basic_Latin_Block.CONTROL_CHARACTER_TABULATION,
- (byte) Basic_Latin_Block.CONTROL_LINE_FEED,
- (byte) Basic_Latin_Block.CONTROL_FORM_FEED,
- (byte) Basic_Latin_Block.CONTROL_CARRIAGE_RETURN,
- (byte) Basic_Latin_Block.SPACE);
+ (byte) U0000_Basic_Latin.CONTROL_NULL,
+ (byte) U0000_Basic_Latin.CONTROL_CHARACTER_TABULATION,
+ (byte) U0000_Basic_Latin.CONTROL_LINE_FEED,
+ (byte) U0000_Basic_Latin.CONTROL_FORM_FEED,
+ (byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN,
+ (byte) U0000_Basic_Latin.SPACE);
/** A standard configuration for these tests. */
private static final ByteArray ESCAPE_CHARS = new ByteArray("\\");
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 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -33,10 +33,10 @@
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.ps.CharSet;
-import org.axsl.unicode.block.Basic_Latin_Block;
-import org.axsl.unicode.block.CJK_Symbols_and_Punctuation_Block;
-import org.axsl.unicode.block.General_Punctuation_Block;
-import org.axsl.unicode.block.Latin_1_Supplement_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
+import org.axsl.unicode.block.U0080_Latin_1_Supplement;
+import org.axsl.unicode.block.U2000_General_Punctuation;
+import org.axsl.unicode.block.U3000_CJK_Symbols_and_Punctuation;
/**
* An implementation of the aXSL {@link Font4a} interface.
@@ -133,38 +133,38 @@
@Override
public int widthEstimate(final int c, final int fontSize) {
switch (c) {
- case Basic_Latin_Block.CONTROL_CHARACTER_TABULATION: // horizontal tab
- case Basic_Latin_Block.CONTROL_LINE_FEED:
- case Basic_Latin_Block.CONTROL_CARRIAGE_RETURN:
- case Latin_1_Supplement_Block.NO_BREAK_SPACE:
+ case U0000_Basic_Latin.CONTROL_CHARACTER_TABULATION: // horizontal tab
+ case U0000_Basic_Latin.CONTROL_LINE_FEED:
+ case U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN:
+ case U0080_Latin_1_Supplement.NO_BREAK_SPACE:
return width(' ', fontSize);
- case General_Punctuation_Block.EN_QUAD:
+ case U2000_General_Punctuation.EN_QUAD:
return getEnWidth(fontSize);
- case General_Punctuation_Block.EM_QUAD:
+ case U2000_General_Punctuation.EM_QUAD:
return getEmWidth(fontSize);
- case General_Punctuation_Block.EN_SPACE:
+ case U2000_General_Punctuation.EN_SPACE:
return getEnWidth(fontSize);
- case General_Punctuation_Block.EM_SPACE:
+ case U2000_General_Punctuation.EM_SPACE:
return getEmWidth(fontSize);
- case General_Punctuation_Block.THREE_PER_EM_SPACE:
+ case U2000_General_Punctuation.THREE_PER_EM_SPACE:
return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_3_PER_EM);
- case General_Punctuation_Block.FOUR_PER_EM_SPACE:
+ case U2000_General_Punctuation.FOUR_PER_EM_SPACE:
return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_4_PER_EM);
- case General_Punctuation_Block.SIX_PER_EM_SPACE:
+ case U2000_General_Punctuation.SIX_PER_EM_SPACE:
return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_6_PER_EM);
- case General_Punctuation_Block.FIGURE_SPACE:
+ case U2000_General_Punctuation.FIGURE_SPACE:
return width(' ', fontSize);
- case General_Punctuation_Block.PUNCTUATION_SPACE:
+ case U2000_General_Punctuation.PUNCTUATION_SPACE:
return width('.', fontSize);
- case General_Punctuation_Block.THIN_SPACE: //thin space (1/5 em)
+ case U2000_General_Punctuation.THIN_SPACE: //thin space (1/5 em)
return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_THIN_SPACE);
- case General_Punctuation_Block.HAIR_SPACE:
+ case U2000_General_Punctuation.HAIR_SPACE:
return Math.round(getEmWidth(fontSize) / Font4a.FACTOR_HAIR_SPACE);
- case General_Punctuation_Block.ZERO_WIDTH_SPACE:
+ case U2000_General_Punctuation.ZERO_WIDTH_SPACE:
return 0;
- case General_Punctuation_Block.NARROW_NO_BREAK_SPACE:
+ case U2000_General_Punctuation.NARROW_NO_BREAK_SPACE:
return Math.round(width(' ', fontSize) / 2);
- case CJK_Symbols_and_Punctuation_Block.IDEOGRAPHIC_SPACE:
+ case U3000_CJK_Symbols_and_Punctuation.IDEOGRAPHIC_SPACE:
return width(' ', fontSize) * 2;
default:
return Integer.MIN_VALUE;
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-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -54,7 +54,7 @@
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.CharSet;
import org.axsl.ps.Encoding;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -550,7 +550,7 @@
}
buffer.append(endTextDelimiter(font));
buffer.append("]TJ");
- buffer.append(Basic_Latin_Block.CONTROL_LINE_FEED);
+ buffer.append(U0000_Basic_Latin.CONTROL_LINE_FEED);
return buffer.toString();
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Font.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Font.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -31,7 +31,7 @@
import org.foray.font.format.FontContent;
import org.axsl.ps.PsFontDictionary;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import java.util.Arrays;
@@ -149,8 +149,8 @@
protected byte[] convertLineEndings(final byte[] input) {
for (int i = 0; i < input.length; i++) {
/* If carriage-return, convert to line-feed. */
- if (input[i] == Basic_Latin_Block.CONTROL_CARRIAGE_RETURN) {
- input[i] = Basic_Latin_Block.CONTROL_LINE_FEED;
+ if (input[i] == U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN) {
+ input[i] = U0000_Basic_Latin.CONTROL_LINE_FEED;
}
}
return input;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParserPfa.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParserPfa.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParserPfa.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -31,7 +31,7 @@
import org.foray.common.ByteSequenceSearcher;
import org.foray.font.format.FontParser;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import java.io.IOException;
@@ -139,10 +139,10 @@
startOfSegment --;
getRandomInput().seek(startOfSegment);
final byte newByte = getRandomInput().readByte();
- if (newByte == Basic_Latin_Block.CONTROL_CARRIAGE_RETURN) {
+ if (newByte == U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN) {
continue;
}
- if (newByte == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (newByte == U0000_Basic_Latin.CONTROL_LINE_FEED) {
continue;
}
if (newByte == '0') {
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoText4a.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -37,7 +37,7 @@
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.fo.FoText;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import org.axsl.value.LinefeedTreatment;
import org.axsl.value.TextTransform;
import org.axsl.value.WhiteSpaceTreatment;
@@ -205,7 +205,7 @@
/* If it is not whitespace, it cannot be changed. */
return c;
}
- if (c == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (c == U0000_Basic_Latin.CONTROL_LINE_FEED) {
/* If it is 0x000A (linefeed), it cannot be changed. */
return c;
}
@@ -217,7 +217,7 @@
if (charAfter == UnicodeCharUtils.INVALID_UNICODE_CHARACTER) {
return c;
}
- if (charAfter != Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (charAfter != U0000_Basic_Latin.CONTROL_LINE_FEED) {
return c;
}
return UnicodeCharUtils.INVALID_UNICODE_CHARACTER;
@@ -227,7 +227,7 @@
if (charBefore == UnicodeCharUtils.INVALID_UNICODE_CHARACTER) {
return c;
}
- if (charBefore != Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (charBefore != U0000_Basic_Latin.CONTROL_LINE_FEED) {
return c;
}
return UnicodeCharUtils.INVALID_UNICODE_CHARACTER;
@@ -237,7 +237,7 @@
default: {
/* If first element, only check next. */
if (charBefore == UnicodeCharUtils.INVALID_UNICODE_CHARACTER) {
- if (charAfter == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (charAfter == U0000_Basic_Latin.CONTROL_LINE_FEED) {
return UnicodeCharUtils.INVALID_UNICODE_CHARACTER;
}
return c;
@@ -244,14 +244,14 @@
}
/* If last element, only check previous. */
if (charAfter == UnicodeCharUtils.INVALID_UNICODE_CHARACTER) {
- if (charBefore == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (charBefore == U0000_Basic_Latin.CONTROL_LINE_FEED) {
return UnicodeCharUtils.INVALID_UNICODE_CHARACTER;
}
return c;
}
/* Otherwise, check both. */
- if (charBefore == Basic_Latin_Block.CONTROL_LINE_FEED
- || charAfter == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (charBefore == U0000_Basic_Latin.CONTROL_LINE_FEED
+ || charAfter == U0000_Basic_Latin.CONTROL_LINE_FEED) {
return UnicodeCharUtils.INVALID_UNICODE_CHARACTER;
}
return c;
@@ -332,7 +332,7 @@
* {@link UnicodeCharUtils#INVALID_UNICODE_CHARACTER} indicating that the character should be removed.
*/
public static char applyLinefeedTreatment(final char c, final LinefeedTreatment linefeedTreatment) {
- if (c != Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (c != U0000_Basic_Latin.CONTROL_LINE_FEED) {
/* This property does not apply to this char. */
return c;
}
@@ -377,7 +377,7 @@
int changeElements = 0;
for (int i = 0; i < charArray.length(); i++) {
final char c = charArray.charAt(i);
- if (c == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (c == U0000_Basic_Latin.CONTROL_LINE_FEED) {
if (linefeedTreatment == LinefeedTreatment.IGNORE) {
discardElements ++;
} else {
@@ -396,7 +396,7 @@
discardElements = 0;
for (int i = 0; i < charArray.length(); i++) {
final char c = charArray.charAt(i);
- if (c == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (c == U0000_Basic_Latin.CONTROL_LINE_FEED) {
final char conversionChar = applyLinefeedTreatment(c,
linefeedTreatment);
if (conversionChar == UnicodeCharUtils.INVALID_UNICODE_CHARACTER) {
@@ -494,7 +494,7 @@
/* If it is not whitespace, nothing should change. */
return c;
}
- if (c == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (c == U0000_Basic_Latin.CONTROL_LINE_FEED) {
/* If it is a linefeed, nothing should change. */
return c;
}
@@ -502,7 +502,7 @@
&& XmlCharacterUtils.isXMLWhitespace(codePointBefore)) {
return UnicodeCharUtils.INVALID_UNICODE_CHARACTER;
}
- if (codePointAfter == Basic_Latin_Block.CONTROL_LINE_FEED) {
+ if (codePointAfter == U0000_Basic_Latin.CONTROL_LINE_FEED) {
return UnicodeCharUtils.INVALID_UNICODE_CHARACTER;
}
return c;
Modified: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoRefinedText4aTests.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoRefinedText4aTests.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/fo/obj/FoRefinedText4aTests.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -28,8 +28,8 @@
package org.foray.fotree.fo.obj;
-import org.axsl.unicode.block.Basic_Latin_Block;
-import org.axsl.unicode.block.General_Punctuation_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
+import org.axsl.unicode.block.U2000_General_Punctuation;
import org.axsl.value.LinefeedTreatment;
import org.axsl.value.TextTransform;
@@ -47,13 +47,13 @@
@Test
public void linefeedTreatment_Test_001() {
final StringBuilder builder = new StringBuilder();
- builder.append(Basic_Latin_Block.CONTROL_LINE_FEED);
+ builder.append(U0000_Basic_Latin.CONTROL_LINE_FEED);
builder.append("Word1");
- builder.append(Basic_Latin_Block.CONTROL_LINE_FEED);
+ builder.append(U0000_Basic_Latin.CONTROL_LINE_FEED);
builder.append("Word2");
- builder.append(Basic_Latin_Block.CONTROL_LINE_FEED);
+ builder.append(U0000_Basic_Latin.CONTROL_LINE_FEED);
builder.append("Word3");
- builder.append(Basic_Latin_Block.CONTROL_LINE_FEED);
+ builder.append(U0000_Basic_Latin.CONTROL_LINE_FEED);
final String input = builder.toString();
assertEquals(19, input.length());
@@ -81,7 +81,7 @@
/* Test TREAT_AS_ZERO_WIDTH_SPACE. */
out = new FoRefinedText4a(input, LinefeedTreatment.TREAT_AS_ZERO_WIDTH_SPACE, textTransform, whiteSpaceCollapse,
-1, -1);
- expected = input.replace(Basic_Latin_Block.CONTROL_LINE_FEED, General_Punctuation_Block.ZERO_WIDTH_SPACE);
+ expected = input.replace(U0000_Basic_Latin.CONTROL_LINE_FEED, U2000_General_Punctuation.ZERO_WIDTH_SPACE);
assertEquals(expected, out.toString());
}
@@ -137,8 +137,8 @@
@Test
public void textWhiteSpaceCollapse_Test_001() {
/* "Julius Caesar," Act v. Scene 5. */
- final String input = " This" + Basic_Latin_Block.CONTROL_LINE_FEED + "was " +
- Basic_Latin_Block.CONTROL_LINE_FEED + " the noblest Roman of them all. ";
+ final String input = " This" + U0000_Basic_Latin.CONTROL_LINE_FEED + "was " +
+ U0000_Basic_Latin.CONTROL_LINE_FEED + " the noblest Roman of them all. ";
assertEquals(50, input.length());
/* Make the other factors neutral. */
@@ -154,23 +154,23 @@
/* Test "true". */
out = new FoRefinedText4a(input, linefeedTreatment, textTransform, true, -1, -1);
assertEquals(41, out.length());
- expected = " This" + Basic_Latin_Block.CONTROL_LINE_FEED + "was" +
- Basic_Latin_Block.CONTROL_LINE_FEED + "the noblest Roman of them all. ";
+ expected = " This" + U0000_Basic_Latin.CONTROL_LINE_FEED + "was" +
+ U0000_Basic_Latin.CONTROL_LINE_FEED + "the noblest Roman of them all. ";
assertEquals(expected, out.toString());
/* Test "true" with space fore and aft. */
out = new FoRefinedText4a(input, linefeedTreatment, textTransform, true, ' ', ' ');
assertEquals(40, out.length());
- expected = "This" + Basic_Latin_Block.CONTROL_LINE_FEED + "was" +
- Basic_Latin_Block.CONTROL_LINE_FEED + "the noblest Roman of them all. ";
+ expected = "This" + U0000_Basic_Latin.CONTROL_LINE_FEED + "was" +
+ U0000_Basic_Latin.CONTROL_LINE_FEED + "the noblest Roman of them all. ";
assertEquals(expected, out.toString());
/* Test "true" with linefeed fore and aft. */
- out = new FoRefinedText4a(input, linefeedTreatment, textTransform, true, Basic_Latin_Block.CONTROL_LINE_FEED,
- Basic_Latin_Block.CONTROL_LINE_FEED);
+ out = new FoRefinedText4a(input, linefeedTreatment, textTransform, true, U0000_Basic_Latin.CONTROL_LINE_FEED,
+ U0000_Basic_Latin.CONTROL_LINE_FEED);
assertEquals(40, out.length());
- expected = "This" + Basic_Latin_Block.CONTROL_LINE_FEED + "was" +
- Basic_Latin_Block.CONTROL_LINE_FEED + "the noblest Roman of them all. ";
+ expected = "This" + U0000_Basic_Latin.CONTROL_LINE_FEED + "was" +
+ U0000_Basic_Latin.CONTROL_LINE_FEED + "the noblest Roman of them all. ";
assertEquals(expected, out.toString());
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Lexer4a.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Lexer4a.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Lexer4a.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -35,7 +35,7 @@
import org.axsl.orthography.optional.Lexer;
import org.axsl.primitive.sequence.IntSequence;
-import org.axsl.unicode.block.Latin_1_Supplement_Block;
+import org.axsl.unicode.block.U0080_Latin_1_Supplement;
import java.util.ArrayList;
import java.util.Collections;
@@ -459,7 +459,7 @@
}
switch (c) {
- case Latin_1_Supplement_Block.NO_BREAK_SPACE: {
+ case U0080_Latin_1_Supplement.NO_BREAK_SPACE: {
return true;
}
}
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 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/Whitespace4a.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -37,7 +37,7 @@
import org.axsl.kp.KpContext;
import org.axsl.kp.KpLeaf;
import org.axsl.kp.KpNode;
-import org.axsl.unicode.block.General_Punctuation_Block;
+import org.axsl.unicode.block.U2000_General_Punctuation;
import org.axsl.value.LinefeedTreatment;
import org.axsl.value.group.TextModifiers;
@@ -235,7 +235,7 @@
case IGNORE: return UnicodeCharUtils.INVALID_UNICODE_CHARACTER;
case PRESERVE: return input;
case TREAT_AS_SPACE: return ' ';
- case TREAT_AS_ZERO_WIDTH_SPACE: return General_Punctuation_Block.ZERO_WIDTH_SPACE;
+ case TREAT_AS_ZERO_WIDTH_SPACE: return U2000_General_Punctuation.ZERO_WIDTH_SPACE;
default: throw new IllegalArgumentException();
}
}
Modified: trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java
===================================================================
--- trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-orthography/src/test/java/org/foray/orthography/TokenFlow4aTests.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -29,7 +29,7 @@
package org.foray.orthography;
import org.axsl.orthography.TextTokenFlowLocation;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import org.axsl.value.LinefeedTreatment;
import org.axsl.value.TextTransform;
import org.axsl.value.WhiteSpaceTreatment;
@@ -195,7 +195,7 @@
WhiteSpaceTreatment.IGNORE_IF_SURROUNDING_LINEFEED);
Mockito.when(textModifiers.traitWhiteSpaceCollapse()).thenReturn(true);
Mockito.when(textModifiers.traitHyphenationCharacter()).thenReturn(
- Character.toString(Basic_Latin_Block.HYPHEN_MINUS));
+ Character.toString(U0000_Basic_Latin.HYPHEN_MINUS));
/* Test extract starting at the start. */
TextTokenFlowLocation start = out.markLocation(0, 0);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfConstants.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -30,7 +30,7 @@
import org.foray.primitive.sequence.ByteArray;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import java.util.Arrays;
import java.util.List;
@@ -111,7 +111,7 @@
/** The carriage-return / linefeed combination, cast as a byte array. */
public static final ByteArray ASCII_CARRIAGE_RETURN_LINEFEED =
- new ByteArray((byte) Basic_Latin_Block.CONTROL_CARRIAGE_RETURN, (byte) Basic_Latin_Block.CONTROL_LINE_FEED);
+ new ByteArray((byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN, (byte) U0000_Basic_Latin.CONTROL_LINE_FEED);
/**
* The PDF delimiter characters.
@@ -143,8 +143,8 @@
PdfConstants.ASCII_CARRIAGE_RETURN_LINEFEED,
/* Single-byte arrays at the bottom of the list. */
- new ByteArray((byte) Basic_Latin_Block.CONTROL_LINE_FEED),
- new ByteArray((byte) Basic_Latin_Block.CONTROL_CARRIAGE_RETURN)
+ new ByteArray((byte) U0000_Basic_Latin.CONTROL_LINE_FEED),
+ new ByteArray((byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN)
);
/**
@@ -152,12 +152,12 @@
* @see "PDF Reference, Sixth Edition (PDF version 1.7), Section 3.1.1, especially Table 3.1."
*/
public static final ByteArray PDF_WHITESPACE = new ByteArray(
- (byte) Basic_Latin_Block.CONTROL_NULL,
- (byte) Basic_Latin_Block.CONTROL_CHARACTER_TABULATION,
- (byte) Basic_Latin_Block.CONTROL_LINE_FEED,
- (byte) Basic_Latin_Block.CONTROL_FORM_FEED,
- (byte) Basic_Latin_Block.CONTROL_CARRIAGE_RETURN,
- (byte) Basic_Latin_Block.SPACE);
+ (byte) U0000_Basic_Latin.CONTROL_NULL,
+ (byte) U0000_Basic_Latin.CONTROL_CHARACTER_TABULATION,
+ (byte) U0000_Basic_Latin.CONTROL_LINE_FEED,
+ (byte) U0000_Basic_Latin.CONTROL_FORM_FEED,
+ (byte) U0000_Basic_Latin.CONTROL_CARRIAGE_RETURN,
+ (byte) U0000_Basic_Latin.SPACE);
/** The maximum size, in bytes, of the file ID field. */
public static final int FILE_ID_SIZE = 16;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/PdfItem.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -32,7 +32,7 @@
import org.foray.primitive.StringUtils;
import org.axsl.pdf.PdfException;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import java.io.IOException;
import java.io.OutputStream;
@@ -49,7 +49,7 @@
/** The String that should be used to end a line in the PDF document.
* Note that this always uses the Unix-style line ending, as it is more compact, and as the PDF generated should be
* identical, regardless of the platform from which it is generated. */
- public static final String EOL = StringUtils.EMPTY_STRING + Basic_Latin_Block.CONTROL_LINE_FEED;
+ public static final String EOL = StringUtils.EMPTY_STRING + U0000_Basic_Latin.CONTROL_LINE_FEED;
/** The String that should be used to end a cross-reference line in the PDF document.
* According to the PDF Reference, 3rd Edition, Section 3.4.3, each cross-reference entry must be exactly 20 bytes
@@ -56,7 +56,7 @@
* long, including the end-of-line character(s).
* If a 1-character eol is used (such as a newline), then an extra character must be padded.
* According to the Reference, that character must be a space. */
- public static final String XREF_EOL = StringUtils.SINGLE_SPACE + Basic_Latin_Block.CONTROL_LINE_FEED;
+ public static final String XREF_EOL = StringUtils.SINGLE_SPACE + U0000_Basic_Latin.CONTROL_LINE_FEED;
/** The String that should be used to end a line in log messages. */
public static final String MSG_EOL = System.getProperty("line.separator");
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 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -50,7 +50,7 @@
import org.axsl.orthography.Orthography;
import org.axsl.pdf.PdfColor;
import org.axsl.pdf.PdfPage;
-import org.axsl.unicode.block.Basic_Latin_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
import org.apache.batik.ext.awt.g2d.GraphicContext;
import org.slf4j.LoggerFactory;
@@ -567,9 +567,9 @@
final String gradientName = this.pdfContext.getGradientName(linearGradient);
if (fill) {
- this.write("/Pattern cs /" + gradientName + " scn" + Basic_Latin_Block.CONTROL_LINE_FEED);
+ this.write("/Pattern cs /" + gradientName + " scn" + U0000_Basic_Latin.CONTROL_LINE_FEED);
} else {
- this.write("/Pattern CS /" + gradientName + " SCN" + Basic_Latin_Block.CONTROL_LINE_FEED);
+ this.write("/Pattern CS /" + gradientName + " SCN" + U0000_Basic_Latin.CONTROL_LINE_FEED);
}
} else if (paint instanceof TexturePaint) { }
}
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/lb/SolitaryLineBreaker.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -33,7 +33,7 @@
import org.axsl.kp.KpUserAgent;
import org.axsl.orthography.Orthography;
import org.axsl.orthography.Word;
-import org.axsl.unicode.block.General_Punctuation_Block;
+import org.axsl.unicode.block.U2000_General_Punctuation;
import org.axsl.value.group.TextModifiers;
/**
@@ -558,7 +558,7 @@
private boolean isSometimesWordChar(final char c) {
switch (c) {
/* Typographic apostrophe. */
- case General_Punctuation_Block.RIGHT_SINGLE_QUOTATION_MARK:
+ case U2000_General_Punctuation.RIGHT_SINGLE_QUOTATION_MARK:
case '\'': {
return true;
}
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/CharacterUtils.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/CharacterUtils.java 2023-01-07 14:24:17 UTC (rev 13026)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/CharacterUtils.java 2023-01-07 15:33:40 UTC (rev 13027)
@@ -29,11 +29,11 @@
package org.foray.primitive;
import org.axsl.constants.PrimitiveConstants;
-import org.axsl.unicode.block.Arabic_Presentation_Forms_B_Block;
-import org.axsl.unicode.block.Basic_Latin_Block;
-import org.axsl.unicode.block.CJK_Symbols_and_Punctuation_Block;
-import org.axsl.unicode.block.General_Punctuation_Block;
-import org.axsl.unicode.block.Latin_1_Supplement_Block;
+import org.axsl.unicode.block.U0000_Basic_Latin;
+import org.axsl.unicode.block.U0080_Latin_1_Supplement;
+import org.axsl.unicode.block.U2000_General_Punctuation;
+import org.axsl.unicode.block.U3000_CJK_Symbols_and_Punctuation;
+import org.axsl.unicode.block.Ufe70_Arabic_Presentation_Forms_B;
import java.util.List;
@@ -43,41 +43,41 @@
public final class CharacterUtils {
/** The maximum printable ASCII character, a tilde ~, 0x7E, 126. */
- public static final char MAX_PRINTABLE_ASCII_CHAR = Basic_Latin_Block.TILDE;
+ public static final char MAX_PRINTABLE_ASCII_CHAR = U0000_Basic_Latin.TILDE;
/** The punctuation characters which, when they immediately precede a word, should not be separated from that word
* during line-breaking. TODO: This list is not comprehensive and should be improved. */
private static final String ATTACHED_LEADING_PUNCTUATION = new String(new char[] {
- Basic_Latin_Block.LEFT_PARENTHESIS,
- Basic_Latin_Block.LEFT_SQUARE_BRACKET,
- General_Punctuation_Block.LEFT_SINGLE_QUOTATION_MARK,
- General_Punctuation_Block.LEFT_DOUBLE_QUOTATION_MARK,
+ U0000_Basic_Latin.LEFT_PARENTHESIS,
+ U0000_Basic_Latin.LEFT_SQUARE_BRACKET,
+ U2000_General_Punctuation.LEFT_SINGLE_QUOTATION_MARK,
+ U2000_General_Punctuation.LEFT_DOUBLE_QUOTATION_MARK,
});
/** The punctuation characters which, when they immediately follow a word, should not be separated from that word
* during line-breaking. TODO: This list is not comprehensive and should be improved. */
private static final String ATTACHED_TRAILING_PUNCTUATION = new String(new char[] {
- Basic_Latin_Block.FULL_STOP, // A period '.'
- Basic_Latin_Block.COMMA,
- Basic_Latin_Block.SEMICOLON,
- Basic_Latin_Block.COLON,
- Basic_Latin_Block.EXCLAMATION_MARK,
- Basic_Latin_Block.QUESTION_MARK,
- Basic_Latin_Block.APOSTROPHE,
- Basic_Latin_Block.QUOTATION_MARK,
- Basic_Latin_Block.RIGHT_PARENTHESIS,
- Basic_Latin_Block.RIGHT_SQUARE_BRACKET,
- General_Punctuation_Block.RIGHT_SINGLE_QUOTATION_MARK,
- General_Punctuation_Block.RIGHT_DOUBLE_QUOTATION_MARK,
+ U0000_Basic_Latin.FULL_STOP, // A period '.'
+ U0000_Basic_Latin.COMMA,
+ U0000_Basic_Latin.SEMICOLON,
+ U0000_Basic_Latin.COLON,
+ U0000_Basic_Latin.EXCLAMATION_MARK,
+ U0000_Basic_Latin.QUESTION_MARK,
+ U0000_Basic_Latin.APOSTROPHE,
+ U0000_Basic_Latin.QUOTATION_MARK,
+ U0000_Basic_Latin.RIGHT_PARENTHESIS,
+ U0000_Basic_Latin.RIGHT_SQUARE_BRACKET,
+ U2000_General_Punctuation.RIGHT_SINGLE_QUOTATION_MARK,
+ U2000_General_Punctuation.RIGHT_DOUBLE_QUOTATION_MARK,
});
/** The punctuation characters which may, depending on context, be treated as intraword punctuation. */
private static final String POSSIBLE_INTRAWORD_PUNCTUATION = new String(new char[] {
- Basic_Latin_Block.APOSTROPHE, //English example: 'Tis the season
- General_Punctuation_Block.RIGHT_SINGLE_QUOTATION_MARK, //English example: ’Tis the season
- Basic_Latin_Block.LEFT_PARENTHESIS, //English example of alternate spelling:
- Basic_Latin_Block.RIGHT_PARENTHESIS, // pa(e)leography
- Basic_Latin_Block.FULL_STOP, //English example: Section 8.16
+ U0000_Basic_Latin.APOSTROPHE, //English example: 'Tis the season
+ U2000_General_Punctuation.RIGHT_SINGLE_QUOTATION_MARK, //English example: ’Tis the season
+ U0000_Basic_Latin.LEFT_PARENTHESIS, //English example of alternate spelling:
+ U0000_Basic_Latin.RIGHT_PARENTHESIS, // pa(e)leography
+ U0000_Basic_Latin.FULL_STOP, //English example: Section 8.16
});
/** The punctuation characters which, when they immediately follow a word, can be separated from that word during
@@ -84,7 +84,7 @@
* line-breaking, but which preferably should not be separated. TODO: This list is not comprehensive and should be
* improved. */
private static final String DETACHABLE_PUNCTUATION = new String(new char[] {
- General_Punctuation_Block.EN_DASH,
+ U2000_General_Punctuation.EN_DASH,
});
/** The punctuation characters which, when they immediately follow a word, can be separated from that word during
@@ -91,29 +91,29 @@
* line-breaking, but which preferably should not be separated. TODO: This list is not comprehensive and should be
* improved.*/
private static final String DETACHED_PUNCTUATION = new String(new char[] {
- General_Punctuation_Block.EM_DASH,
+ U2000_General_Punctuation.EM_DASH,
});
/** The set of characters that are Arabic digits, i.e. "0" through "9". */
private static final String ARABIC_DIGIT = new String(new char[] {
- Basic_Latin_Block.DIGIT_ZERO,
- Basic_Latin_Block.DIGIT_ONE,
- Basic_Latin_Block.DIGIT_TWO,
- Basic_Latin_Block.DIGIT_THREE,
- Basic_Latin_Block.DIGIT_FOUR,
- Basic_Latin_Block.DIGIT_FIVE,
- Basic_Latin_Block.DIGIT_SIX,
- Basic_Latin_Block.DIGIT_SEVEN,
- Basic_Latin_Block.DIGIT_EIGHT,
- Basic_Latin_Block.DIGIT_NINE,
+ U0000_Basic_Latin.DIGIT_ZERO,
+ U0000_Basic_Latin.DIGIT_ONE,
+ U0000_Basic_Latin.DIGIT_TWO,
+ U0000_Basic_Latin.DIGIT_THREE,
+ U0000_Basic_Latin.DIGIT_FOUR,
+ U0000_Basic_Latin.DIGIT_FIVE,
+ U0000_Basic_Latin.DIGIT_SIX,
+ U0000_Basic_Latin.DIGIT_SEVEN,
+ U0000_Basic_Latin.DIGIT_EIGHT,
+ U0000_Basic_Latin.DIGIT_NINE,
});
/** The set of characters that could be included with {@link #ARABIC_DIGIT} code points to form an Arabic
* Numeral. */
private static final String ARABIC_NUMERAL_ADDITIONAL = new String(new char[] {
- Basic_Latin_Block.FULL_STOP,
- Basic_Latin_Block.COMMA,
- Basic_Latin_Block.HYPHEN_MINUS,
+ U0000_Basic_Latin.FULL_STOP,
+ U0000_Basic_Latin.COMMA,
+ U0000_Basic_Latin.HYPHEN_MINUS,
});
/**
@@ -252,7 +252,7 @@
* @return True if the character is a normal space
*/
public static boolean isBreakableSpace(final int c) {
- return c == Basic_Latin_Block.SPACE || isFixedWidthSpace(c);
+ return c == U0000_Basic_Latin.SPACE || isFixedWidthSpace(c);
}
/**
@@ -261,9 +261,9 @@
* @return True if and only if {@code c} is a zero-width space character.
*/
public static boolean isZeroWidthSpace(final int c) {
- return c == General_Punctuation_Block.ZERO_WIDTH_SPACE
- || c == General_Punctuation_Block.WORD_JOINER
- || c == Arabic_Presentation_Forms_B_Block.ZERO_WIDTH_NO_BREAK_SPACE;
+ return c == U2000_General_Punctuation.ZERO_WIDTH_SPACE
+ || c == U2000_General_Punctuation.WORD_JOINER
+ || c == Ufe70_Arabic_Presentation_Forms_B.ZERO_WIDTH_NO_BREAK_SPACE;
}
/**
@@ -272,21 +272,21 @@
* @return True if and only if {@code c} is a fixed-width space character.
*/
public static boolean isFixedWidthSpace(final int c) {
- return (c >= General_Punctuation_Block.EN_QUAD
-// || c == General_Punctuation_Block.EN_QUAD // 0x2000
-// || c == General_Punctuation_Block.EM_QUAD // 0x2001
-// || c == General_Punctuation_Block.EN_SPACE // 0x2002
-// || c == General_Punctuation_Block.EM_SPACE // 0x2003
-// || c == General_Punctuation_Block.THREE_PER_EM_SPACE // 0x2004
-// || c == General_Punctuation_Block.FOUR_PER_EM_SPACE // 0x2005
-// || c == General_Punctuation_Block.SIX_PER_EM_SPACE // 0x2006
-// || c == General_Punctuation_Block.FIGURE_SPACE // 0x2007
-// || c == General_Punctuation_Block.PUNCTUATION_SPACE // 0x2008
-// || c == General_Punctuation_Block.THIN_SPACE // 0x2009
-// || c == General_Punctuation_Block.HAIR_SPACE // 0x200a
-// || c == General_Punctuation_Block.ZERO_WIDTH_SPACE // 0x200b
- && c <= General_Punctuation_Block.ZERO_WIDTH_SPACE)
- || c == CJK_Symbols_and_Punctuation_Block.IDEOGRAPHIC_SPACE;
+ return (c >= U2000_General_Punctuation.EN_QUAD
+// || c == U2000_General_Punctuation.EN_QUAD // 0x2000
+// || c == U2000_General_Punctuation.EM_QUAD // 0x2001
+// || c == U2000_General_Punctuation.EN_SPACE // 0x2002
+// || c == U2000_General_Punctuation.EM_SPACE // 0x2003
+// || c == U2000_General_Punctuation.THREE_PER_EM_SPACE // 0x2004
+// || c == U2000_General_Punctuation.FOUR_PER_EM_SPACE // 0x2005
+// || c == U2000_General_Punctuation.SIX_PER_EM_SPACE // 0x2006
+// || c == U2000_General_Punctuation.FIGURE_SPACE // 0x2007
+// || c == U2000_General_Punctuation.PUNCTUATION_SPACE // 0x2008
+// || c == U2000_General_Punctuation.THIN_SPACE // 0x2009
+// || c == U2000_General_Punctuation.HAIR_SPACE // 0x200a
+// || c == U2000_General_Punctuation.ZERO_WIDTH_SPACE // 0x200b
+ && c <= U2000_General_Punctuation.ZERO_WIDTH_SPACE)
+ || c == U3000_CJK_Symbols_and_Punctuation.IDEOGRAPHIC_SPACE;
}
/**
@@ -297,8 +297,8 @@
public static boolean isAdjustableSpace(final int c) {
/* TODO: This list may not be complete. */
return
- c == Basic_Latin_Block.SPACE
- || c == Latin_1_Supplement_Block.NO_BREAK_SPACE;
+ c == U0000_Basic_Latin.SPACE
+ || c == U0080_Latin_1_Supplement.NO_BREAK_SPACE;
}
/**
@@ -307,7 +307,7 @@
* @return True if and only if {@code c} is a breaking space character.
*/
public static boolean isBreakableSpace(final char c) {
- return c == Basic_Latin_Block.SPACE || isFixedWidthSpace(c);
+ return c == U0000_Basic_Latin.SPACE || isFixedWidthSpace(c);
}
/**
@@ -317,11 +317,11 @@
*/
public static boolean isNonBreakableSpace(final char c) {
return
- c == Latin_1_Supplement_Block.NO_BREAK_SPACE
- || c == General_Punctuation_Block.NARROW_NO_BREAK_SPACE
- || c == CJK_Symbols_and_Punctuation_Block.IDEOGRAPHIC_SPACE
- || c == General_Punctuation_Block.WORD_JOINER
- || c == Arabic_Presentation_Forms_B_Block.ZERO_WIDTH_NO_BREAK_SPACE;
+ c == U0080_Latin_1_Supplement.NO_BREAK_SPACE
+ || c == U2000_General_Punctuation.NARROW_NO_BREAK_SPACE
+ || c == U3000_CJK_Symbols_and_Punctuation.IDEOGRAPHIC_SPACE
+ || c == U2000_General_Punctuation.WORD_JOINER
+ || c == Ufe70_Arabic_Presentation_Forms_B.ZERO_WIDTH_NO_BREAK_SPACE;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2023-01-07 14:24:19
|
Revision: 13026
http://sourceforge.net/p/foray/code/13026
Author: victormote
Date: 2023-01-07 14:24:17 +0000 (Sat, 07 Jan 2023)
Log Message:
-----------
Add disabled test class in preparation for width refactoring.
Added Paths:
-----------
trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java
Added: trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java (rev 0)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java 2023-01-07 14:24:17 UTC (rev 13026)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2023 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.font;
+
+import org.foray.font.config.RegisteredFontContent;
+
+import org.axsl.font.FontException;
+import org.axsl.font.zzz.FontContextMdo;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests of {@link FsType1Font}.
+ */
+public class FsType1FontTests {
+
+ /**
+ * Tests of {@link FsType1Font#width(int, int)}.
+ */
+ @Test
+ @Disabled("Activate as part of the width refactoring. ")
+ public void widthTest() throws FontException {
+ final FontContextMdo fontOptionsWithKerning = new FontContextMdo();
+ fontOptionsWithKerning.setKerning(true);
+ final FontContextMdo fontOptionsWithoutKerning = new FontContextMdo();
+ fontOptionsWithoutKerning.setKerning(false);
+
+ final FontServer4a server = FontServer4aTests.getServer();
+ assertNotNull(server);
+ final RegisteredFontContent rf = server.getRegisteredFont("Base14-Helvetica");
+ assertNotNull(rf);
+ final FreeStandingFont fsf = rf.getFreeStandingFont();
+ assertNotNull(fsf);
+
+ /* Font metrics are from Helvetica.afm. */
+
+ /* First test some glyphs from WinAnsiEncoding. */
+
+ /* Line 31: C 37 ; WX 889 ; N percent... 889 * 12 = 10,668. */
+ assertEquals(10_668, fsf.width('%', 12000));
+ /* Line 69: C 75 ; WX 667 ; N K... 667 * 12 = 8,004. */
+ assertEquals(8_004, fsf.width('K', 12000));
+ /* Line 112: C 118 ; WX 500 ; N v... 500 * 12 = 6,000. */
+ assertEquals(6_000, fsf.width('v', 12000));
+ /* Line 228: C -1 ; WX 778 ; N Ograve... 778 * 12 = 9,336. */
+ assertEquals(9_336, fsf.width('Ò', 12000));
+
+ /* Now some glyphs NOT from WinAnsiEncoding. */
+
+ /* Line 291: C -1 ; WX 556 ; N edotaccent... 556 * 12 = 6,672. */
+ assertEquals(6_672, fsf.width(0x0117, 12000));
+ /* Line 251: C -1 ; WX 600 ; N summation... 600 * 12 = 7,200. */
+ assertEquals(7_200, fsf.width(0x2211, 12000));
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/test/java/org/foray/font/FsType1FontTests.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|