[FOray-commit] SF.net SVN: foray:[12457] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2022-01-22 21:31:35
|
Revision: 12457
http://sourceforge.net/p/foray/code/12457
Author: victormote
Date: 2022-01-22 21:31:32 +0000 (Sat, 22 Jan 2022)
Log Message:
-----------
Conform to aXSL change: Add and use new FontSelectionConstraints interface.
Modified Paths:
--------------
trunk/foray/foray-app/src/main/java/org/foray/app/CommandLineStarter.java
trunk/foray/foray-app/src/main/java/org/foray/app/ant/ForayAntTaskStarter.java
trunk/foray/foray-app/src/main/java/org/foray/app/test/TestConverter.java
trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoAwtViewer.java
trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoFo2Pdf.java
trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoObj2Pdf.java
trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoXml2Pdf.java
trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/AbstractDemoServlet.java
trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/DemoPrintServlet.java
trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/DemoServlet.java
trunk/foray/foray-app/src/test/java/org/foray/app/area/AbstractAreaTreeTest.java
trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java
trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontSelectorCbc.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.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/testFixtures/java/org/foray/font/util/MockFont.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTest.java
trunk/foray/foray-output/src/main/java/org/foray/output/MifConverter.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentTests.java
trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
Added Paths:
-----------
trunk/foray/foray-common/src/main/java/org/foray/common/FontSelectionConstraints4a.java
Modified: trunk/foray/foray-app/src/main/java/org/foray/app/CommandLineStarter.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/app/CommandLineStarter.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/app/CommandLineStarter.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -129,7 +129,7 @@
final LineBreakerFactory lbFactory = session.getLineBreakerFactory();
final LayoutStrategy layout = new PioneerLayoutStrategy(session.getLogger());
final ForayTarget target =
- new ForayTarget(document, textServer, lbFactory, layout, outputTarget.getFontSources());
+ new ForayTarget(document, textServer, lbFactory, layout, outputTarget.getFontSelectionConstraints());
target.addOutputTarget(outputTarget, outputStream);
/*
Modified: trunk/foray/foray-app/src/main/java/org/foray/app/ant/ForayAntTaskStarter.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/app/ant/ForayAntTaskStarter.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/app/ant/ForayAntTaskStarter.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -319,7 +319,7 @@
this.task.getRendererType(), this.outputConfig, out,
session.getLogger(), session.getGraphicServer());
final ForayTarget target = new ForayTarget(document, session.getTextServer(),
- session.getLineBreakerFactory(), null, outputTarget.getFontSources());
+ session.getLineBreakerFactory(), null, outputTarget.getFontSelectionConstraints());
target.addOutputTarget(outputTarget, out);
session.process();
Modified: trunk/foray/foray-app/src/main/java/org/foray/app/test/TestConverter.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/app/test/TestConverter.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/app/test/TestConverter.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -312,7 +312,7 @@
session.getGraphicServer());
final ForayTarget target = new ForayTarget(document, session.getTextServer(),
- session.getLineBreakerFactory(), null, renderer.getFontSources());
+ session.getLineBreakerFactory(), null, renderer.getFontSelectionConstraints());
target.addOutputTarget(renderer, bos);
this.log.debug("ddir:" + this.destdir + " on:" + outname + ".pdf");
Modified: trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoAwtViewer.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoAwtViewer.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoAwtViewer.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -151,7 +151,7 @@
//Setup ForayTarget
final ForayTarget target = new ForayTarget(document, session.getTextServer(), session.getLineBreakerFactory(),
- null, renderer.getFontSources());
+ null, renderer.getFontSelectionConstraints());
target.addOutputTarget(renderer, null);
//Create preview dialog (target for the AWTRenderer)
Modified: trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoFo2Pdf.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoFo2Pdf.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoFo2Pdf.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -78,7 +78,7 @@
//Setup ForayTarget
final ForayTarget target = new ForayTarget(document, session.getTextServer(), session.getLineBreakerFactory(),
- null, renderer.getFontSources());
+ null, renderer.getFontSelectionConstraints());
target.addOutputTarget(renderer, out);
// Start the processing.
Modified: trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoObj2Pdf.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoObj2Pdf.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoObj2Pdf.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -101,7 +101,7 @@
//Setup ForayTarget
final ForayTarget target = new ForayTarget(document, session.getTextServer(), session.getLineBreakerFactory(),
- null, renderer.getFontSources());
+ null, renderer.getFontSelectionConstraints());
target.addOutputTarget(renderer, out);
// Start the processing.
Modified: trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoXml2Pdf.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoXml2Pdf.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/demo/embed/DemoXml2Pdf.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -102,7 +102,7 @@
//Setup ForayTarget
final ForayTarget target = new ForayTarget(document, session.getTextServer(), session.getLineBreakerFactory(),
- null, renderer.getFontSources());
+ null, renderer.getFontSelectionConstraints());
target.addOutputTarget(renderer, out);
// Start the processing.
Modified: trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/AbstractDemoServlet.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/AbstractDemoServlet.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/AbstractDemoServlet.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -199,7 +199,8 @@
session.getLogger(), session.getGraphicServer());
// Setup ForayTarget
- final ForayTarget target = new ForayTarget(document, null, null, null, renderer.getFontSources());
+ final ForayTarget target = new ForayTarget(document, null, null, null,
+ renderer.getFontSelectionConstraints());
target.addOutputTarget(renderer, output);
// Run the ForaySession
@@ -248,7 +249,8 @@
session.getLogger(), session.getGraphicServer());
// Setup ForayTarget
- final ForayTarget target = new ForayTarget(document, null, null, null, renderer.getFontSources());
+ final ForayTarget target = new ForayTarget(document, null, null, null,
+ renderer.getFontSelectionConstraints());
target.addOutputTarget(renderer, output);
// Run the ForaySession
Modified: trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/DemoPrintServlet.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/DemoPrintServlet.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/DemoPrintServlet.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -134,7 +134,7 @@
pj.setCopies(1);
final AwtPrintRenderer renderer = new AwtPrintRenderer(null, pj);
// Setup ForayTarget
- final ForayTarget target = new ForayTarget(document, null, null, null, renderer.getFontSources());
+ final ForayTarget target = new ForayTarget(document, null, null, null, renderer.getFontSelectionConstraints());
target.addOutputTarget(renderer, null);
return target;
}
Modified: trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/DemoServlet.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/DemoServlet.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/main/java/org/foray/demo/servlet/DemoServlet.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -140,7 +140,7 @@
document.getLogger(), document.getGraphicServer());
// Setup ForayTarget
- final ForayTarget target = new ForayTarget(document, null, null, null, renderer.getFontSources());
+ final ForayTarget target = new ForayTarget(document, null, null, null, null);
target.addOutputTarget(renderer, output);
return target;
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/area/AbstractAreaTreeTest.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/area/AbstractAreaTreeTest.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/area/AbstractAreaTreeTest.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -82,7 +82,7 @@
Assert.assertNotNull(rf);
final FreeStandingFont fsf = rf.getFreeStandingFont();
Assert.assertNotNull(fsf);
- final FontConsumer4a fontConsumer = fontServer.makeFontConsumer();
+ final FontConsumer4a fontConsumer = fontServer.makeFontConsumer(null);
final Font4a font = rf.getBestFont();
final ConsumerFont4a consumerFont = new ConsumerFont4a(font, fontConsumer);
final FontUse4a fontUse = new FontUse4a(consumerFont, null, font.getInternalEncoding());
Modified: trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java
===================================================================
--- trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -136,7 +136,7 @@
}
final FontServer fontServer = this.treeServer.getFontServer();
- final FontConsumer fontConsumer = fontServer.makeFontConsumer();
+ final FontConsumer fontConsumer = fontServer.makeFontConsumer(null);
foTree.setFontConsumer(fontConsumer);
return foTree;
}
Added: trunk/foray/foray-common/src/main/java/org/foray/common/FontSelectionConstraints4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/FontSelectionConstraints4a.java (rev 0)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/FontSelectionConstraints4a.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2022 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.common;
+
+import org.axsl.font.FontSelectionConstraints;
+
+/**
+ * Foray implementation of {@link FontSelectionConstraints}.
+ * Instances of this class are immutable.
+ */
+public final class FontSelectionConstraints4a implements FontSelectionConstraints {
+
+ /** Instance indicating that there are no constraints. */
+ public static final FontSelectionConstraints4a NO_CONSTRAINTS = new FontSelectionConstraints4a(true, true);
+
+ /** Instance indicating that only free-standing fonts should be selected. */
+ public static final FontSelectionConstraints4a FREE_STANDING_ONLY = new FontSelectionConstraints4a(true, false);
+
+ /** Instance indicating that only system fonts should be selected. */
+ public static final FontSelectionConstraints4a SYSTEM_ONLY = new FontSelectionConstraints4a(false, true);
+
+ /** Indicates whether free-standing fonts can be selected. */
+ private boolean canSelectFreeStandingFonts;
+
+ /** Indicates whether system fonts can be selected. */
+ private boolean canSelectSystemFonts;
+
+ /**
+ * Constructor.
+ * @param canSelectFreeStandingFonts Indicates whether free-standing fonts can be selected.
+ * @param canSelectSystemFonts Indicates whether system fonts can be selected.
+ */
+ public FontSelectionConstraints4a(final boolean canSelectFreeStandingFonts, final boolean canSelectSystemFonts) {
+ this.canSelectFreeStandingFonts = canSelectFreeStandingFonts;
+ this.canSelectSystemFonts = canSelectSystemFonts;
+ }
+
+ @Override
+ public boolean canSelectFreeStandingFonts() {
+ return this.canSelectFreeStandingFonts;
+ }
+
+ @Override
+ public boolean canSelectSystemFonts() {
+ return this.canSelectSystemFonts;
+ }
+
+}
Property changes on: trunk/foray/foray-common/src/main/java/org/foray/common/FontSelectionConstraints4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java
===================================================================
--- trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -34,8 +34,8 @@
import org.axsl.area.AreaTreeFactory;
import org.axsl.area.event.AreaTreeEvent;
import org.axsl.area.event.AreaTreeListener;
-import org.axsl.font.Font;
import org.axsl.font.FontConsumer;
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.font.FontServer;
import org.axsl.fotree.FoTree;
import org.axsl.fotree.FoTreeEvent;
@@ -125,11 +125,11 @@
* @param textServer The text server.
* @param lbFactory The line-breaker factory to be used.
* @param layout The layout implementation responsible for laying the document out.
- * @param fontSources The font sources that are eligible for selection by this target.
+ * @param selectionConstraints The constraints on font selection.
* @throws ForayException For errors during document processing.
*/
public ForayTarget(final ForayDocument document, final TextServer textServer, final LineBreakerFactory lbFactory,
- final Layout layout, final Font.Source[] fontSources) throws ForayException {
+ final Layout layout, final FontSelectionConstraints selectionConstraints) throws ForayException {
// Validate the ForayDocument.
this.document = document;
if (this.document == null) {
@@ -150,8 +150,7 @@
/* Obtain a FontConsumer instance. */
final FontServer server = getFontServer();
- this.fontConsumer = server.makeFontConsumer();
- this.fontConsumer.setFontSources(fontSources);
+ this.fontConsumer = server.makeFontConsumer(selectionConstraints);
// Start the renderer.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -28,6 +28,7 @@
package org.foray.font;
+import org.foray.common.FontSelectionConstraints4a;
import org.foray.font.config.RegisteredFont;
import org.foray.font.config.RegisteredFontFamily;
import org.foray.font.config.RegisteredFontFamilyMember;
@@ -36,6 +37,7 @@
import org.axsl.font.Font;
import org.axsl.font.FontConsumer;
import org.axsl.font.FontException;
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.font.FontUse;
import org.axsl.font.Panose;
import org.axsl.ps.Encoding;
@@ -93,12 +95,9 @@
*/
private Logger logger;
- /** Set to true if the FontConsumer can use free-standing fonts. */
- private boolean usesFreeStandingFonts;
+ /** The font selection constraints. */
+ private FontSelectionConstraints selectionConstraints;
- /** Set to true if the FontConsumer can use system fonts. */
- private boolean usesSystemFonts;
-
/**
* Set to true if FreeStandingFonts should be selected where possible,
* false if SystemFont should be selected where possible.
@@ -105,7 +104,7 @@
* In cases where usesFreeStandingFonts and usesSystemFonts are both set to
* true, this breaks the tie.
*/
- private boolean prefersFreeStandingFonts;
+ private boolean prefersFreeStandingFonts = true;
/**
* Collection of fonts used by this FontConsumer.
@@ -132,37 +131,15 @@
/**
* Constructor.
* @param server The FOrayFontServer instance serving this FontConsumer.
+ * @param selectionConstraints The constraints on font selection.
+ * If null, wide-open constraints (i.e. no constraints) will be used.
*/
- public FontConsumer4a(final FontServer4a server) {
+ public FontConsumer4a(final FontServer4a server, final FontSelectionConstraints selectionConstraints) {
this.server = server;
- this.usesFreeStandingFonts = true;
- this.usesSystemFonts = true;
- this.prefersFreeStandingFonts = true;
+ this.selectionConstraints = selectionConstraints == null ? FontSelectionConstraints4a.NO_CONSTRAINTS
+ : selectionConstraints;
}
- @Override
- public void setFontSources(final Font.Source...fontSources) {
- if (fontSources == null
- || fontSources.length < 1) {
- return;
- }
- if (fontSources[0] == Font.Source.SYSTEM) {
- this.prefersFreeStandingFonts = false;
- } else {
- this.prefersFreeStandingFonts = true;
- }
- for (int i = 0; i < fontSources.length; i++) {
- if (fontSources[i] == Font.Source.FREE_STANDING) {
- this.usesFreeStandingFonts = true;
- break;
- }
- if (fontSources[i] == Font.Source.SYSTEM) {
- this.usesSystemFonts = true;
- break;
- }
- }
- }
-
/**
* Use this method to set a logger for this font consumer. This will
* override the logger used by FOrayFontServer.
@@ -186,22 +163,14 @@
}
/**
- * Indicates whether this consumer can use free-standing fonts or not.
- * @return True if and only if this consumer can use free-standing fonts.
+ * Returns the font selection constraints.
+ * @return The font selection constraints.
*/
- public boolean isUsingFreeStandingFonts() {
- return this.usesFreeStandingFonts;
+ public FontSelectionConstraints getSelectionConstraints() {
+ return this.selectionConstraints;
}
/**
- * Indicates whether this consumer can use system fonts or not.
- * @return True if and only if this consumer can use system fonts.
- */
- public boolean isUsingSystemFonts() {
- return this.usesSystemFonts;
- }
-
- /**
* Indicates whether free-standing fonts are preferred over system fonts.
* @return True if and only if free-standing fonts are preferred over system fonts.
*/
@@ -356,7 +325,7 @@
return null;
}
Font4a fontSelected = null;
- if (isUsingFreeStandingFonts()) {
+ if (this.selectionConstraints.canSelectFreeStandingFonts()) {
fontSelected = fontDescSelected.getRegisteredFont()
.getFreeStandingFont();
} else {
@@ -426,7 +395,7 @@
*/
private FreeStandingFont eligibleFreeStandingFont(
final RegisteredFontFamilyMember rfd, final int codePoint) {
- if (! isUsingFreeStandingFonts()) {
+ if (! this.selectionConstraints.canSelectFreeStandingFonts()) {
return null;
}
final FreeStandingFont fsf =
@@ -456,7 +425,7 @@
*/
private SystemFont eligibleSystemFont(final RegisteredFont rf,
final int codePoint) {
- if (! isUsingSystemFonts()) {
+ if (! this.selectionConstraints.canSelectSystemFonts()) {
return null;
}
final SystemFont sf = rf.getSystemFont();
@@ -475,13 +444,13 @@
*/
private RegisteredFontFamilyMember selectDefaultFont() {
RegisteredFontFamilyMember defaultFont = null;
- if (isUsingFreeStandingFonts()) {
+ if (this.selectionConstraints.canSelectFreeStandingFonts()) {
defaultFont = this.server.getDefaultFreeStandingFont();
}
if (defaultFont != null) {
return defaultFont;
}
- if (isUsingSystemFonts()) {
+ if (this.selectionConstraints.canSelectSystemFonts()) {
defaultFont = this.server.getDefaultSystemFont();
}
return defaultFont;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontSelectorCbc.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontSelectorCbc.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontSelectorCbc.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -33,19 +33,19 @@
import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.font.FontSelectionConstraints;
import java.util.List;
/**
* The standard character-by-character font selector.
- * XSL-FO 1.0, Section 7.8.3, described the character-by-character strategy as
- * being "the same as the strategy used to select fonts in CSS."
+ * XSL-FO 1.0, Section 7.8.3, described the character-by-character strategy as being "the same as the strategy used to
+ * select fonts in CSS."
* Therefore, the CSS documentation should be consulted.
- * The algorithm for font selection is described in the CSS 2 standard at
- * Section 15.5.
+ * The algorithm for font selection is described in the CSS 2 standard at Section 15.5.
* Even though there are now versions of CSS past version 2, we still use CSS 2.
- * CSS 2.1 removed the font-stretch property, but XSL-FO 1.1 requires it, so,
- * until given more clear guidance, we use the 2.0 algorithm.
+ * CSS 2.1 removed the font-stretch property, but XSL-FO 1.1 requires it, so, until given more clear guidance, we use
+ * the 2.0 algorithm.
*/
public class FontSelectorCbc extends FontSelector {
@@ -113,9 +113,10 @@
if (rff == null) {
return null;
}
+ final FontSelectionConstraints constraints = this.getConsumer().getSelectionConstraints();
return rff.findRegisteredFontDesc(style, weight, variant, stretch,
- this.getConsumer().isUsingFreeStandingFonts(),
- this.getConsumer().isUsingSystemFonts());
+ constraints.canSelectFreeStandingFonts(),
+ constraints.canSelectSystemFonts());
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -37,6 +37,7 @@
import org.foray.font.format.FontParserClient;
import org.axsl.font.FontException;
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.font.FontServer;
import org.axsl.ps.Encoding;
import org.axsl.ps.PsServer;
@@ -1075,8 +1076,8 @@
}
@Override
- public FontConsumer4a makeFontConsumer() {
- return new FontConsumer4a(this);
+ public FontConsumer4a makeFontConsumer(final FontSelectionConstraints constraints) {
+ return new FontConsumer4a(this, constraints);
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -578,4 +578,9 @@
return getFontBBox();
}
+ @Override
+ public Source getFontSource() {
+ return Source.FREE_STANDING;
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -580,4 +580,9 @@
return BoundingBoxUtils.ZEROES;
}
+ @Override
+ public Source getFontSource() {
+ return Source.SYSTEM;
+ }
+
}
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 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/Font4aTests.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -90,7 +90,7 @@
final FreeStandingFont fsf = rf.getFreeStandingFont();
Assert.assertNotNull(fsf);
- final FontConsumer4a fontConsumer = server.makeFontConsumer();
+ final FontConsumer4a fontConsumer = server.makeFontConsumer(null);
final Font4a font = rf.getBestFont();
final ConsumerFont4a consumerFont = new ConsumerFont4a(font, fontConsumer);
final FontUse4a fontUse = new FontUse4a(consumerFont, null, font.getInternalEncoding());
Modified: trunk/foray/foray-font/src/testFixtures/java/org/foray/font/util/MockFont.java
===================================================================
--- trunk/foray/foray-font/src/testFixtures/java/org/foray/font/util/MockFont.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-font/src/testFixtures/java/org/foray/font/util/MockFont.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -338,4 +338,9 @@
return metricIndex;
}
+ @Override
+ public Source getFontSource() {
+ return Source.FREE_STANDING;
+ }
+
}
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 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -126,7 +126,9 @@
foTree.setOrthographyServer(this.server.getOrthographyServer());
foTree.setGraphicSearchPath(this.server.getGraphicSearchPath());
foTree.setCachingGraphics(this.server.isCachingGraphics());
- foTree.setFontConsumer(this.server.getFontServer().makeFontConsumer());
+ /* TODO: Either remove the need for a FontConsumer in the FO Tree, or allow this to get reset by the
+ * ForayTarget instance. */
+ foTree.setFontConsumer(this.server.getFontServer().makeFontConsumer(null));
}
@Override
Modified: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTest.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTest.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTest.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -31,6 +31,7 @@
import org.foray.fotree.fo.obj.Root4a;
import org.axsl.font.FontConsumer;
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.font.FontServer;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoInlineContext;
@@ -122,7 +123,7 @@
protected static final FoObj makeTestFObj() {
final FontConsumer fontConsumer = Mockito.mock(FontConsumer.class);
final FontServer fontServer = Mockito.mock(FontServer.class);
- Mockito.when(fontServer.makeFontConsumer()).thenReturn(fontConsumer);
+ Mockito.when(fontServer.makeFontConsumer(Mockito.any(FontSelectionConstraints.class))).thenReturn(fontConsumer);
final FoTreeServer4a server = Mockito.mock(FoTreeServer4a.class);
Mockito.when(server.getFontServer()).thenReturn(fontServer);
Modified: trunk/foray/foray-output/src/main/java/org/foray/output/MifConverter.java
===================================================================
--- trunk/foray/foray-output/src/main/java/org/foray/output/MifConverter.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-output/src/main/java/org/foray/output/MifConverter.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -28,7 +28,9 @@
package org.foray.output;
-import org.axsl.font.Font;
+import org.foray.common.FontSelectionConstraints4a;
+
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.fo.Block;
import org.axsl.fotree.fo.Table;
@@ -257,8 +259,8 @@
}
@Override
- public Font.Source[] getFontSources() {
- return new Font.Source[] {Font.Source.FREE_STANDING};
+ public FontSelectionConstraints getFontSelectionConstraints() {
+ return FontSelectionConstraints4a.FREE_STANDING_ONLY;
}
@Override
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 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentTests.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -87,7 +87,7 @@
/* TODO: This is too painful for just wanting to use a Base-14 font. */
final FontServer4a fontServer = new FontServer4a();
- final FontConsumer4a fontConsumer = fontServer.makeFontConsumer();
+ final FontConsumer4a fontConsumer = fontServer.makeFontConsumer(null);
final RegisteredFont rf = fontServer.getRegisteredFont("Base14-Helvetica");
final RegisteredFontFamily rff = fontServer.getRegisteredFontFamily("Base14-Helvetica");
final FreeStandingFont font = rf.getFreeStandingFont();
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -28,7 +28,10 @@
package org.foray.render;
+import org.foray.common.FontSelectionConstraints4a;
+
import org.axsl.font.Font;
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.galley.BorderPaddingAreaG5;
import org.axsl.galley.GalleyVisitorException;
import org.axsl.galley.GlyphAreaSequenceG5;
@@ -241,8 +244,8 @@
}
@Override
- public Font.Source[] getFontSources() {
- return new Font.Source[] {Font.Source.FREE_STANDING};
+ public FontSelectionConstraints getFontSelectionConstraints() {
+ return FontSelectionConstraints4a.FREE_STANDING_ONLY;
}
@Override
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 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -39,12 +39,13 @@
package org.foray.render.awt;
+import org.foray.common.FontSelectionConstraints4a;
import org.foray.common.Mime;
import org.foray.common.WellKnownConstants;
import org.foray.common.url.UrlFactory;
import org.foray.render.Renderer;
-import org.axsl.font.Font;
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.font.FontUse;
import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.BorderPaddingAreaG5;
@@ -827,9 +828,8 @@
}
}
- @Override
- public Font.Source[] getFontSources() {
- return new Font.Source[] {Font.Source.FREE_STANDING, Font.Source.SYSTEM};
+ public FontSelectionConstraints getFontSelectionConstraints() {
+ return FontSelectionConstraints4a.NO_CONSTRAINTS;
}
@Override
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -28,12 +28,13 @@
package org.foray.render.svg;
+import org.foray.common.FontSelectionConstraints4a;
import org.foray.common.SvgUtil;
import org.foray.common.WellKnownConstants;
import org.foray.common.primitive.XmlUtils;
import org.foray.render.Renderer;
-import org.axsl.font.Font;
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.galley.AreaG5;
import org.axsl.galley.BookmarkTreeG5;
import org.axsl.galley.BorderPaddingAreaG5;
@@ -622,8 +623,8 @@
}
@Override
- public Font.Source[] getFontSources() {
- return new Font.Source[] {Font.Source.SYSTEM};
+ public FontSelectionConstraints getFontSelectionConstraints() {
+ return FontSelectionConstraints4a.SYSTEM_ONLY;
}
@Override
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-01-22 17:08:15 UTC (rev 12456)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-01-22 21:31:32 UTC (rev 12457)
@@ -33,11 +33,13 @@
package org.foray.render.xml;
+import org.foray.common.FontSelectionConstraints4a;
import org.foray.common.WellKnownConstants;
import org.foray.common.primitive.XmlCharacterUtils;
import org.foray.render.Renderer;
import org.axsl.font.Font;
+import org.axsl.font.FontSelectionConstraints;
import org.axsl.galley.AreaG5;
import org.axsl.galley.AreaNodeG5;
import org.axsl.galley.BackgroundAreaG5;
@@ -466,8 +468,8 @@
}
@Override
- public Font.Source[] getFontSources() {
- return new Font.Source[] {Font.Source.FREE_STANDING};
+ public FontSelectionConstraints getFontSelectionConstraints() {
+ return FontSelectionConstraints4a.FREE_STANDING_ONLY;
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|