foray-commit Mailing List for FOray (Page 50)
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
(2) |
Dec
|
|
From: <vic...@us...> - 2022-06-13 18:16:15
|
Revision: 12650
http://sourceforge.net/p/foray/code/12650
Author: victormote
Date: 2022-06-13 18:16:11 +0000 (Mon, 13 Jun 2022)
Log Message:
-----------
Dictionary additions.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml
Modified: trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml
===================================================================
--- trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml 2022-06-13 18:15:48 UTC (rev 12649)
+++ trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml 2022-06-13 18:16:11 UTC (rev 12650)
@@ -10246,7 +10246,7 @@
<w><t>as-sem-bled</t></w>
<w><t>as-sem-bler</t></w>
<w><t>As-sem-bly</t></w>
-<w><t>as-sem-bly</t></w>
+<w><t>as-sem-bly</t><noun><pluralizable/></noun></w>
<phrase><t>as-sem-bly line</t></phrase>
<w><t>as-sem-bly-man</t></w>
<w><t>as-sem-blé</t></w>
@@ -10327,7 +10327,7 @@
<w><t>As-sin-i-boin</t></w>
<w><t>As-sin-i-boine</t></w>
<w><t>As-si-si</t></w>
-<w><t>as-sist</t></w>
+<w><t>as-sist</t><noun><pluralizable/></noun><verb><regular-root/></verb></w>
<w><t>as-sis-tance</t></w>
<w><t>as-sis-tant</t></w>
<phrase><t>as-sis-tant pro-fes-sor</t></phrase>
@@ -10932,7 +10932,7 @@
<w><t>at-tempt-a-ble</t></w>
<w><t>at-tempt-er</t></w>
<w><t>At-ten-bor-ough</t></w>
-<w><t>at-tend</t></w>
+<w><t>at-tend</t><verb><regular-root/></verb></w>
<w><t>at-tend-ance</t></w>
<phrase><t>at-tend-ance al-low-ance</t></phrase>
<phrase><t>at-tend-ance cen-tre</t></phrase>
@@ -24665,7 +24665,7 @@
<w><t>ce-a-no-thus</t></w>
<w><t>Cea-r</t></w>
<w><t>Ce-a-rá</t></w>
-<w><t>cease</t></w>
+<w><t>cease</t><verb><regular-root/></verb></w>
<w><t>cease-less</t></w>
<w><t>cease-less-ly</t></w>
<w><t>cease-less-ness</t></w>
@@ -31879,7 +31879,7 @@
<w><t>con-gre-gate</t></w>
<w><t>con-gre-gat-ed</t></w>
<w><t>con-gre-gat-ing</t></w>
-<w><t>con-gre-ga-tion</t></w>
+<w><t>con-gre-ga-tion</t><noun><pluralizable/></noun></w>
<w><t>con-gre-ga-tion-al</t></w>
<phrase><t>Con-gre-ga-tion-al Church</t></phrase>
<w><t>Con-gre-ga-tion-al-ism</t></w>
@@ -51126,7 +51126,8 @@
<w><t>es-tat-ing</t></w>
<w><t>Es-te</t></w>
<w><t>Es-te-ban</t></w>
-<w><t>es-teem</t></w>
+<w><t>es-teem</t><noun/></w>
+<w><t>es-teem-ed</t><adjective/></w>
<w><t>Es-tel-la</t></w>
<w><t>Es-telle</t></w>
<w><t>Es-ter</t></w>
@@ -64254,7 +64255,7 @@
<w><t>green-ing</t></w>
<w><t>green-ish</t></w>
<w><t>green-keep-er</t></w>
-<w><t>Green-land</t></w>
+<w><t>Green-land</t><noun><convertible-to-possessive/></noun></w>
<phrase><t>Green-land Sea</t></phrase>
<phrase><t>Green-land whale</t></phrase>
<w><t>Green-land-er</t></w>
@@ -81764,7 +81765,7 @@
<w><t>jour-ney</t></w>
<w><t>jour-neyed</t></w>
<w><t>jour-ney-er</t></w>
-<w><t>jour-ney-ing</t></w>
+<w><t>jour-ney-ing</t><noun><pluralizable/></noun></w>
<w><t>jour-ney-man</t></w>
<w><t>jour-ney-work</t></w>
<w><t>journ-o</t></w>
@@ -83697,7 +83698,7 @@
<w><t>kis-mat</t></w>
<w><t>Kis-ma-yu</t></w>
<w><t>kis-met</t></w>
-<w><t>kiss</t></w>
+<w><t>kiss</t><noun><pluralizable/></noun><verb><regular-root/></verb></w>
<w><t>kiss-a-bil-i-ty</t></w>
<w><t>kiss-a-ble</t></w>
<w><t>kiss-a-ble-ness</t></w>
@@ -95798,7 +95799,7 @@
<w><t>min-i-pill</t></w>
<w><t>min-i-skirt</t></w>
<w><t>min-i-skirt-ed</t></w>
-<w><t>min-is-ter</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
+<w><t>min-is-ter</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>min-is-ter of state</t></phrase>
<phrase><t>min-is-ter plen-i-po-ten-tiar-y</t></phrase>
<w><t>min-is-te-ri-al</t></w>
@@ -97748,7 +97749,7 @@
<w><t>mont-gol-fi-ers</t></w>
<w><t>Mont-gom-er-y</t></w>
<w><t>Mont-gom-er-y-shire</t></w>
-<w><t>month</t></w>
+<w><t>month</t><noun><pluralizable/></noun></w>
<w><t>Mon-ther-lant</t></w>
<w><t>month-ly</t></w>
<w><t>Mon-ti-cel-lo</t></w>
@@ -98339,7 +98340,7 @@
<phrase><t>Mount Des-ert Is-land</t></phrase>
<phrase><t>Mount I-sa</t></phrase>
<w><t>Moun-tain</t></w>
-<w><t>moun-tain</t></w>
+<w><t>moun-tain</t><noun><pluralizable/></noun></w>
<phrase><t>moun-tain ash</t></phrase>
<phrase><t>moun-tain av-ens</t></phrase>
<phrase><t>moun-tain cat</t></phrase>
@@ -98502,6 +98503,7 @@
<w><t>m-ster</t></w>
<w><t>M-ster</t></w>
<w><t>M-ster-berg</t></w>
+<w><t>Mt</t><abbrev referenced-word="Mount"/></w>
<w><t>MTB</t></w>
<w><t>mtg</t></w>
<w><t>m-ti-er</t></w>
@@ -108846,7 +108848,7 @@
<w><t>of-fen-sive</t></w>
<w><t>of-fen-sive-ly</t></w>
<w><t>of-fen-sive-ness</t></w>
-<w><t>of-fer</t></w>
+<w><t>of-fer</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<w><t>Of-fer</t></w>
<phrase><t>of-fer price</t></phrase>
<w><t>of-fer-a-ble</t></w>
@@ -117610,7 +117612,7 @@
<w><t>per-i-he-li-on</t></w>
<w><t>Per-i-kei-rom-e-ne</t></w>
<w><t>Per-i-ki-rom-e-ne</t></w>
-<w><t>per-il</t></w>
+<w><t>per-il</t><noun><pluralizable/></noun></w>
<w><t>Per-i-la-us</t></w>
<w><t>per-iled</t></w>
<w><t>per-il-ing</t></w>
@@ -120147,7 +120149,7 @@
<phrase><t>Pis-cis Aus-tri-nus</t></phrase>
<w><t>pis-civ-o-rous</t></w>
<w><t>pis-co</t></w>
-<w><t>Pis-gah</t></w>
+<w><t>Pis-gah</t><noun><convertible-to-possessive/></noun></w>
<w><t>pish</t></w>
<w><t>pi-shogue</t></w>
<w><t>Pish-pek</t></w>
@@ -127998,7 +128000,7 @@
<w><t>proph-e-si-a-ble</t></w>
<w><t>proph-e-si-er</t></w>
<w><t>proph-e-sy</t></w>
-<w><t>proph-et</t></w>
+<w><t>proph-et</t><noun><pluralizable/></noun></w>
<w><t>Proph-et</t></w>
<w><t>proph-et=flow-er</t></w>
<w><t>pro-phet-ic</t></w>
@@ -128448,9 +128450,10 @@
<w><t>pro-to-zo-ö-log-i-cal</t></w>
<w><t>pro-to-zo-öl-o-gist</t></w>
<w><t>pro-to-zo-öl-o-gy</t></w>
-<w><t>pro-tract</t></w>
-<w><t>pro-tract-ed-ly</t></w>
-<w><t>pro-tract-ed-ness</t></w>
+<w><t>pro-tract</t><verb><regular-root/></verb></w>
+<w><t>pro-tract-ed</t><adjective/></w>
+<w><t>pro-tract-ed-ly</t><adverb/></w>
+<w><t>pro-tract-ed-ness</t><noun/></w>
<w><t>pro-tract-i-ble</t></w>
<w><t>pro-trac-tile</t></w>
<w><t>pro-trac-til-i-ty</t></w>
@@ -132804,7 +132807,7 @@
<w><t>re-ac-cused</t></w>
<w><t>re-ac-cus-ing</t></w>
<w><t>re-ac-cus-tom</t></w>
-<w><t>reach</t></w>
+<w><t>reach</t><verb><regular-root/></verb></w>
<w><t>reach-a-ble</t></w>
<w><t>reach-er</t></w>
<w><t>re-a-cid-i-fi-ca-tion</t></w>
@@ -136907,7 +136910,7 @@
<w><t>re-spec-i-fied</t></w>
<w><t>re-spec-i-fy</t></w>
<w><t>re-spec-i-fy-ing</t></w>
-<w><t>re-spect</t></w>
+<w><t>re-spect</t><noun><pluralizable/></noun></w>
<w><t>re-spect-a-bil-i-ty</t></w>
<w><t>re-spect-a-ble</t></w>
<w><t>re-spect-er</t></w>
@@ -140454,7 +140457,7 @@
<phrase><t>Sa-hit-ya A-kad-e-mi</t></phrase>
<w><t>sa-hua-ro</t></w>
<w><t>saice</t></w>
-<w><t>said</t></w>
+<w><t>said</t><verb/></w>
<w><t>sa-id</t></w>
<w><t>Sa-i-da</t></w>
<w><t>sai-ga</t></w>
@@ -141747,7 +141750,7 @@
<w><t>sax-o-phon-ist</t></w>
<w><t>sax-tu-ba</t></w>
<w><t>Say</t></w>
-<w><t>say</t></w>
+<w><t>say</t><verb/></w>
<w><t>say=so</t></w>
<w><t>say-a-ble</t></w>
<phrase><t>Sa-yan Moun-tains</t></phrase>
@@ -141760,6 +141763,7 @@
<w><t>sa-yo-na-ra</t></w>
<w><t>Sayre</t></w>
<w><t>Sayre-ville</t></w>
+<w><t>says</t><verb/></w>
<w><t>say-yid</t></w>
<w><t>Sa-yão</t></w>
<w><t>saz-e-rac</t></w>
@@ -146039,7 +146043,7 @@
<w><t>shad-i-ness</t></w>
<w><t>shad-ing</t></w>
<w><t>sha-doof</t></w>
-<w><t>shad-ow</t></w>
+<w><t>shad-ow</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>shad-ow mask</t></phrase>
<phrase><t>shad-ow play</t></phrase>
<phrase><t>shad-ow test</t></phrase>
@@ -146857,7 +146861,7 @@
<w><t>shop-wom-en</t></w>
<w><t>shop-worn</t></w>
<w><t>shor-an</t></w>
-<w><t>shore</t></w>
+<w><t>shore</t><noun><pluralizable/></noun></w>
<w><t>Shore</t></w>
<phrase><t>shore pa-trol</t></phrase>
<w><t>shore-less</t></w>
@@ -181730,7 +181734,7 @@
<w><t>vo-gie</t></w>
<w><t>vogue</t></w>
<w><t>Vo-gul</t></w>
-<w><t>voice</t></w>
+<w><t>voice</t><noun><pluralizable/></noun></w>
<w><t>voice=lead-ing</t></w>
<w><t>voice=o-ver</t></w>
<w><t>voiced</t></w>
@@ -183203,7 +183207,7 @@
<w><t>weed-kil-ler</t></w>
<w><t>weeds</t></w>
<w><t>weed-y</t></w>
-<w><t>week</t></w>
+<w><t>week</t><noun><pluralizable/></noun></w>
<w><t>week-day</t></w>
<w><t>week-days</t></w>
<w><t>week-end</t></w>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-06-13 18:15:49
|
Revision: 12649
http://sourceforge.net/p/foray/code/12649
Author: victormote
Date: 2022-06-13 18:15:48 +0000 (Mon, 13 Jun 2022)
Log Message:
-----------
Fix to runtime logging.
Modified Paths:
--------------
trunk/foray/foray-orthography/build.gradle
Modified: trunk/foray/foray-orthography/build.gradle
===================================================================
--- trunk/foray/foray-orthography/build.gradle 2022-06-13 17:29:13 UTC (rev 12648)
+++ trunk/foray/foray-orthography/build.gradle 2022-06-13 18:15:48 UTC (rev 12649)
@@ -5,7 +5,8 @@
description = 'foray-orthography'
dependencies {
- implementation (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
+ api (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
+ runtimeOnly group: 'ch.qos.logback', name: 'logback-classic', version: versions.logbackClassic
api group: 'commons-cli', name: 'commons-cli', version: versions.commonsCli
api group: 'commons-io', name: 'commons-io', version: versions.commonsIo
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-06-13 17:29:15
|
Revision: 12648
http://sourceforge.net/p/foray/code/12648
Author: victormote
Date: 2022-06-13 17:29:13 +0000 (Mon, 13 Jun 2022)
Log Message:
-----------
Handle parsing of marker element "abbrev".
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java 2022-06-09 20:47:10 UTC (rev 12647)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java 2022-06-13 17:29:13 UTC (rev 12648)
@@ -337,6 +337,7 @@
case "convertible-to-possessive": break;
case "possessive": break;
case "extensible": break;
+ case "abbrev": break;
default: {
throw new IllegalStateException("Unknown element started: " + localName + ", " +
getLocationString(getLocator()));
@@ -465,6 +466,7 @@
case "convertible-to-possessive": break;
case "possessive": break;
case "extensible": break;
+ case "abbrev": break;
default: {
throw new IllegalStateException("Unknown element ended: " + localName);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-06-09 20:47:13
|
Revision: 12647
http://sourceforge.net/p/foray/code/12647
Author: victormote
Date: 2022-06-09 20:47:10 +0000 (Thu, 09 Jun 2022)
Log Message:
-----------
Dictionary additions.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999-archaic.dict.xml
trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml
Modified: trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999-archaic.dict.xml
===================================================================
--- trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999-archaic.dict.xml 2022-06-07 20:21:39 UTC (rev 12646)
+++ trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999-archaic.dict.xml 2022-06-09 20:47:10 UTC (rev 12647)
@@ -7,8 +7,12 @@
<axsl-dictionary language="eng" script="Latn" hard-hyphen-char="="
soft-hyphen-char="-">
+<w><t>hum-bleth</t></w>
+<w><t>lov-eth</t></w>
<w><t>pre-ëm-i-nence</t></w>
+<w><t>pre-ëm-i-nent-ly</t><adverb/></w>
<w><t>seek-est</t></w>
<w><t>speak-eth</t></w>
+<w><t>walk-eth</t></w>
</axsl-dictionary>
Modified: trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml
===================================================================
--- trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml 2022-06-07 20:21:39 UTC (rev 12646)
+++ trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml 2022-06-09 20:47:10 UTC (rev 12647)
@@ -10907,7 +10907,7 @@
<w><t>at-tach-a-ble</t></w>
<w><t>at-tached</t></w>
<w><t>at-tach-er</t></w>
-<w><t>at-tach-ment</t></w>
+<w><t>at-tach-ment</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>at-ta-ché</t></w>
<w><t>at-ta-chés</t></w>
<w><t>at-tack</t></w>
@@ -16484,7 +16484,7 @@
<w><t>Birch-ism</t></w>
<w><t>Birch-ite</t></w>
<w><t>Bird</t></w>
-<w><t>bird</t></w>
+<w><t>bird</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>bird cher-ry</t></phrase>
<phrase><t>bird of par-a-dise</t></phrase>
<phrase><t>bird of pas-sage</t></phrase>
@@ -17133,8 +17133,7 @@
<w><t>bless-ed-ly</t></w>
<w><t>bless-ed-ness</t></w>
<w><t>bless-er</t></w>
-<w><t>bless-ing</t></w>
-<w><t>bles-sing</t></w>
+<w><t>bless-ing</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>bless-ing-ly</t></w>
<w><t>blest</t></w>
<w><t>blet</t></w>
@@ -19099,7 +19098,7 @@
<w><t>bran</t></w>
<w><t>Bran</t></w>
<w><t>Branch</t></w>
-<w><t>branch</t></w>
+<w><t>branch</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>branch of-fic-er</t></phrase>
<w><t>bran-chi-a</t></w>
<w><t>bran-chi-ae</t></w>
@@ -19370,7 +19369,7 @@
<w><t>Breath-a-lys-er</t></w>
<w><t>breath-a-lyze</t></w>
<w><t>Breath-a-lyz-er</t></w>
-<w><t>breathe</t></w>
+<w><t>breathe</t><verb><regular-root/></verb></w>
<w><t>breathe-a-ble-ness</t></w>
<w><t>breath-er</t></w>
<w><t>breath-i-er</t></w>
@@ -23844,7 +23843,7 @@
<phrase><t>cas-ca-ra sa-gra-da</t></phrase>
<w><t>cas-ca-ril-la</t></w>
<w><t>cas-chrom</t></w>
-<w><t>case</t></w>
+<w><t>case</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>case his-to-ry</t></phrase>
<w><t>case=hard-en</t></w>
<w><t>case=work-er</t></w>
@@ -24688,7 +24687,7 @@
<w><t>ce-cum</t></w>
<w><t>Ce-cyle</t></w>
<w><t>Ce-da-li-on</t></w>
-<w><t>ce-dar</t></w>
+<w><t>ce-dar</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>ce-dar of Leb-a-non</t></phrase>
<phrase><t>Ce-dar Rap-ids</t></phrase>
<w><t>Ce-dar-burg</t></w>
@@ -27605,7 +27604,7 @@
<w><t>chu-pras-si</t></w>
<w><t>Chur</t></w>
<w><t>chu-rad-a</t></w>
-<w><t>church</t></w>
+<w><t>church</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>Church Ar-my</t></phrase>
<phrase><t>Church Com-mis-sion-ers</t></phrase>
<phrase><t>Church of Eng-land</t></phrase>
@@ -28040,7 +28039,7 @@
<w><t>cir-cum-spec-tive-ly</t></w>
<w><t>cir-cum-spect-ly</t></w>
<w><t>cir-cum-spect-ness</t></w>
-<w><t>cir-cum-stance</t></w>
+<w><t>cir-cum-stance</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>cir-cum-stanced</t></w>
<w><t>cir-cum-stanc-ing</t></w>
<w><t>cir-cum-stan-tial</t></w>
@@ -29012,7 +29011,7 @@
<w><t>clot</t></w>
<w><t>cloth</t></w>
<w><t>cloth-bound</t></w>
-<w><t>clothe</t></w>
+<w><t>clothe</t><verb><regular-root/></verb></w>
<w><t>clothes</t></w>
<w><t>clothes-bas-ket</t></w>
<w><t>clothes-horse</t></w>
@@ -30478,7 +30477,7 @@
<w><t>com-fi-ness</t></w>
<w><t>com-fit</t></w>
<w><t>Com-fort</t></w>
-<w><t>com-fort</t></w>
+<w><t>com-fort</t><noun><pluralizable/></noun><verb><regular-root/></verb></w>
<phrase><t>com-fort sta-tion</t></phrase>
<w><t>com-fort-a-ble</t></w>
<w><t>com-fort-a-ble-ness</t></w>
@@ -31420,7 +31419,7 @@
<w><t>con-clud-er</t></w>
<w><t>con-clud-i-ble</t></w>
<w><t>con-clud-ing</t></w>
-<w><t>con-clu-sion</t></w>
+<w><t>con-clu-sion</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>con-clu-sion-al</t></w>
<w><t>con-clu-sion-al-ly</t></w>
<w><t>con-clu-sive</t></w>
@@ -31664,7 +31663,7 @@
<w><t>con-fer-va-like</t></w>
<w><t>con-fer-void</t></w>
<w><t>con-fer-vous</t></w>
-<w><t>con-fess</t></w>
+<w><t>con-fess</t><verb><regular-root/></verb></w>
<w><t>con-fess-a-ble</t></w>
<w><t>con-fess-ant</t></w>
<w><t>con-fess-ed-ly</t></w>
@@ -32869,7 +32868,7 @@
<w><t>con-ver-san-cy</t></w>
<w><t>con-ver-sant</t></w>
<w><t>con-ver-sant-ly</t></w>
-<w><t>con-ver-sa-tion</t></w>
+<w><t>con-ver-sa-tion</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>con-ver-sa-tion piece</t></phrase>
<w><t>con-ver-sa-tion-al</t></w>
<w><t>con-ver-sa-tion-al-ist</t></w>
@@ -34169,7 +34168,7 @@
<w><t>coun-se-lor=at=law</t></w>
<w><t>coun-se-lors=at=law</t></w>
<w><t>coun-se-lor-ship</t></w>
-<w><t>count</t></w>
+<w><t>count</t><noun/><verb><regular-root/></verb></w>
<phrase><t>count a-gainst</t></phrase>
<phrase><t>count pal-a-tine</t></phrase>
<w><t>count-a-ble</t></w>
@@ -38765,7 +38764,7 @@
<w><t>deep=chest-ed</t></w>
<w><t>deep=root-ed</t></w>
<w><t>deep=seat-ed</t></w>
-<w><t>deep-en</t></w>
+<w><t>deep-en</t><verb><regular-root/></verb></w>
<w><t>deep-en-er</t></w>
<w><t>deep-en-ing-ly</t></w>
<w><t>deep-freeze</t></w>
@@ -40034,7 +40033,7 @@
<w><t>de-pas-ture</t></w>
<w><t>de-paup-er-ate</t></w>
<w><t>de-pau-per-a-tion</t></w>
-<w><t>de-pend</t></w>
+<w><t>de-pend</t><verb><regular-root/></verb></w>
<w><t>de-pend-a-bil-i-ty</t></w>
<w><t>de-pend-a-ble</t></w>
<w><t>de-pend-a-ble-ness</t></w>
@@ -43064,7 +43063,7 @@
<w><t>dis-man-tler</t></w>
<w><t>dis-mast</t></w>
<w><t>dis-mast-ment</t></w>
-<w><t>dis-may</t></w>
+<w><t>dis-may</t><noun/><verb><regular-root/></verb></w>
<w><t>dis-mayed-ness</t></w>
<w><t>dis-mem-ber</t></w>
<w><t>dis-mem-ber-er</t></w>
@@ -44235,7 +44234,7 @@
<w><t>Do-li-us</t></w>
<w><t>Doll</t></w>
<w><t>doll</t></w>
-<w><t>dol-lar</t></w>
+<w><t>dol-lar</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>dol-lar di-plo-ma-cy</t></phrase>
<w><t>dol-lar-bird</t></w>
<w><t>dol-lar-fish</t></w>
@@ -49383,7 +49382,7 @@
<w><t>en-join</t></w>
<w><t>en-join-er</t></w>
<w><t>en-join-ment</t></w>
-<w><t>en-joy</t></w>
+<w><t>en-joy</t><verb><regular-root/></verb></w>
<w><t>en-joy-a-ble</t></w>
<w><t>en-joy-a-ble-ness</t></w>
<w><t>en-joy-a-bly</t></w>
@@ -54587,7 +54586,7 @@
<w><t>feel-er</t></w>
<phrase><t>feel-er gauge</t></phrase>
<w><t>fee-less</t></w>
-<w><t>feel-ing</t></w>
+<w><t>feel-ing</t><noun><pluralizable/></noun></w>
<w><t>feel-ing-ful</t></w>
<w><t>feel-ing-less</t></w>
<w><t>feel-ing-less-ly</t></w>
@@ -55271,7 +55270,7 @@
<w><t>fie</t></w>
<w><t>Fied-ler</t></w>
<w><t>fief</t></w>
-<w><t>field</t></w>
+<w><t>field</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>Field</t></w>
<phrase><t>field ar-til-ler-y</t></phrase>
<phrase><t>field bat-ter-y</t></phrase>
@@ -55462,7 +55461,7 @@
<w><t>Fi-lip-pi-no</t></w>
<w><t>Fi-lip-po</t></w>
<w><t>fil-is-ter</t></w>
-<w><t>fill</t></w>
+<w><t>fill</t><noun/><verb><regular-root/></verb></w>
<phrase><t>fill a-way</t></phrase>
<w><t>fill=in</t></w>
<w><t>fill-a-ble</t></w>
@@ -56473,7 +56472,7 @@
<w><t>flick-er-y</t></w>
<w><t>flied</t></w>
<w><t>fli-er</t></w>
-<w><t>flight</t></w>
+<w><t>flight</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>flight ar-row</t></phrase>
<phrase><t>flight en-gi-neer</t></phrase>
<phrase><t>flight feath-er</t></phrase>
@@ -56746,7 +56745,7 @@
<w><t>flout</t></w>
<w><t>flout-er</t></w>
<w><t>flout-ing-ly</t></w>
-<w><t>flow</t></w>
+<w><t>flow</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<w><t>flow=on</t></w>
<w><t>flow-a-ble</t></w>
<w><t>flow-age</t></w>
@@ -57591,7 +57590,7 @@
<w><t>fore-spoke</t></w>
<w><t>fore-spo-ken</t></w>
<w><t>For-est</t></w>
-<w><t>for-est</t></w>
+<w><t>for-est</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>for-est rang-er</t></phrase>
<w><t>fore-staff</t></w>
<w><t>fore-stage</t></w>
@@ -58022,8 +58021,7 @@
<w><t>fouls</t></w>
<w><t>fou-mart</t></w>
<w><t>found</t></w>
-<w><t>founda-tion</t></w>
-<w><t>foun-da-tion</t></w>
+<w><t>foun-da-tion</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>foun-da-tion gar-ment</t></phrase>
<phrase><t>foun-da-tion stone</t></phrase>
<w><t>foun-da-tion-al</t></w>
@@ -58735,7 +58733,7 @@
<w><t>fried-cake</t></w>
<w><t>Frie-drich</t></w>
<w><t>Friend</t></w>
-<w><t>friend</t></w>
+<w><t>friend</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>friend-ed</t></w>
<w><t>friend-less</t></w>
<w><t>friend-less-ness</t></w>
@@ -67736,7 +67734,7 @@
<w><t>head-work-ing</t></w>
<w><t>head-y</t></w>
<w><t>heaf</t></w>
-<w><t>heal</t></w>
+<w><t>heal</t><verb><regular-root/></verb></w>
<w><t>heal-a-ble</t></w>
<w><t>heald</t></w>
<w><t>Healds-burg</t></w>
@@ -71130,8 +71128,9 @@
<w><t>horse-laugh-ter</t></w>
<w><t>horse-leech</t></w>
<w><t>horse-like</t></w>
-<w><t>horse-man</t></w>
+<w><t>horse-man</t><noun><singular/></noun></w>
<w><t>horse-man-ship</t></w>
+<w><t>horse-men</t><noun><plural/></noun></w>
<w><t>horse-mint</t></w>
<w><t>Hor-sens</t></w>
<w><t>horse-play</t></w>
@@ -75275,7 +75274,7 @@
<w><t>in-ces-tu-ous</t></w>
<w><t>in-ces-tu-ous-ly</t></w>
<w><t>in-ces-tu-ous-ness</t></w>
-<w><t>inch</t></w>
+<w><t>inch</t><noun><pluralizable/></noun></w>
<w><t>In-cheon</t></w>
<w><t>inch-meal</t></w>
<w><t>in-cho-ate</t></w>
@@ -86301,7 +86300,7 @@
<w><t>leal-ly</t></w>
<w><t>le-al-ty</t></w>
<phrase><t>Leam-ing-ton Spa</t></phrase>
-<w><t>lean</t></w>
+<w><t>lean</t><verb><regular-root/></verb><adjective><extensible/></adjective></w>
<w><t>lean=to</t></w>
<w><t>Le-an-der</t></w>
<w><t>lean-er</t></w>
@@ -88138,7 +88137,7 @@
<w><t>Li-ons</t></w>
<w><t>Li-ou</t></w>
<w><t>Liou-ville</t></w>
-<w><t>lip</t></w>
+<w><t>lip</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>lip serv-ice</t></phrase>
<w><t>lip=read-ing</t></w>
<w><t>li-pae-mi-a</t></w>
@@ -93873,7 +93872,7 @@
<w><t>Mel-vyn</t></w>
<w><t>mem</t></w>
<w><t>Mem-ber</t></w>
-<w><t>mem-ber</t></w>
+<w><t>mem-ber</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>Mem-ber of Par-lia-ment</t></phrase>
<w><t>mem-ber-less</t></w>
<w><t>mem-ber-ship</t></w>
@@ -95799,7 +95798,7 @@
<w><t>min-i-pill</t></w>
<w><t>min-i-skirt</t></w>
<w><t>min-i-skirt-ed</t></w>
-<w><t>min-is-ter</t></w>
+<w><t>min-is-ter</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>min-is-ter of state</t></phrase>
<phrase><t>min-is-ter plen-i-po-ten-tiar-y</t></phrase>
<w><t>min-is-te-ri-al</t></w>
@@ -96589,7 +96588,7 @@
<w><t>mis-tak-a-ble</t></w>
<w><t>mis-tak-a-ble-ness</t></w>
<w><t>mis-tak-a-bly</t></w>
-<w><t>mis-take</t></w>
+<w><t>mis-take</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>mis-take-a-ble</t></w>
<w><t>mis-tak-en</t></w>
<w><t>mis-tak-en-ly</t></w>
@@ -97250,7 +97249,7 @@
<w><t>mo-nan-drous</t></w>
<w><t>mo-nan-dry</t></w>
<w><t>mo-nan-thous</t></w>
-<w><t>mon-arch</t></w>
+<w><t>mon-arch</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>mo-nar-chal</t></w>
<w><t>mo-nar-chal-ly</t></w>
<w><t>mo-nar-chi-al</t></w>
@@ -109541,7 +109540,7 @@
<w><t>O-pe-li-ka</t></w>
<w><t>Op-e-lou-sas</t></w>
<w><t>O-pelt</t></w>
-<w><t>o-pen</t></w>
+<w><t>o-pen</t><verb><regular-root/></verb></w>
<phrase><t>o-pen air</t></phrase>
<phrase><t>O-pen Breth-ren</t></phrase>
<phrase><t>o-pen chain</t></phrase>
@@ -110620,12 +110619,13 @@
<w><t>OTC</t></w>
<w><t>O-tel-ia</t></w>
<w><t>O-tel-lo</t></w>
-<w><t>oth-er</t></w>
+<w><t>oth-er</t><pronoun/><adjective/></w>
<phrase><t>oth-er world</t></phrase>
<w><t>oth-er=di-rect-ed</t></w>
<w><t>oth-er-gates</t></w>
<w><t>oth-er-guess</t></w>
<w><t>oth-er-ness</t></w>
+<w><t>oth-ers</t><pronoun/></w>
<w><t>oth-er-where</t></w>
<w><t>oth-er-while</t></w>
<w><t>oth-er-whiles</t></w>
@@ -117350,7 +117350,7 @@
<w><t>per-cep-ti-ble</t></w>
<w><t>per-cep-ti-ble-ness</t></w>
<w><t>per-cep-ti-bly</t></w>
-<w><t>per-cep-tion</t></w>
+<w><t>per-cep-tion</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>per-cep-tion-al</t></w>
<w><t>per-cep-tive</t></w>
<w><t>per-cep-tive-ly</t></w>
@@ -117932,6 +117932,7 @@
<w><t>per-plex-ed-ly</t></w>
<w><t>per-plex-ed-ness</t></w>
<w><t>per-plex-er</t></w>
+<w><t>per-plex-ing</t><adjective/></w>
<w><t>per-plex-ing-ly</t></w>
<w><t>per-plex-i-ty</t></w>
<w><t>per-qui-site</t></w>
@@ -118076,7 +118077,7 @@
<w><t>per-suad-a-ble</t></w>
<w><t>per-suad-a-ble-ness</t></w>
<w><t>per-suad-a-bly</t></w>
-<w><t>per-suade</t></w>
+<w><t>per-suade</t><verb><regular-root/></verb></w>
<w><t>per-suad-ed-ly</t></w>
<w><t>per-suad-ed-ness</t></w>
<w><t>per-suad-er</t></w>
@@ -119780,7 +119781,7 @@
<w><t>pil-fer-age</t></w>
<w><t>pil-gar-lic</t></w>
<w><t>pil-gar-lick-y</t></w>
-<w><t>pil-grim</t></w>
+<w><t>pil-grim</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>Pil-grim Fa-thers</t></phrase>
<w><t>pil-grim-age</t></w>
<phrase><t>Pil-grim-age of Grace</t></phrase>
@@ -120342,7 +120343,7 @@
<w><t>plac-a-to-ry</t></w>
<w><t>pla-ca-to-ry</t></w>
<w><t>plac-cate</t></w>
-<w><t>place</t></w>
+<w><t>place</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>place set-ting</t></phrase>
<w><t>place=kick-er</t></w>
<w><t>place-a-ble</t></w>
@@ -120428,7 +120429,7 @@
<w><t>plais-ter</t></w>
<w><t>plait</t></w>
<w><t>plait-ing</t></w>
-<w><t>plan</t></w>
+<w><t>plan</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<w><t>Pla-na</t></w>
<w><t>pla-nar</t></w>
<phrase><t>pla-nar pro-cess</t></phrase>
@@ -120502,7 +120503,7 @@
<w><t>pla-no-sol</t></w>
<w><t>plan-o-spore</t></w>
<w><t>plan-sheer</t></w>
-<w><t>plant</t></w>
+<w><t>plant</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>plant king-dom</t></phrase>
<w><t>plant=cut-ter</t></w>
<w><t>plant-a-ble</t></w>
@@ -121343,7 +121344,7 @@
<w><t>poind</t></w>
<w><t>Poi-ne</t></w>
<w><t>poin-set-ti-a</t></w>
-<w><t>point</t></w>
+<w><t>point</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>point d'ap-pui</t></phrase>
<phrase><t>point de-fect</t></phrase>
<phrase><t>point du-ty</t></phrase>
@@ -123424,7 +123425,7 @@
<w><t>pre-ac-cus-ing</t></w>
<w><t>pre-ac-cus-tom</t></w>
<w><t>pre-ac-e-tab-u-lar</t></w>
-<w><t>preach</t></w>
+<w><t>preach</t><verb><regular-root/></verb></w>
<w><t>preach-er</t></w>
<w><t>Preach-er</t></w>
<w><t>preach-i-er</t></w>
@@ -124682,6 +124683,7 @@
<w><t>pree-mie</t></w>
<w><t>pre-em-i-nence</t></w>
<w><t>pre-em-i-nent</t></w>
+<w><t>pre-em-i-nent-ly</t><adverb/></w>
<w><t>pre-e-mo-tion</t></w>
<w><t>pre-e-mo-tion-al</t></w>
<w><t>pre-em-per-or</t></w>
@@ -126951,7 +126953,7 @@
<w><t>prin-cip-i-a</t></w>
<w><t>prin-cip-i-um</t></w>
<w><t>Prin-ci-ple</t></w>
-<w><t>prin-ci-ple</t></w>
+<w><t>prin-ci-ple</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>prin-ci-pled</t></w>
<w><t>prink</t></w>
<w><t>prink-er</t></w>
@@ -128613,7 +128615,7 @@
<w><t>prun-a-bil-i-ty</t></w>
<w><t>prun-a-ble</t></w>
<w><t>prun-a-ble-ness</t></w>
-<w><t>prune</t></w>
+<w><t>prune</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<w><t>Pru-nel-la</t></w>
<w><t>pru-nel-la</t></w>
<w><t>pru-nelle</t></w>
@@ -131356,7 +131358,7 @@
<w><t>quest</t></w>
<w><t>quest-er</t></w>
<w><t>quest-ing-ly</t></w>
-<w><t>ques-tion</t></w>
+<w><t>ques-tion</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>ques-tion mark</t></phrase>
<phrase><t>ques-tion mas-ter</t></phrase>
<phrase><t>ques-tion time</t></phrase>
@@ -132819,7 +132821,7 @@
<w><t>re-ac-quired</t></w>
<w><t>re-ac-quir-ing</t></w>
<w><t>re-ac-qui-si-tion</t></w>
-<w><t>re-act</t></w>
+<w><t>re-act</t><verb><regular-root/></verb></w>
<w><t>re-ac-tance</t></w>
<w><t>re-ac-tant</t></w>
<w><t>re-ac-tion</t></w>
@@ -136291,7 +136293,7 @@
<w><t>re-pop-u-lat-ed</t></w>
<w><t>re-pop-u-lat-ing</t></w>
<w><t>re-pop-u-la-tion</t></w>
-<w><t>re-port</t></w>
+<w><t>re-port</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>re-port stage</t></phrase>
<w><t>re-port-a-ble</t></w>
<w><t>re-port-age</t></w>
@@ -136547,7 +136549,7 @@
<w><t>req-ui-es-cat</t></w>
<w><t>re-quire</t></w>
<w><t>re-quired</t></w>
-<w><t>re-quire-ment</t></w>
+<w><t>re-quire-ment</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>re-quir-ing</t></w>
<w><t>req-ui-site</t></w>
<w><t>req-ui-site-ly</t></w>
@@ -139819,7 +139821,7 @@
<w><t>ru-in-ous-ness</t></w>
<w><t>Ruis-dael</t></w>
<w><t>rule</t></w>
-<w><t>rul-er</t></w>
+<w><t>rul-er</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>Rules</t></w>
<w><t>rul-ing</t></w>
<w><t>Rum</t></w>
@@ -143017,7 +143019,7 @@
<w><t>sea-side</t></w>
<w><t>Sea-side</t></w>
<w><t>sea-snail</t></w>
-<w><t>sea-son</t></w>
+<w><t>sea-son</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>sea-son tick-et</t></phrase>
<w><t>sea-son-a-ble</t></w>
<w><t>sea-son-a-ble-ness</t></w>
@@ -145775,7 +145777,7 @@
<w><t>ses-ti-na</t></w>
<w><t>Ses-tos</t></w>
<w><t>SET</t></w>
-<w><t>set</t></w>
+<w><t>set</t><noun><pluralizable/><convertible-to-possessive/></noun><verb/></w>
<w><t>Set</t></w>
<phrase><t>set a-bout</t></phrase>
<phrase><t>set a-gainst</t></phrase>
@@ -145807,7 +145809,7 @@
<w><t>set-ting</t></w>
<phrase><t>set-ting lo-tion</t></phrase>
<phrase><t>set-ting rule</t></phrase>
-<w><t>set-tle</t></w>
+<w><t>set-tle</t><verb><regular-root/></verb></w>
<phrase><t>set-tle down</t></phrase>
<phrase><t>set-tle for</t></phrase>
<phrase><t>set-tle in</t></phrase>
@@ -150315,6 +150317,7 @@
<w><t>sor-row-er</t></w>
<w><t>sor-row-ful-ly</t></w>
<w><t>sor-row-ful-ness</t></w>
+<w><t>sor-row-ing</t><adjective/></w>
<w><t>sor-row-less</t></w>
<w><t>sor-ry</t></w>
<w><t>sort</t></w>
@@ -152611,7 +152614,7 @@
<w><t>stars</t><verb><regular-root value="false"/></verb></w>
<w><t>stars=of=Beth-le-hem</t></w>
<w><t>stars=of=Je-ru-sa-lem</t></w>
-<w><t>start</t></w>
+<w><t>start</t><noun><pluralizable/></noun><verb><regular-root/></verb></w>
<w><t>start-er</t></w>
<phrase><t>start-ing block</t></phrase>
<phrase><t>start-ing gate</t></phrase>
@@ -153890,15 +153893,15 @@
<w><t>Strand</t></w>
<w><t>strand</t></w>
<w><t>Strand-lop-er</t></w>
-<w><t>strange</t></w>
+<w><t>strange</t><adjective><extensible/></adjective></w>
<phrase><t>strange par-ti-cle</t></phrase>
<w><t>strange-ly</t></w>
<w><t>strange-ness</t></w>
-<w><t>strang-er</t></w>
-<w><t>stran-ger</t></w>
+<w><t>stran-ger</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
+<w><t>strang-er</t><adjective/></w>
<phrase><t>stran-ger's gal-ler-y</t></phrase>
<w><t>stran-ger-like</t></w>
-<w><t>strang-est</t></w>
+<w><t>strang-est</t><adjective/></w>
<w><t>stran-gle</t></w>
<w><t>stran-gle-hold</t></w>
<w><t>stran-gles</t></w>
@@ -154033,7 +154036,7 @@
<w><t>Strei-sand</t></w>
<w><t>stre-lit-zi-a</t></w>
<w><t>strength</t><noun><pluralizable/></noun></w>
-<w><t>strength-en</t></w>
+<w><t>strength-en</t><verb><regular-root/></verb></w>
<w><t>strength-en-er</t></w>
<w><t>strength-en-ing-ly</t></w>
<w><t>stren-u-os-i-ty</t></w>
@@ -154203,7 +154206,7 @@
<w><t>Strom-bo-li</t></w>
<w><t>strome</t></w>
<w><t>strom-ing</t></w>
-<w><t>strong</t></w>
+<w><t>strong</t><adjective><extensible/></adjective></w>
<phrase><t>strong in-ter-ac-tion</t></phrase>
<phrase><t>strong wa-ters</t></phrase>
<w><t>strong=mind-ed</t></w>
@@ -154212,6 +154215,7 @@
<w><t>strong-box</t></w>
<w><t>strong-hold</t></w>
<w><t>strong-ish</t></w>
+<w><t>strong-ly</t><adverb/></w>
<w><t>strong-man</t></w>
<w><t>strong-ness</t></w>
<w><t>strong-point</t></w>
@@ -156280,7 +156284,7 @@
<w><t>sug-gest-i-ble-ness</t></w>
<w><t>sug-gest-i-bly</t></w>
<w><t>sug-gest-ing-ly</t></w>
-<w><t>sug-ges-tion</t></w>
+<w><t>sug-ges-tion</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>sug-ges-tive</t></w>
<w><t>sug-ges-tive-ly</t></w>
<w><t>sug-ges-tive-ness</t></w>
@@ -164799,7 +164803,7 @@
<w><t>tre-de-cil-lion</t></w>
<w><t>tre-de-cil-lionth</t></w>
<w><t>Tree</t></w>
-<w><t>tree</t></w>
+<w><t>tree</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>tree creep-er</t></phrase>
<phrase><t>tree kan-ga-roo</t></phrase>
<phrase><t>tree mal-low</t></phrase>
@@ -165465,7 +165469,7 @@
<w><t>trit-u-rat-ing</t></w>
<w><t>trit-u-ra-tion</t></w>
<w><t>trit-u-ra-tor</t></w>
-<w><t>tri-umph</t></w>
+<w><t>tri-umph</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>tri-um-phal</t></w>
<phrase><t>tri-um-phal arch</t></phrase>
<w><t>tri-um-phant</t></w>
@@ -165813,7 +165817,7 @@
<w><t>truss-er</t></w>
<w><t>truss-ing</t></w>
<w><t>Truss-ville</t></w>
-<w><t>trust</t></w>
+<w><t>trust</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>trust ac-count</t></phrase>
<phrase><t>trust com-pa-ny</t></phrase>
<phrase><t>trust ter-ri-to-ry</t></phrase>
@@ -166322,7 +166326,7 @@
<w><t>tur-mer-ic</t></w>
<phrase><t>tur-mer-ic pa-per</t></phrase>
<w><t>tur-moil</t></w>
-<w><t>turn</t></w>
+<w><t>turn</t><noun/><verb><regular-root/></verb></w>
<phrase><t>turn a-gainst</t></phrase>
<phrase><t>turn a-way</t></phrase>
<w><t>turn-a-bout</t></w>
@@ -176307,8 +176311,9 @@
<w><t>un-rig-ging</t></w>
<w><t>un-right-a-ble</t></w>
<w><t>un-right-ed</t></w>
-<w><t>un-right-eous</t></w>
-<w><t>un-right-eous-ly</t></w>
+<w><t>un-right-eous</t><adjective/></w>
+<w><t>un-right-eous-ly</t><adverb/></w>
+<w><t>un-right-eous-ness</t><noun/></w>
<w><t>un-right-ful</t></w>
<w><t>un-rig-id</t></w>
<w><t>un-rig-or-ous</t></w>
@@ -182225,7 +182230,7 @@
<w><t>wait-list</t></w>
<w><t>wait-ress</t></w>
<w><t>wait-ress-less</t></w>
-<w><t>waive</t></w>
+<w><t>waive</t><verb><regular-root/></verb></w>
<w><t>waiv-er</t></w>
<w><t>waiv-ing</t></w>
<w><t>Wai-yeung</t></w>
@@ -182441,7 +182446,7 @@
<w><t>wan-nest</t></w>
<w><t>wan-ning</t></w>
<w><t>wan-nish</t></w>
-<w><t>want</t></w>
+<w><t>want</t><noun><pluralizable/></noun><verb><regular-root/></verb></w>
<w><t>want-er</t></w>
<w><t>want-ing</t></w>
<w><t>want-less</t></w>
@@ -182526,7 +182531,7 @@
<w><t>war-like</t></w>
<w><t>war-lock</t></w>
<w><t>war-lord</t></w>
-<w><t>warm</t></w>
+<w><t>warm</t><verb><regular-root/></verb><adjective><extensible/></adjective></w>
<phrase><t>warm bod-y</t></phrase>
<phrase><t>warm o-ver</t></phrase>
<phrase><t>warm sec-tor</t></phrase>
@@ -185184,7 +185189,7 @@
<w><t>wi-sent</t></w>
<w><t>wis-er</t></w>
<w><t>wis-est</t></w>
-<w><t>wish</t></w>
+<w><t>wish</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>wish ful-fil-ment</t></phrase>
<w><t>wish-bone</t></w>
<w><t>wish-ful</t></w>
@@ -186539,7 +186544,7 @@
<w><t>you've</t></w>
<w><t>you=all</t></w>
<w><t>You-lou</t></w>
-<w><t>young</t></w>
+<w><t>young</t><adjective><extensible/></adjective></w>
<w><t>Young</t></w>
<phrase><t>Young Ire-land</t></phrase>
<phrase><t>young la-dy</t></phrase>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-06-07 20:21:42
|
Revision: 12646
http://sourceforge.net/p/foray/code/12646
Author: victormote
Date: 2022-06-07 20:21:39 +0000 (Tue, 07 Jun 2022)
Log Message:
-----------
Dictionary additions.
Modified Paths:
--------------
trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml
Modified: trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml
===================================================================
--- trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml 2022-05-28 20:27:02 UTC (rev 12645)
+++ trunk/foray/foray-orthography/src/main/data/dictionaries/eng-Latn-999.dict.xml 2022-06-07 20:21:39 UTC (rev 12646)
@@ -2006,7 +2006,7 @@
<w><t>ad-mi-ra-tive-ly</t></w>
<w><t>ad-mire</t></w>
<w><t>ad-mired</t></w>
-<w><t>ad-mir-er</t></w>
+<w><t>ad-mir-er</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>ad-mir-ing</t></w>
<w><t>ad-mir-ing-ly</t></w>
<w><t>ad-mis-si-bil-i-ty</t></w>
@@ -2993,7 +2993,7 @@
<w><t>ag-i-tat-ed</t></w>
<w><t>ag-i-tat-ed-ly</t></w>
<w><t>ag-i-tat-ing</t></w>
-<w><t>ag-i-ta-tion</t></w>
+<w><t>ag-i-ta-tion</t><noun><pluralizable/></noun></w>
<w><t>ag-i-ta-tion-al</t></w>
<w><t>ag-i-ta-tive</t></w>
<w><t>a-gi-ta-to</t></w>
@@ -5087,6 +5087,7 @@
<w><t>am-i-ca-ble-ness</t></w>
<w><t>am-i-ca-bly</t></w>
<w><t>am-ice</t></w>
+<w><t>a-mi-cus</t><noun/></w>
<phrase><t>a-mi-cus cu-ri-ae</t></phrase>
<w><t>a-mid</t></w>
<w><t>A-mi-da</t></w>
@@ -19636,7 +19637,7 @@
<w><t>Bright</t></w>
<w><t>bright</t><adjective><extensible/></adjective></w>
<phrase><t>Bright's dis-ease</t></phrase>
-<w><t>bright-en</t></w>
+<w><t>bright-en</t><verb><regular-root/></verb></w>
<w><t>bright-en-er</t></w>
<w><t>bright-ish</t></w>
<w><t>bright-ly</t></w>
@@ -23319,7 +23320,7 @@
<w><t>car-du-a-ceous</t></w>
<w><t>Car-duc-ci</t></w>
<w><t>car-du-e-line</t></w>
-<w><t>care</t></w>
+<w><t>care</t><noun><pluralizable/></noun><verb><regular-root/></verb></w>
<w><t>CARE</t></w>
<w><t>ca-reen</t></w>
<w><t>ca-reen-age</t></w>
@@ -23359,7 +23360,8 @@
<w><t>car-fax</t></w>
<w><t>car-float</t></w>
<w><t>car-fuf-fle</t></w>
-<w><t>car-go</t></w>
+<w><t>car-go</t><noun><pluralizable/></noun></w>
+<w><t>car-goes</t><noun><plural/></noun></w>
<phrase><t>car-go cult</t></phrase>
<w><t>car-hop</t></w>
<w><t>Car-i-a</t></w>
@@ -25767,7 +25769,7 @@
<w><t>char-a-banc</t></w>
<w><t>char-a-cid</t></w>
<w><t>char-a-cin</t></w>
-<w><t>char-ac-ter</t></w>
+<w><t>char-ac-ter</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<phrase><t>char-ac-ter ac-tor</t></phrase>
<phrase><t>char-ac-ter sketch</t></phrase>
<phrase><t>char-ac-ter type</t></phrase>
@@ -34154,7 +34156,7 @@
<w><t>coun-ci-lor-ship</t></w>
<w><t>coun-cil-wom-an</t></w>
<w><t>coun-cil-wom-en</t></w>
-<w><t>coun-sel</t></w>
+<w><t>coun-sel</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<w><t>coun-sel-a-ble</t></w>
<w><t>coun-seled</t></w>
<w><t>coun-sel-ing</t></w>
@@ -42765,7 +42767,7 @@
<w><t>dis-cus-sant</t></w>
<w><t>dis-cuss-er</t></w>
<w><t>dis-cuss-i-ble</t></w>
-<w><t>dis-cus-sion</t></w>
+<w><t>dis-cus-sion</t><noun><pluralizable/></noun></w>
<w><t>dis-cus-sion-al</t></w>
<w><t>dis-cu-ti-ent</t></w>
<w><t>dis-dain</t></w>
@@ -49659,7 +49661,7 @@
<w><t>en-ter-pris-ing</t></w>
<w><t>en-ter-pris-ing-ly</t></w>
<w><t>en-ter-rol-o-gist</t></w>
-<w><t>en-ter-tain</t></w>
+<w><t>en-ter-tain</t><verb><regular-root/></verb></w>
<w><t>en-ter-tain-er</t></w>
<w><t>en-ter-tain-ing</t></w>
<w><t>en-ter-tain-ing-ly</t></w>
@@ -67763,6 +67765,7 @@
<w><t>heap-y</t></w>
<w><t>hear</t></w>
<w><t>hear-a-ble</t></w>
+<w><t>heard</t><verb></verb></w>
<w><t>hear-er</t></w>
<w><t>hear-ing</t></w>
<phrase><t>hear-ing aid</t></phrase>
@@ -89250,7 +89253,7 @@
<w><t>lo-ran</t></w>
<w><t>Lor-ca</t></w>
<w><t>Lord</t></w>
-<w><t>lord</t></w>
+<w><t>lord</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>Lord Ad-vo-cate</t></phrase>
<phrase><t>Lord Cham-ber-lain</t></phrase>
<phrase><t>Lord Chan-cel-lor</t></phrase>
@@ -127039,7 +127042,7 @@
<w><t>priv-i-er</t></w>
<w><t>priv-ies</t></w>
<w><t>priv-i-est</t></w>
-<w><t>priv-i-lege</t></w>
+<w><t>priv-i-lege</t><noun><pluralizable/></noun><verb></verb></w>
<w><t>priv-i-leged</t></w>
<w><t>priv-i-leg-er</t></w>
<w><t>priv-i-leg-ing</t></w>
@@ -128674,7 +128677,7 @@
<w><t>psalm</t></w>
<w><t>psalm-book</t></w>
<w><t>psalm-ic</t></w>
-<w><t>psalm-ist</t></w>
+<w><t>psalm-ist</t><noun><pluralizable/><convertible-to-possessive/></noun></w>
<w><t>psal-mo-dist</t></w>
<w><t>psalm-o-dy</t></w>
<w><t>psal-mo-dy</t></w>
@@ -132299,7 +132302,7 @@
<w><t>ra-ni</t></w>
<phrase><t>Ran-jit Singh</t></phrase>
<w><t>Rank</t></w>
-<w><t>rank</t></w>
+<w><t>rank</t><noun><pluralizable/></noun><verb><regular-root/></verb><adjective></adjective></w>
<w><t>rank=and=fil-er</t></w>
<w><t>rank-er</t></w>
<w><t>ran-ket</t></w>
@@ -135641,12 +135644,12 @@
<w><t>re-mag-ni-fy-ing</t></w>
<w><t>re-mail</t></w>
<w><t>re-maim</t></w>
-<w><t>re-main</t></w>
+<w><t>re-main</t><verb><regular-root/></verb></w>
<w><t>re-main-der</t></w>
<w><t>re-main-der-man</t></w>
<w><t>re-main-made</t></w>
<w><t>re-main-mak-ing</t></w>
-<w><t>re-mains</t></w>
+<w><t>re-mains</t><noun><plural/></noun></w>
<w><t>re-make</t></w>
<w><t>re-mak-er</t></w>
<w><t>re-man</t></w>
@@ -142496,7 +142499,7 @@
<w><t>sco-ri-fy</t></w>
<w><t>sco-ri-fy-ing</t></w>
<w><t>scor-ing</t></w>
-<w><t>scorn</t></w>
+<w><t>scorn</t><noun></noun><verb><regular-root/></verb></w>
<w><t>scorn-er</t></w>
<w><t>scorn-ful</t></w>
<w><t>scorn-ful-ly</t></w>
@@ -145690,7 +145693,7 @@
<w><t>serv-ant</t></w>
<w><t>serv-ant-less</t></w>
<w><t>serv-ant-like</t></w>
-<w><t>serve</t></w>
+<w><t>serve</t><noun></noun><verb><regular-root/></verb></w>
<w><t>serv-er</t></w>
<w><t>Ser-ve-tian-ism</t></w>
<w><t>Ser-ve-tus</t></w>
@@ -160941,7 +160944,7 @@
<w><t>ter-gum</t></w>
<w><t>Ter-hune</t></w>
<w><t>ter-i-ya-ki</t></w>
-<w><t>term</t></w>
+<w><t>term</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<phrase><t>term in-sur-ance</t></phrase>
<w><t>ter-ma-gant</t></w>
<w><t>term-er</t></w>
@@ -163159,7 +163162,7 @@
<w><t>togue</t></w>
<w><t>to-he-ro-a</t></w>
<w><t>to-hu-bo-hu</t></w>
-<w><t>toil</t></w>
+<w><t>toil</t><noun><pluralizable/><convertible-to-possessive/></noun><verb><regular-root/></verb></w>
<w><t>toile</t></w>
<w><t>toi-let</t></w>
<phrase><t>toi-let pa-per</t></phrase>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-05-28 20:27:04
|
Revision: 12645
http://sourceforge.net/p/foray/code/12645
Author: victormote
Date: 2022-05-28 20:27:02 +0000 (Sat, 28 May 2022)
Log Message:
-----------
Implement standard SAX logic, althought not using it yet.
Modified Paths:
--------------
trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayAssignId.java
Modified: trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayAssignId.java
===================================================================
--- trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayAssignId.java 2022-05-28 20:26:33 UTC (rev 12644)
+++ trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayAssignId.java 2022-05-28 20:27:02 UTC (rev 12645)
@@ -48,8 +48,8 @@
import org.w3c.dom.traversal.NodeIterator;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -77,7 +77,7 @@
/**
* Command-line application that reads an XML file, recomputes the Id attributes found in it, and writes the result.
*/
-public class ForayAssignId {
+public class ForayAssignId extends SaxParser<Object> {
/** Command-line status constant indicating that the command line itself was not properly formed. */
public static final byte STATUS_COMMAND_LINE_ERROR = 1;
@@ -97,17 +97,10 @@
/** The output stream to which the modified output should be sent. */
private OutputStream output;
- /** The locator instance for identifying the document, line, and column
- * number of specific elements. */
- private Locator locator;
-
/** The entity resolver to be used for resolving Dtd catalogs and other
* entities. */
private EntityResolver entityResolver;
- /** The logger (lazily created). Use {#getLogger()} to get the instance. */
- private Logger logger;
-
/** The string to use for formatting Ids for Graphic elements. */
private String ancestorParaFormatString = "%03d";
@@ -133,7 +126,10 @@
private List<String> paraLevelElements = Arrays.asList(
"Para", "Head1", "Head2", "Signature", "Dateline", "PoetryVerse");
+ /** The location of catalogs to use during parsing. */
+ private String[] catalogs;
+
/**
* Constructor.
* @param input The input source encapsulating the document to be modified.
@@ -150,6 +146,14 @@
}
}
+ @Override
+ public Object parse(final InputSource inputSource) throws IOException, ParserConfigurationException, SAXException {
+ final EntityResolver entityResolver = XmlUtils.getEntityResolver(this.catalogs);
+ final XMLReader parser = createSax2Parser(true, true, true, entityResolver, true);
+ parser.parse(inputSource);
+ return null;
+ }
+
/**
* Intantiates parser and starts parsing of input.
* @throws IOException For I/O Errors.
@@ -275,7 +279,7 @@
try {
dbf.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
} catch (final ParserConfigurationException e) {
- logError("Parser does not recognize the \"namespace-prefixes\" feature.");
+ errorMessage("Parser does not recognize the \"namespace-prefixes\" feature.");
}
/* Turn on validation if it is available. */
@@ -282,7 +286,7 @@
try {
dbf.setFeature("http://xml.org/sax/features/validation", true);
} catch (final ParserConfigurationException e1) {
- logError("Parser does not recognize the \"validation\" feature.");
+ errorMessage("Parser does not recognize the \"validation\" feature.");
}
/* Turn on "notify-char-refs" feature.
@@ -297,7 +301,7 @@
dbf.setFeature("http://apache.org/xml/features/scanner/notify-char-refs", true);
} catch (final ParserConfigurationException e) {
/* Make this a fatal error. */
- logError("Parser cannot report character entities. Aborting.");
+ errorMessage("Parser cannot report character entities. Aborting.");
return null;
}
@@ -306,31 +310,12 @@
return db;
}
- /**
- * Returns the logger.
- * @return The logger.
- */
- private Logger getLogger() {
- if (this.logger == null) {
- this.logger = LoggerFactory.getLogger(ForayAssignId.class);
- }
- return this.logger;
+ @Override
+ public void reset() {
+ throw new UnsupportedOperationException();
}
/**
- * Convenience method to log an error.
- * @param message The message to be logged.
- */
- private void logError(final String message) {
- if (this.locator != null) {
- this.getLogger().error(this.locator.getSystemId() + ":"
- + this.locator.getLineNumber() + ":"
- + this.locator.getColumnNumber());
- }
- this.getLogger().error(message);
- }
-
- /**
* Returns the command-line options for the {@link #main(String[])} method.
* @return Command-line options.
*/
@@ -351,12 +336,10 @@
/**
* Command-line interface for modifying an XML document.
*
- * <p>Design Note: We use files instead of URLs here to more easily
- * integrate with desktop tools such as XML editors, which typically know
- * how to pass parameters for local files, but not how to convert them to
- * URLs.
- * If URLs are needed, additional flags probably need to be added to the
- * command-line interface to designate that.</p>
+ * <p>Design Note: We use files instead of URLs here to more easily integrate with desktop tools such as XML
+ * editors, which typically know how to pass parameters for local files, but not how to convert them to URLs.
+ * If URLs are needed, additional flags probably need to be added to the command-line interface to designate
+ * that.</p>
*
* <p>Return status is one of:</p>
* <ul>
@@ -369,8 +352,7 @@
* @param args command-line arguments.
* Argument 1 is the location of the input file.
* Argument 2 is the location of the output file.
- * Argument 3 is an optional location of an OASIS-compliant catalog file
- * that can be used to locate local DTDs.
+ * Argument 3 is an optional location of an OASIS-compliant catalog file that can be used to locate local DTDs.
*/
public static void main(final String[] args) {
final Logger logger = LoggerFactory.getLogger(ForayAssignId.class);
@@ -412,26 +394,13 @@
/* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_FILE_NOT_FOUND);
}
- final ForayAssignId processor = new ForayAssignId(inputSource, outputStream,
- catalog);
+ final ForayAssignId processor = new ForayAssignId(inputSource, outputStream, catalog);
try {
processor.start();
- } catch (final IOException e) {
+ } catch (final IOException | ParserConfigurationException | SAXException | TransformerException e) {
logger.error("Error parsing input.", e);
/* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_PARSING_ERROR);
- } catch (final ParserConfigurationException e) {
- logger.error("Error parsing input.", e);
- /* CheckStyle: Allow System.exit() in main method. */
- System.exit(ForayAssignId.STATUS_PARSING_ERROR);
- } catch (final SAXException e) {
- logger.error("Error parsing input.", e);
- /* CheckStyle: Allow System.exit() in main method. */
- System.exit(ForayAssignId.STATUS_PARSING_ERROR);
- } catch (final TransformerException e) {
- logger.error("Error writing output.", e);
- /* CheckStyle: Allow System.exit() in main method. */
- System.exit(ForayAssignId.STATUS_WRITING_ERROR);
}
logger.info("Input: " + input + " successfully modified,\n output in: " + output);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-05-28 20:26:35
|
Revision: 12644
http://sourceforge.net/p/foray/code/12644
Author: victormote
Date: 2022-05-28 20:26:33 +0000 (Sat, 28 May 2022)
Log Message:
-----------
Cosmetic changes.
Modified Paths:
--------------
trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayPretty.java
Modified: trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayPretty.java
===================================================================
--- trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayPretty.java 2022-03-28 17:28:56 UTC (rev 12643)
+++ trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayPretty.java 2022-05-28 20:26:33 UTC (rev 12644)
@@ -1092,6 +1092,11 @@
this.indentBlocksInsideMixedContent = indent;
}
+ @Override
+ public void reset() {
+ throw new UnsupportedOperationException();
+ }
+
/**
* Returns the command-line options for the {@link #main(String[])} method.
* @return Command-line options.
@@ -1113,12 +1118,10 @@
/**
* Command-line interface for pretty-printing an XML document.
*
- * <p>Design Note: We use files instead of URLs here to more easily
- * integrate with desktop tools such as XML editors, which typically know
- * how to pass parameters for local files, but not how to convert them to
- * URLs.
- * If URLs are needed, additional flags probably need to be added to the
- * command-line interface to designate that.</p>
+ * <p>Design Note: We use files instead of URLs here to more easily integrate with desktop tools such as XML
+ * editors, which typically know how to pass parameters for local files, but not how to convert them to URLs.
+ * If URLs are needed, additional flags probably need to be added to the command-line interface to designate
+ * that.</p>
*
* <p>Return status is one of:</p>
* <ul>
@@ -1131,8 +1134,7 @@
* @param args command-line arguments.
* Argument 1 is the location of the input file.
* Argument 2 is the location of the output file.
- * Argument 3 is an optional location of an OASIS-compliant catalog file
- * that can be used to locate local DTDs.
+ * Argument 3 is an optional location of an OASIS-compliant catalog file that can be used to locate local DTDs.
*/
public static void main(final String[] args) {
final Logger logger = LoggerFactory.getLogger(ForayPretty.class);
@@ -1177,25 +1179,12 @@
final ForayPretty processor = new ForayPretty(outputStream, catalog);
try {
processor.parse(inputSource);
- } catch (final IOException e) {
+ } catch (final IOException | ParserConfigurationException | SAXException e) {
logger.error("Error parsing " + input, e);
/* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayPretty.STATUS_PARSING_ERROR);
- } catch (final ParserConfigurationException e) {
- logger.error("Error parsing input.", e);
- /* CheckStyle: Allow System.exit() in main method. */
- System.exit(ForayPretty.STATUS_PARSING_ERROR);
- } catch (final SAXException e) {
- logger.error("Error parsing input.", e);
- /* CheckStyle: Allow System.exit() in main method. */
- System.exit(ForayPretty.STATUS_PARSING_ERROR);
}
logger.info("Input: " + input + " successfully pretty-printed,\n output in: " + output);
}
- @Override
- public void reset() {
- throw new UnsupportedOperationException();
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-03-28 17:29:04
|
Revision: 12643
http://sourceforge.net/p/foray/code/12643
Author: victormote
Date: 2022-03-28 17:28:56 +0000 (Mon, 28 Mar 2022)
Log Message:
-----------
Bring config generator up-to-date with DTD changes.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java
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 2022-03-28 15:26:27 UTC (rev 12642)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java 2022-03-28 17:28:56 UTC (rev 12643)
@@ -146,16 +146,18 @@
rootElement.appendChild(lastFamilyElement);
}
lastFamily = fontFamily;
- final Element memberElement = document.createElement("family-member");
+
+ final Element fontContentElement = document.createElement("font-content");
+ fontContentElement.setAttribute("id", configFile.getPostScriptName());
+ fontContentElement.setAttribute("font-file", configFile.getFontUrl());
+ lastFamilyElement.appendChild(fontContentElement);
+
+ final Element fontElement = document.createElement("font");
final Font.Style style = configFile.getStyle();
- memberElement.setAttribute("style", style.getFoValue());
+ fontElement.setAttribute("style", style.getFoValue());
final Font.Weight weight = configFile.getWeight();
- memberElement.setAttribute("weight", weight.getFoValue());
- lastFamilyElement.appendChild(memberElement);
- final Element fontElement = document.createElement("font");
- fontElement.setAttribute("id", configFile.getPostScriptName());
- fontElement.setAttribute("font-file", configFile.getFontUrl());
- memberElement.appendChild(fontElement);
+ fontElement.setAttribute("weight", weight.getFoValue());
+ fontContentElement.appendChild(fontElement);
}
return document;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-03-28 15:26:29
|
Revision: 12642
http://sourceforge.net/p/foray/code/12642
Author: victormote
Date: 2022-03-28 15:26:27 +0000 (Mon, 28 Mar 2022)
Log Message:
-----------
Improvements to parsing of font-config files.
Modified Paths:
--------------
trunk/foray/foray-00-master/config/checkstyle/checkstyle-config.xml
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
Modified: trunk/foray/foray-00-master/config/checkstyle/checkstyle-config.xml
===================================================================
--- trunk/foray/foray-00-master/config/checkstyle/checkstyle-config.xml 2022-03-28 15:24:00 UTC (rev 12641)
+++ trunk/foray/foray-00-master/config/checkstyle/checkstyle-config.xml 2022-03-28 15:26:27 UTC (rev 12642)
@@ -67,6 +67,14 @@
<property name="checkFormat" value="MagicNumber"/>
</module>
+ <!-- Skip some checks for classes of Data Transfer Objects (DTOs) that are only wrappers for data. -->
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="Checkstyle: Suppress some checks for Data Transfer Object (DTO) class."/>
+ <property name="onCommentFormat" value="Checkstyle: Restart checks after DTO class."/>
+ <!-- Allow non-private instance variables. -->
+ <property name="checkFormat" value="VisibilityModifier"/>
+ </module>
+
<!-- Skip this one. -->
<!--<module name="AbstractClassName"/>-->
<module name="ConstantName"/>
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-28 15:24:00 UTC (rev 12641)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-28 15:26:27 UTC (rev 12642)
@@ -32,6 +32,7 @@
import org.foray.common.primitive.StringUtils;
import org.foray.common.url.UrlFactory;
import org.foray.font.FontServer4a;
+import org.foray.xml.SaxLocation;
import org.foray.xml.SaxParser;
import org.axsl.font.Font;
@@ -65,11 +66,73 @@
*/
public class FontConfigParser extends SaxParser<Object> {
+ /**
+ * Inner class for storing font-group items.
+ */
+ private class FontGroup {
+
+ /** Remembers the state of currentEmbed before this group was reached, so that it can be restored when this
+ * group is exited. */
+ private Font.Embedding saveEmbed;
+
+ /** Remembers the state of currentXMLBase before this group was reached, so that it can be restored when this
+ * group is exited. */
+ private URL saveXMLBase;
+
+ /**
+ * Constructor.
+ * @param label The label for the font group.
+ * @param previousEmbed The status of "embed" before the font-group was entered.
+ * @param previousXMLBase The status of the "base" before the font-group was entered.
+ */
+ FontGroup(final String label, final Font.Embedding previousEmbed, final URL previousXMLBase) {
+ /* Ignore the label. */
+ this.saveEmbed = previousEmbed;
+ this.saveXMLBase = previousXMLBase;
+ }
+
+ /**
+ * Return the previous "embed" value.
+ * @return The previous "embed" value.
+ */
+ Font.Embedding getPreviousEmbed() {
+ return this.saveEmbed;
+ }
+
+ /**
+ * Return the previous "base" value.
+ * @return The previous "base" value.
+ */
+ URL getPreviousXMLBase() {
+ return this.saveXMLBase;
+ }
+
+ }
+
+ /* Checkstyle: Suppress some checks for Data Transfer Object (DTO) class. */
+ /**
+ * Inner Data Transfer Object class storing parsed "font" elements whose related "font-content" element has not yet
+ * been parsed.
+ */
+ private class UnresolvedFont {
+
+ /** The font that is unresolved. */
+ private RegisteredFont font;
+
+ /** The id of the "font-content" element. */
+ private String fontContentId;
+
+ /** The location in which the unresolved font was found. */
+ private SaxLocation location;
+
+ }
+ /* Checkstyle: Restart checks after DTO class. */
+
/** Stateful variable tracking which {@link RegisteredFontFamily}, if any, is currently being parsed. */
private RegisteredFontFamily currentFontFamily = null;
/** The list of registered fonts that have been parsed, but whose related {@link RegisteredFontContent} has not. */
- private List<RegisteredFont> unresolvedFonts = new ArrayList<RegisteredFont>();
+ private List<UnresolvedFont> unresolvedFonts = new ArrayList<UnresolvedFont>();
// /** The current "simulate-small-caps" value. */
// private transient String currentSimulateSmallCaps = null;
@@ -402,7 +465,11 @@
variant, stretch);
if (font.getRegisteredFont() == null) {
- this.unresolvedFonts.add(font);
+ final UnresolvedFont unresolved = new UnresolvedFont();
+ unresolved.font = font;
+ unresolved.fontContentId = contentString;
+ unresolved.location = new SaxLocation(getLocator());
+ this.unresolvedFonts.add(unresolved);
} else {
try {
this.currentFontFamily.registerFont(font);
@@ -723,55 +790,30 @@
return output.toString();
}
- /**
- * Inner class for storing font-group items.
- */
- private class FontGroup {
-
- /** Remembers the state of currentEmbed before this group was reached,
- * so that it can be restored when this group is exited. */
- private Font.Embedding saveEmbed;
-
- /** Remembers the state of currentXMLBase before this group was reached,
- * so that it can be restored when this group is exited. */
- private URL saveXMLBase;
-
- /**
- * Constructor.
- * @param label The label for the font group.
- * @param previousEmbed The status of "embed" before the font-group
- * was entered.
- * @param previousXMLBase The status of the "base" before the font-group
- * was entered.
- */
- FontGroup(final String label, final Font.Embedding previousEmbed,
- final URL previousXMLBase) {
- /* Ignore the label. */
- this.saveEmbed = previousEmbed;
- this.saveXMLBase = previousXMLBase;
- }
-
- /**
- * Return the previous "embed" value.
- * @return The previous "embed" value.
- */
- Font.Embedding getPreviousEmbed() {
- return this.saveEmbed;
- }
-
- /**
- * Return the previous "base" value.
- * @return The previous "base" value.
- */
- URL getPreviousXMLBase() {
- return this.saveXMLBase;
- }
-
- }
-
@Override
public void reset() {
throw new UnsupportedOperationException();
}
+ @Override
+ public void endDocument() throws SAXException {
+ /* Handle unresolved "font" elements. */
+ while (this.unresolvedFonts.size() > 0) {
+ final UnresolvedFont unresolved = this.unresolvedFonts.get(0);
+ final RegisteredFontContent content = this.fontServer.getRegisteredFont(unresolved.fontContentId);
+ if (content == null) {
+ errorMessage(unresolved.location, "Font cannot be registered due to unregistered font-content: " +
+ unresolved.fontContentId);
+ } else {
+ unresolved.font.setRegisteredFontContent(content);
+ try {
+ unresolved.font.getRegisteredFontFamily().registerFont(unresolved.font);
+ } catch (final FontException e) {
+ throw new SAXException(e);
+ }
+ }
+ this.unresolvedFonts.remove(0);
+ }
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-03-28 15:24:00 UTC (rev 12641)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-03-28 15:26:27 UTC (rev 12642)
@@ -491,6 +491,23 @@
}
/**
+ * Sets the related {@link RegisteredFontContent} instance.
+ * In cases where "font" and "font-content" elements are parsed from XML, this value may not be known at
+ * construction time.
+ * This method allows the resolved font-content item to be added later if necessary.
+ * Once set, however, it is considered to be immutable.
+ * @param content The new content value for this font.
+ * @throws IllegalStateException If this method is called on an instance for which the content is already set.
+ */
+ public void setRegisteredFontContent(final RegisteredFontContent content) {
+ if (this.registeredFont == null) {
+ this.registeredFont = content;
+ } else {
+ throw new IllegalStateException("The content of this font has already been set.");
+ }
+ }
+
+ /**
* Returns the related registered font family instance.
* @return The related registered font family instance.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-03-28 15:24:03
|
Revision: 12641
http://sourceforge.net/p/foray/code/12641
Author: victormote
Date: 2022-03-28 15:24:00 +0000 (Mon, 28 Mar 2022)
Log Message:
-----------
Improvements to logging during XML parsing.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternParser.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/SpellChecker.java
trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxParser.java
Added Paths:
-----------
trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxLocation.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 2022-03-27 18:56:35 UTC (rev 12640)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeParser4a.java 2022-03-28 15:24:00 UTC (rev 12641)
@@ -298,7 +298,8 @@
}
final Namespace namespace = getTreeServer().getNamespace(namespaceURI);
if (namespace == null) {
- final String message = "Unregistered namespace: " + namespaceURI + ": " + getShortLocationString();
+ final String message = "Unregistered namespace: " + namespaceURI + ": " +
+ getShortLocationString(getLocator());
throw new SAXException(message);
}
/* the formatting object started */
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java 2022-03-27 18:56:35 UTC (rev 12640)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/DictionaryParser.java 2022-03-28 15:24:00 UTC (rev 12641)
@@ -338,7 +338,8 @@
case "possessive": break;
case "extensible": break;
default: {
- throw new IllegalStateException("Unknown element started: " + localName + ", " + getLocationString());
+ throw new IllegalStateException("Unknown element started: " + localName + ", " +
+ getLocationString(getLocator()));
}
}
}
@@ -353,7 +354,7 @@
if (this.logDictionaryProblems) {
final String actualContentLowercase = actualContent.toLowerCase();
if (actualContentLowercase.compareTo(this.lastWord) < 0) {
- warningMessage("Out of alphabetical sequence: " + actualContent + " " + getLocationString());
+ warningMessage("Out of alphabetical sequence: " + actualContent);
}
this.lastWord = actualContentLowercase;
}
@@ -386,7 +387,7 @@
final char theChar = inputLine.charAt(inputLineIndex);
if (theChar == this.currentDictionary.softHyphenChar) {
if (builder.length() < 1) {
- throw new SAXException("0-length syllable on line: " + getLocationString());
+ throw new SAXException("0-length syllable on line: " + getLocationString(getLocator()));
}
final StringWordSegment wordSegment = createSegment(builder.toString());
segmentList.add(wordSegment);
@@ -407,7 +408,7 @@
segmentSet.add(wordSegment);
}
if (segmentList.size() < 1) {
- throw new SAXException("0-syllable word: " + getLocationString());
+ throw new SAXException("0-syllable word: " + getLocationString(getLocator()));
}
this.currentSegments = new StringWordSegment[segmentList.size()];
segmentList.toArray(this.currentSegments);
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java 2022-03-27 18:56:35 UTC (rev 12640)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/OrthographyParser.java 2022-03-28 15:24:00 UTC (rev 12641)
@@ -242,7 +242,6 @@
final DictionaryResource resource = this.dictionaries.get(reference);
if (resource == null) {
errorMessage("dictionary-resource not found: {}", reference);
- errorMessage(getLocationString());
} else {
this.currentOrthographyConfig.setDictionaryResource(resource);
}
@@ -253,7 +252,6 @@
final HyphenationPatternsResource resource = this.hyphenationPatterns.get(reference);
if (resource == null) {
errorMessage("hyphenation-patterns-resource not found: {}", reference);
- errorMessage(getLocationString());
} else {
this.currentOrthographyConfig.setHyphenationPatternsResource(resource);
}
@@ -264,7 +262,6 @@
final List<Pattern> patterns = this.hyphenationServer.getMatchRules(reference);
if (patterns == null) {
errorMessage("match-rules not found: {}", reference);
- errorMessage(getLocationString());
} else {
this.currentOrthographyConfig.registerMatchRuleListId(reference);
}
@@ -275,7 +272,6 @@
final List<DerivativePattern> rules = this.hyphenationServer.getDerivativePatterns(reference);
if (rules == null) {
errorMessage("derivative-rules not found: {}", reference);
- errorMessage(getLocationString());
} else {
this.currentOrthographyConfig.registerDerivativeRuleListId(reference);
}
@@ -286,7 +282,6 @@
final List<WordWrapperFactory<?>> factories = this.derivativeLists.get(reference);
if (factories == null) {
errorMessage("derivative-factories not found: {}", reference);
- errorMessage(getLocationString());
} else {
this.currentOrthographyConfig.setWordWrapperFactories(factories);
}
@@ -438,22 +433,18 @@
final Language4a language = Language4a.findFrom3Char(languageString);
if (language == null) {
errorMessage("Unable to find language for: {}", languageString);
- errorMessage(getLocationString());
}
final Script4a script = Script4a.findFromAlpha(scriptString);
if (script == null) {
errorMessage("Unable to find script for: {}", scriptString);
- errorMessage(getLocationString());
}
final Country4a country = Country4a.findFrom3Char(countryString);
if (country == null) {
errorMessage("Unable to find country for: {}", countryString);
- errorMessage(getLocationString());
}
final WritingSystem4a writingSystem = WritingSystem4a.find(language, script, country);
if (writingSystem == null) {
errorMessage("Unable to find script for: {}_{}_{}", languageString, scriptString, countryString);
- errorMessage(getLocationString());
}
this.hyphenationServer.registerOrthography(writingSystem, this.currentOrthographyConfig);
}
@@ -621,7 +612,6 @@
return new URL(urlString);
} catch (final MalformedURLException e) {
errorMessage("Invalid URL: {}", urlString);
- errorMessage(getLocationString());
return null;
}
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternParser.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternParser.java 2022-03-27 18:56:35 UTC (rev 12640)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternParser.java 2022-03-28 15:24:00 UTC (rev 12641)
@@ -190,7 +190,8 @@
break;
}
default: {
- throw new IllegalStateException("Unknown element started: " + local + ", " + getLocationString());
+ throw new IllegalStateException("Unknown element started: " + local + ", " +
+ getLocationString(getLocator()));
}
}
this.token.setLength(0);
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/SpellChecker.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/SpellChecker.java 2022-03-27 18:56:35 UTC (rev 12640)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/SpellChecker.java 2022-03-28 15:24:00 UTC (rev 12641)
@@ -248,7 +248,7 @@
if (languageAttr == null) {
if (this.currentOrthographyConfig == null) {
- this.output.println("Orthography not specified. " + getLocationString());
+ this.output.println("Orthography not specified. " + getLocationString(getLocator()));
}
} else {
/* Is there a country code? */
@@ -271,7 +271,7 @@
final String message = String.format(
"Orthography not found. Language: %1$s, Country: %2$s, Script: %3$s ", languageString,
countryString, script.getAlphaCode());
- this.output.println(message + getLocationString());
+ this.output.println(message + getLocationString(getLocator()));
} else {
final Orthography4a config = this.server.getOrthography(element.writingSystem);
if (config == null) {
@@ -278,7 +278,7 @@
final String message = String.format(
"Unconfigured orthography. Language: %1$s, Country: %2$s, Script: %3$s ",
languageString, countryString, script.getAlphaCode());
- this.output.println(message + getLocationString());
+ this.output.println(message + getLocationString(getLocator()));
} else {
element.orthographyConfig = config;
}
@@ -364,7 +364,7 @@
return;
}
- this.output.println("Not found: " + word + " " + getShortLocationString());
+ this.output.println("Not found: " + word + " " + getShortLocationString(getLocator()));
this.notFoundCounter ++;
}
Added: trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxLocation.java
===================================================================
--- trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxLocation.java (rev 0)
+++ trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxLocation.java 2022-03-28 15:24:00 UTC (rev 12641)
@@ -0,0 +1,87 @@
+/*
+ * 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.xml;
+
+import org.xml.sax.Locator;
+
+/**
+ * Captures a snapshot of a given location provided by another {@link Locator}, so that it can be used after the SAX
+ * event is out of scope.
+ * This is useful for cases where, for example, the validity of an element is contingent on some downstream event, and
+ * we wish to capture its location for that contingency.
+ */
+public class SaxLocation implements Locator {
+
+ /** The public identifier for the document event. */
+ private String publicId;
+
+ /** The system identifier for the document event. */
+ private String systemId;
+
+ /** The line number where the document event ends. */
+ private int lineNumber;
+
+ /** The column number where the document event ends. */
+ private int columnNumber;
+
+ /**
+ * Constructor creating a new instance based on the current state of another {@link Locator} instance.
+ * @param locator The SAX {@link Locator} whose state should be captured by the new instance.
+ */
+ public SaxLocation(final Locator locator) {
+ if (locator == null) {
+ return;
+ }
+ this.publicId = locator.getPublicId();
+ this.systemId = locator.getSystemId();
+ this.lineNumber = locator.getLineNumber();
+ this.columnNumber = locator.getColumnNumber();
+ }
+
+ @Override
+ public String getPublicId() {
+ return this.publicId;
+ }
+
+ @Override
+ public String getSystemId() {
+ return this.systemId;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return this.lineNumber;
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return this.columnNumber;
+ }
+
+}
Property changes on: trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxLocation.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxParser.java
===================================================================
--- trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxParser.java 2022-03-27 18:56:35 UTC (rev 12640)
+++ trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxParser.java 2022-03-28 15:24:00 UTC (rev 12641)
@@ -125,8 +125,7 @@
*/
public static String getParserClassName() {
try {
- return SAXParserFactory.newInstance().newSAXParser()
- .getXMLReader().getClass().getName();
+ return SAXParserFactory.newInstance().newSAXParser().getXMLReader().getClass().getName();
} catch (final ParserConfigurationException e) {
return null;
} catch (final SAXException e) {
@@ -135,36 +134,47 @@
}
/**
- * Returns the current location in the input document as a formatted string.
- * @return The current location in the input document as a formatted string.
+ * Returns a location in the input document as a formatted string.
+ * @param location The location being marked.
+ * @return A location in the input document as a formatted string.
*/
- protected String getLocationString() {
- if (this.locator == null) {
+ protected String getLocationString(final Locator location) {
+ if (location == null) {
return StringUtils.EMPTY_STRING;
}
- return String.format(LOCATION_FORMAT_STRING, this.locator.getSystemId(), this.locator.getLineNumber(),
- this.locator.getColumnNumber());
+ return String.format(LOCATION_FORMAT_STRING, location.getSystemId(), location.getLineNumber(),
+ location.getColumnNumber());
}
/**
- * Returns the line and column number of the current location in the input document as a formatted string.
- * @return The line and column number of the current location in the input document as a formatted string.
+ * Returns the line and column number of a location in the input document as a formatted string.
+ * @param location The location being marked.
+ * @return The line and column number of a location in the input document as a formatted string.
*/
- protected String getShortLocationString() {
- if (this.locator == null) {
+ protected String getShortLocationString(final Locator location) {
+ if (location == null) {
return StringUtils.EMPTY_STRING;
}
- return String.format(SHORT_LOCATION_FORMAT_STRING, this.locator.getLineNumber(),
- this.locator.getColumnNumber());
+ return String.format(SHORT_LOCATION_FORMAT_STRING, location.getLineNumber(), location.getColumnNumber());
}
/**
* Returns the locator, if any, for this parsing session.
- * This may be useful for some subclasses that need fine-grained control over reporting, but most will want to use
- * {@link #getLocationString()} or {@link #getShortLocationString()} instead.
+ * This may be useful for some subclasses that need fine-grained control over reporting, but most will instead want
+ * to use one of the methods mentioned in the "See ..." documentation for this method.
* @return The locator.
- * @see #getLocationString()
- * @see #getShortLocationString()
+ * @see #errorMessage(String, Object...)
+ * @see #errorMessage(Locator, String, Object...)
+ * @see #warningMessage(String, Object...)
+ * @see #warningMessage(Locator, String, Object...)
+ * @see #infoMessage(String, Object...)
+ * @see #infoMessage(Locator, String, Object...)
+ * @see #debugMessage(String, Object...)
+ * @see #debugMessage(Locator, String, Object...)
+ * @see #traceMessage(String, Object...)
+ * @see #traceMessage(Locator, String, Object...)
+ * @see #getLocationString(Locator)
+ * @see #getShortLocationString(Locator)
*/
protected Locator getLocator() {
return this.locator;
@@ -325,56 +335,106 @@
}
/**
+ * Logs an error message, noting the location of the event being tagged.
+ * @param location The location of the event being tagged.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void errorMessage(final Locator location, final String message, final Object... arguments) {
+ final String template = getLocationString(location) + ": " + message;
+ this.logger.error(template, arguments);
+ }
+
+ /**
* Logs an error message, noting the location currently being parsed.
* @param message The message to be logged.
* @param arguments Parameters for the string template, if needed.
*/
public void errorMessage(final String message, final Object... arguments) {
- final String template = getLocationString() + ": " + message;
- this.logger.error(template, arguments);
+ errorMessage(this.locator, message, arguments);
}
/**
+ * Logs a warning message, noting the location of the event being tagged.
+ * @param location The location of the event being tagged.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void warningMessage(final Locator location, final String message, final Object... arguments) {
+ final String template = getLocationString(location) + ": " + message;
+ this.logger.warn(template, arguments);
+ }
+
+ /**
* Logs a warning message, noting the location currently being parsed.
* @param message The message to be logged.
* @param arguments Parameters for the string template, if needed.
*/
public void warningMessage(final String message, final Object... arguments) {
- final String template = getLocationString() + ": " + message;
- this.logger.warn(template, arguments);
+ warningMessage(this.locator, message, arguments);
}
/**
+ * Logs an info message, noting the location of the event being logged.
+ * @param location The location of the event being tagged.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void infoMessage(final Locator location, final String message, final Object... arguments) {
+ final String template = getLocationString(location) + ": " + message;
+ this.logger.info(template, arguments);
+ }
+
+ /**
* Logs an info message, noting the location currently being parsed.
* @param message The message to be logged.
* @param arguments Parameters for the string template, if needed.
*/
public void infoMessage(final String message, final Object... arguments) {
- final String template = getLocationString() + ": " + message;
- this.logger.info(template, arguments);
+ infoMessage(this.locator, message, arguments);
}
/**
+ * Logs a debug message, noting the location of the event being logged.
+ * @param location The location of the event being tagged.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void debugMessage(final Locator location, final String message, final Object... arguments) {
+ final String template = getLocationString(location) + ": " + message;
+ this.logger.debug(template, arguments);
+ }
+
+ /**
* Logs a debug message, noting the location currently being parsed.
* @param message The message to be logged.
* @param arguments Parameters for the string template, if needed.
*/
public void debugMessage(final String message, final Object... arguments) {
- final String template = getLocationString() + ": " + message;
- this.logger.debug(template, arguments);
+ debugMessage(this.locator, message, arguments);
}
/**
* Logs a trace message, noting the location currently being parsed.
+ * @param location The location of the event being tagged.
* @param message The message to be logged.
* @param arguments Parameters for the string template, if needed.
*/
- public void traceMessage(final String message, final Object... arguments) {
- final String template = getLocationString() + ": " + message;
+ public void traceMessage(final Locator location, final String message, final Object... arguments) {
+ final String template = getLocationString(location) + ": " + message;
this.logger.trace(template, arguments);
}
/**
+ * Logs a trace message, noting the location currently being parsed.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void traceMessage(final String message, final Object... arguments) {
+ traceMessage(this.locator, message, arguments);
+ }
+
+ /**
* Sets or unsets whether text parsing is active.
* If not active, the text will not be accumulated.
* @param isActive The new value for text parsing active.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-03-27 18:56:38
|
Revision: 12640
http://sourceforge.net/p/foray/code/12640
Author: victormote
Date: 2022-03-27 18:56:35 +0000 (Sun, 27 Mar 2022)
Log Message:
-----------
Improvements to font config parsing.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/primitive/StringUtils.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java
trunk/foray/foray-font/src/test/resources/font-config.xml
trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxParser.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/primitive/StringUtils.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/primitive/StringUtils.java 2022-03-26 13:37:29 UTC (rev 12639)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/primitive/StringUtils.java 2022-03-27 18:56:35 UTC (rev 12640)
@@ -440,4 +440,12 @@
}
}
+ /**
+ * Indicates whether a given string is either null or empty.
+ * @param string The string to be tested.
+ * @return True if and only if {@code param} is either null or empty.
+ */
+ public static boolean isNullOrEmpty(final String string) {
+ return string == null || string.length() < 1;
+ }
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java 2022-03-26 13:37:29 UTC (rev 12639)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java 2022-03-27 18:56:35 UTC (rev 12640)
@@ -44,8 +44,7 @@
/**
* Constructor.
- * @param consumer The font consumer for whom this selector is being
- * created.
+ * @param consumer The font consumer for whom this selector is being created.
*/
public FontSelector(final FontConsumer4a consumer) {
super();
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-03-26 13:37:29 UTC (rev 12639)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java 2022-03-27 18:56:35 UTC (rev 12640)
@@ -75,8 +75,7 @@
*/
public class FontServer4a implements FontServer, FontParserClient {
- /** Constant indicating the default percentage to be applied when creating
- * faux small-caps. */
+ /** Constant indicating the default percentage to be applied when creating faux small-caps. */
private static final int DEFAULT_SMALL_CAPS_SIZE = 80;
/**
@@ -92,19 +91,16 @@
private URL baseFontURL = null;
/**
- * Map whose key is a String containing a font-family name (such as
- * "Courier") and whose value is the RegisteredFontFamily instance that
- * is associated with that font-family name.
+ * Map whose key is a String containing a font-family name (such as "Courier") and whose value is the
+ * RegisteredFontFamily instance that is associated with that font-family name.
*/
- private Map<String, RegisteredFontFamily> fontFamilies
- = new HashMap<String, RegisteredFontFamily>();
+ private Map<String, RegisteredFontFamily> fontFamilies = new HashMap<String, RegisteredFontFamily>();
/**
- * Map whose key is a String containing a font-family-alias and whose value
- * is the RegisteredFontFamily to which that alias is attached.
+ * Map whose key is a String containing a font-family-alias and whose value is the RegisteredFontFamily to which
+ * that alias is attached.
*/
- private Map<String, RegisteredFontFamily> fontFamilyAliases
- = new HashMap<String, RegisteredFontFamily>();
+ private Map<String, RegisteredFontFamily> fontFamilyAliases = new HashMap<String, RegisteredFontFamily>();
/** The logger. */
private Logger logger = LoggerFactory.getLogger(FontServer4a.class);
@@ -130,12 +126,11 @@
/** Used to get some environmental information. */
private Graphics2D graphic = null;
- /** This is the FreeStandingFont that should be used when a FreeStandingFont
- * is required and all other fallback options fail. */
+ /** This is the FreeStandingFont that should be used when a FreeStandingFont is required and all other fallback
+ * options fail. */
private RegisteredFont defaultFreeStandingFont = null;
- /** This is the SystemFont that should be used when a SystemFont
- * is required and all other fallback options fail. */
+ /** This is the SystemFont that should be used when a SystemFont is required and all other fallback options fail. */
private RegisteredFont defaultSystemFont = null;
/** An EntityResolver to be used by XML parsers (for handling DTD catalogs,
@@ -143,17 +138,15 @@
private EntityResolver entityResolver = null;
/**
- * Map whose key is a String containing a font ID, and whose value is the
- * RegisteredFont for that font ID.
+ * Map whose key is a String containing the id of a {@link RegisteredFontContent} instance, and whose value is that
+ * instance.
*/
- private Map<String, RegisteredFontContent> registeredFonts
- = new HashMap<String, RegisteredFontContent>();
+ private Map<String, RegisteredFontContent> registeredFontContent = new HashMap<String, RegisteredFontContent>();
- /** Map of registered font selector factories. The key is String containing
- * the name of the factory, and the value is the {@link FontSelectorFactory}
- * that the name maps to. */
- private Map<String, FontSelectorFactory> registeredFontSelectorFactories
- = new HashMap<String, FontSelectorFactory>();
+ /** Map of registered font selector factories. The key is String containing the name of the factory, and the value
+ * is the {@link FontSelectorFactory} that the name maps to. */
+ private Map<String, FontSelectorFactory> registeredFontSelectorFactories =
+ new HashMap<String, FontSelectorFactory>();
/** The PostScript server. */
private PsServer psServer;
@@ -227,11 +220,12 @@
}
/* Punt and try to create something that will work. */
try {
- final RegisteredFontContent rf = new RegisteredFontContent(this, null, null, null,
- null, null, "serif");
+ final RegisteredFontContent rf = new RegisteredFontContent(this, null, null, null, null, null, "serif");
final RegisteredFontFamily rff = this.registerFontFamily2("serif");
- rff.registerFontDesc(rf, null, "normal", "normal", "normal",
- "normal", null, null, null, null);
+ final RegisteredFont font = new RegisteredFont(rf, rff, null, org.axsl.font.Font.Style.NORMAL,
+ org.axsl.font.Font.Weight.NORMAL, org.axsl.font.Font.Variant.NORMAL,
+ org.axsl.font.Font.Stretch.NORMAL);
+ rff.registerFont(font);
} catch (final FontException e) {
getLogger().error("Unable to create default system font.");
}
@@ -657,18 +651,15 @@
if (awtFont.isBold()) {
fontWeight = org.axsl.font.Font.Weight.BOLD;
}
- final org.axsl.font.Font.Variant fontVariant
- = org.axsl.font.Font.Variant.NORMAL;
- final org.axsl.font.Font.Stretch fontStretch
- = org.axsl.font.Font.Stretch.NORMAL;
- new RegisteredFont(rf, rff, null, fontStyle, fontWeight,
- fontVariant, fontStretch);
+ final org.axsl.font.Font.Variant fontVariant = org.axsl.font.Font.Variant.NORMAL;
+ final org.axsl.font.Font.Stretch fontStretch = org.axsl.font.Font.Stretch.NORMAL;
+ final RegisteredFont font = new RegisteredFont(rf, rff, null, fontStyle, fontWeight, fontVariant,
+ fontStretch);
+ font.setSimulateSmallCaps(FontServer.SMALL_CAP_SIMULATION_INVALID);
+ font.setSimulateOblique(FontServer.OBLIQUE_SIMULATION_INVALID);
+ font.setSimulateBackslant(FontServer.OBLIQUE_SIMULATION_INVALID);
try {
- rff.registerFontDesc(rf,
- null, fontStyle, fontWeight, fontVariant, fontStretch,
- FontServer.SMALL_CAP_SIMULATION_INVALID,
- FontServer.OBLIQUE_SIMULATION_INVALID,
- FontServer.OBLIQUE_SIMULATION_INVALID, null);
+ rff.registerFont(font);
} catch (final FontException e) {
this.logger.error(e.getMessage());
}
@@ -741,13 +732,11 @@
* @return The registered font family instance.
* @throws FontException If the font-family is already registered.
*/
- public RegisteredFontFamily registerFontFamily2(final String name)
- throws FontException {
+ public RegisteredFontFamily registerFontFamily2(final String name) throws FontException {
/* Make sure it is not already registered. */
RegisteredFontFamily rff = this.getRegisteredFontFamily(name);
if (rff != null) {
- throw new FontException("font-family already registered: "
- + name);
+ throw new FontException("font-family already registered: " + name);
}
rff = new RegisteredFontFamily(this, name);
this.fontFamilies.put(name, rff);
@@ -757,14 +746,11 @@
/**
* Add an alias to a RegisteredFontFamily.
* @param alias The name of the font family alias (e.g. "sans-serif").
- * @param realFamily The name of the real font family to which this alias
- * should be associated (e.g. "Helvetica").
- * @throws FontException If the {@code realFamily} does not exist, or
- * if the alias is already registered to another font-family.
+ * @param realFamily The name of the real font family to which this alias should be associated (e.g. "Helvetica").
+ * @throws FontException If the {@code realFamily} does not exist, or if the alias is already registered to another
+ * font-family.
*/
- public void registerFontFamilyAlias(final String alias,
- final String realFamily)
- throws FontException {
+ public void registerFontFamilyAlias(final String alias, final String realFamily) throws FontException {
final RegisteredFontFamily rff = this.fontFamilies.get(realFamily);
if (rff == null) {
throw new FontException("Font family " + realFamily
@@ -996,7 +982,7 @@
* been registered.
*/
public RegisteredFontContent getRegisteredFont(final String name) {
- return this.registeredFonts.get(name);
+ return this.registeredFontContent.get(name);
}
/**
@@ -1005,18 +991,17 @@
* @param rf The registered font instance to be associated with the name.
* @throws FontException If the {@code fontID} is already registered.
*/
- public void registerFont(final String fontID, final RegisteredFontContent rf)
- throws FontException {
- final Object object = this.registeredFonts.get(fontID);
+ public void registerFont(final String fontID, final RegisteredFontContent rf) throws FontException {
+ final Object object = this.registeredFontContent.get(fontID);
if (object != null) {
throw new FontException("Font ID already registered: " + fontID);
}
- this.registeredFonts.put(fontID, rf);
+ this.registeredFontContent.put(fontID, rf);
}
@Override
public boolean isRegisteredFont(final String fontID) {
- final Object object = this.registeredFonts.get(fontID);
+ final Object object = this.registeredFontContent.get(fontID);
return object != null;
}
@@ -1030,12 +1015,14 @@
final float simulatedSmallCaps, final float simulatedOblique,
final float simulatedBackslant, final float[] simulatedStretch)
throws FontException {
- final RegisteredFontFamily rff = this.getRegisteredFontFamily(
- fontFamily);
+ final RegisteredFontFamily rff = this.getRegisteredFontFamily(fontFamily);
final RegisteredFontContent rf = this.getRegisteredFont(fontID);
- rff.registerFontDesc(rf, encoding, style, weight, variant, stretch,
- simulatedSmallCaps, simulatedOblique, simulatedBackslant,
- simulatedStretch);
+ final RegisteredFont font = new RegisteredFont(rf, rff, encoding, style, weight, variant, stretch);
+ font.setSimulateSmallCaps(simulatedSmallCaps);
+ font.setSimulateOblique(simulatedOblique);
+ font.setSimulateBackslant(simulatedBackslant);
+ font.setSimulateStretch(simulatedStretch);
+ rff.registerFont(font);
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-26 13:37:29 UTC (rev 12639)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-27 18:56:35 UTC (rev 12640)
@@ -29,6 +29,7 @@
package org.foray.font.config;
import org.foray.common.ForayEntityResolver;
+import org.foray.common.primitive.StringUtils;
import org.foray.common.url.UrlFactory;
import org.foray.font.FontServer4a;
import org.foray.xml.SaxParser;
@@ -64,24 +65,15 @@
*/
public class FontConfigParser extends SaxParser<Object> {
- /** Stateful variable tracking which RegisteredFontFamily is currently being parsed. */
+ /** Stateful variable tracking which {@link RegisteredFontFamily}, if any, is currently being parsed. */
private RegisteredFontFamily currentFontFamily = null;
- /**
- * Counter for registering fonts which haven't been given an id. It will
- * be reset at the beginning of each font-family. The font name will be the
- * name of the font family + "Member" + counter. Starting at 1 because it
- * is more natural for humans (the name may appear in error messages).
- */
- private int fontIdCounter = 1;
+ /** The list of registered fonts that have been parsed, but whose related {@link RegisteredFontContent} has not. */
+ private List<RegisteredFont> unresolvedFonts = new ArrayList<RegisteredFont>();
- /** Stateful variable tracking which FontFamilyMember is currently
- * being parsed. */
- private transient FontFamilyMember currentFontFamilyMember = null;
+// /** The current "simulate-small-caps" value. */
+// private transient String currentSimulateSmallCaps = null;
- /** The current "simulate-small-caps" value. */
- private transient String currentSimulateSmallCaps = null;
-
/** The current "encoding" value. */
private transient String currentEncoding = null;
@@ -151,55 +143,55 @@
return null;
}
- /**
- * {@inheritDoc}
- * Recognizes each valid element and parses its attributes.
- */
@Override
- public void startElement(final String uri, final String localName,
- final String qName, final Attributes attributes) {
- if (localName.equals("axsl-font-config")) {
+ public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
+ throws SAXException {
+ switch(localName) {
+ case "axsl-font-config": {
parseElementRoot(attributes);
return;
}
- if (localName.equals("glyph-list")) {
+ case "glyph-list": {
parseElementGlyphList(attributes);
return;
}
- if (localName.equals("encoding")) {
+ case "encoding": {
parseElementEncoding(attributes);
return;
}
- if (localName.equals("font-group")) {
+ case "font-group": {
parseElementFontGroup(attributes);
return;
}
- if (localName.equals("font-content")) {
+ case "font-content": {
parseElementFontContent(attributes);
return;
}
- if (localName.equals("font")) {
+ case "font": {
parseElementFont(attributes);
return;
}
- if (localName.equals("server")) {
+ case "server": {
parseElementServer(attributes);
return;
}
- if (localName.equals("font-family")) {
+ case "font-family": {
parseElementFontFamily(attributes);
return;
}
- if (localName.equals("font-family-alias")) {
+ case "font-family-alias": {
parseElementFontFamilyAlias(attributes);
return;
}
- if (localName.equals("parameter")) {
+ case "parameter": {
parseElementParameter(attributes);
return;
}
- // Make sure user knows about unknown tag
- errorMessage("Unknown tag in font configuration " + "file: " + localName);
+ default: {
+ /* Make sure user knows about unknown tag. */
+ errorMessage("Unknown tag in font configuration " + "file: " + localName);
+ }
+ }
}
/**
@@ -222,7 +214,7 @@
|| alias.equals("")
|| family == null
|| family.equals("")) {
- errorMessage("font-family-alias entry invalid. " + "Ignored.");
+ errorMessage("font-family-alias entry invalid. " + "Igcase red.");
} else {
try {
this.fontServer.registerFontFamilyAlias(alias, family);
@@ -309,24 +301,20 @@
this.previousEmbed = this.currentEmbed;
final String name = attributes.getValue("name");
- if (name == null
- || name.equals("")) {
+ if (StringUtils.isNullOrEmpty(name)) {
errorMessage("\"name\" attribute required for font-family. Ignored.");
return;
}
try {
- this.currentFontFamily
- = this.fontServer.registerFontFamily2(name);
+ this.currentFontFamily = this.fontServer.registerFontFamily2(name);
} catch (final FontException e) {
/* Log a warning. */
warningMessage(e.getMessage());
/* Use the existing font family if you can. */
- this.currentFontFamily = this.fontServer.getRegisteredFontFamily(
- name);
+ this.currentFontFamily = this.fontServer.getRegisteredFontFamily(name);
return;
}
- this.currentSimulateSmallCaps = attributes.getValue(
- "simulate-small-caps");
+// this.currentSimulateSmallCaps = attributes.getValue("simulate-small-caps");
this.currentEncoding = attributes.getValue("encoding");
final String embed = attributes.getValue("embed");
if (embed != null && !embed.equals("")) {
@@ -343,7 +331,6 @@
errorMessage("Unable to create URL from " + this.previousXMLBase.getPath() + " AND " + xmlBase);
}
}
- this.fontIdCounter = 0;
}
/**
@@ -366,36 +353,34 @@
}
/**
- * Parses the "family-member" element.
+ * Parses the "font" element.
* @param attributes The raw parsed attributes.
*/
- private void parseElementFont(final Attributes attributes) {
+ private void parseElementFont(final Attributes attributes) throws SAXException {
if (this.currentFontFamily == null) {
return;
}
- final String style = attributes.getValue("style");
- final String weight = attributes.getValue("weight");
- final String variant = attributes.getValue("variant");
- final String stretch = attributes.getValue("stretch");
- String simulateSmallCaps = attributes.getValue("simulate-small-caps");
- if (simulateSmallCaps == null) {
- /* Inherit the value from font-family. */
- simulateSmallCaps = this.currentSimulateSmallCaps;
- }
- final String simulateOblique = attributes.getValue("simulate-oblique");
- final String simulateBackslant = attributes.getValue(
- "simulate-backslant");
- String encodingName = attributes.getValue("encoding");
- if (encodingName == null) {
- /* Inherit the value from font-family. */
- encodingName = this.currentEncoding;
- }
- PsEncoding encoding = null;
- if (encodingName != null) {
- encoding = this.fontServer.getPsServer().getPredefinedEncoding(encodingName);
- }
- final String[] simulateStretch
- = new String[RegisteredFont.QTY_SIMULATED_STRETCH];
+ final String contentString = required(attributes, "content");
+ final String styleString = required(attributes, "style");
+ final String weightString = required(attributes, "weight");
+ final String variantString = optional(attributes, "variant", "normal");
+ final String stretchString = optional(attributes, "stretch", "normal");
+// final String simulateSmallCapsString =
+// optional(attributes, "simulate-small-caps", this.currentSimulateSmallCaps);
+// final String simulateObliqueString = optional(attributes, "simulate-oblique", "1");
+ final String encodingString = optional(attributes, "encoding", this.currentEncoding);
+
+ final RegisteredFontContent content = this.fontServer.getRegisteredFont(contentString);
+ final Font.Style style = Font.Style.parseFo(styleString);
+ final Font.Weight weight = Font.Weight.parseFo(weightString);
+ final Font.Variant variant = Font.Variant.parseFo(variantString);
+ final Font.Stretch stretch = Font.Stretch.parseFo(stretchString);
+// final float simulateOblique = Float.parseFloat(simulateObliqueString);
+// final String simulateBackslant = attributes.getValue("simulate-backslant");
+ final PsEncoding encoding = encodingString == null ? null :
+ this.fontServer.getPsServer().getPredefinedEncoding(encodingString);
+
+ final String[] simulateStretch = new String[RegisteredFont.QTY_SIMULATED_STRETCH];
simulateStretch[RegisteredFont.SIMULATE_ULTRA_CONDENSED_INDEX]
= attributes.getValue("simulate-ultra-condensed");
simulateStretch[RegisteredFont.SIMULATE_EXTRA_CONDENSED_INDEX]
@@ -412,17 +397,19 @@
= attributes.getValue("simulate-extra-expanded");
simulateStretch[RegisteredFont.SIMULATE_ULTRA_EXPANDED_INDEX]
= attributes.getValue("simulate-ultra-expanded");
- this.currentFontFamilyMember = new FontFamilyMember(
- encoding,
- style,
- weight,
- variant,
- stretch,
- simulateSmallCaps,
- simulateOblique,
- simulateBackslant,
- simulateStretch);
- this.fontIdCounter++;
+
+ final RegisteredFont font = new RegisteredFont(content, this.currentFontFamily, encoding, style, weight,
+ variant, stretch);
+
+ if (font.getRegisteredFont() == null) {
+ this.unresolvedFonts.add(font);
+ } else {
+ try {
+ this.currentFontFamily.registerFont(font);
+ } catch (final FontException e) {
+ throw new SAXException(e);
+ }
+ }
}
/**
@@ -430,8 +417,12 @@
* @param attributes The raw parsed attributes.
*/
private void parseElementFontContent(final Attributes attributes) {
+ final String fontID = attributes.getValue("id");
+ if (StringUtils.isNullOrEmpty(fontID)) {
+ errorMessage("Attribute \"id\" is required. Ignoring element.");
+ return;
+ }
final String fontFile = replaceParameters(attributes.getValue("font-file"));
- String fontID = attributes.getValue("id");
final String metricsFile = replaceParameters(attributes.getValue("metrics-file"));
final String collectionID = attributes.getValue("collection-id");
final String embedString = attributes.getValue("embed");
@@ -445,7 +436,7 @@
embed = Font.Embedding.valueOf(replaceParameters(embedString.toLowerCase()).toUpperCase());
}
final String systemName = attributes.getValue("system-name");
- String refID = attributes.getValue("ref");
+// String refID = attributes.getValue("ref");
URL fontFileSource = null;
if (fontFile != null) {
@@ -452,7 +443,7 @@
try {
fontFileSource = UrlFactory.createURL(this.currentXMLBase, fontFile);
} catch (final MalformedURLException e) {
- this.errorMessage("Malformed font file URL in font configuration: " + fontFile);
+ errorMessage("Malformed font file URL in font configuration: " + fontFile);
/* TODO: Just invalidate this one font and warn the user instead
* of invalidating everything. */
this.fontServer.setFatalConfigurationError(true);
@@ -465,7 +456,7 @@
try {
metricsFileSource = UrlFactory.createURL(this.currentXMLBase, metricsFile);
} catch (final MalformedURLException e) {
- this.errorMessage("Malformed metrics file URL in font configuration: " + metricsFile);
+ errorMessage("Malformed metrics file URL in font configuration: " + metricsFile);
/* TODO: Just invalidate this one font and warn the user instead
* of invalidating everything. */
this.fontServer.setFatalConfigurationError(true);
@@ -473,52 +464,18 @@
debugMessage("Metrics file: " + metricsFileSource.toExternalForm());
}
- /* TODO vh: check that if ref is declared, it is alone */
- if (this.currentFontFamilyMember == null) {
- return; // Font declared outside a family-member element
+ try {
+ this.fontServer.registerFont(fontID, fontFileSource, metricsFileSource, collectionID, embed, systemName);
+ } catch (final FontException e) {
+ this.errorMessage(e.getMessage());
+ return;
}
- if (refID == null || refID.equals("")) {
- if (fontID == null || fontID.equals("")) {
- final StringBuilder name = new StringBuilder(
- this.currentFontFamily.getName());
- if (this.currentFontFamilyMember.weight != null) {
- name.append(this.currentFontFamilyMember.weight);
- }
- if (this.currentFontFamilyMember.style != null) {
- name.append(this.currentFontFamilyMember.style);
- }
- name.append(this.fontIdCounter);
- fontID = name.toString();
- }
- try {
- this.fontServer.registerFont(fontID, fontFileSource,
- metricsFileSource, collectionID, embed, systemName);
- } catch (final FontException e) {
- this.errorMessage(e.getMessage());
- return;
- }
- refID = fontID;
- }
- final RegisteredFontContent registeredFont = this.fontServer.getRegisteredFont(
- refID);
+
+ final RegisteredFontContent registeredFont = this.fontServer.getRegisteredFont(fontID);
if (registeredFont == null) {
- warningMessage("Font is not registered: " + refID);
+ warningMessage("font-content is not registered: " + fontID);
return;
}
- try {
- this.currentFontFamily.registerFontDesc(registeredFont,
- this.currentFontFamilyMember.encoding,
- this.currentFontFamilyMember.style,
- this.currentFontFamilyMember.weight,
- this.currentFontFamilyMember.variant,
- this.currentFontFamilyMember.stretch,
- this.currentFontFamilyMember.simulateSmallCaps,
- this.currentFontFamilyMember.simulateOblique,
- this.currentFontFamilyMember.simulateBackslant,
- this.currentFontFamilyMember.simulateStretch);
- } catch (final FontException e) {
- warningMessage(e.getMessage());
- }
}
/**
@@ -550,33 +507,32 @@
}
@Override
- public void endElement(final String uri, final String localName,
- final String qName) {
- if (localName.equals("axsl-font-config")) {
+ public void endElement(final String uri, final String localName, final String qName) {
+ switch(localName) {
+ case "axsl-font-config": {
return;
}
- if (localName.equals("server")) {
+ case "server": {
configureRootAttributes();
return;
}
- if (localName.equals("font-content")) {
+ case "font-content": {
return;
}
- if (localName.equals("font-family")) {
- this.currentSimulateSmallCaps = null;
+ case "font-family": {
+// this.currentSimulateSmallCaps = null;
this.currentEncoding = null;
this.currentXMLBase = this.previousXMLBase;
this.currentEmbed = this.previousEmbed;
return;
}
- if (localName.equals("font")) {
- this.currentFontFamilyMember = null;
+ case "font": {
return;
}
- if (localName.equals("font-family-alias")) {
+ case "font-family-alias": {
return;
}
- if (localName.equals("font-group")) {
+ case "font-group": {
/* Pop the font-group stack. */
final FontGroup fontGroup = this.fontGroupStack.pop();
if (fontGroup != null) {
@@ -587,6 +543,8 @@
}
return;
}
+
+ }
}
/**
@@ -811,75 +769,6 @@
}
- /**
- * Inner class for storing font family members.
- */
- private final class FontFamilyMember {
-
- /** The encoding for this instance. */
- private final PsEncoding encoding;
-
- /** The style for this instance. */
- private final String style;
-
- /** The weight for this instance. */
- private final String weight;
-
- /** The variant value for this instance. */
- private final String variant;
-
- /** The stretch value for this instance. */
- private final String stretch;
-
- /** The "simulate-small-caps" value for this instance. */
- private final String simulateSmallCaps;
-
- /** The "simulate-oblique" value for this instance. */
- private final String simulateOblique;
-
- /** The "simulate-backslant" value for this instance. */
- private final String simulateBackslant;
-
- /** The "simulate-stretch" value for this instance. */
- private final String[] simulateStretch;
-
- /**
- * Constructor.
- * @param encoding The encoding for this instance.
- * @param style The style for this instance.
- * @param weight The weight for this instance.
- * @param variant The variant value for this instance.
- * @param stretch The stretch value for this instance.
- * @param simulateSmallCaps The "simulate-small-caps" value for this
- * instance.
- * @param simulateOblique The "simulate-oblique" value for this
- * instance.
- * @param simulateBackslant The "simulate-backslant" value for this
- * instance.
- * @param simulateStretch he "simulate-stretch" value for this instance.
- */
- private FontFamilyMember(
- final PsEncoding encoding,
- final String style,
- final String weight,
- final String variant,
- final String stretch,
- final String simulateSmallCaps,
- final String simulateOblique,
- final String simulateBackslant,
- final String[] simulateStretch) {
- this.encoding = encoding;
- this.style = style;
- this.weight = weight;
- this.variant = variant;
- this.stretch = stretch;
- this.simulateSmallCaps = simulateSmallCaps;
- this.simulateOblique = simulateOblique;
- this.simulateBackslant = simulateBackslant;
- this.simulateStretch = simulateStretch;
- }
- }
-
@Override
public void reset() {
throw new UnsupportedOperationException();
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-03-26 13:37:29 UTC (rev 12639)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-03-27 18:56:35 UTC (rev 12640)
@@ -80,7 +80,7 @@
* stretch bucket. */
public static final byte SIMULATE_ULTRA_EXPANDED_INDEX = 7;
- /** The parent RegisteredFont instance. */
+ /** The RegisteredFont instance. */
private RegisteredFontContent registeredFont;
/** The parent RegisteredFontFamily instance. */
@@ -147,7 +147,7 @@
}
/**
- * Construct a FontDescription instance.
+ * Constructor.
* @param rf The parent registered font.
* @param rff The parent registered font family.
* @param encoding The specified encoding.
@@ -156,10 +156,9 @@
* @param fontVariant The font variant (normal, small-caps)
* @param fontStretch The font stretch (normal, condensed, etc.)
*/
- public RegisteredFont(final RegisteredFontContent rf,
- final RegisteredFontFamily rff, final Encoding encoding,
- final Font.Style fontStyle, final Font.Weight fontWeight,
- final Font.Variant fontVariant, final Font.Stretch fontStretch) {
+ public RegisteredFont(final RegisteredFontContent rf, final RegisteredFontFamily rff, final Encoding encoding,
+ final Font.Style fontStyle, final Font.Weight fontWeight, final Font.Variant fontVariant,
+ final Font.Stretch fontStretch) {
this.registeredFont = rf;
this.registeredFontFamily = rff;
this.encoding = encoding;
@@ -169,6 +168,41 @@
this.fontStretch = fontStretch;
}
+// /**
+// * Factory method thatConstructor for unparsed characteristics.
+// * @param fontContent The font content for this font.
+// * @param encoding The encoding for the font description.
+// * @param style The style (normal, italic, etc.).
+// * @param weight The weight (normal, bold, 100, etc.).
+// * @param variant The variant (normal, small-caps).
+// * @param stretch The stretch (normal, condensed, etc.).
+// * @throws FontException For error in registration.
+// */
+// public RegisteredFont make(final RegisteredFontContent fontContent,
+// final Encoding encoding, final String style, final String weight,
+// final String variant, final String stretch)
+// throws FontException {
+// Font.Style fontStyle = Font.Style.parseFo(style, false);
+// if (fontStyle == null) {
+// fontStyle = Font.Style.NORMAL;
+// }
+// Font.Weight fontWeight = Font.Weight.parseFo(weight, false);
+// if (fontWeight == null) {
+// fontWeight = Font.Weight.NORMAL;
+// }
+// Font.Variant fontVariant = Font.Variant.parseFo(variant, false);
+// if (fontVariant == null) {
+// fontVariant = Font.Variant.NORMAL;
+// }
+// Font.Stretch fontStretch = Font.Stretch.parseFo(stretch, false);
+// if (fontStretch == null) {
+// fontStretch = Font.Stretch.NORMAL;
+// }
+// registerFontDesc(registeredFont, encoding, fontStyle, fontWeight,
+// fontVariant, fontStretch, simSmallCaps, simOblique,
+// simBackslant, simStretch);
+// }
+
/**
* Returns the font style.
* @return The font style.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java 2022-03-26 13:37:29 UTC (rev 12639)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java 2022-03-27 18:56:35 UTC (rev 12640)
@@ -32,8 +32,6 @@
import org.axsl.font.Font;
import org.axsl.font.FontException;
-import org.axsl.font.FontServer;
-import org.axsl.ps.Encoding;
import java.util.ArrayList;
import java.util.List;
@@ -46,25 +44,21 @@
*/
public class RegisteredFontFamily {
- /** The number of possible weight values during font selection, that is,
- * 9. */
+ /** The number of possible weight values during font selection, which is {@value}. */
private static final byte QTY_WEIGHT_VALUES = 9;
- /** The factor to be used when converting between a weight value (100, 200,
- * etc.) and the related index for such items. (0, 1, etc.). */
+ /** The factor to be used when converting between a weight value (100, 200, etc.) and the related index for such
+ * items, (0, 1, etc.). */
private static final byte WEIGHT_INDEX_FACTOR = 100;
/** The parent FOrayFontServer. */
private FontServer4a fontServer;
- /** The name of this font family, for example "Courier", as presented
- * in the font configuration. **/
+ /** The name of this font family, for example "Courier", as presented in the font configuration. **/
private String name;
- /** Collection of {@link RegisteredFont} instances that are associated
- * with this family. */
- private List<RegisteredFont> fontDescriptions
- = new ArrayList<RegisteredFont>();
+ /** Collection of {@link RegisteredFont} instances that are associated with this family. */
+ private List<RegisteredFont> fontDescriptions = new ArrayList<RegisteredFont>();
/**
* Constructor.
@@ -71,8 +65,7 @@
* @param fontServer The parent font server.
* @param name The name of this font family (e.g. "Courier").
*/
- public RegisteredFontFamily(final FontServer4a fontServer,
- final String name) {
+ public RegisteredFontFamily(final FontServer4a fontServer, final String name) {
this.fontServer = fontServer;
this.name = name;
}
@@ -86,114 +79,42 @@
}
/**
- * Maps a font-description to a RegisteredFont for this font-family.
- * @param registeredFont the RegisteredFont that should be supplied when
- * a font matching this description is requested.
- * @param encoding The encoding for the font description.
- * @param style The style (normal, italic, etc.).
- * @param weight The weight (normal, bold, 100, etc.).
- * @param variant The variant (normal, small-caps).
- * @param stretch The stretch (normal, condensed, etc.).
- * @param simulatedSmallCaps A percentage.
- * @param simulatedOblique A number of degrees.
- * @param simulatedBackslant A number of degrees.
- * @param simulatedStretch A percentage.
- * @throws FontException For error in registration.
+ * Register the description of a font with this family.
+ * @param font The font to be registered.
+ * @throws FontException For a font that is missing required parameters, and for the case of an already registered
+ * font having the same characteristics.
*/
- public void registerFontDesc(final RegisteredFontContent registeredFont,
- final Encoding encoding, final String style, final String weight,
- final String variant, final String stretch,
- final String simulatedSmallCaps, final String simulatedOblique,
- final String simulatedBackslant, final String[] simulatedStretch)
- throws FontException {
- Font.Style fontStyle = Font.Style.parseFo(style, false);
- if (fontStyle == null) {
- fontStyle = Font.Style.NORMAL;
+ public void registerFont(final RegisteredFont font) throws FontException {
+ /* Check basic completeness. */
+ if (font.getRegisteredFont() == null) {
+ throw new FontException(RegisteredFontContent.class.getName() + " is required.");
}
- Font.Weight fontWeight = Font.Weight.parseFo(weight, false);
- if (fontWeight == null) {
- fontWeight = Font.Weight.NORMAL;
+ if (font.getFontStyle() == null) {
+ throw new FontException(Font.Style.class.getName() + " is required.");
}
- Font.Variant fontVariant = Font.Variant.parseFo(variant, false);
- if (fontVariant == null) {
- fontVariant = Font.Variant.NORMAL;
+ if (font.getFontWeight() == null) {
+ throw new FontException(Font.Weight.class.getName() + " is required.");
}
- Font.Stretch fontStretch = Font.Stretch.parseFo(stretch, false);
- if (fontStretch == null) {
- fontStretch = Font.Stretch.NORMAL;
+ if (font.getFontVariant() == null) {
+ throw new FontException(Font.Variant.class.getName() + " is required.");
}
- final float simSmallCaps;
- if ("native".equals(simulatedSmallCaps)) {
- simSmallCaps = FontServer.SMALL_CAP_SIMULATION_NATIVE;
- } else {
- simSmallCaps = convertPercent(simulatedSmallCaps,
- FontServer.SMALL_CAP_SIMULATION_INVALID);
+ if (font.getFontStretch() == null) {
+ throw new FontException(Font.Stretch.class.getName() + " is required.");
}
- final float simOblique = convertPercent(simulatedOblique,
- FontServer.OBLIQUE_SIMULATION_INVALID);
- final float simBackslant = convertPercent(simulatedBackslant,
- FontServer.OBLIQUE_SIMULATION_INVALID);
- final float[] simStretch
- = new float[RegisteredFont.QTY_SIMULATED_STRETCH];
- for (int i = 0; i < simStretch.length; i++) {
- simStretch[i] = FontServer.STRETCH_SIMULATION_INVALID;
- }
- if (simulatedStretch != null) {
- for (int i = 0; i < simStretch.length; i++) {
- if (i < simulatedStretch.length) {
- simStretch[i] = convertPercent(simulatedStretch[i],
- FontServer.STRETCH_SIMULATION_INVALID);
- }
+
+ /* Check for match with fonts already registered. */
+ for (int index = 0; index < this.fontDescriptions.size(); index ++) {
+ final RegisteredFont existingFont = this.fontDescriptions.get(index);
+ if (existingFont.equivalent(font)) {
+ final String template = "Equivalent font-description already exists in font-family {}: " +
+ "font-style {}, font-weight {}";
+ final String message = String.format(template, this.name, font.getFontStyle().getFoValue(),
+ font.getFontWeight().getFoValue());
+ throw new FontException(message);
}
}
- registerFontDesc(registeredFont, encoding, fontStyle, fontWeight,
- fontVariant, fontStretch, simSmallCaps, simOblique,
- simBackslant, simStretch);
- }
- /**
- * Maps a font-description to a RegisteredFont for this font-family.
- * @param registeredFont the RegisteredFont that should be supplied when
- * a font matching this description is requested.
- * @param encoding The encoding for the font description.
- * @param style The style (normal, italic, etc.).
- * @param weight The weight (normal, bold, 100, etc.).
- * @param variant The variant (normal, small-caps).
- * @param stretch The stretch (normal, condensed, etc.).
- * @param simulatedSmallCaps A percentage.
- * @param simulatedOblique A number of degrees.
- * @param simulatedBackslant A number of degrees.
- * @param simulatedStretch A percentage.
- * @throws FontException For error in registration.
- */
- public void registerFontDesc(final RegisteredFontContent registeredFont,
- final Encoding encoding, final Font.Style style,
- final Font.Weight weight,
- final Font.Variant variant, final Font.Stretch stretch,
- final float simulatedSmallCaps, final float simulatedOblique,
- final float simulatedBackslant, final float[] simulatedStretch)
- throws FontException {
- final RegisteredFont description = new RegisteredFont(
- registeredFont, this, encoding, style, weight, variant,
- stretch);
- description.setSimulateSmallCaps(simulatedSmallCaps);
- description.setSimulateOblique(simulatedOblique);
- description.setSimulateBackslant(simulatedBackslant);
- description.setSimulateStretch(simulatedStretch);
- for (int i = 0; i < this.fontDescriptions.size(); i++) {
- final RegisteredFont registeredDesc
- = this.fontDescriptions.get(i);
- if (description.equivalent(registeredDesc)) {
- throw new FontException("Equivalent font-description "
- + "already exists in font-family \""
- + this.name + "\":\n"
- + "font-style "
- + description.getFontStyle().getFoValue()
- + " font-weight "
- + weight.toString());
- }
- }
- this.fontDescriptions.add(description);
+ this.fontDescriptions.add(font);
}
/**
Modified: trunk/foray/foray-font/src/test/resources/font-config.xml
===================================================================
--- trunk/foray/foray-font/src/test/resources/font-config.xml 2022-03-26 13:37:29 UTC (rev 12639)
+++ trunk/foray/foray-font/src/test/resources/font-config.xml 2022-03-27 18:56:35 UTC (rev 12640)
@@ -3,8 +3,12 @@
PUBLIC "-//aXSL//DTD Font Configuration V0.1//EN"
"http://www.axsl.org/dtds/0.1/en/axsl-font-config.dtd">
-<!-- This file is a sample aXSL font configuration file. -->
+<!--
+This file is a sample aXSL font configuration file.
+Note that the PDF Base-14 fonts are automatically registered by FOray, and do not need to be included in this file.
+-->
+
<axsl-font-config embed="all" xml:base="file:///src/test/resources/">
<server setup-free-standing-fonts="true"
Modified: trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxParser.java
===================================================================
--- trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxParser.java 2022-03-26 13:37:29 UTC (rev 12639)
+++ trunk/foray/foray-xml/src/main/java/org/foray/xml/SaxParser.java 2022-03-27 18:56:35 UTC (rev 12640)
@@ -32,6 +32,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
@@ -108,8 +109,7 @@
* @throws ParserConfigurationException For errors during parser configuration.
* @throws SAXException For errors found by the SAX parser.
*/
- public T parse(final URL input)
- throws IOException, ParserConfigurationException, SAXException {
+ public T parse(final URL input) throws IOException, ParserConfigurationException, SAXException {
final InputSource inputSource = new InputSource(input.toExternalForm());
return parse(inputSource);
}
@@ -383,4 +383,31 @@
this.textParsingActive = isActive;
}
+ /**
+ * Retrieves a given required attribute, throwing a {@link SAXException} if it is missing.
+ * @param attributes The attributes collection in which we expect to find the requested attribute.
+ * @param attributeName The name of the attribute to be retrieved.
+ * @return The attribute value, if it is found.
+ * @throws SAXException If the attribute is not found.
+ */
+ public String required(final Attributes attributes, final String attributeName) throws SAXException {
+ final String attributeValue = attributes.getValue(attributeName);
+ if (attributeValue == null) {
+ throw new SAXException();
+ }
+ return attributeValue;
+ }
+
+ /**
+ * Retrieves a given optional attribute, returning a provided default value if it is missing.
+ * @param attributes The attributes collection in which we expect to find the requested attribute.
+ * @param attributeName The name of the attribute to be retrieved.
+ * @param defaultValue The value to be returned if the attribute is not found.
+ * @return The attribute value, if it is found, otherwise {@code defaultValue}.
+ */
+ public String optional(final Attributes attributes, final String attributeName, final String defaultValue) {
+ final String attributeValue = attributes.getValue(attributeName);
+ return attributeValue == null ? defaultValue : attributeValue;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-03-26 13:37:32
|
Revision: 12639
http://sourceforge.net/p/foray/code/12639
Author: victormote
Date: 2022-03-26 13:37:29 +0000 (Sat, 26 Mar 2022)
Log Message:
-----------
Remove unnecessary throws during font selection.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontSelectorCbc.java
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-03-26 13:20:48 UTC (rev 12638)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java 2022-03-26 13:37:29 UTC (rev 12639)
@@ -228,12 +228,8 @@
final Font.Weight weight, final Font.Variant variant,
final Font.Stretch stretch, final int size, final int codePoint) {
final FontSelector selector = getFontSelector(selectionStrategy);
- final RegisteredFont fontDescSelected;
- try {
- fontDescSelected = selector.selectFont(familyList, style, weight, variant, stretch, size, codePoint);
- } catch (final FontException e) {
- return null;
- }
+ final RegisteredFont fontDescSelected = selector.selectFont(familyList, style, weight, variant, stretch, size,
+ codePoint);
if (fontDescSelected == null) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < familyList.size(); i++) {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java 2022-03-26 13:20:48 UTC (rev 12638)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java 2022-03-26 13:37:29 UTC (rev 12639)
@@ -31,7 +31,6 @@
import org.foray.font.config.RegisteredFont;
import org.axsl.font.Font;
-import org.axsl.font.FontException;
import java.util.List;
@@ -60,17 +59,13 @@
* @param weight The font weight (100, 200, normal, bold, etc.).
* @param variant The font variant (normal, small-caps).
* @param stretch The font stretch (normal, condensed, etc.).
- * @param size The font size, in millipoints. This is used only for
- * bitmapped fonts.
- * @param codePoint The Unicode code point which must be encodable by the
- * selected font.
- * @return The best registered font description matching the selection
- * criteria.
- * @throws FontException For invalid input.
+ * @param size The font size, in millipoints.
+ * This is used only for bitmapped fonts.
+ * @param codePoint The Unicode code point which must be encodable by the selected font.
+ * @return The best registered font description matching the selection criteria.
*/
- public abstract RegisteredFont selectFont(List<String> familyList,
- Font.Style style, Font.Weight weight, Font.Variant variant,
- Font.Stretch stretch, int size, int codePoint) throws FontException;
+ public abstract RegisteredFont selectFont(List<String> familyList, Font.Style style, Font.Weight weight,
+ Font.Variant variant, Font.Stretch stretch, int size, int codePoint);
/**
* Returns the parent font consumer instance.
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-03-26 13:20:48 UTC (rev 12638)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontSelectorCbc.java 2022-03-26 13:37:29 UTC (rev 12639)
@@ -32,7 +32,6 @@
import org.foray.font.config.RegisteredFontFamily;
import org.axsl.font.Font;
-import org.axsl.font.FontException;
import org.axsl.font.FontSelectionConstraints;
import java.util.List;
@@ -51,8 +50,7 @@
/**
* Constructor.
- * @param consumer The font consumer for whom this selector is being
- * created.
+ * @param consumer The font consumer for whom this selector is being created.
*/
public FontSelectorCbc(final FontConsumer4a consumer) {
super(consumer);
@@ -59,57 +57,51 @@
}
@Override
- public RegisteredFont selectFont(final List<String> familyList,
- final Font.Style style, final Font.Weight weight,
- final Font.Variant variant, final Font.Stretch stretch,
- final int size, final int codePoint) throws FontException {
+ public RegisteredFont selectFont(final List<String> familyList, final Font.Style style, final Font.Weight weight,
+ final Font.Variant variant, final Font.Stretch stretch, final int size, final int codePoint) {
Font4a fontSelected = null;
RegisteredFont fontDescSelected = null;
- if (familyList != null) {
- for (int i = 0; i < familyList.size(); i++) {
- final String familyToUse = familyList.get(i);
- fontDescSelected = selectFont(familyToUse, style, weight,
- variant, stretch, size);
- /* Skip this font-family if it doesn't have a font that fits. */
- if (fontDescSelected == null) {
- continue;
- }
- /* Use the SystemFont or FreeStandingFont? */
- fontSelected = this.getConsumer().whichUse(fontDescSelected,
- codePoint);
- /* Skip this font-family if we can't use the type of font it
- * supports or if it can't encode the character. */
- if (fontSelected == null) {
- continue;
- }
- /* Otherwise, this one works. */
- return fontDescSelected;
+ if (familyList == null) {
+ return null;
+ }
+ for (int i = 0; i < familyList.size(); i++) {
+ final String familyToUse = familyList.get(i);
+ fontDescSelected = selectFont(familyToUse, style, weight, variant, stretch, size);
+ /* Skip this font-family if it doesn't have a font that fits. */
+ if (fontDescSelected == null) {
+ continue;
}
+ /* Use the SystemFont or FreeStandingFont? */
+ fontSelected = this.getConsumer().whichUse(fontDescSelected, codePoint);
+ /* Skip this font-family if we can't use the type of font it supports or if it can't encode the
+ * character. */
+ if (fontSelected == null) {
+ continue;
+ }
+ /* Otherwise, this one works. */
+ return fontDescSelected;
}
return null;
}
/**
- * Tries to select a font from a specifid font-family.
+ * Tries to select a font from a specified font-family.
* @param familyToTry The font family currently being tested.
* @param style The font style (normal, italic, etc.).
* @param weight The font weight (100, 200, normal, bold, etc.).
* @param variant The font variant (normal, small-caps).
* @param stretch The font stretch (normal, condensed, etc.).
- * @param size The font size, in millipoints. This is used only for
- * bitmapped fonts.
- * @return The registered font description matching the selection criteria,
- * or null if there is none.
+ * @param size The font size, in millipoints.
+ * This is used only for bitmapped fonts.
+ * @return The {@link RegisteredFont} matching the selection criteria, or null if there is none.
*/
- private RegisteredFont selectFont(final String familyToTry,
- final Font.Style style, final Font.Weight weight,
- final Font.Variant variant, final Font.Stretch stretch,
- final int size) {
+ private RegisteredFont selectFont(final String familyToTry, final Font.Style style, final Font.Weight weight,
+ final Font.Variant variant, final Font.Stretch stretch, final int size) {
if (familyToTry == null) {
return null;
}
RegisteredFontFamily rff = null;
- rff = getFontServer().getRegisteredFontFamily(familyToTry);
+ rff = this.getConsumer().getFontServer().getRegisteredFontFamily(familyToTry);
if (rff == null) {
return null;
}
@@ -119,12 +111,4 @@
constraints.canSelectSystemFonts());
}
- /**
- * Returns the font server.
- * @return The font server.
- */
- public FontServer4a getFontServer() {
- return this.getConsumer().getFontServer();
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-03-26 13:20:51
|
Revision: 12638
http://sourceforge.net/p/foray/code/12638
Author: victormote
Date: 2022-03-26 13:20:48 +0000 (Sat, 26 Mar 2022)
Log Message:
-----------
Rename RegisteredFontFamilyMember to RegisteredFont, for clarity, and to match XML configuration.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.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/FontUse4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/package-info.java
trunk/foray/foray-pdf/src/test/java/org/foray/pdf/object/PdfDocumentTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamilyMember.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2022-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -28,7 +28,7 @@
package org.foray.font;
-import org.foray.font.config.RegisteredFontFamilyMember;
+import org.foray.font.config.RegisteredFont;
import org.axsl.ps.Encoding;
import org.axsl.ps.PsEncoding;
@@ -163,7 +163,7 @@
* returned font use.
* @return The best font use.
*/
- public FontUse4a selectFontUse(final RegisteredFontFamilyMember rfd, final int codePoint) {
+ public FontUse4a selectFontUse(final RegisteredFont rfd, final int codePoint) {
if (rfd == null) {
return null;
}
@@ -218,7 +218,7 @@
* or created.
* @return The selected or created font use.
*/
- public FontUse4a getFontUse(final RegisteredFontFamilyMember rfd,
+ public FontUse4a getFontUse(final RegisteredFont rfd,
final Encoding encoding) {
for (int i = 0; i < this.fontUses.size(); i++) {
final FontUse4a fontUse = this.fontUses.get(i);
@@ -239,7 +239,7 @@
* @param codePoint The Unicode code point.
* @return The appropriate encoding.
*/
- public Encoding findEncoding(final RegisteredFontFamilyMember rfd,
+ public Encoding findEncoding(final RegisteredFont rfd,
final int codePoint) {
switch (this.consumer.getEncodingLatitude()) {
case FontConsumer4a.ENCODING_SPECIFIED_ONLY: {
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-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -29,9 +29,9 @@
package org.foray.font;
import org.foray.common.FontSelectionConstraints4a;
+import org.foray.font.config.RegisteredFont;
import org.foray.font.config.RegisteredFontContent;
import org.foray.font.config.RegisteredFontFamily;
-import org.foray.font.config.RegisteredFontFamilyMember;
import org.foray.font.format.Panose4a;
import org.axsl.font.Font;
@@ -67,7 +67,7 @@
/**
* Constant indicating that only the encoding specified in the
- * {@link RegisteredFontFamilyMember} (from the font-configuration) should be used
+ * {@link RegisteredFont} (from the font-configuration) should be used
* during the font selection process.
*/
public static final byte ENCODING_SPECIFIED_ONLY = 2;
@@ -228,7 +228,7 @@
final Font.Weight weight, final Font.Variant variant,
final Font.Stretch stretch, final int size, final int codePoint) {
final FontSelector selector = getFontSelector(selectionStrategy);
- final RegisteredFontFamilyMember fontDescSelected;
+ final RegisteredFont fontDescSelected;
try {
fontDescSelected = selector.selectFont(familyList, style, weight, variant, stretch, size, codePoint);
} catch (final FontException e) {
@@ -262,7 +262,7 @@
* @return The FontUse that should be used.
* @throws FontException For errors in font selection.
*/
- private org.axsl.font.FontUse getFontUse(final RegisteredFontFamilyMember fontDescSelected, final int codePoint)
+ private org.axsl.font.FontUse getFontUse(final RegisteredFont fontDescSelected, final int codePoint)
throws FontException {
Font4a fontSelected = null;
if (fontDescSelected != null) {
@@ -292,7 +292,7 @@
@Override
public FontUse4a selectFontFallback() {
- final RegisteredFontFamilyMember fontDescSelected = selectDefaultFont();
+ final RegisteredFont fontDescSelected = selectDefaultFont();
if (fontDescSelected == null) {
return null;
}
@@ -310,7 +310,7 @@
}
/**
- * <p>Since {@link RegisteredFontContent} and {@link RegisteredFontFamilyMember} instances
+ * <p>Since {@link RegisteredFontContent} and {@link RegisteredFont} instances
* can encapsulate either a FreeStandingFont or a SystemFont, or both,
* this method selects which one should be used, based on the FontConsumer
* instances parameters.</p>
@@ -328,7 +328,7 @@
* that it can be encoded.
* @return The FontUse instance dictated by the parameters of consumer.
*/
- protected Font4a whichUse(final RegisteredFontFamilyMember rfd,
+ protected Font4a whichUse(final RegisteredFont rfd,
final int codePoint) {
final RegisteredFontContent rf = rfd.getRegisteredFont();
@@ -366,7 +366,7 @@
* eligible, or null otherwise.
*/
private FreeStandingFont eligibleFreeStandingFont(
- final RegisteredFontFamilyMember rfd, final int codePoint) {
+ final RegisteredFont rfd, final int codePoint) {
if (! this.selectionConstraints.canSelectFreeStandingFonts()) {
return null;
}
@@ -414,8 +414,8 @@
* Returns the default font.
* @return The default font.
*/
- private RegisteredFontFamilyMember selectDefaultFont() {
- RegisteredFontFamilyMember defaultFont = null;
+ private RegisteredFont selectDefaultFont() {
+ RegisteredFont defaultFont = null;
if (this.selectionConstraints.canSelectFreeStandingFonts()) {
defaultFont = this.server.getDefaultFreeStandingFont();
}
@@ -564,11 +564,11 @@
} catch (final FontException e) {
return null;
}
- RegisteredFontFamilyMember bestFit = null;
+ RegisteredFont bestFit = null;
long bestDifference = Long.MAX_VALUE;
for (RegisteredFontFamily rff : this.server.registeredFontFamilies()) {
for (int i = 0; i < rff.getFontDescriptions().size(); i++) {
- final RegisteredFontFamilyMember rfd = rff.getFontDescriptions().get(i);
+ final RegisteredFont rfd = rff.getFontDescriptions().get(i);
final Panose4a panoseInstance = rfd.getRegisteredFont()
.getPanose();
final long difference = panoseInstance.difference(desiredPanose, null);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java 2022-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontSelector.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -28,7 +28,7 @@
package org.foray.font;
-import org.foray.font.config.RegisteredFontFamilyMember;
+import org.foray.font.config.RegisteredFont;
import org.axsl.font.Font;
import org.axsl.font.FontException;
@@ -68,7 +68,7 @@
* criteria.
* @throws FontException For invalid input.
*/
- public abstract RegisteredFontFamilyMember selectFont(List<String> familyList,
+ public abstract RegisteredFont selectFont(List<String> familyList,
Font.Style style, Font.Weight weight, Font.Variant variant,
Font.Stretch stretch, int size, int codePoint) throws FontException;
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-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontSelectorCbc.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -28,8 +28,8 @@
package org.foray.font;
+import org.foray.font.config.RegisteredFont;
import org.foray.font.config.RegisteredFontFamily;
-import org.foray.font.config.RegisteredFontFamilyMember;
import org.axsl.font.Font;
import org.axsl.font.FontException;
@@ -59,12 +59,12 @@
}
@Override
- public RegisteredFontFamilyMember selectFont(final List<String> familyList,
+ public RegisteredFont selectFont(final List<String> familyList,
final Font.Style style, final Font.Weight weight,
final Font.Variant variant, final Font.Stretch stretch,
final int size, final int codePoint) throws FontException {
Font4a fontSelected = null;
- RegisteredFontFamilyMember fontDescSelected = null;
+ RegisteredFont fontDescSelected = null;
if (familyList != null) {
for (int i = 0; i < familyList.size(); i++) {
final String familyToUse = familyList.get(i);
@@ -101,7 +101,7 @@
* @return The registered font description matching the selection criteria,
* or null if there is none.
*/
- private RegisteredFontFamilyMember selectFont(final String familyToTry,
+ private RegisteredFont selectFont(final String familyToTry,
final Font.Style style, final Font.Weight weight,
final Font.Variant variant, final Font.Stretch stretch,
final int size) {
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-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -31,9 +31,9 @@
import org.foray.common.Environment;
import org.foray.common.url.classpath.Handler;
import org.foray.font.config.FontConfigParser;
+import org.foray.font.config.RegisteredFont;
import org.foray.font.config.RegisteredFontContent;
import org.foray.font.config.RegisteredFontFamily;
-import org.foray.font.config.RegisteredFontFamilyMember;
import org.foray.font.format.FontParserClient;
import org.axsl.font.FontException;
@@ -132,11 +132,11 @@
/** This is the FreeStandingFont that should be used when a FreeStandingFont
* is required and all other fallback options fail. */
- private RegisteredFontFamilyMember defaultFreeStandingFont = null;
+ private RegisteredFont defaultFreeStandingFont = null;
/** This is the SystemFont that should be used when a SystemFont
* is required and all other fallback options fail. */
- private RegisteredFontFamilyMember defaultSystemFont = null;
+ private RegisteredFont defaultSystemFont = null;
/** An EntityResolver to be used by XML parsers (for handling DTD catalogs,
* etc.). */
@@ -201,7 +201,7 @@
* Returns the fallback free-standing font when no other font can be used.
* @return The fallback free-standing font.
*/
- public RegisteredFontFamilyMember getDefaultFreeStandingFont() {
+ public RegisteredFont getDefaultFreeStandingFont() {
if (this.defaultFreeStandingFont != null) {
return this.defaultFreeStandingFont;
}
@@ -217,7 +217,7 @@
* Returns the fallback system font when no other font can be used.
* @return The fallback system font.
*/
- protected RegisteredFontFamilyMember getDefaultSystemFont() {
+ protected RegisteredFont getDefaultSystemFont() {
if (this.defaultSystemFont != null) {
return this.defaultSystemFont;
}
@@ -245,9 +245,9 @@
* sought or system fonts (mutually exclusive).
* @return A default registered font description.
*/
- protected RegisteredFontFamilyMember getDefaultFont(
+ protected RegisteredFont getDefaultFont(
final boolean freeStandingFont) {
- RegisteredFontFamilyMember defaultFont = null;
+ RegisteredFont defaultFont = null;
final RegisteredFontFamily rff = getRegisteredFontFamily("any");
if (rff != null) {
/* Try to find one with normal characteristics. */
@@ -661,7 +661,7 @@
= org.axsl.font.Font.Variant.NORMAL;
final org.axsl.font.Font.Stretch fontStretch
= org.axsl.font.Font.Stretch.NORMAL;
- new RegisteredFontFamilyMember(rf, rff, null, fontStyle, fontWeight,
+ new RegisteredFont(rf, rff, null, fontStyle, fontWeight,
fontVariant, fontStretch);
try {
rff.registerFontDesc(rf,
@@ -864,11 +864,11 @@
public List<Font4a> getAllFonts(final boolean freeStandingFonts, final boolean systemFonts) {
final List<Font4a> fontList = new ArrayList<Font4a>();
for (RegisteredFontFamily family : this.fontFamilies.values()) {
- final List<RegisteredFontFamilyMember> rfdList
+ final List<RegisteredFont> rfdList
= family.getFontDescriptions();
if (rfdList != null) {
for (int i = 0; i < rfdList.size(); i++) {
- final RegisteredFontFamilyMember rfd = rfdList.get(i);
+ final RegisteredFont rfd = rfdList.get(i);
final RegisteredFontContent rf = rfd.getRegisteredFont();
if (freeStandingFonts
&& rf.getFreeStandingFont() != null) {
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 2022-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -33,7 +33,7 @@
import org.foray.common.primitive.UnicodeCharUtils;
import org.foray.common.sequence.ByteArray;
import org.foray.common.sequence.IntArrayBuilder;
-import org.foray.font.config.RegisteredFontFamilyMember;
+import org.foray.font.config.RegisteredFont;
import org.foray.font.format.ttf.TrueTypeFont;
import org.foray.font.format.ttf.TtfTableGsub;
import org.foray.font.format.type1.Type1Font;
@@ -83,7 +83,7 @@
private Encoding encoding;
/** The encapsulated registeredFontDesc. */
- private RegisteredFontFamilyMember registeredFontDesc;
+ private RegisteredFont registeredFontDesc;
/** Indicates whether this has been used at all. */
private boolean anyCharsUsed = false;
@@ -95,7 +95,7 @@
* @param encoding The specific encoding for this font use.
*/
public FontUse4a(final ConsumerFont4a consumerFont,
- final RegisteredFontFamilyMember rfd, final Encoding encoding) {
+ final RegisteredFont rfd, final Encoding encoding) {
this.consumerFont = consumerFont;
this.registeredFontDesc = rfd;
this.encoding = encoding;
@@ -219,7 +219,7 @@
@Override
public Font.Weight nextBolderWeight() {
- final RegisteredFontFamilyMember desc =
+ final RegisteredFont desc =
this.registeredFontDesc.nextBolderFont();
if (desc != null) {
return desc.getFontWeight();
@@ -229,7 +229,7 @@
@Override
public Font.Weight nextLighterWeight() {
- final RegisteredFontFamilyMember desc =
+ final RegisteredFont desc =
this.registeredFontDesc.nextLighterFont();
if (desc != null) {
return desc.getFontWeight();
@@ -239,7 +239,7 @@
@Override
public org.axsl.font.FontUse nextBolderFont() {
- final RegisteredFontFamilyMember desc =
+ final RegisteredFont desc =
this.registeredFontDesc.nextBolderFont();
return fontUseForDesc(desc);
}
@@ -246,7 +246,7 @@
@Override
public org.axsl.font.FontUse nextLighterFont() {
- final RegisteredFontFamilyMember desc =
+ final RegisteredFont desc =
this.registeredFontDesc.nextLighterFont();
return fontUseForDesc(desc);
}
@@ -253,13 +253,13 @@
/**
* Finds the FontUse instance that should be used for a given
- * {@link RegisteredFontFamilyMember} instance.
+ * {@link RegisteredFont} instance.
* @param desc The registered font description for which a FontUse is
* needed.
* @return The appropriate FontUse instance.
*/
private org.axsl.font.FontUse fontUseForDesc(
- final RegisteredFontFamilyMember desc) {
+ final RegisteredFont desc) {
if (desc == null) {
return null;
}
@@ -464,7 +464,7 @@
* Returns the parent registered font description.
* @return The parent registered font description.
*/
- public RegisteredFontFamilyMember getRegisteredFontDesc() {
+ public RegisteredFont getRegisteredFontDesc() {
return this.registeredFontDesc;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -395,22 +395,22 @@
encoding = this.fontServer.getPsServer().getPredefinedEncoding(encodingName);
}
final String[] simulateStretch
- = new String[RegisteredFontFamilyMember.QTY_SIMULATED_STRETCH];
- simulateStretch[RegisteredFontFamilyMember.SIMULATE_ULTRA_CONDENSED_INDEX]
+ = new String[RegisteredFont.QTY_SIMULATED_STRETCH];
+ simulateStretch[RegisteredFont.SIMULATE_ULTRA_CONDENSED_INDEX]
= attributes.getValue("simulate-ultra-condensed");
- simulateStretch[RegisteredFontFamilyMember.SIMULATE_EXTRA_CONDENSED_INDEX]
+ simulateStretch[RegisteredFont.SIMULATE_EXTRA_CONDENSED_INDEX]
= attributes.getValue("simulate-extra-condensed");
- simulateStretch[RegisteredFontFamilyMember.SIMULATE_CONDENSED_INDEX]
+ simulateStretch[RegisteredFont.SIMULATE_CONDENSED_INDEX]
= attributes.getValue("simulate-condensed");
- simulateStretch[RegisteredFontFamilyMember.SIMULATE_SEMI_CONDENSED_INDEX]
+ simulateStretch[RegisteredFont.SIMULATE_SEMI_CONDENSED_INDEX]
= attributes.getValue("simulate-semi-condensed");
- simulateStretch[RegisteredFontFamilyMember.SIMULATE_SEMI_EXPANDED_INDEX]
+ simulateStretch[RegisteredFont.SIMULATE_SEMI_EXPANDED_INDEX]
= attributes.getValue("simulate-semi-expanded");
- simulateStretch[RegisteredFontFamilyMember.SIMULATE_EXPANDED_INDEX]
+ simulateStretch[RegisteredFont.SIMULATE_EXPANDED_INDEX]
= attributes.getValue("simulate-expanded");
- simulateStretch[RegisteredFontFamilyMember.SIMULATE_EXTRA_EXPANDED_INDEX]
+ simulateStretch[RegisteredFont.SIMULATE_EXTRA_EXPANDED_INDEX]
= attributes.getValue("simulate-extra-expanded");
- simulateStretch[RegisteredFontFamilyMember.SIMULATE_ULTRA_EXPANDED_INDEX]
+ simulateStretch[RegisteredFont.SIMULATE_ULTRA_EXPANDED_INDEX]
= attributes.getValue("simulate-ultra-expanded");
this.currentFontFamilyMember = new FontFamilyMember(
encoding,
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java (from rev 12637, trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamilyMember.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -0,0 +1,801 @@
+/*
+ * Copyright 2005 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.config;
+
+import org.foray.common.WellKnownConstants;
+import org.foray.font.Font4a;
+
+import org.axsl.font.Font;
+import org.axsl.font.FontServer;
+import org.axsl.ps.Encoding;
+
+/**
+ * <p>Binds a set of user font-selection criteria to a {@link RegisteredFontContent} instance, as configured in the
+ * "font" element in the font-configuration XML.
+ * This is used primarily in font resolution, where the characteristics of the {@link RegisteredFont} are compared to
+ * those requested by the font selection process.
+ * A {@link RegisteredFont} instance operates within a {@link RegisteredFontFamily}, which provides the context in which
+ * it can be selected.</p>
+ */
+public class RegisteredFont {
+
+ /** Constant indicating the number of simulated "stretch" components. */
+ public static final byte QTY_SIMULATED_STRETCH = 8;
+
+ /** Constant indicating the index for the "ultra-condensed" simulated
+ * stretch bucket. */
+ public static final byte SIMULATE_ULTRA_CONDENSED_INDEX = 0;
+
+ /** Constant indicating the index for the "extra-condensed" simulated
+ * stretch bucket. */
+ public static final byte SIMULATE_EXTRA_CONDENSED_INDEX = 1;
+
+ /** Constant indicating the index for the "condensed" simulated
+ * stretch bucket. */
+ public static final byte SIMULATE_CONDENSED_INDEX = 2;
+
+ /** Constant indicating the index for the "semi-condensed" simulated
+ * stretch bucket. */
+ public static final byte SIMULATE_SEMI_CONDENSED_INDEX = 3;
+
+ /** Constant indicating the index for the "semi-expanded" simulated
+ * stretch bucket. */
+ public static final byte SIMULATE_SEMI_EXPANDED_INDEX = 4;
+
+ /** Constant indicating the index for the "expanded" simulated
+ * stretch bucket. */
+ public static final byte SIMULATE_EXPANDED_INDEX = 5;
+
+ /** Constant indicating the index for the "extra-expanded" simulated
+ * stretch bucket. */
+ public static final byte SIMULATE_EXTRA_EXPANDED_INDEX = 6;
+
+ /** Constant indicating the index for the "ultra-expanded" simulated
+ * stretch bucket. */
+ public static final byte SIMULATE_ULTRA_EXPANDED_INDEX = 7;
+
+ /** The parent RegisteredFont instance. */
+ private RegisteredFontContent registeredFont;
+
+ /** The parent RegisteredFontFamily instance. */
+ private RegisteredFontFamily registeredFontFamily;
+
+ /** The encoding to be used. */
+ private Encoding encoding;
+
+ /** The style of this description. */
+ private Font.Style fontStyle;
+
+ /** The weight of this description. */
+ private Font.Weight fontWeight;
+
+ /** The variant value of this description. */
+ private Font.Variant fontVariant;
+
+ /** The stretch value of this description. */
+ private Font.Stretch fontStretch;
+
+ /**
+ * Percentage that should be applied to the standard font size to obtain
+ * the font size to be used for simulating small caps.
+ * A typical amount might be 80%.
+ * Invalid or unset amounts are indicated by the value
+ * {@link FontServer#SMALL_CAP_SIMULATION_INVALID}
+ */
+ private float simulateSmallCaps = FontServer.SMALL_CAP_SIMULATION_INVALID;
+
+ /**
+ * Number of degrees by which the font should be slanted clockwise for the
+ * simulated oblique effect.
+ * Invalid or unset amounts are indicated by the value
+ * {@link FontServer#SMALL_CAP_SIMULATION_INVALID}.
+ */
+ private float simulateOblique = FontServer.OBLIQUE_SIMULATION_INVALID;
+
+ /**
+ * Number of degrees by which the font should be slanted counterclockwise
+ * for the simulated backslant effect.
+ * Invalid or unset amounts are indicated by the value
+ * {@link FontServer#SMALL_CAP_SIMULATION_INVALID}.
+ */
+ private float simulateBackslant = FontServer.OBLIQUE_SIMULATION_INVALID;
+
+ /**
+ * Array containing percentages by which the font should be stretched
+ * horizontally for various font-stretch values.
+ * Values greater than 100 will result in wider characters.
+ * Values less than 100 will result in narrower characters.
+ * Invalid or unset amounts are indicated by the value
+ * {@link FontServer#STRETCH_SIMULATION_INVALID}.
+ * Element 0 corresponds to ultra-condensed (the narrowest value), and
+ * element 7 corresponds to ultra-expanded (the widest value).
+ * Note that there is no element for "normal", since that does not need to
+ * be simulated.
+ */
+ private float simulateStretch[]
+ = new float[RegisteredFont.QTY_SIMULATED_STRETCH];
+ {
+ for (int i = 0; i < this.simulateStretch.length; i++) {
+ this.simulateStretch[i] = FontServer.STRETCH_SIMULATION_INVALID;
+ }
+ }
+
+ /**
+ * Construct a FontDescription instance.
+ * @param rf The parent registered font.
+ * @param rff The parent registered font family.
+ * @param encoding The specified encoding.
+ * @param fontStyle The font style (normal, italic, etc.)
+ * @param fontWeight The font weight(100, 200, bold, etc.)
+ * @param fontVariant The font variant (normal, small-caps)
+ * @param fontStretch The font stretch (normal, condensed, etc.)
+ */
+ public RegisteredFont(final RegisteredFontContent rf,
+ final RegisteredFontFamily rff, final Encoding encoding,
+ final Font.Style fontStyle, final Font.Weight fontWeight,
+ final Font.Variant fontVariant, final Font.Stretch fontStretch) {
+ this.registeredFont = rf;
+ this.registeredFontFamily = rff;
+ this.encoding = encoding;
+ this.fontStyle = fontStyle;
+ this.fontWeight = fontWeight;
+ this.fontVariant = fontVariant;
+ this.fontStretch = fontStretch;
+ }
+
+ /**
+ * Returns the font style.
+ * @return The font style.
+ */
+ public Font.Style getFontStyle() {
+ return this.fontStyle;
+ }
+
+ /**
+ * Returns the font weight.
+ * @return The font weight.
+ */
+ public Font.Weight getFontWeight() {
+ return this.fontWeight;
+ }
+
+ /**
+ * Return the font-variant for this registered description.
+ * @return The font-variant value.
+ */
+ public Font.Variant getFontVariant() {
+ return this.fontVariant;
+ }
+
+ /**
+ * Return the font-stretch for this registered description.
+ * @return The font-stretch value.
+ */
+ public Font.Stretch getFontStretch() {
+ return this.fontStretch;
+ }
+
+ /**
+ * Sets the simulated small-caps for this registered description.
+ * @param simulateSmallCaps The percentage that should be applied to
+ * simulated small-caps items for this font.
+ * A value of "80" will result in small-caps items that are 80% of the
+ * font-size of caps.
+ */
+ public void setSimulateSmallCaps(final float simulateSmallCaps) {
+ this.simulateSmallCaps = simulateSmallCaps;
+ }
+
+ /**
+ * Returns the simulated small-caps percentage.
+ * @return The simulated small-caps percentage.
+ */
+ public float getSimulateSmallCaps() {
+ if (this.simulateSmallCaps == FontServer.SMALL_CAP_SIMULATION_NATIVE) {
+ final Font4a font = this.getRegisteredFont().getBestFont();
+ this.simulateSmallCaps = font.getXheight(WellKnownConstants.MILLIPOINTS_PER_POINT);
+ this.simulateSmallCaps /= font.getAscender(WellKnownConstants.MILLIPOINTS_PER_POINT);
+ this.simulateSmallCaps *= WellKnownConstants.PERCENT_CONVERSION;
+ }
+ return this.simulateSmallCaps;
+ }
+
+ /**
+ * Sets the simulated oblique angle.
+ * @param simulateOblique The new simulated oblique angle.
+ */
+ public void setSimulateOblique(final float simulateOblique) {
+ this.simulateOblique = simulateOblique;
+ }
+
+ /**
+ * Returns the simulated oblique angle.
+ * @return The simulated oblique angle.
+ */
+ public float getSimulateOblique() {
+ return this.simulateOblique;
+ }
+
+ /**
+ * Sets the simulated backslant angle.
+ * @param simulateBackSlant The new simulated backslant angle.
+ */
+ public void setSimulateBackslant(final float simulateBackSlant) {
+ this.simulateBackslant = simulateBackSlant;
+ }
+
+ /**
+ * Returns the simulated backslant angle.
+ * @return The simulated backslant angle.
+ */
+ public float getSimulateBackslant() {
+ return this.simulateBackslant;
+ }
+
+ /**
+ * Set the simulated font-stretch value by array position.
+ * @param index Index into the internal array.
+ * @param value The percentage value to which the array element should be
+ * set.
+ */
+ public void setSimulateStretch(final int index, final float value) {
+ if (index < 0) {
+ return;
+ }
+ if (index > this.simulateStretch.length) {
+ return;
+ }
+ this.simulateStretch[index] = value;
+ }
+
+ /**
+ * Get the simulated font-stretch value by array position.
+ * @param index Index into the internal array.
+ * @return The percentage value of the stretch for the index provided.
+ */
+ public float getSimulateStretch(final int index) {
+ if (this.simulateStretch == null) {
+ return 0;
+ }
+ if (index < 0) {
+ return 0;
+ }
+ if (index > this.simulateStretch.length) {
+ return 0;
+ }
+ return this.simulateStretch[index];
+ }
+
+ /**
+ * Sets the simulated stretch array.
+ * @param newStretchArray The new simulated stretch array.
+ */
+ public void setSimulateStretch(final float[] newStretchArray) {
+ if (newStretchArray == null
+ || newStretchArray.length != this.simulateStretch.length) {
+ return;
+ }
+ this.simulateStretch = newStretchArray;
+ }
+
+ /**
+ * Sets the simulated "ultra-condensed" percentage.
+ * @param value The new simulated "ultra-condensed" percentage.
+ */
+ public void setSimulateUltraCondensed(final float value) {
+ this.setSimulateStretch(
+ RegisteredFont.SIMULATE_ULTRA_CONDENSED_INDEX, value);
+ }
+
+ /**
+ * Returns the simulated "ultra-condensed" percentage.
+ * @return The simulated "ultra-condensed" percentage.
+ */
+ public float getSimulateUltraCondensed() {
+ return this.getSimulateStretch(
+ RegisteredFont.SIMULATE_ULTRA_CONDENSED_INDEX);
+ }
+
+ /**
+ * Sets the simulated "extra-condensed" percentage.
+ * @param value The new simulated "extra-condensed" percentage.
+ */
+ public void setSimulateExtraCondensed(final float value) {
+ this.setSimulateStretch(
+ RegisteredFont.SIMULATE_EXTRA_CONDENSED_INDEX, value);
+ }
+
+ /**
+ * Returns the simulated "extra-condensed" percentage.
+ * @return The simulated "extra-condensed" percentage.
+ */
+ public float getSimulateExtraCondensed() {
+ return this.getSimulateStretch(
+ RegisteredFont.SIMULATE_EXTRA_CONDENSED_INDEX);
+ }
+
+ /**
+ * Sets the simulated "condensed" percentage.
+ * @param value The new simulated "condensed" percentage.
+ */
+ public void setSimulateCondensed(final float value) {
+ this.setSimulateStretch(
+ RegisteredFont.SIMULATE_CONDENSED_INDEX, value);
+ }
+
+ /**
+ * Returns the simulated "condensed" percentage.
+ * @return The simulated "condensed" percentage.
+ */
+ public float getSimulateCondensed() {
+ return this.getSimulateStretch(
+ RegisteredFont.SIMULATE_CONDENSED_INDEX);
+ }
+
+ /**
+ * Sets the simulated "semi-condensed" percentage.
+ * @param value The new simulated "semi-condensed" percentage.
+ */
+ public void setSimulateSemiCondensed(final float value) {
+ this.setSimulateStretch(
+ RegisteredFont.SIMULATE_SEMI_CONDENSED_INDEX, value);
+ }
+
+ /**
+ * Returns the simulated "semi-condensed" percentage.
+ * @return The simulated "semi-condensed" percentage.
+ */
+ public float getSimulateSemiCondensed() {
+ return this.getSimulateStretch(
+ RegisteredFont.SIMULATE_SEMI_CONDENSED_INDEX);
+ }
+
+ /**
+ * Sets the simulated "semi-expanded" percentage.
+ * @param value The new simulated "semi-expanded" percentage.
+ */
+ public void setSimulateSemiExpanded(final float value) {
+ this.setSimulateStretch(
+ RegisteredFont.SIMULATE_SEMI_EXPANDED_INDEX, value);
+ }
+
+ /**
+ * Returns the simulated "semi-expanded" percentage.
+ * @return The simulated "semi-expanded" percentage.
+ */
+ public float getSimulateSemiExpanded() {
+ return this.getSimulateStretch(
+ RegisteredFont.SIMULATE_SEMI_EXPANDED_INDEX);
+ }
+
+ /**
+ * Sets the simulated "expanded" percentage.
+ * @param value The new simulated "expanded" percentage.
+ */
+ public void setSimulateExpanded(final float value) {
+ this.setSimulateStretch(
+ RegisteredFont.SIMULATE_EXPANDED_INDEX, value);
+ }
+
+ /**
+ * Returns the simulated "expanded" percentage.
+ * @return The simulated "expanded" percentage.
+ */
+ public float getSimulateExpanded() {
+ return this.getSimulateStretch(
+ RegisteredFont.SIMULATE_EXPANDED_INDEX);
+ }
+
+ /**
+ * Sets the simulated "extra-expanded" percentage.
+ * @param value The new simulated "extra-expanded" percentage.
+ */
+ public void setSimulateExtraExpanded(final float value) {
+ this.setSimulateStretch(
+ RegisteredFont.SIMULATE_EXTRA_EXPANDED_INDEX, value);
+ }
+
+ /**
+ * Returns the simulated "extra-expanded" percentage.
+ * @return The simulated "extra-expanded" percentage.
+ */
+ public float getSimulateExtraExpanded() {
+ return this.getSimulateStretch(
+ RegisteredFont.SIMULATE_EXTRA_EXPANDED_INDEX);
+ }
+
+ /**
+ * Sets the simulated "ultra-expanded" percentage.
+ * @param value The new simulated "ultra-expanded" percentage.
+ */
+ public void setSimulateUltraExpanded(final float value) {
+ this.setSimulateStretch(
+ RegisteredFont.SIMULATE_ULTRA_EXPANDED_INDEX, value);
+ }
+
+ /**
+ * Returns the simulated "ultra-expanded" percentage.
+ * @return The simulated "ultra-expanded" percentage.
+ */
+ public float getSimulateUltraExpanded() {
+ return this.getSimulateStretch(
+ RegisteredFont.SIMULATE_ULTRA_EXPANDED_INDEX);
+ }
+
+ /**
+ * Returns the related registered font instance.
+ * @return The related registered font instance.
+ */
+ public RegisteredFontContent getRegisteredFont() {
+ return this.registeredFont;
+ }
+
+ /**
+ * Returns the related registered font family instance.
+ * @return The related registered font family instance.
+ */
+ public RegisteredFontFamily getRegisteredFontFamily() {
+ return this.registeredFontFamily;
+ }
+
+ /**
+ * Return the prescribed encoding for this description.
+ * @return The prescribed encoding for this description.
+ */
+ public Encoding getEncoding() {
+ return this.encoding;
+ }
+
+ /**
+ * Returns the next bolder font in the font-family than this font.
+ * @return The next bolder font in the font-family than this one.
+ */
+ public RegisteredFont nextBolderFont() {
+ return this.registeredFontFamily.nextBolderFont(this);
+ }
+
+ /**
+ * Returns the next lighter font in the font-family than this font.
+ * @return The next lighter font in the font-family than this one.
+ */
+ public RegisteredFont nextLighterFont() {
+ return this.registeredFontFamily.nextLighterFont(this);
+ }
+
+ /**
+ * Determine whether two RegisteredFontDesc instances have the same set of
+ * characteristics (font-weight, font-style, etc).
+ * Note that, for purposes of this method, the encoding is not
+ * considered to be a characteristic.
+ * @param otherDesc A RegisteredFontDesc instance which should be compared
+ * to this one.
+ * @return True if and only if otherDesc has the same set of characteristics as this.
+ */
+ public boolean equivalent(final RegisteredFont otherDesc) {
+ return matchPerfect(otherDesc.getRegisteredFontFamily(),
+ false,
+ otherDesc.getFontStyle(),
+ otherDesc.getFontWeight(),
+ otherDesc.getFontVariant(),
+ otherDesc.getFontStretch(),
+ true,
+ true);
+ }
+
+ /**
+ * Determine whether two RegisteredFontDesc instances have the same set of
+ * characteristics (font-family, font-style, etc), but without regard to
+ * font-weight.
+ * Note that, for purposes of this method, the encoding is not
+ * considered to be a characteristic.
+ * @param otherDesc A RegisteredFontDesc instance which should be compared
+ * to this one.
+ * @return True if and only if otherDesc has the same set of characteristics as this,
+ * but without regard to font-weight.
+ * In other words, if all other characteristics are equal, true will be
+ * returned, regardless of whether font-weight is equal or not.
+ */
+ public boolean equivalentExceptWeight(final RegisteredFont otherDesc) {
+ return matchIgnoreWeight(otherDesc.getRegisteredFontFamily(),
+ false,
+ otherDesc.getFontStyle(),
+ otherDesc.getFontVariant(),
+ otherDesc.getFontStretch(),
+ true,
+ true);
+ }
+
+ /**
+ * Indicates whether this font description matches a given style.
+ * @param inputDesiredStyle The style to match.
+ * @param considerSimulated Indicates whether simulated features should be
+ * considered in the test.
+ * @return True if and only if the style of this font description matches the criteria.
+ */
+ public boolean styleMatches(final Font.Style inputDesiredStyle,
+ final boolean considerSimulated) {
+ if (inputDesiredStyle == Font.Style.ANY) {
+ return true;
+ }
+ if (considerSimulated) {
+ if (this.simulateOblique != FontServer.OBLIQUE_SIMULATION_INVALID) {
+ /* If it can simulate oblique, it can be used for either
+ * oblique or italic or normal. */
+ switch (inputDesiredStyle) {
+ case NORMAL:
+ case ITALIC:
+ case OBLIQUE:
+ case ANY: {
+ return true;
+ }
+ case BACKSLANT:
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ Font.Style actualStyle = getFontStyle();
+ /* Check the easy case first. */
+ if (actualStyle == inputDesiredStyle) {
+ return true;
+ }
+ /* If they are not equal, we need to treat "oblique" and "italic" as
+ * equivalent. */
+ if (actualStyle == Font.Style.OBLIQUE) {
+ actualStyle = Font.Style.ITALIC;
+ }
+ Font.Style desiredStyle = inputDesiredStyle;
+ if (inputDesiredStyle == Font.Style.OBLIQUE) {
+ desiredStyle = Font.Style.ITALIC;
+ }
+ /* Test it again. */
+ if (actualStyle == desiredStyle) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether this font description matches a given variant.
+ * @param desiredVariant The variant to match.
+ * @param considerSimulated Indicates whether simulated features should be
+ * considered in the test.
+ * @return True if and only if the style of this font description matches the criteria.
+ */
+ public boolean variantMatches(final Font.Variant desiredVariant,
+ final boolean considerSimulated) {
+ if (desiredVariant == Font.Variant.ANY) {
+ return true;
+ }
+ if (considerSimulated) {
+ if (this.simulateSmallCaps != FontServer.SMALL_CAP_SIMULATION_INVALID) {
+ /* If it can simulate small-caps, it can be used for either
+ * small-caps or normal. */
+ return true;
+ }
+ }
+ final Font.Variant actualVariant = getFontVariant();
+ if (actualVariant == desiredVariant) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether this font description matches a given stretch.
+ * @param desiredStretch The stretch to match.
+ * @param considerSimulated Indicates whether simulated features should be
+ * considered in the test.
+ * @return True if and only if the style of this font description matches the criteria.
+ */
+ public boolean stretchMatches(final Font.Stretch desiredStretch,
+ final boolean considerSimulated) {
+ if (desiredStretch == Font.Stretch.ANY) {
+ return true;
+ }
+ final Font.Stretch actualStretch = getFontStretch();
+ if (actualStretch == desiredStretch) {
+ return true;
+ }
+ if (considerSimulated) {
+ final int simulatedIndex = stretchSimulationIndex(desiredStretch);
+ if (simulatedIndex > -1) {
+ final float simulationPercent =
+ this.simulateStretch[simulatedIndex];
+ if (simulationPercent != FontServer.STRETCH_SIMULATION_INVALID) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether this font description matches a given weight.
+ * @param desiredWeight The weight to match.
+ * @return True if and only if the style of this font description matches the criteria.
+ */
+ public boolean weightMatches(final Font.Weight desiredWeight) {
+ if (desiredWeight == Font.Weight.ANY) {
+ return true;
+ }
+ final Font.Weight actualWeight = getFontWeight();
+ if (actualWeight == desiredWeight) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether this font description perfectly matches a given set of
+ * criteria.
+ * @param family The desired font-family.
+ * @param considerSimulated Indicates whether simulated features should be
+ * considered in this selection.
+ * @param style The desired style.
+ * @param weight The desired weight.
+ * @param variant The desired variant.
+ * @param stretch The desired stretch.
+ * @param freeStandingFonts Indicates whether free-standing fonts can be
+ * considered in this selection.
+ * @param systemFonts Indicates whether system fonts can be consdidered in
+ * this selection.
+ * @return True if and only if this font descriptions perfectly matches all of the
+ * selection criteria.
+ */
+ public boolean matchPerfect(final RegisteredFontFamily family,
+ final boolean considerSimulated, final Font.Style style,
+ final Font.Weight weight, final Font.Variant variant,
+ final Font.Stretch stretch, final boolean freeStandingFonts,
+ final boolean systemFonts) {
+ if (! generalTypeMatches(freeStandingFonts, systemFonts)) {
+ return false;
+ }
+ if (! matchIgnoreWeight(family, considerSimulated, style, variant,
+ stretch, freeStandingFonts, systemFonts)) {
+ return false;
+ }
+ if (! weightMatches(weight)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Indicates whether this font description matches a given set of criteria,
+ * withour regard to the font-weight.
+ * @param family The desired font-family.
+ * @param considerSimulated Indicates whether simulated features should be
+ * considered in this selection.
+ * @param style The desired style.
+ * @param variant The desired variant.
+ * @param stretch The desired stretch.
+ * @param freeStandingFonts Indicates whether free-standing fonts can be
+ * considered in this selection.
+ * @param systemFonts Indicates whether system fonts can be consdidered in
+ * this selection.
+ * @return True if and only if this font descriptions perfectly matches all of the
+ * selection criteria.
+ */
+ public boolean matchIgnoreWeight(final RegisteredFontFamily family,
+ final boolean considerSimulated, final Font.Style style,
+ final Font.Variant variant, final Font.Stretch stretch,
+ final boolean freeStandingFonts, final boolean systemFonts) {
+ if (! generalTypeMatches(freeStandingFonts, systemFonts)) {
+ return false;
+ }
+ /* First, make sure desc is in this font-family. */
+ if (family != this.registeredFontFamily) {
+ return false;
+ }
+ if (! styleMatches(style, considerSimulated)) {
+ return false;
+ }
+ if (! variantMatches(variant, considerSimulated)) {
+ return false;
+ }
+ if (! stretchMatches(stretch, considerSimulated)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Determines whether this registered font can return a Font instance that
+ * matches the general type requested.
+ * @param freeStandingFonts True if and only if the returned font can be a
+ * FreeStandingFont.
+ * @param systemFonts True if and only if the returned font can be a SystemFont.
+ * @return True if and only if this registered font is able to return a Font instance
+ * that matches the needs described by freeStandingFonts and systemFonts.
+ */
+ public boolean generalTypeMatches(final boolean freeStandingFonts,
+ final boolean systemFonts) {
+ if (freeStandingFonts && this.registeredFont.hasFreeStandingFont()) {
+ return true;
+ }
+ if (systemFonts && this.registeredFont.hasSystemFont()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Converts a {@link org.axsl.font.Font.Stretch} value into the appropriate index into
+ * the simulated percentages.
+ * @param stretch The Stretch value for which the index is needed.
+ * @return The index into {@link #simulateStretch} for the stretch value.
+ */
+ private static int stretchSimulationIndex(final Font.Stretch stretch) {
+ switch(stretch) {
+ case ULTRA_CONDENSED:
+ return RegisteredFont.SIMULATE_ULTRA_CONDENSED_INDEX;
+ case EXTRA_CONDENSED:
+ return RegisteredFont.SIMULATE_EXTRA_CONDENSED_INDEX;
+ case CONDENSED:
+ return RegisteredFont.SIMULATE_CONDENSED_INDEX;
+ case SEMI_CONDENSED:
+ return RegisteredFont.SIMULATE_SEMI_CONDENSED_INDEX;
+ case SEMI_EXPANDED:
+ return RegisteredFont.SIMULATE_SEMI_EXPANDED_INDEX;
+ case EXPANDED:
+ return RegisteredFont.SIMULATE_EXPANDED_INDEX;
+ case EXTRA_EXPANDED:
+ return RegisteredFont.SIMULATE_EXTRA_EXPANDED_INDEX;
+ case ULTRA_EXPANDED:
+ return RegisteredFont.SIMULATE_ULTRA_EXPANDED_INDEX;
+ default: return -1;
+ }
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("[");
+ builder.append(this.registeredFont.getConfiguredFontName());
+ builder.append(", ");
+ builder.append(this.registeredFontFamily.getName());
+ builder.append(", ");
+ final String encodingString = this.encoding == null ? "unspecified" : this.encoding.toString();
+ builder.append(encodingString);
+ builder.append(", ");
+ builder.append(this.fontStyle.toString());
+ builder.append(", ");
+ builder.append(this.fontWeight.toString());
+ builder.append(", ");
+ builder.append(this.fontVariant.toString());
+ builder.append(", ");
+ builder.append(this.fontStretch.toString());
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2022-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -52,24 +52,21 @@
import java.net.URL;
/**
- * <p>A font file (or system-registered equivalent) that has been registered for use with FOray.
- * Such a file can be referenced by multiple instances of {@link RegisteredFontFamilyMember}.
+ * <p>A font file (or system-registered equivalent) that has been registered for use with FOray, as configured in a
+ * "font-content" element in the configuration XML.
+ * Such a file can be referenced by multiple instances of {@link RegisteredFont}, as configured in a "font" element
+ * in the configuration XML.
* The purpose of that class is to bind an abstract font description (font-family, style, weight, etc.) to an instance
* of this class.
- * The purpose of this class is to bind to a physical font file (or system-registered equivalent).
- * Instances of this class encapsulate the information in a "font-content" element in the font configuration XML.</p>
+ * The purpose of this class is to link the {@link RegisteredFont} to a physical font file (or system-registered
+ * equivalent).</p>
*
- * <p>It is tempting to question why this separate class is needed. Because fonts
- * can be registered from several sources (hard-coded, font configuration,
- * operating system registration, and directly by the client application), a
- * separate registry concept ensures that all of the registered fonts can be
- * managed, even though they may not have been parsed yet. It is good to not
- * parse the font until it is known to be necessary.
- *
- * Note that the data stored in RegisteredFont corresponds to the data passed
- * in the <font> element of the font configuration file.
- * Data from the actual font file itself tends to be stored in FreeStandingFont
- * or one of its subclasses.</p>
+ * <p>The main purpose for keeping {@link RegisteredFont} separate from {@link RegisteredFontContent} is so that the
+ * latter can be reused without duplication of parsing.
+ * A secondary benefit is that it adds clarity to the notion that the former is user-oriented and the latter is
+ * system-oriented.
+ * has font-content to be It is tempting to question why this separate class is needed. It is good to not
+ * parse the font until it is known to be necessary.</p>
*/
public class RegisteredFontContent implements FontParserClient {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java 2022-03-26 12:39:37 UTC (rev 12637)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java 2022-03-26 13:20:48 UTC (rev 12638)
@@ -61,10 +61,10 @@
* in the font configuration. **/
private String name;
- /** Collection of {@link RegisteredFontFamilyMember} instances that are associated
+ /** Collection of {@link RegisteredFont} instances that are associated
* with this family. */
- private List<RegisteredFontFamilyMember> fontDescriptions
- = new ArrayList<RegisteredFontFamilyMember>();
+ private List<RegisteredFont> fontDescriptions
+ = new ArrayList<RegisteredFont>();
/**
* Constructor.
@@ -134,7 +134,7 @@
final float simBackslant = convertPercent(simulatedBackslant,
FontServer.OBLIQUE_SIMULATION_INVALID);
final float[] simStretch
- = new float[RegisteredFontFamilyMember.QTY_SIMULATED_STRETCH];
+ = new float[RegisteredFont.QTY_SIMULATED_STRETCH];
for (int i = 0; i < simStretch.length; i++) {
simStretch[i] = FontServer.STRETCH_SIMULATION_INVALID;
}
@@ -173,7 +173,7 @@
final float simulatedSmallCaps, final float simulatedOblique,
final float simulatedBackslant, final float[] simulatedStretch)
throws FontException {
- final RegisteredFontFamilyMember description = new RegisteredFontFamilyMember(
+ final RegisteredFont description = new RegisteredFont(
registeredFont, this, encoding, style, weight, variant,
stretch);
description.setSimulateSmallCaps(simulatedSmallCaps);
@@ -181,7 +181,7 @@
description.setSimulateBackslant(simulatedBackslant);
description.setSimulateStretch(simulatedStretch);
for (int i = 0; i < this.fontDescriptions.size(); i++) {
- final RegisteredFontFamilyMember registeredDesc
+ final RegisteredFont registeredDesc
= this.fontDescriptions.get(i);
if (description.equivalent(registeredDesc)) {
throw new FontException("Equivalent font-description "
@@ -210,7 +210,7 @@
* @return The first matching RegisteredFontDesc found for this font-family,
* or null if none match.
*/
- public RegisteredFontFamilyMember findRegisteredFontDesc(final Font.Style style,
+ public RegisteredFont findRegisteredFontDesc(final Font.Style style,
final Font.Weight weight, final Font.Variant variant,
final Font.Stretch stretch, final boolean freeStandingFonts,
final boolean systemFonts) {
@@ -230,14 +230,14 @@
* is, it is assigned the next darker assigned keyword, if any, or
* the next lightest otherwise. */
- final RegisteredFontFamilyMember[] matches =
- new RegisteredFontFamilyMember[RegisteredFontFamily.QTY_WEIGHT_VALUES];
- RegisteredFontFamilyMember bestMatch = null;
+ final RegisteredFont[] matches =
+ new RegisteredFont[RegisteredFontFamily.QTY_WEIGHT_VALUES];
+ RegisteredFont bestMatch = null;
/* First, look for a perfect match without considering simulated
* features. */
for (int i = 0; i < this.fontDescriptions.size(); i++) {
- final RegisteredFontFamilyMember fd = this.fontDescriptions.get(i);
+ final RegisteredFont fd = this.fontDescriptions.get(i);
if (fd.matchIgnoreWeight(this, false, style, variant, stretch,
freeStandingFonts, systemFonts)) {
if (weight == Font.Weight.ANY) {
@@ -256,7 +256,7 @@
/* Next, look for a perfect match that does consider the simulated
* features. */
for (int i = 0; i < this.fontDescriptions.size(); i++) {
- final RegisteredFontFamilyMember fd = this.fontDescriptions.get(i);
+ final RegisteredFont fd = this.fontDescriptions.get(i);
if (fd.matchPerfect(this, true, style, weight, variant, stretch,
freeStandingFonts, systemFonts)) {
if (weight == Font.Weight.ANY) {
@@ -272,13 +272,13 @@
}
/**
- * Decides which of two {@link RegisteredFontFamilyMember} instances best fills the
+ * Decides which of two {@link RegisteredFont} instances best fills the
* requested weight value.
* @param matches The candidate font descriptors.
* @param weight The requested weight value.
* @return The descriptor best matching the requested weight.
*/
- private RegisteredFontFamilyMember bestWeightMatch(final RegisteredFontFamilyMember[] matches,
+ private RegisteredFont bestWeightMatch(final RegisteredFont[] matches,
final Font.Weight weight) {
final int index = weightArrayIndex(weight);
final int normalIndex = weightArrayIndex(Font.Weight.NORMAL);
@@ -363,11 +363,11 @@
* @return The next bolder font, or the baseline font if no bolder font
* exists.
*/
- public RegisteredFontFamilyMember nextBolderFont(
- final RegisteredFontFamilyMember baseline) {
- RegisteredFontFamilyMember best = null;
+ public RegisteredFont nextBolderFont(
+ final RegisteredFont baseline) {
+ RegisteredFont best = null;
for (int i = 0; i < this.fontDescriptions.size(); i++) {
- final RegisteredFontFamilyMember candidate = this.fontDescriptions.get(i);
+ final RegisteredFont candidate = this.fontDescriptions.get(i);
// Ignore the baseline.
if (candidate == baseline) {
continue;
@@ -402,11 +402,11 @@
* @return The next lighter font, or the baseline font if no lighter font
* exists.
*/
- public RegisteredFontFamilyMember nextLighterFont(
- final RegisteredFontFamilyMember baseline) {
- RegisteredFontFamilyMember best = null;
+ public RegisteredFont nextLighterFont(
+ final RegisteredFont baseline) {
+ RegisteredFont best = null;
for (int i = 0; i < this.fontDescriptions.size(); i++) {
- final RegisteredFontFamilyMember candidate = this.fontDescriptions.get(i);
+ final RegisteredFont candidate = this.fontDescriptions.get(i);
// Ignore the baseline.
if (candidate == baseline) {
continue;
@@ -458,11 +458,11 @@
}
/**
- * Returns the list of {@link RegisteredFontFamilyMember} instances that are
+ * Returns the list of {@link RegisteredFont} instances that are
* ass...
[truncated message content] |
|
From: <vic...@us...> - 2022-03-26 12:39:40
|
Revision: 12637
http://sourceforge.net/p/foray/code/12637
Author: victormote
Date: 2022-03-26 12:39:37 +0000 (Sat, 26 Mar 2022)
Log Message:
-----------
Rename RegisteredFont to RegisteredFontContent, for clarity, and in accordance with DTD changes.
Modified Paths:
--------------
trunk/foray/foray-app/src/test/java/org/foray/app/area/AbstractAreaTreeTest.java
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.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/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamilyMember.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
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
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-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/area/AbstractAreaTreeTest.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -44,7 +44,7 @@
import org.foray.font.FontServer4a;
import org.foray.font.FontUse4a;
import org.foray.font.FreeStandingFont;
-import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.axsl.font.FontException;
import org.axsl.linebreak.LineBreakerFactory;
@@ -77,7 +77,7 @@
protected FontUse4a getHelveticaFont() throws FontException {
final FontServer4a fontServer = getFontServer();
Assert.assertNotNull(fontServer);
- final RegisteredFont rf = fontServer.getRegisteredFont("Base14-Helvetica");
+ final RegisteredFontContent rf = fontServer.getRegisteredFont("Base14-Helvetica");
Assert.assertNotNull(rf);
final FreeStandingFont fsf = rf.getFreeStandingFont();
Assert.assertNotNull(fsf);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2022-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -29,7 +29,7 @@
import org.foray.common.FontContext4a;
import org.foray.common.WellKnownConstants;
-import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.Kerning;
import org.axsl.font.Font;
@@ -88,13 +88,13 @@
/**
* The RegisteredFont that is attached to this Font instance.
*/
- private RegisteredFont registeredFont = null;
+ private RegisteredFontContent registeredFont = null;
/**
* Constructor.
* @param rf The parent registered font.
*/
- protected Font4a(final RegisteredFont rf) {
+ protected Font4a(final RegisteredFontContent rf) {
this.registeredFont = rf;
}
@@ -311,7 +311,7 @@
* Return the parent registered font.
* @return The registered font.
*/
- public RegisteredFont getRegisteredFont() {
+ public RegisteredFontContent getRegisteredFont() {
return this.registeredFont;
}
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-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -29,7 +29,7 @@
package org.foray.font;
import org.foray.common.FontSelectionConstraints4a;
-import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.foray.font.config.RegisteredFontFamily;
import org.foray.font.config.RegisteredFontFamilyMember;
import org.foray.font.format.Panose4a;
@@ -310,7 +310,7 @@
}
/**
- * <p>Since {@link RegisteredFont} and {@link RegisteredFontFamilyMember} instances
+ * <p>Since {@link RegisteredFontContent} and {@link RegisteredFontFamilyMember} instances
* can encapsulate either a FreeStandingFont or a SystemFont, or both,
* this method selects which one should be used, based on the FontConsumer
* instances parameters.</p>
@@ -330,7 +330,7 @@
*/
protected Font4a whichUse(final RegisteredFontFamilyMember rfd,
final int codePoint) {
- final RegisteredFont rf = rfd.getRegisteredFont();
+ final RegisteredFontContent rf = rfd.getRegisteredFont();
/* Avoid instantiating the non-preferred manifestation if it won't be
* used anyway. */
@@ -395,7 +395,7 @@
* @return The {@link SystemFont instance}, if it exists and is eligible, or
* null otherwise.
*/
- private SystemFont eligibleSystemFont(final RegisteredFont rf,
+ private SystemFont eligibleSystemFont(final RegisteredFontContent rf,
final int codePoint) {
if (! this.selectionConstraints.canSelectSystemFonts()) {
return null;
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-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -31,7 +31,7 @@
import org.foray.common.Environment;
import org.foray.common.url.classpath.Handler;
import org.foray.font.config.FontConfigParser;
-import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.foray.font.config.RegisteredFontFamily;
import org.foray.font.config.RegisteredFontFamilyMember;
import org.foray.font.format.FontParserClient;
@@ -146,8 +146,8 @@
* Map whose key is a String containing a font ID, and whose value is the
* RegisteredFont for that font ID.
*/
- private Map<String, RegisteredFont> registeredFonts
- = new HashMap<String, RegisteredFont>();
+ private Map<String, RegisteredFontContent> registeredFonts
+ = new HashMap<String, RegisteredFontContent>();
/** Map of registered font selector factories. The key is String containing
* the name of the factory, and the value is the {@link FontSelectorFactory}
@@ -227,7 +227,7 @@
}
/* Punt and try to create something that will work. */
try {
- final RegisteredFont rf = new RegisteredFont(this, null, null, null,
+ final RegisteredFontContent rf = new RegisteredFontContent(this, null, null, null,
null, null, "serif");
final RegisteredFontFamily rff = this.registerFontFamily2("serif");
rff.registerFontDesc(rf, null, "normal", "normal", "normal",
@@ -440,9 +440,9 @@
this.getLogger().warn("Serialized Base-14 font metrics not found: " + resourceName);
return;
}
- RegisteredFont rf = null;
+ RegisteredFontContent rf = null;
try {
- rf = new RegisteredFont(this, fontName, null, null, null, org.axsl.font.Font.Embedding.NONE, null);
+ rf = new RegisteredFontContent(this, fontName, null, null, null, org.axsl.font.Font.Embedding.NONE, null);
} catch (final FontException e) {
this.logger.warn(e.getMessage(), e);
}
@@ -639,9 +639,9 @@
continue;
}
}
- final RegisteredFont rf;
+ final RegisteredFontContent rf;
try {
- rf = new RegisteredFont(this, awtFont.getFontName(),
+ rf = new RegisteredFontContent(this, awtFont.getFontName(),
null, null, null, org.axsl.font.Font.Embedding.NONE, awtFont.getFontName());
} catch (final FontException e) {
this.logger.error(e.getMessage());
@@ -869,7 +869,7 @@
if (rfdList != null) {
for (int i = 0; i < rfdList.size(); i++) {
final RegisteredFontFamilyMember rfd = rfdList.get(i);
- final RegisteredFont rf = rfd.getRegisteredFont();
+ final RegisteredFontContent rf = rfd.getRegisteredFont();
if (freeStandingFonts
&& rf.getFreeStandingFont() != null) {
fontList.add(rf.getFreeStandingFont());
@@ -955,7 +955,7 @@
if (! isUsableFont(systemName, fontFileSource, metricsFileSource)) {
return;
}
- new RegisteredFont(this, fontID, fontFileSource, metricsFileSource, collectionID, requestedEmbedding,
+ new RegisteredFontContent(this, fontID, fontFileSource, metricsFileSource, collectionID, requestedEmbedding,
systemName);
}
@@ -995,17 +995,17 @@
* @return The registered font instance, or null if the font name has not
* been registered.
*/
- public RegisteredFont getRegisteredFont(final String name) {
+ public RegisteredFontContent getRegisteredFont(final String name) {
return this.registeredFonts.get(name);
}
/**
- * Maps a given font name to its related {@link RegisteredFont} instance.
+ * Maps a given font name to its related {@link RegisteredFontContent} instance.
* @param fontID The name of the font to be associated.
* @param rf The registered font instance to be associated with the name.
* @throws FontException If the {@code fontID} is already registered.
*/
- public void registerFont(final String fontID, final RegisteredFont rf)
+ public void registerFont(final String fontID, final RegisteredFontContent rf)
throws FontException {
final Object object = this.registeredFonts.get(fontID);
if (object != null) {
@@ -1032,7 +1032,7 @@
throws FontException {
final RegisteredFontFamily rff = this.getRegisteredFontFamily(
fontFamily);
- final RegisteredFont rf = this.getRegisteredFont(fontID);
+ final RegisteredFontContent rf = this.getRegisteredFont(fontID);
rff.registerFontDesc(rf, encoding, style, weight, variant, stretch,
simulatedSmallCaps, simulatedOblique, simulatedBackslant,
simulatedStretch);
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-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -29,7 +29,7 @@
package org.foray.font;
import org.foray.common.WellKnownConstants;
-import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.FontParser;
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
@@ -130,7 +130,7 @@
* Constructor.
* @param rf The parent registered font.
*/
- protected FreeStandingFont(final RegisteredFont rf) {
+ protected FreeStandingFont(final RegisteredFontContent rf) {
super(rf);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2022-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -32,7 +32,7 @@
import org.foray.common.WellKnownConstants;
import org.foray.common.data.BoundingBoxShort;
import org.foray.common.data.BoundingBoxUtils;
-import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.ttf.TrueTypeContainer;
import org.foray.font.format.ttf.TrueTypeFont;
import org.foray.font.format.ttf.TtfSubSetFile;
@@ -76,7 +76,7 @@
* @throws FontException For errors parsing the font.
* @throws IOException For errors reading content.
*/
- public FsTrueTypeFont(final RegisteredFont rf) throws FontException, IOException {
+ public FsTrueTypeFont(final RegisteredFontContent rf) throws FontException, IOException {
super(rf);
parseFont();
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2022-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -30,7 +30,7 @@
import org.foray.common.WellKnownConstants;
import org.foray.common.data.BoundingBoxUtils;
-import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.FontParser;
import org.foray.font.format.type1.Type1Font;
import org.foray.font.format.type1.Type1FontParser;
@@ -70,7 +70,7 @@
* @param rf The RegisteredFont that should be used to create this font.
* @throws FontException For error creating font.
*/
- public FsType1Font(final RegisteredFont rf) throws FontException {
+ public FsType1Font(final RegisteredFontContent rf) throws FontException {
super(rf);
parseFont();
}
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-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -31,7 +31,7 @@
import org.foray.common.Environment;
import org.foray.common.WellKnownConstants;
import org.foray.common.data.BoundingBoxUtils;
-import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.FontParser;
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
@@ -85,11 +85,11 @@
/**
* Private constructor.
* To obtain a SystemFont instance, use
- * {@link #makeSystemFont(RegisteredFont)}.
+ * {@link #makeSystemFont(RegisteredFontContent)}.
* @param rf The parent RegisteredFont instance.
* @throws FontException For error creating font.
*/
- private SystemFont(final RegisteredFont rf) throws FontException {
+ private SystemFont(final RegisteredFontContent rf) throws FontException {
super(rf);
final Font newFont = createFont();
this.lastMetrics = getGraphics().getFontMetrics(newFont);
@@ -100,7 +100,7 @@
* @param rf The parent RegisteredFont instance.
* @return The new SystemFont instance.
*/
- public static SystemFont makeSystemFont(final RegisteredFont rf) {
+ public static SystemFont makeSystemFont(final RegisteredFontContent rf) {
/* Don't allow the SystemFont to be created unless we are running in a
* graphical environment. Trying to create AWT fonts in a non-graphical
* environment will result in a runtime Error and will crash the
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -499,7 +499,7 @@
}
refID = fontID;
}
- final RegisteredFont registeredFont = this.fontServer.getRegisteredFont(
+ final RegisteredFontContent registeredFont = this.fontServer.getRegisteredFont(
refID);
if (registeredFont == null) {
warningMessage("Font is not registered: " + refID);
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -1,555 +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.font.config;
-
-import org.foray.common.sequence.ByteArray;
-import org.foray.common.sequence.ByteSequenceParser;
-import org.foray.font.Font4a;
-import org.foray.font.FontServer4a;
-import org.foray.font.FreeStandingFont;
-import org.foray.font.FsTrueTypeFont;
-import org.foray.font.FsType1Font;
-import org.foray.font.SystemFont;
-import org.foray.font.format.FontParser;
-import org.foray.font.format.FontParserClient;
-import org.foray.font.format.Panose4a;
-import org.foray.font.format.type1.Type1MetricsParser;
-
-import org.axsl.font.Font;
-import org.axsl.font.FontException;
-import org.axsl.ps.PsServer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * <p>Class representing a font that has been registered for use with FOray.
- * RegisteredFont is not really a Font, as it is not part of the Font hierarcy
- * (i.e. it does not subclass Font).
- * It is really the bridge between the font configuration and the actual Font
- * classes.
- * It first encapsulates the information from the "font" element in the
- * font-configuration.
- * During font resolution, a RegisteredFontDesc element (representing a
- * "font-description" element in font-configuration) is selected, which in
- * turn points to RegisteredFont instance.
- * It then, as requested, converts that information into actual Font instances
- * that can be used by the client application.</p>
- *
- * It is tempting to question why this separate class is needed. Because fonts
- * can be registered from several sources (hard-coded, font configuration,
- * operating system registration, and directly by the client application), a
- * separate registry concept ensures that all of the registered fonts can be
- * managed, even though they may not have been parsed yet. It is good to not
- * parse the font until it is known to be necessary.
- *
- * Note that the data stored in RegisteredFont corresponds to the data passed
- * in the <font> element of the font configuration file.
- * Data from the actual font file itself tends to be stored in FreeStandingFont
- * or one of its subclasses.
- */
-public class RegisteredFont implements FontParserClient {
-
- /** Array of the base-14 font names. */
- public static final String[] STANDARD_PDF_FONT_NAMES = new String[] {
- "Helvetica",
- "Helvetica-Oblique",
- "Helvetica-Bold",
- "Helvetica-BoldOblique",
- "Times-Roman",
- "Times-Italic",
- "Times-Bold",
- "Times-BoldItalic",
- "Courier",
- "Courier-Oblique",
- "Courier-Bold",
- "Courier-BoldOblique",
- "Symbol",
- "ZapfDingbats"
- };
-
- /** The name of the font as specified in the font configuration file. */
- private String configuredFontName = null;
-
- /** The system-name (AWT name) for this font, as specified in the font
- * configuration file. */
- private String systemName = null;
-
- /**
- * For TrueType collections, ttcName specifies the name of the font within
- * the TTC that should be used.
- */
- private String ttcName = null;
-
- /** The serialized metrics file. This will be null if the font is not a
- * Type 1 font, or if its metrics file is not serialized. */
- private URL serializedMetricsFile;
-
- /** The font file contents. This should be null for fonts where we know how to read or re-read the contents. */
- private byte[] fontFileContents;
-
- /** Description of the font source. This should be null unless {@link #fontFileContents} is not. */
- private String fontFileDescription;
-
- /** The metric file contents. This should be null for fonts where we know how to read or re-read the contents. */
- private byte[] metricsFileContents;
-
- /** Description of the font metrics source. This should be null unless {@link #metricsFileContents} is not. */
- private String metricsFileDescription;
-
- /** The requested embedding for this font. */
- private Font.Embedding requestedEmbedding = Font.Embedding.NONE;
-
- /** The FreeStandingFont instance, if any, that has been created for this
- * RegisteredFont. */
- private FreeStandingFont fsFont = null;
-
- /** The SystemFont instance, if any, that has been created for this
- * RegisteredFont. */
- private SystemFont systemFont = null;
-
- /** Indicates whether the creation of the FreeStandingFont has already
- * been attempted. */
- private boolean fsFontCreationCompleted = false;
-
- /** Indicates whether the creation of the SystemFont has already been
- * attempted. */
- private boolean systemFontCreationCompleted = false;
-
- /** The parent FontServer. */
- private FontServer4a fontServer = null;
-
- /** The source of the font file, if any. */
- private URL fontFileSource;
-
- /** The source of the metrics file, if any. */
- private URL metricsFileSource;
-
- /**
- * Constructor useful for registering a Font that has not yet been read.
- * @param server The parent font server.
- * @param fontName The name of the font.
- * @param fontFileSource The source of the font file, if any.
- * @param metricsFileSource The source of the metrics file, if any.
- * @param ttcName The font name to be used within a TrueType Collection file
- * to select the proper font.
- * @param embedding Indicates whether and how much of the font should be
- * embedded.
- * @param systemName A non-null value indicates that this font can manifest
- * itself as a SystemFont.
- * @throws FontException For an error during font registration.
- */
- public RegisteredFont(final FontServer4a server, final String fontName, final URL fontFileSource,
- final URL metricsFileSource, final String ttcName,
- final Font.Embedding embedding, final String systemName)
- throws FontException {
- this.fontServer = server;
- this.fontFileSource = fontFileSource;
- this.metricsFileSource = metricsFileSource;
- this.configuredFontName = fontName;
- this.ttcName = ttcName;
- if (embedding == null) {
- this.requestedEmbedding = Font.Embedding.NONE;
- } else {
- this.requestedEmbedding = embedding;
- }
- this.systemName = systemName;
- server.registerFont(fontName, this);
- }
-
- /**
- * Constructor useful for registering a font whose contents have been extracted from a document.
- * @param server The parent font server.
- * @param fontID A unique ID for this font (e.g. "Courier-Bold").
- * @param fontFileDescription A description of the font file. This is used primarily in user messages.
- * @param fontFileContents Byte array containing the font file contents.
- * @param metricsFileDescription A description of the metrics file. This is used primarily in user messages.
- * @param metricsFileContents Byte array containing the metrics contents.
- * This is always null for TrueType and OpenType fonts.
- * @param collectionID For TrueType collections, indicates which font in the collection corresponds to this font.
- * @param embedding One of "none", "all", or "subset", indicating whether this font should be embedded in output
- * documents.
- * @param systemName For system fonts only, this is the name that should be supplied to the operating system font
- * registry to obtain the font from it. For other fonts, set this to null.
- * @throws FontException If a font with this {@code fontID} is already registered.
- */
- public RegisteredFont(final FontServer4a server, final String fontID,
- final String fontFileDescription, final byte[] fontFileContents,
- final String metricsFileDescription, final byte[] metricsFileContents,
- final String collectionID, final Font.Embedding embedding, final String systemName)
- throws FontException {
- this(server, fontID, null, null, null, embedding, systemName);
- this.fontFileDescription = fontFileDescription;
- this.fontFileContents = fontFileContents;
- this.metricsFileDescription = metricsFileDescription;
- this.metricsFileContents = metricsFileContents;
- server.registerFont(fontID, this);
- }
-
- /**
- * Attempts to create a SystemFont manifestation of this registered font.
- */
- private void createFreeStandingFont() {
- if (this.fsFontCreationCompleted) {
- return;
- }
- this.fsFontCreationCompleted = true;
-
- if (! this.hasFreeStandingFont()) {
- /* We do not have what is needed to create a FreeStandingFont. */
- return;
- }
-
- try {
- this.fsFont = createFSFont();
- if (this.fsFont == null) {
- this.fsFont = getFontServer().getDefaultFreeStandingFont()
- .getRegisteredFont().fsFont;
- getLogger().error("Unable to open font "
- + this.configuredFontName + ".");
- getLogger().error("Using a default font instead.");
- return;
- }
- if (! (this.requestedEmbedding == Font.Embedding.NONE)
- && ! this.fsFont.allowsEmbedding()) {
- getLogger().warn("Font " + this.configuredFontName
- + " does not allow embedding.");
- }
- } catch (final FontException ex) {
- getLogger().error("Failed to create font object "
- + "for: "
- + this.configuredFontName);
- getLogger().error(ex.getMessage());
- }
- }
-
- /**
- * Creates a SytemFont manifestation of this registered font if possible.
- */
- private void createSystemFont() {
- if (this.systemFontCreationCompleted) {
- return;
- }
- this.systemFontCreationCompleted = true;
- this.systemFont = SystemFont.makeSystemFont(this);
- }
-
- /**
- * Creates a font file reader for this registered font.
- * @return The reader.
- * @throws FontException For errors opening the font file reader.
- */
- public FontParser createFontFileReader() throws FontException {
- if (this.fontFileSource != null) {
- try {
- return new FontParser(this, this.fontFileSource.openStream());
- } catch (final IOException e) {
- throw new FontException(e);
- }
- }
-
- if (this.fontFileContents != null) {
- try {
- final ByteArray byteArray = new ByteArray(this.fontFileContents);
- final ByteSequenceParser bsp = new ByteSequenceParser(byteArray);
- return new FontParser(this, bsp);
- } catch (final IOException e) {
- throw new FontException(e);
- }
- }
-
- return null;
- }
-
- /**
- * Creates a metrics file reader for this registered font.
- * @return The reader.
- * @throws FontException For errors opening the metrics file reader.
- */
- public Type1MetricsParser createMetricsFileReader() throws FontException {
- if (this.metricsFileSource != null) {
- try {
- return new Type1MetricsParser(this.fontServer, this.metricsFileSource.openStream());
- } catch (final IOException e) {
- throw new FontException(e);
- }
- }
-
- if (this.metricsFileContents != null) {
- try {
- final ByteArray byteArray = new ByteArray(this.metricsFileContents);
- final ByteSequenceParser bsp = new ByteSequenceParser(byteArray);
- return new Type1MetricsParser(this.fontServer, bsp);
- } catch (final IOException e) {
- throw new FontException(e);
- }
- }
-
- return null;
- }
-
- /**
- * Attempts to create a FreeStandingFont manifestation of this registered
- * font.
- * @return The FreeStandingFont manifestation.
- * @throws FontException For error during FreeStandingFont creation.
- */
- private FreeStandingFont createFSFont() throws FontException {
- final Font.Format fontFormat;
- if (this.fontFileSource == null) {
- /* The assumption here is that we have a metrics file for this
- * font, but not a font file, therefore it is Type 1. */
- fontFormat = Font.Format.TYPE1;
- } else {
- /* TODO: See if we ca*/
- fontFormat = createFontFileReader().getFontFormat();
- }
- switch (fontFormat) {
- case TYPE1: {
- return new FsType1Font(this);
- }
- case TRUETYPE:
- case OTF_CFF:
- case OTF_TRUETYPE: {
- try {
- return new FsTrueTypeFont(this);
- } catch (final IOException e) {
- /* TODO: Remove the throwing of the exception caught here. */
- throw new IllegalStateException(e);
- }
- }
- }
- throw new FontException("Font " + this.configuredFontName
- + " is an unknown format.");
- }
-
- /**
- * Returns the {@link FreeStandingFont} manifestation of this font.
- * @return The {@link FreeStandingFont} manifestation, if any, of this
- * RegisteredFont.
- */
- public FreeStandingFont getFreeStandingFont() {
- if (this.fsFont == null) {
- createFreeStandingFont();
- }
- return this.fsFont;
- }
-
- /**
- * Returns the {@link SystemFont} manifestation of this font.
- * @return The SystemFont manifestation, if any, of this RegisteredFont.
- */
- public SystemFont getSystemFont() {
- if (this.systemFont == null) {
- createSystemFont();
- }
- return this.systemFont;
- }
-
- /**
- * Returns the system name for this registerered font.
- * @return The "system-name" as configured by the user. This is the name of
- * the AWT font (not font-family) that can be created.
- */
- public String getSystemName() {
- return this.systemName;
- }
-
- /**
- * Return the registered TrueType collection name that should be used to
- * access this font within a TTC file.
- * @return The TTC name.
- */
- public String getTTCName() {
- return this.ttcName;
- }
-
- /**
- * Returns the parent font server.
- * @return The parent font server.
- */
- public FontServer4a getFontServer() {
- return this.fontServer;
- }
-
- /**
- * Returns the logger.
- * @return The logger.
- */
- private Logger getLogger() {
- /* Not cached because not expected to get used much. */
- return LoggerFactory.getLogger(getClass());
- }
-
- /**
- * Returns the configured font name.
- * @return Returns the configuredFontName.
- */
- public String getConfiguredFontName() {
- return this.configuredFontName;
- }
-
- /**
- * Indicates whether this font should be embedded.
- * @return Returns the embedding.
- */
- public boolean isEmbedding() {
- return this.requestedEmbedding != Font.Embedding.NONE;
- }
-
- /**
- * Indicates whether this font should be subsetted.
- * @return Returns the subsetting.
- */
- public boolean isSubsetting() {
- return this.requestedEmbedding == Font.Embedding.SUBSET;
- }
-
- /**
- * Indicates whether this can return the content of the font.
- * @return True if and only if, this can return the content of the font.
- */
- public boolean hasFontContent() {
- if (this.fontFileSource != null) {
- return true;
- }
- if (this.fontFileContents != null) {
- return true;
- }
- return false;
- }
-
- /**
- * Indicates whether a FreeStandingFont manifestation of this registered
- * font exists.
- * @return True if and only if a FreeStandingFont manifestation of this registered
- * font exists.
- */
- public boolean hasFreeStandingFont() {
- if (this.fontFileSource != null) {
- return true;
- }
- if (this.fontFileContents != null) {
- return true;
- }
- if (this.metricsFileSource != null) {
- return true;
- }
- if (this.serializedMetricsFile != null) {
- return true;
- }
- return false;
- }
-
- /**
- * Indicates whether a SystemFont manifestation of this registered font
- * exists.
- * @return True if and only if a SystemFont manifestation of this registered font
- * exists.
- */
- public boolean hasSystemFont() {
- if (this.systemName != null && !this.systemName.equals("")) {
- return true;
- }
- /* Try to create a system font and return true if it has succeeded */
- createSystemFont();
- return this.systemFont != null;
- }
-
- /**
- * Returns the Panose instance, if any, that should be used to evaluate
- * this font description.
- * @return The Panose value for this instance.
- */
- public Panose4a getPanose() {
- if (this.hasFreeStandingFont()) {
- return this.getFreeStandingFont().getPanoseInstance();
- }
- return null;
- }
-
- /**
- * Returns the serialized metrics file.
- * @return The serialized metrics file, or null if the there is no metrics
- * file or if the metrics file is not serialized.
- */
- public URL getSerializedMetricsFile() {
- return this.serializedMetricsFile;
- }
-
- /**
- * Sets the serialized metrics file.
- * @param serializedMetricsFile The new serialized metrics file.
- */
- public void setSerializedMetricsFile(final URL serializedMetricsFile) {
- this.serializedMetricsFile = serializedMetricsFile;
- }
-
- /**
- * Returns the {@link FreeStandingFont} linked to this registered font, if it exists, or the
- * System font if no FreeStandingFont exists.
- * @return The best font associated with this registered font.
- */
- public Font4a getBestFont() {
- if (this.hasFreeStandingFont()) {
- return this.getFreeStandingFont();
- }
- return this.getSystemFont();
- }
-
- @Override
- public PsServer getPsServer() {
- return this.fontServer.getPsServer();
- }
-
- @Override
- public String toString() {
- return this.configuredFontName;
- }
-
- /**
- * Returns the font file description.
- * @return The font file description.
- */
- public String getFontFileDescription() {
- return fontFileDescription;
- }
-
- /**
- * Returns the metrics file description.
- * @return The metrics file description.
- */
- public String getMetricsFileDescription() {
- return metricsFileDescription;
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java (from rev 12626, trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -0,0 +1,549 @@
+/*
+ * 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.font.config;
+
+import org.foray.common.sequence.ByteArray;
+import org.foray.common.sequence.ByteSequenceParser;
+import org.foray.font.Font4a;
+import org.foray.font.FontServer4a;
+import org.foray.font.FreeStandingFont;
+import org.foray.font.FsTrueTypeFont;
+import org.foray.font.FsType1Font;
+import org.foray.font.SystemFont;
+import org.foray.font.format.FontParser;
+import org.foray.font.format.FontParserClient;
+import org.foray.font.format.Panose4a;
+import org.foray.font.format.type1.Type1MetricsParser;
+
+import org.axsl.font.Font;
+import org.axsl.font.FontException;
+import org.axsl.ps.PsServer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * <p>A font file (or system-registered equivalent) that has been registered for use with FOray.
+ * Such a file can be referenced by multiple instances of {@link RegisteredFontFamilyMember}.
+ * The purpose of that class is to bind an abstract font description (font-family, style, weight, etc.) to an instance
+ * of this class.
+ * The purpose of this class is to bind to a physical font file (or system-registered equivalent).
+ * Instances of this class encapsulate the information in a "font-content" element in the font configuration XML.</p>
+ *
+ * <p>It is tempting to question why this separate class is needed. Because fonts
+ * can be registered from several sources (hard-coded, font configuration,
+ * operating system registration, and directly by the client application), a
+ * separate registry concept ensures that all of the registered fonts can be
+ * managed, even though they may not have been parsed yet. It is good to not
+ * parse the font until it is known to be necessary.
+ *
+ * Note that the data stored in RegisteredFont corresponds to the data passed
+ * in the <font> element of the font configuration file.
+ * Data from the actual font file itself tends to be stored in FreeStandingFont
+ * or one of its subclasses.</p>
+ */
+public class RegisteredFontContent implements FontParserClient {
+
+ /** Array of the base-14 font names. */
+ public static final String[] STANDARD_PDF_FONT_NAMES = new String[] {
+ "Helvetica",
+ "Helvetica-Oblique",
+ "Helvetica-Bold",
+ "Helvetica-BoldOblique",
+ "Times-Roman",
+ "Times-Italic",
+ "Times-Bold",
+ "Times-BoldItalic",
+ "Courier",
+ "Courier-Oblique",
+ "Courier-Bold",
+ "Courier-BoldOblique",
+ "Symbol",
+ "ZapfDingbats"
+ };
+
+ /** The name of the font as specified in the font configuration file. */
+ private String configuredFontName = null;
+
+ /** The system-name (AWT name) for this font, as specified in the font
+ * configuration file. */
+ private String systemName = null;
+
+ /**
+ * For TrueType collections, ttcName specifies the name of the font within
+ * the TTC that should be used.
+ */
+ private String ttcName = null;
+
+ /** The serialized metrics file. This will be null if the font is not a
+ * Type 1 font, or if its metrics file is not serialized. */
+ private URL serializedMetricsFile;
+
+ /** The font file contents. This should be null for fonts where we know how to read or re-read the contents. */
+ private byte[] fontFileContents;
+
+ /** Description of the font source. This should be null unless {@link #fontFileContents} is not. */
+ private String fontFileDescription;
+
+ /** The metric file contents. This should be null for fonts where we know how to read or re-read the contents. */
+ private byte[] metricsFileContents;
+
+ /** Description of the font metrics source. This should be null unless {@link #metricsFileContents} is not. */
+ private String metricsFileDescription;
+
+ /** The requested embedding for this font. */
+ private Font.Embedding requestedEmbedding = Font.Embedding.NONE;
+
+ /** The FreeStandingFont instance, if any, that has been created for this
+ * RegisteredFont. */
+ private FreeStandingFont fsFont = null;
+
+ /** The SystemFont instance, if any, that has been created for this
+ * RegisteredFont. */
+ private SystemFont systemFont = null;
+
+ /** Indicates whether the creation of the FreeStandingFont has already
+ * been attempted. */
+ private boolean fsFontCreationCompleted = false;
+
+ /** Indicates whether the creation of the SystemFont has already been
+ * attempted. */
+ private boolean systemFontCreationCompleted = false;
+
+ /** The parent FontServer. */
+ private FontServer4a fontServer = null;
+
+ /** The source of the font file, if any. */
+ private URL fontFileSource;
+
+ /** The source of the metrics file, if any. */
+ private URL metricsFileSource;
+
+ /**
+ * Constructor useful for registering a Font that has not yet been read.
+ * @param server The parent font server.
+ * @param fontName The name of the font.
+ * @param fontFileSource The source of the font file, if any.
+ * @param metricsFileSource The source of the metrics file, if any.
+ * @param ttcName The font name to be used within a TrueType Collection file
+ * to select the proper font.
+ * @param embedding Indicates whether and how much of the font should be
+ * embedded.
+ * @param systemName A non-null value indicates that this font can manifest
+ * itself as a SystemFont.
+ * @throws FontException For an error during font registration.
+ */
+ public RegisteredFontContent(final FontServer4a server, final String fontName, final URL fontFileSource,
+ final URL metricsFileSource, final String ttcName,
+ final Font.Embedding embedding, final String systemName)
+ throws FontException {
+ this.fontServer = server;
+ this.fontFileSource = fontFileSource;
+ this.metricsFileSource = metricsFileSource;
+ this.configuredFontName = fontName;
+ this.ttcName = ttcName;
+ if (embedding == null) {
+ this.requestedEmbedding = Font.Embedding.NONE;
+ } else {
+ this.requestedEmbedding = embedding;
+ }
+ this.systemName = systemName;
+ server.registerFont(fontName, this);
+ }
+
+ /**
+ * Constructor useful for registering a font whose contents have been extracted from a document.
+ * @param server The parent font server.
+ * @param fontID A unique ID for this font (e.g. "Courier-Bold").
+ * @param fontFileDescription A description of the font file. This is used primarily in user messages.
+ * @param fontFileContents Byte array containing the font file contents.
+ * @param metricsFileDescription A description of the metrics file. This is used primarily in user messages.
+ * @param metricsFileContents Byte array containing the metrics contents.
+ * This is always null for TrueType and OpenType fonts.
+ * @param collectionID For TrueType collections, indicates which font in the collection corresponds to this font.
+ * @param embedding One of "none", "all", or "subset", indicating whether this font should be embedded in output
+ * documents.
+ * @param systemName For system fonts only, this is the name that should be supplied to the operating system font
+ * registry to obtain the font from it. For other fonts, set this to null.
+ * @throws FontException If a font with this {@code fontID} is already registered.
+ */
+ public RegisteredFontContent(final FontServer4a server, final String fontID,
+ final String fontFileDescription, final byte[] fontFileContents,
+ final String metricsFileDescription, final byte[] metricsFileContents,
+ final String collectionID, final Font.Embedding embedding, final String systemName)
+ throws FontException {
+ this(server, fontID, null, null, null, embedding, systemName);
+ this.fontFileDescription = fontFileDescription;
+ this.fontFileContents = fontFileContents;
+ this.metricsFileDescription = metricsFileDescription;
+ this.metricsFileContents = metricsFileContents;
+ server.registerFont(fontID, this);
+ }
+
+ /**
+ * Attempts to create a SystemFont manifestation of this registered font.
+ */
+ private void createFreeStandingFont() {
+ if (this.fsFontCreationCompleted) {
+ return;
+ }
+ this.fsFontCreationCompleted = true;
+
+ if (! this.hasFreeStandingFont()) {
+ /* We do not have what is needed to create a FreeStandingFont. */
+ return;
+ }
+
+ try {
+ this.fsFont = createFSFont();
+ if (this.fsFont == null) {
+ this.fsFont = getFontServer().getDefaultFreeStandingFont()
+ .getRegisteredFont().fsFont;
+ getLogger().error("Unable to open font "
+ + this.configuredFontName + ".");
+ getLogger().error("Using a default font instead.");
+ return;
+ }
+ if (! (this.requestedEmbedding == Font.Embedding.NONE)
+ && ! this.fsFont.allowsEmbedding()) {
+ getLogger().warn("Font " + this.configuredFontName
+ + " does not allow embedding.");
+ }
+ } catch (final FontException ex) {
+ getLogger().error("Failed to create font object "
+ + "for: "
+ + this.configuredFontName);
+ getLogger().error(ex.getMessage());
+ }
+ }
+
+ /**
+ * Creates a SytemFont manifestation of this registered font if possible.
+ */
+ private void createSystemFont() {
+ if (this.systemFontCreationCompleted) {
+ return;
+ }
+ this.systemFontCreationCompleted = true;
+ this.systemFont = SystemFont.makeSystemFont(this);
+ }
+
+ /**
+ * Creates a font file reader for this registered font.
+ * @return The reader.
+ * @throws FontException For errors opening the font file reader.
+ */
+ public FontParser createFontFileReader() throws FontException {
+ if (this.fontFileSource != null) {
+ try {
+ return new FontParser(this, this.fontFileSource.openStream());
+ } catch (final IOException e) {
+ throw new FontException(e);
+ }
+ }
+
+ if (this.fontFileContents != null) {
+ try {
+ final ByteArray byteArray = new ByteArray(this.fontFileContents);
+ final ByteSequenceParser bsp = new ByteSequenceParser(byteArray);
+ return new FontParser(this, bsp);
+ } catch (final IOException e) {
+ throw new FontException(e);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates a metrics file reader for this registered font.
+ * @return The reader.
+ * @throws FontException For errors opening the metrics file reader.
+ */
+ public Type1MetricsParser createMetricsFileReader() throws FontException {
+ if (this.metricsFileSource != null) {
+ try {
+ return new Type1MetricsParser(this.fontServer, this.metricsFileSource.openStream());
+ } catch (final IOException e) {
+ throw new FontException(e);
+ }
+ }
+
+ if (this.metricsFileContents != null) {
+ try {
+ final ByteArray byteArray = new ByteArray(this.metricsFileContents);
+ final ByteSequenceParser bsp = new ByteSequenceParser(byteArray);
+ return new Type1MetricsParser(this.fontServer, bsp);
+ } catch (final IOException e) {
+ throw new FontException(e);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Attempts to create a FreeStandingFont manifestation of this registered
+ * font.
+ * @return The FreeStandingFont manifestation.
+ * @throws FontException For error during FreeStandingFont creation.
+ */
+ private FreeStandingFont createFSFont() throws FontException {
+ final Font.Format fontFormat;
+ if (this.fontFileSource == null) {
+ /* The assumption here is that we have a metrics file for this
+ * font, but not a font file, therefore it is Type 1. */
+ fontFormat = Font.Format.TYPE1;
+ } else {
+ /* TODO: See if we ca*/
+ fontFormat = createFontFileReader().getFontFormat();
+ }
+ switch (fontFormat) {
+ case TYPE1: {
+ return new FsType1Font(this);
+ }
+ case TRUETYPE:
+ case OTF_CFF:
+ case OTF_TRUETYPE: {
+ try {
+ return new FsTrueTypeFont(this);
+ } catch (final IOException e) {
+ /* TODO: Remove the throwing of the exception caught here. */
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+ throw new FontException("Font " + this.configuredFontName
+ + " is an unknown format.");
+ }
+
+ /**
+ * Returns the {@link FreeStandingFont} manifestation of this font.
+ * @return The {@link FreeStandingFont} manifestation, if any, of this
+ * RegisteredFont.
+ */
+ public FreeStandingFont getFreeStandingFont() {
+ if (this.fsFont == null) {
+ createFreeStandingFont();
+ }
+ return this.fsFont;
+ }
+
+ /**
+ * Returns the {@link SystemFont} manifestation of this font.
+ * @return The SystemFont manifestation, if any, of this RegisteredFont.
+ */
+ public SystemFont getSystemFont() {
+ if (this.systemFont == null) {
+ createSystemFont();
+ }
+ return this.systemFont;
+ }
+
+ /**
+ * Returns the system name for this registerered font.
+ * @return The "system-name" as configured by the user. This is the name of
+ * the AWT font (not font-family) that can be created.
+ */
+ public String getSystemName() {
+ return this.systemName;
+ }
+
+ /**
+ * Return the registered TrueType collection name that should be used to
+ * access this font within a TTC file.
+ * @return The TTC name.
+ */
+ public String getTTCName() {
+ return this.ttcName;
+ }
+
+ /**
+ * Returns the parent font server.
+ * @return The parent font server.
+ */
+ public FontServer4a getFontServer() {
+ return this.fontServer;
+ }
+
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
+ /**
+ * Returns the configured font name.
+ * @return Returns the configuredFontName.
+ */
+ public String getConfiguredFontName() {
+ return this.configuredFontName;
+ }
+
+ /**
+ * Indicates whether this font should be embedded.
+ * @return Returns the embedding.
+ */
+ public boolean isEmbedding() {
+ return this.requestedEmbedding != Font.Embedding.NONE;
+ }
+
+ /**
+ * Indicates whether this font should be subsetted.
+ * @return Returns the subsetting.
+ */
+ public boolean isSubsetting() {
+ return this.requestedEmbedding == Font.Embedding.SUBSET;
+ }
+
+ /**
+ * Indicates whether this can return the content of the font.
+ * @return True if and only if, this can return the content of the font.
+ */
+ public boolean hasFontContent() {
+ if (this.fontFileSource != null) {
+ return true;
+ }
+ if (this.fontFileContents != null) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether a FreeStandingFont manifestation of this registered
+ * font exists.
+ * @return True if and only if a FreeStandingFont manifestation of this registered
+ * font exists.
+ */
+ public boolean hasFreeStandingFont() {
+ if (this.fontFileSource != null) {
+ return true;
+ }
+ if (this.fontFileContents != null) {
+ return true;
+ }
+ if (this.metricsFileSource != null) {
+ return true;
+ }
+ if (this.serializedMetricsFile != null) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether a SystemFont manifestation of this registered font
+ * exists.
+ * @return True if and only if a SystemFont manifestation of this registered font
+ * exists.
+ */
+ public boolean hasSystemFont() {
+ if (this.systemName != null && !this.systemName.equals("")) {
+ return true;
+ }
+ /* Try to create a system font and return true if it has succeeded */
+ createSystemFont();
+ return this.systemFont != null;
+ }
+
+ /**
+ * Returns the Panose instance, if any, that should be used to evaluate
+ * this font description.
+ * @return The Panose value for this instance.
+ */
+ public Panose4a getPanose() {
+ if (this.hasFreeStandingFont()) {
+ return this.getFreeStandingFont().getPanoseInstance();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the serialized metrics file.
+ * @return The serialized metrics file, or null if the there is no metrics
+ * file or if the metrics file is not serialized.
+ */
+ public URL getSerializedMetricsFile() {
+ return this.serializedMetricsFile;
+ }
+
+ /**
+ * Sets the serialized metrics file.
+ * @param serializedMetricsFile The new serialized metrics file.
+ */
+ public void setSerializedMetricsFile(final URL serializedMetricsFile) {
+ this.serializedMetricsFile = serializedMetricsFile;
+ }
+
+ /**
+ * Returns the {@link FreeStandingFont} linked to this registered font, if it exists, or the
+ * System font if no FreeStandingFont exists.
+ * @return The best font associated with this registered font.
+ */
+ public Font4a getBestFont() {
+ if (this.hasFreeStandingFont()) {
+ return this.getFreeStandingFont();
+ }
+ return this.getSystemFont();
+ }
+
+ @Override
+ public PsServer getPsServer() {
+ return this.fontServer.getPsServer();
+ }
+
+ @Override
+ public String toString() {
+ return this.configuredFontName;
+ }
+
+ /**
+ * Returns the font file description.
+ * @return The font file description.
+ */
+ public String getFontFileDescription() {
+ return fontFileDescription;
+ }
+
+ /**
+ * Returns the metrics file description.
+ * @return The metrics file description.
+ */
+ public String getMetricsFileDescription() {
+ return metricsFileDescription;
+ }
+
+}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java 2022-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamily.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -100,7 +100,7 @@
* @param simulatedStretch A percentage.
* @throws FontException For error in registration.
*/
- public void registerFontDesc(final RegisteredFont registeredFont,
+ public void registerFontDesc(final RegisteredFontContent registeredFont,
final Encoding encoding, final String style, final String weight,
final String variant, final String stretch,
final String simulatedSmallCaps, final String simulatedOblique,
@@ -166,7 +166,7 @@
* @param simulatedStretch A percentage.
* @throws FontException For error in registration.
*/
- public void registerFontDesc(final RegisteredFont registeredFont,
+ public void registerFontDesc(final RegisteredFontContent registeredFont,
final Encoding encoding, final Font.Style style,
final Font.Weight weight,
final Font.Variant variant, final Font.Stretch stretch,
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamilyMember.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamilyMember.java 2022-03-26 12:06:59 UTC (rev 12636)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontFamilyMember.java 2022-03-26 12:39:37 UTC (rev 12637)
@@ -40,7 +40,7 @@
* font is used.
* An RFD instance has one {@link RegisteredFontFamily} parent, which provides
* the font-family context in which it can be selected, and one
- * {@link RegisteredFont} parent, which provides the link to the actual font.
+ * {@link RegisteredFontContent} parent, which provides the link to the actual font.
* It is analogous to the font-description element in the font configuration,
* and is typically created directly as that is parsed.</p>
*
@@ -87,7 +87,7 @@
public static final byte SIMULATE_ULTRA_EXPANDED_INDEX = 7;
/** The parent RegisteredFont instance. */
- private RegisteredFont registeredFont;
+ private Reg...
[truncated message content] |
|
From: <vic...@us...> - 2022-03-26 12:07:03
|
Revision: 12636
http://sourceforge.net/p/foray/code/12636
Author: victormote
Date: 2022-03-26 12:06:59 +0000 (Sat, 26 Mar 2022)
Log Message:
-----------
Conform to aXSL changes in font config DTD: 1. Rename font to font-content. 2. Rename family-member to font. 3. Make font and font-content peers.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-font/src/test/resources/font-config.xml
trunk/foray/settings.gradle
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-02-28 18:15:21 UTC (rev 12635)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2022-03-26 12:06:59 UTC (rev 12636)
@@ -64,8 +64,7 @@
*/
public class FontConfigParser extends SaxParser<Object> {
- /** Stateful variable tracking which RegisteredFontFamily is currently
- * being parsed. */
+ /** Stateful variable tracking which RegisteredFontFamily is currently being parsed. */
private RegisteredFontFamily currentFontFamily = null;
/**
@@ -140,8 +139,7 @@
try {
this.currentXMLBase = UrlFactory.createURL("file", null, ".");
} catch (final MalformedURLException e) {
- /* This shouldn't fail, but if it does, there isn't much that can
- * be done. */
+ /* This shouldn't fail, but if it does, there isn't much that can be done. */
errorMessage(e.getMessage());
}
}
@@ -176,14 +174,14 @@
parseElementFontGroup(attributes);
return;
}
+ if (localName.equals("font-content")) {
+ parseElementFontContent(attributes);
+ return;
+ }
if (localName.equals("font")) {
parseElementFont(attributes);
return;
}
- if (localName.equals("family-member")) {
- parseElementFamilyMember(attributes);
- return;
- }
if (localName.equals("server")) {
parseElementServer(attributes);
return;
@@ -201,7 +199,7 @@
return;
}
// Make sure user knows about unknown tag
- logError("Unknown tag in font configuration " + "file: " + localName);
+ errorMessage("Unknown tag in font configuration " + "file: " + localName);
}
/**
@@ -224,12 +222,12 @@
|| alias.equals("")
|| family == null
|| family.equals("")) {
- logError("font-family-alias entry invalid. " + "Ignored.");
+ errorMessage("font-family-alias entry invalid. " + "Ignored.");
} else {
try {
this.fontServer.registerFontFamilyAlias(alias, family);
} catch (final FontException e) {
- logError(e.getMessage());
+ errorMessage(e.getMessage());
}
}
}
@@ -264,8 +262,7 @@
}
}
if (value == null) {
- logWarning("Environment variable '" + fromEnvironment
- + "' not found.");
+ warningMessage("Environment variable '" + fromEnvironment + "' not found.");
} else {
this.parameters.put(key, value);
}
@@ -282,7 +279,7 @@
final String fromEnvironment) {
if (key == null
|| key.equals("")) {
- logError("<parameter> element requires 'key' attribute. Ignored.");
+ errorMessage("<parameter> element requires 'key' attribute. Ignored.");
return false;
}
final boolean valueNull =
@@ -292,13 +289,11 @@
fromEnvironment == null
|| fromEnvironment.equals("");
if (valueNull && fromEnvironmentNull) {
- logError("<parameter> element requires either 'value' or "
- + "'from-environment' attribute. Ignored.");
+ errorMessage("<parameter> element requires either 'value' or 'from-environment' attribute. Ignored.");
return false;
}
if (! valueNull && ! fromEnvironmentNull) {
- logError("<parameter> element cannot have both a 'value' and a "
- + "'from-environment' attribute. Ignored.");
+ errorMessage("<parameter> element cannot have both a 'value' and a 'from-environment' attribute. Ignored.");
return false;
}
return true;
@@ -316,7 +311,7 @@
final String name = attributes.getValue("name");
if (name == null
|| name.equals("")) {
- logError("\"name\" attribute required for font-family. Ignored.");
+ errorMessage("\"name\" attribute required for font-family. Ignored.");
return;
}
try {
@@ -324,7 +319,7 @@
= this.fontServer.registerFontFamily2(name);
} catch (final FontException e) {
/* Log a warning. */
- logWarning(e.getMessage());
+ warningMessage(e.getMessage());
/* Use the existing font family if you can. */
this.currentFontFamily = this.fontServer.getRegisteredFontFamily(
name);
@@ -345,9 +340,7 @@
this.currentXMLBase = UrlFactory.createURL(this.previousXMLBase,
xmlBase);
} catch (final MalformedURLException e) {
- logError("Unable to create URL from "
- + this.previousXMLBase.getPath()
- + " AND " + xmlBase);
+ errorMessage("Unable to create URL from " + this.previousXMLBase.getPath() + " AND " + xmlBase);
}
}
this.fontIdCounter = 0;
@@ -376,7 +369,7 @@
* Parses the "family-member" element.
* @param attributes The raw parsed attributes.
*/
- private void parseElementFamilyMember(final Attributes attributes) {
+ private void parseElementFont(final Attributes attributes) {
if (this.currentFontFamily == null) {
return;
}
@@ -433,10 +426,10 @@
}
/**
- * Parses a "font" element.
+ * Parses a "font-content" element.
* @param attributes The raw parsed attributes.
*/
- private void parseElementFont(final Attributes attributes) {
+ private void parseElementFontContent(final Attributes attributes) {
final String fontFile = replaceParameters(attributes.getValue("font-file"));
String fontID = attributes.getValue("id");
final String metricsFile = replaceParameters(attributes.getValue("metrics-file"));
@@ -459,7 +452,7 @@
try {
fontFileSource = UrlFactory.createURL(this.currentXMLBase, fontFile);
} catch (final MalformedURLException e) {
- this.logError("Malformed font file URL in font configuration: " + fontFile);
+ this.errorMessage("Malformed font file URL in font configuration: " + fontFile);
/* TODO: Just invalidate this one font and warn the user instead
* of invalidating everything. */
this.fontServer.setFatalConfigurationError(true);
@@ -472,7 +465,7 @@
try {
metricsFileSource = UrlFactory.createURL(this.currentXMLBase, metricsFile);
} catch (final MalformedURLException e) {
- this.logError("Malformed metrics file URL in font configuration: " + metricsFile);
+ this.errorMessage("Malformed metrics file URL in font configuration: " + metricsFile);
/* TODO: Just invalidate this one font and warn the user instead
* of invalidating everything. */
this.fontServer.setFatalConfigurationError(true);
@@ -501,7 +494,7 @@
this.fontServer.registerFont(fontID, fontFileSource,
metricsFileSource, collectionID, embed, systemName);
} catch (final FontException e) {
- this.logError(e.getMessage());
+ this.errorMessage(e.getMessage());
return;
}
refID = fontID;
@@ -509,7 +502,7 @@
final RegisteredFont registeredFont = this.fontServer.getRegisteredFont(
refID);
if (registeredFont == null) {
- logWarning("Font is not registered: " + refID);
+ warningMessage("Font is not registered: " + refID);
return;
}
try {
@@ -524,7 +517,7 @@
this.currentFontFamilyMember.simulateBackslant,
this.currentFontFamilyMember.simulateStretch);
} catch (final FontException e) {
- logWarning(e.getMessage());
+ warningMessage(e.getMessage());
}
}
@@ -550,12 +543,9 @@
}
try {
/* Update the current xml base. */
- this.currentXMLBase = UrlFactory.createURL(this.currentXMLBase,
- xmlBase);
+ this.currentXMLBase = UrlFactory.createURL(this.currentXMLBase, xmlBase);
} catch (final MalformedURLException e) {
- logError("Unable to create URL from "
- + this.currentXMLBase.getPath()
- + " AND " + xmlBase);
+ errorMessage("Unable to create URL from " + this.currentXMLBase.getPath() + " AND " + xmlBase);
}
}
@@ -569,7 +559,7 @@
configureRootAttributes();
return;
}
- if (localName.equals("font")) {
+ if (localName.equals("font-content")) {
return;
}
if (localName.equals("font-family")) {
@@ -579,10 +569,7 @@
this.currentEmbed = this.previousEmbed;
return;
}
- if (localName.equals("font-description")) {
- return;
- }
- if (localName.equals("family-member")) {
+ if (localName.equals("font")) {
this.currentFontFamilyMember = null;
return;
}
@@ -630,8 +617,7 @@
this.currentXMLBase = UrlFactory.createURL(directory);
}
} catch (final MalformedURLException e1) {
- logError("Cannot create URL from current directory: "
- + directory);
+ errorMessage("Cannot create URL from current directory: " + directory);
}
return;
}
@@ -640,7 +626,7 @@
this.parsedRootXMLBase);
this.currentXMLBase = UrlFactory.createURL(modifiedBase);
} catch (final MalformedURLException e) {
- logError("Cannot create URL from: " + this.parsedRootXMLBase);
+ errorMessage("Cannot create URL from: " + this.parsedRootXMLBase);
}
}
@@ -652,19 +638,18 @@
final String name = attributes.getValue("name");
if (name == null
|| name.equals("")) {
- logError("Attribute \"name\" required for element \"encoding\".");
+ errorMessage("Attribute \"name\" required for element \"encoding\".");
return;
}
PsEncoding encoding = this.fontServer.getPsServer().getPredefinedEncoding(name);
if (encoding != null) {
- logError("Encoding already defined: " + name);
+ errorMessage("Encoding already defined: " + name);
return;
}
final String encodingFile = attributes.getValue("file");
if (encodingFile == null
|| encodingFile.equals("")) {
- logError("Attribute \"file\" required for "
- + "element \"encoding\".");
+ errorMessage("Attribute \"file\" required for element \"encoding\".");
return;
}
final URL url;
@@ -671,7 +656,7 @@
try {
url = UrlFactory.createURL(encodingFile);
} catch (final MalformedURLException e) {
- logError("Unable to create URL: " + encodingFile);
+ errorMessage("Unable to create URL: " + encodingFile);
return;
}
final InputStream input;
@@ -678,14 +663,13 @@
try {
input = url.openStream();
} catch (final IOException e1) {
- logError("Unable to read: " + encodingFile);
+ errorMessage("Unable to read: " + encodingFile);
return;
}
final String parseColumn = attributes.getValue("column-to-parse");
if (parseColumn == null
|| parseColumn.equals("")) {
- logError("Attribute \"column-to-parse\" "
- + "required for element \"encoding\".");
+ errorMessage("Attribute \"column-to-parse\" required for element \"encoding\".");
return;
}
final int columnNumber = Integer.parseInt(parseColumn);
@@ -692,8 +676,7 @@
final String radixString = attributes.getValue("radix");
if (radixString == null
|| parseColumn.equals("")) {
- logError("Attribute \"radix\" "
- + "required for element \"encoding\".");
+ errorMessage("Attribute \"radix\" required for element \"encoding\".");
return;
}
final int radix = Integer.parseInt(radixString);
@@ -708,9 +691,9 @@
encoding = this.fontServer.getPsServer().parseEncodingVector(name, input, columnNumber, radix, glyphList);
this.encodingsMap.put(name, encoding);
} catch (final IOException e) {
- logError("Error parsing Encoding Vector \"" + name + "\": " + e.getMessage());
+ errorMessage("Error parsing Encoding Vector \"" + name + "\": " + e.getMessage());
} catch (final PsException e) {
- logError("Error parsing Encoding Vector \"" + name + "\": " + e.getMessage());
+ errorMessage("Error parsing Encoding Vector \"" + name + "\": " + e.getMessage());
}
}
@@ -722,15 +705,13 @@
final String name = attributes.getValue("name");
if (name == null
|| name.equals("")) {
- logError("Attribute \"name\" required for "
- + "element \"glyph-list\".");
+ errorMessage("Attribute \"name\" required for element \"glyph-list\".");
return;
}
final String file = attributes.getValue("file");
if (file == null
|| file.equals("")) {
- logError("Attribute \"file\" required for "
- + "element \"glyph-list\".");
+ errorMessage("Attribute \"file\" required for element \"glyph-list\".");
return;
}
final URL url;
@@ -737,7 +718,7 @@
try {
url = UrlFactory.createURL(file);
} catch (final MalformedURLException e) {
- logError("Unable to create URL: " + file);
+ errorMessage("Unable to create URL: " + file);
return;
}
final InputStream input;
@@ -744,7 +725,7 @@
try {
input = url.openStream();
} catch (final IOException e1) {
- logError("Unable to read: " + file);
+ errorMessage("Unable to read: " + file);
return;
}
try {
@@ -751,9 +732,9 @@
final GlyphList glyphList = this.fontServer.getPsServer().parseGlyphList(name, input);
this.glyphListMap.put(name, glyphList);
} catch (final IOException e) {
- logError("Error parsing \"" + file + "\": " + e.getMessage());
+ errorMessage("Error parsing \"" + file + "\": " + e.getMessage());
} catch (final PsException e) {
- logError("Error parsing \"" + file + "\": " + e.getMessage());
+ errorMessage("Error parsing \"" + file + "\": " + e.getMessage());
}
}
@@ -785,32 +766,6 @@
}
/**
- * Logs a warning to the logger.
- * @param message The warning message.
- */
- private void logWarning(final String message) {
- warningMessage(message + "\n" + getContextMessage());
- }
-
- /**
- * Logs an error to the logger.
- * @param message The error message.
- */
- private void logError(final String message) {
- errorMessage(message + "\n" + getContextMessage());
- }
-
- /**
- * Provides a formatted string showing the current locator context, which
- * is useful in user messages to indicate where in the document a condition
- * arose.
- * @return The formatted context message.
- */
- private String getContextMessage() {
- return " Context: " + getLocationString();
- }
-
- /**
* Inner class for storing font-group items.
*/
private class FontGroup {
Modified: trunk/foray/foray-font/src/test/resources/font-config.xml
===================================================================
--- trunk/foray/foray-font/src/test/resources/font-config.xml 2022-02-28 18:15:21 UTC (rev 12635)
+++ trunk/foray/foray-font/src/test/resources/font-config.xml 2022-03-26 12:06:59 UTC (rev 12636)
@@ -14,77 +14,40 @@
<!-- Some standard AWT fonts. -->
<font-group label="AWT-standard">
<font-family name="AWT-sans-serif">
- <family-member style="normal" weight="normal">
- <font
- id="AWT-sans-serif-plain"
- system-name="sansserif"/>
- </family-member>
- <family-member style="italic" weight="normal">
- <font
- id="AWT-sans-serif-italic"
- system-name="sansserif.italic"/>
- </family-member>
- <family-member style="normal" weight="bold">
- <font
- id="AWT-sans-serif-bold"
- system-name="sansserif.bold"/>
- </family-member>
- <family-member style="italic" weight="bold">
- <font
- id="AWT-sans-serif-bold-italic"
- system-name="sansserif.bolditalic"/>
- </family-member>
+ <font-content id="AWT-sans-serif-plain" system-name="sansserif"/>
+ <font-content id="AWT-sans-serif-italic" system-name="sansserif.italic"/>
+ <font-content id="AWT-sans-serif-bold" system-name="sansserif.bold"/>
+ <font-content id="AWT-sans-serif-bold-italic" system-name="sansserif.bolditalic"/>
+ <font content="AWT-sans-serif-plain" style="normal" weight="normal"/>
+ <font content="AWT-sans-serif-italic" style="italic" weight="normal"/>
+ <font content="AWT-sans-serif-bold" style="normal" weight="bold"/>
+ <font content="AWT-sans-serif-bold-italic" style="italic" weight="bold"/>
</font-family>
+
<font-family name="AWT-serif">
- <family-member style="normal" weight="normal">
- <font
- id="AWT-serif-plain"
- system-name="serif"/>
- </family-member>
- <family-member style="italic" weight="normal">
- <font
- id="AWT-serif-italic"
- system-name="serif.italic"/>
- </family-member>
- <family-member style="normal" weight="bold">
- <font
- id="AWT-serif-bold"
- system-name="serif.bold"/>
- </family-member>
- <family-member style="italic" weight="bold">
- <font
- id="AWT-serif-bold-italic"
- system-name="serif.bolditalic"/>
- </family-member>
+ <font-content id="AWT-serif-plain" system-name="serif"/>
+ <font-content id="AWT-serif-italic" system-name="serif.italic"/>
+ <font-content id="AWT-serif-bold" system-name="serif.bold"/>
+ <font-content id="AWT-serif-bold-italic" system-name="serif.bolditalic"/>
+ <font content="AWT-serif-plain" style="normal" weight="normal"/>
+ <font content="AWT-serif-italic" style="italic" weight="normal"/>
+ <font content="AWT-serif-bold" style="normal" weight="bold"/>
+ <font content="AWT-serif-bold-italic" style="italic" weight="bold"/>
</font-family>
+
<font-family name="AWT-monospaced">
- <family-member style="normal" weight="normal">
- <font
- id="AWT-monospaced-plain"
- system-name="monospaced"/>
- </family-member>
- <family-member style="italic" weight="normal">
- <font
- id="AWT-monospaced-italic"
- system-name="monospaced.italic"/>
- </family-member>
- <family-member style="normal" weight="bold">
- <font
- id="AWT-monospaced-bold"
- system-name="monospaced.bold"/>
- </family-member>
- <family-member style="italic" weight="bold">
- <font
- id="AWT-monospaced-bold-italic"
- system-name="monospaced.bolditalic"/>
- </family-member>
+ <font-content id="AWT-monospaced-plain" system-name="monospaced"/>
+ <font-content id="AWT-monospaced-italic" system-name="monospaced.italic"/>
+ <font-content id="AWT-monospaced-bold" system-name="monospaced.bold"/>
+ <font-content id="AWT-monospaced-bold-italic" system-name="monospaced.bolditalic"/>
+ <font content="AWT-monospaced-plain" style="normal" weight="normal"/>
+ <font content="AWT-monospaced-italic" style="italic" weight="normal"/>
+ <font content="AWT-monospaced-bold" style="normal" weight="bold"/>
+ <font content="AWT-monospaced-bold-italic" style="italic" weight="bold"/>
</font-family>
<font-family name="AWT-unicode">
- <family-member style="normal" weight="normal">
- <font
- id="AWT-unicode"
- system-name="Lucida Sans Unicode"/>
- </family-member>
+ <font-content id="AWT-unicode" system-name="Lucida Sans Unicode"/>
+ <font content="AWT-unicode" style="normal" weight="normal"/>
</font-family>
</font-group>
<!-- End of standard AWT fonts. -->
Modified: trunk/foray/settings.gradle
===================================================================
--- trunk/foray/settings.gradle 2022-02-28 18:15:21 UTC (rev 12635)
+++ trunk/foray/settings.gradle 2022-03-26 12:06:59 UTC (rev 12636)
@@ -1,5 +1,6 @@
rootProject.name = 'foray'
+include 'foray-00-master'
include 'foray-app'
include 'foray-areatree'
include 'foray-common'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-28 18:15:24
|
Revision: 12635
http://sourceforge.net/p/foray/code/12635
Author: victormote
Date: 2022-02-28 18:15:21 +0000 (Mon, 28 Feb 2022)
Log Message:
-----------
Remove SLF4J references from Application Binary Interface of foray-core.
Modified Paths:
--------------
trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java
trunk/foray/foray-core/build.gradle
trunk/foray/foray-core/src/main/java/org/foray/core/ForayDocument.java
trunk/foray/foray-core/src/main/java/org/foray/core/ForaySession.java
trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java
Modified: trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java 2022-02-28 17:26:21 UTC (rev 12634)
+++ trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java 2022-02-28 18:15:21 UTC (rev 12635)
@@ -94,7 +94,6 @@
* or in instantiating the ForaySession.
*/
public static ForaySession makeFOraySession(final SessionConfig sessionConfig) throws ForayException {
- final Logger logger = LoggerFactory.getLogger(ForaySpecific.class);
final FontServer fontServer = ForaySpecific.makeFontServer(sessionConfig);
final FoOrthographyServer hyphenServer = ForaySpecific.makeHyphenationServer(sessionConfig);
final GraphicServer graphicServer = ForaySpecific.makeGraphicServer();
@@ -104,8 +103,7 @@
final LineBreakerFactory lbFactory = ForaySpecific.makeLineBreakerFactory();
final LayoutFactory layoutFactory = ForaySpecific.makeLayoutFactory(lbFactory);
final SpeechServer speechServer = ForaySpecific.makeSpeechServer();
- final ForaySession session = new ForaySession(logger, sessionConfig,
- fontServer, hyphenServer, graphicServer,
+ final ForaySession session = new ForaySession(sessionConfig, fontServer, hyphenServer, graphicServer,
speechServer, foTreeServer, areaTreeFactory, lbFactory, layoutFactory);
return session;
}
Modified: trunk/foray/foray-core/build.gradle
===================================================================
--- trunk/foray/foray-core/build.gradle 2022-02-28 17:26:21 UTC (rev 12634)
+++ trunk/foray/foray-core/build.gradle 2022-02-28 18:15:21 UTC (rev 12635)
@@ -5,8 +5,7 @@
description = 'foray-core'
dependencies {
- /* TODO: Convert SLF4J "api" dependency to "implementation". */
- api group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j
+ implementation (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
implementation group: 'xml-resolver', name: 'xml-resolver', version: versions.xmlResolver
Modified: trunk/foray/foray-core/src/main/java/org/foray/core/ForayDocument.java
===================================================================
--- trunk/foray/foray-core/src/main/java/org/foray/core/ForayDocument.java 2022-02-28 17:26:21 UTC (rev 12634)
+++ trunk/foray/foray-core/src/main/java/org/foray/core/ForayDocument.java 2022-02-28 18:15:21 UTC (rev 12635)
@@ -41,7 +41,6 @@
import org.axsl.layout.LayoutFactory;
import org.axsl.speech.SpeechServer;
-import org.slf4j.Logger;
import org.w3c.dom.Document;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
@@ -298,18 +297,17 @@
if (! this.getSessionConfig().optionVerbosity().equals("debug")) {
return;
}
- final Logger log = getLogger();
if (exception instanceof SAXException) {
- log.error(exception.getMessage());
+ this.session.logError(exception.getMessage());
if (((SAXException) exception).getException() != null) {
- log.error(((SAXException) exception).getException().getMessage());
+ this.session.logError(((SAXException) exception).getException().getMessage());
}
} else if (exception instanceof ForayException) {
if (((ForayException) exception).getCause() != null) {
- log.error(((ForayException) exception).getCause().getMessage());
+ this.session.logError(((ForayException) exception).getCause().getMessage());
}
} else {
- log.error(exception.getMessage());
+ this.session.logError(exception.getMessage());
}
}
@@ -331,14 +329,6 @@
}
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.session.getLogger();
- }
-
- /**
* Returns the FontServer.
* @return The FontServer.
*/
@@ -387,6 +377,14 @@
}
/**
+ * Returns the {@link ForaySession} for this document.
+ * @return The session for this document.
+ */
+ public ForaySession getSession() {
+ return this.session;
+ }
+
+ /**
* Returns the SessionConfig for this document.
* @return The SessionConfig for this document.
*/
Modified: trunk/foray/foray-core/src/main/java/org/foray/core/ForaySession.java
===================================================================
--- trunk/foray/foray-core/src/main/java/org/foray/core/ForaySession.java 2022-02-28 17:26:21 UTC (rev 12634)
+++ trunk/foray/foray-core/src/main/java/org/foray/core/ForaySession.java 2022-02-28 18:15:21 UTC (rev 12635)
@@ -39,6 +39,7 @@
import org.axsl.speech.SpeechServer;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xml.sax.EntityResolver;
import java.util.ArrayList;
@@ -57,7 +58,7 @@
private List<ForayDocument> documentList = new ArrayList<ForayDocument>();
/** An logger to be used for this session. */
- private Logger log;
+ private Logger logger = LoggerFactory.getLogger(getClass());
/** A FontServer instance to be used for this session. */
private FontServer fontServer;
@@ -92,31 +93,22 @@
/**
* Constructor.
- * @param logger The (optional) logger that should be used for this
- * session. If null is passed, a default Logger will be created.
- * @param configuration The Configuration instance that should be used
- * with this session.
- * @param fontServer The (optional) FontServer instance that should be used
- * for this session. If null is passed, then a FontServer instance will be
- * created by this ForaySession. If an instance is passed, it needs to be
- * fully configured and ready to be used.
- * @param hyphenServer The HyphenationServer instance that should be used
- * for this session.
- * @param graphicServer The (optional) GraphicServer instance that should
- * be used for this session. If null is passed, then a GraphicServer
- * instance will be created by this FOray Session. If an instance is passed,
- * it needs to be fully configured and ready to be used.
- * @param speechServer The SpeechServer instance that should
- * be used for this session.
- * @param foTreeFactory The FOTreeFactory that should be used for this
- * session.
- * @param areaTreeFactory The AreaTreeFactory that should be used for this
- * session.
- * @param lbFactory The LineBreakerFactory that should be used for this session.
- * @param layoutFactory The LayoutFactory that should be used for this session.
+ * @param configuration The {@link SessionConfig} instance that should be used with this session.
+ * @param fontServer The (optional) {@link FontServer} instance that should be used for this session.
+ * If null is passed, then a {@link FontServer} instance will be created by this {@link ForaySession}.
+ * If an instance is passed, it needs to be fully configured and ready to be used.
+ * @param hyphenServer The {@link OrthographyServer} instance that should be used for this session.
+ * @param graphicServer The (optional) {@link GraphicServer} instance that should be used for this session.
+ * If null is passed, then a {@link GraphicServer} instance will be created by this {@link ForaySession}.
+ * If an instance is passed, it needs to be fully configured and ready to be used.
+ * @param speechServer The {@link SpeechServer} instance that should be used for this session.
+ * @param foTreeFactory The {@link FoTreeFactory} that should be used for this session.
+ * @param areaTreeFactory The {@link AreaTreeFactory} that should be used for this session.
+ * @param lbFactory The {@link LineBreakerFactory} that should be used for this session.
+ * @param layoutFactory The {@link LayoutFactory} that should be used for this session.
* @throws ForayException For invalid parameters.
*/
- public ForaySession(final Logger logger, final SessionConfig configuration,
+ public ForaySession(final SessionConfig configuration,
final FontServer fontServer, final OrthographyServer hyphenServer,
final GraphicServer graphicServer,
final SpeechServer speechServer,
@@ -125,13 +117,7 @@
final LineBreakerFactory lbFactory,
final LayoutFactory layoutFactory)
throws ForayException {
- /* Validate Logger. */
- if (logger == null) {
- throw new ForayException("Logger required for ForaySession.");
- }
- this.log = logger;
- this.log.info(Application.getApplicationNameShort() + " "
- + Application.getVersion());
+ logInfo(Application.getApplicationNameShort() + " " + Application.getVersion());
/* Validate Configuration. */
this.configuration = configuration;
@@ -196,14 +182,6 @@
}
/**
- * Returns the logger for this session.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.log;
- }
-
- /**
* Registers a ForayDocument instance that this ForaySession should process.
* @param document The ForayDocument instance that should be processed.
*/
@@ -218,22 +196,20 @@
* Sets up a FontServer instance if there is not one already.
*/
private void setupFontServer() {
- if (this.log.isDebugEnabled()) {
- final List<String> systemFontFamilies =
- this.fontServer.getSystemFontFamilyList();
- if (systemFontFamilies != null) {
- this.log.debug("Java font family names:");
- for (int i = 0; i < systemFontFamilies.size(); i++) {
- this.log.debug(" " + systemFontFamilies.get(i));
- }
+ final List<String> systemFontFamilies =
+ this.fontServer.getSystemFontFamilyList();
+ if (systemFontFamilies != null) {
+ logDebug("Java font family names:");
+ for (int i = 0; i < systemFontFamilies.size(); i++) {
+ logDebug(" " + systemFontFamilies.get(i));
}
- final List<java.awt.Font> systemFonts =
- this.fontServer.getSystemFontList();
- if (systemFonts != null) {
- this.log.debug("Java font names:");
- for (int i = 0; i < systemFonts.size(); i++) {
- this.log.debug(" " + systemFonts.get(i).getFontName());
- }
+ }
+ final List<java.awt.Font> systemFonts =
+ this.fontServer.getSystemFontList();
+ if (systemFonts != null) {
+ logDebug("Java font names:");
+ for (int i = 0; i < systemFonts.size(); i++) {
+ logDebug(" " + systemFonts.get(i).getFontName());
}
}
}
@@ -337,4 +313,49 @@
return this.lbFactory;
}
+ /**
+ * Logs an error message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logError(final String message, final Object... arguments) {
+ this.logger.error(message, arguments);
+ }
+
+ /**
+ * Logs a warning message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logWarning(final String message, final Object... arguments) {
+ this.logger.warn(message, arguments);
+ }
+
+ /**
+ * Logs an info message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logInfo(final String message, final Object... arguments) {
+ this.logger.info(message, arguments);
+ }
+
+ /**
+ * Logs a debug message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logDebug(final String message, final Object... arguments) {
+ this.logger.debug(message, arguments);
+ }
+
+ /**
+ * Logs a trace message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logTrace(final String message, final Object... arguments) {
+ this.logger.trace(message, arguments);
+ }
+
}
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-02-28 17:26:21 UTC (rev 12634)
+++ trunk/foray/foray-core/src/main/java/org/foray/core/ForayTarget.java 2022-02-28 18:15:21 UTC (rev 12635)
@@ -51,7 +51,6 @@
import org.axsl.output.OutputTarget;
import org.axsl.output.Renderer;
-import org.slf4j.Logger;
import org.xml.sax.SAXException;
import java.io.IOException;
@@ -221,25 +220,22 @@
final long memoryNow = this.runtime.totalMemory() - this.runtime.freeMemory();
final long memoryUsed = (memoryNow - this.initialMemory) / WellKnownConstants.BYTES_PER_KILOBYTE;
- getLogger().debug("Initial heap size: " + (this.initialMemory / WellKnownConstants.BYTES_PER_KILOBYTE) + "Kb");
- getLogger().debug("Current heap size: "
- + (memoryNow / WellKnownConstants.BYTES_PER_KILOBYTE) + "Kb");
- getLogger().debug("Total memory used: " + memoryUsed + "Kb");
+ getSession().logDebug("Initial heap size: " + (this.initialMemory / WellKnownConstants.BYTES_PER_KILOBYTE) +
+ "Kb");
+ getSession().logDebug("Current heap size: " + (memoryNow / WellKnownConstants.BYTES_PER_KILOBYTE) + "Kb");
+ getSession().logDebug("Total memory used: " + memoryUsed + "Kb");
if (! ForayTarget.MEM_PROFILE_WITH_GC) {
- getLogger().debug(" Memory use is indicative; no GC was "
- + "performed");
- getLogger().debug(" These figures should not be used "
- + "comparatively");
+ getSession().logDebug(" Memory use is indicative; no GC was performed");
+ getSession().logDebug(" These figures should not be used comparatively");
}
final long timeUsed = System.currentTimeMillis() - this.startTime;
- getLogger().debug("Total time used: " + timeUsed + "ms");
- getLogger().debug("Pages rendered: " + this.pageCount);
+ getSession().logDebug("Total time used: " + timeUsed + "ms");
+ getSession().logDebug("Pages rendered: " + this.pageCount);
if (this.pageCount != 0) {
- getLogger().debug("Avg render time: " + (timeUsed / this.pageCount)
- + "ms/page");
+ getSession().logDebug("Avg render time: " + (timeUsed / this.pageCount) + "ms/page");
}
}
@@ -265,8 +261,7 @@
private void renderOutputTarget(final PageSequence pageSequence, final OutputTarget outputTarget)
throws ForayException {
if (outputTarget instanceof Renderer) {
- getLogger().info("Starting layout of page-sequence "
- + this.pageSequenceCount + ".");
+ getSession().logInfo("Starting layout of page-sequence " + this.pageSequenceCount + ".");
final Renderer renderer = (Renderer) outputTarget;
final org.axsl.galley.Galley areaTreeR = getRenderedAreaTree();
renderer.setGalley(areaTreeR);
@@ -283,7 +278,7 @@
} catch (final LayoutException e) {
throw new ForayException(e);
}
- getLogger().info("Ending layout of page-sequence "
+ getSession().logInfo("Ending layout of page-sequence "
+ this.pageSequenceCount + ": "
+ pageCollection.qtyAreaNodeChildren() + " pages produced.");
}
@@ -326,7 +321,7 @@
try {
renderer.render(page);
} catch (final GalleyVisitorException e) {
- this.getLogger().error("Rendering error: " + e.getMessage());
+ getSession().logError("Rendering error: " + e.getMessage());
}
}
}
@@ -333,14 +328,6 @@
this.pageCount++;
}
- /**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.document.getLogger();
- }
-
@Override
public void foComplete(final FoTreeEvent event) {
}
@@ -452,4 +439,12 @@
return this.document.getLayoutFactory();
}
+ /**
+ * Returns the {@link ForaySession} for this target.
+ * @return The session.
+ */
+ public ForaySession getSession() {
+ return this.document.getSession();
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-28 17:26:24
|
Revision: 12634
http://sourceforge.net/p/foray/code/12634
Author: victormote
Date: 2022-02-28 17:26:21 +0000 (Mon, 28 Feb 2022)
Log Message:
-----------
Remove SLF4J references from Application Binary Interface of foray-areatree.
Modified Paths:
--------------
trunk/foray/foray-areatree/build.gradle
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageCollection4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java
Modified: trunk/foray/foray-areatree/build.gradle
===================================================================
--- trunk/foray/foray-areatree/build.gradle 2022-02-28 14:34:34 UTC (rev 12633)
+++ trunk/foray/foray-areatree/build.gradle 2022-02-28 17:26:21 UTC (rev 12634)
@@ -5,8 +5,7 @@
description = 'foray-areatree'
dependencies {
- /* TODO: Convert SLF4J "api" dependency to "implementation". */
- api group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j
+ implementation (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
api group: 'org.axsl', name: 'axsl-areatree', version: versions.axsl
api group: "org.axsl", name: "axsl-font", version: versions.axsl
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2022-02-28 14:34:34 UTC (rev 12633)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2022-02-28 17:26:21 UTC (rev 12634)
@@ -48,8 +48,6 @@
import org.axsl.value.TextTransform;
import org.axsl.value.WhiteSpaceTreatment;
-import org.slf4j.Logger;
-
import java.awt.Color;
import java.util.Iterator;
import java.util.List;
@@ -322,14 +320,6 @@
return getParent().getPage();
}
- /**
- * Return the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return getParent().getLogger();
- }
-
@Override
public Area4a nearestGeneratedByBlockLevelFo() {
if (this instanceof Area4a && traitGeneratedBy().isBlockLevelFo()) {
@@ -547,8 +537,7 @@
final AreaNode4a child = this.getChildren().get(currentIndex);
final boolean shouldRemove = child.optimize();
if (shouldRemove) {
- getLogger().debug("Removing empty "
- + child.getAreaName());
+ getAreaTree().logDebug("Removing empty " + child.getAreaName());
child.remove();
startingIndex = currentIndex;
endingIndex --;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java 2022-02-28 14:34:34 UTC (rev 12633)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java 2022-02-28 17:26:21 UTC (rev 12634)
@@ -171,11 +171,6 @@
}
@Override
- public Logger getLogger() {
- return this.logger;
- }
-
- @Override
public void contentComplete() {
this.processQueue(true);
layoutBookmarkTree(this.getRoot());
@@ -432,4 +427,49 @@
return this.documentMetadata;
}
+ /**
+ * Logs an error message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logError(final String message, final Object... arguments) {
+ this.logger.error(message, arguments);
+ }
+
+ /**
+ * Logs a warning message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logWarning(final String message, final Object... arguments) {
+ this.logger.warn(message, arguments);
+ }
+
+ /**
+ * Logs an info message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logInfo(final String message, final Object... arguments) {
+ this.logger.info(message, arguments);
+ }
+
+ /**
+ * Logs a debug message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logDebug(final String message, final Object... arguments) {
+ this.logger.debug(message, arguments);
+ }
+
+ /**
+ * Logs a trace message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logTrace(final String message, final Object... arguments) {
+ this.logger.trace(message, arguments);
+ }
+
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-02-28 14:34:34 UTC (rev 12633)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/LineArea4a.java 2022-02-28 17:26:21 UTC (rev 12634)
@@ -143,8 +143,7 @@
return 0;
}
default:
- getLogger().error("Invalid 'text-align': "
- + traitGeneratedBy().traitTextAlign(this));
+ getAreaTree().logError("Invalid 'text-align': " + traitGeneratedBy().traitTextAlign(this));
return 0;
}
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageCollection4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageCollection4a.java 2022-02-28 14:34:34 UTC (rev 12633)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageCollection4a.java 2022-02-28 17:26:21 UTC (rev 12634)
@@ -205,9 +205,9 @@
final CharSequence formattedPageNumber = this.pageNumberGenerator.makeFormattedPageNumber(newPageNumber);
newPage.setFormattedNumber(formattedPageNumber);
if (!isBlank) {
- getLogger().info("[" + formattedPageNumber + "]");
+ getAreaTree().logInfo("[" + formattedPageNumber + "]");
} else {
- getLogger().info("[" + formattedPageNumber + "] (blank)");
+ getAreaTree().logInfo("[" + formattedPageNumber + "] (blank)");
}
this.currentPageNumber++;
return newPage;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java 2022-02-28 14:34:34 UTC (rev 12633)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/TableRa.java 2022-02-28 17:26:21 UTC (rev 12634)
@@ -283,8 +283,7 @@
for (int i = 0; i < table.getTableColumns().length; i++) {
final TableColumn column = table.getTableColumns()[i];
if (column == null) {
- getLogger().warn("No table-column specification for column " +
- (i + 1) + ".");
+ getAreaTree().logWarning("No table-column specification for column " + (i + 1) + ".");
} else {
final double tu = column.traitColumnWidthTableUnits();
/* Keep track of minimum number of proportional units in any
@@ -333,8 +332,7 @@
} else if (table.traitIpDimensionMax(this) >= 0) {
optIPD = maxIPD;
} else {
- getLogger().error("At least one of minimum, optimum, or "
- + "maximum IPD must be specified on table.");
+ getAreaTree().logError("At least one of minimum, optimum, or maximum IPD must be specified on table.");
optIPD = maxIPD;
}
}
@@ -351,10 +349,8 @@
if (iProportionalWidth > 0) {
dUnitLength = iProportionalWidth / totalTableUnits;
} else {
- getLogger().error("Sum of fixed column widths "
- + totalFixedWidth
- + " greater than maximum available IPD "
- + maxAllocationIPD + "; no space for "
+ getAreaTree().logError("Sum of fixed column widths " + totalFixedWidth
+ + " greater than maximum available IPD " + maxAllocationIPD + "; no space for "
+ totalTableUnits + " proportional units.");
/* Set remaining proportional units to a number which
* will assure the minimum column size for tuMin.
@@ -372,11 +368,11 @@
dWidthFactor = (double) minIPD / (double) totalFixedWidth;
} else if (maxIPD < totalFixedWidth) {
// Note: if maxIPD=auto, use maxAllocWidth
- getLogger().warn("Sum of fixed column widths "
+ getAreaTree().logWarning("Sum of fixed column widths "
+ totalFixedWidth
+ " greater than maximum specified IPD " + maxIPD);
} else if (optIPD != -1 && totalFixedWidth != optIPD) {
- getLogger().warn("Sum of fixed column widths "
+ getAreaTree().logWarning("Sum of fixed column widths "
+ totalFixedWidth
+ " differs from specified optimum IPD " + optIPD);
}
@@ -399,7 +395,7 @@
// Check minimum values and adjust if necessary
if (colWidth <= 0) {
- getLogger().warn("Zero-width table column!");
+ getAreaTree().logWarning("Zero-width table column!");
}
if (dWidthFactor > 0.0) {
// Increase column sizes to use up extra space
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-28 14:34:37
|
Revision: 12633
http://sourceforge.net/p/foray/code/12633
Author: victormote
Date: 2022-02-28 14:34:34 +0000 (Mon, 28 Feb 2022)
Log Message:
-----------
Remove SLF4J references from Application Binary Interface of foray-fotree.
Modified Paths:
--------------
trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java
trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java
trunk/foray/foray-fotree/build.gradle
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTree4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeServer4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Bookmark4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/PageMasterResolver4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/PageSequence4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Table4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdBackgroundImage.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdColumnNumber.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/math/obj/InstreamMathElement.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/svg/obj/InstreamSvgElement.java
Modified: trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -98,8 +98,8 @@
final FontServer fontServer = ForaySpecific.makeFontServer(sessionConfig);
final FoOrthographyServer hyphenServer = ForaySpecific.makeHyphenationServer(sessionConfig);
final GraphicServer graphicServer = ForaySpecific.makeGraphicServer();
- final FoTreeFactory foTreeServer = ForaySpecific.makeFOTreeFactory(
- logger, sessionConfig, fontServer, graphicServer, hyphenServer);
+ final FoTreeFactory foTreeServer = ForaySpecific.makeFOTreeFactory(sessionConfig, fontServer, graphicServer,
+ hyphenServer);
final AreaTreeFactory areaTreeFactory = ForaySpecific.makeAreaTreeFactory();
final LineBreakerFactory lbFactory = ForaySpecific.makeLineBreakerFactory();
final LayoutFactory layoutFactory = ForaySpecific.makeLayoutFactory(lbFactory);
@@ -181,7 +181,6 @@
/**
* Make a standard FOTreeFactory instance for use in FOray.
- * @param logger The logger.
* @param configuration The session configuration.
* @param fontServer The FontServer instance to use.
* @param graphicServer The GraphicServer instance to use.
@@ -190,7 +189,6 @@
* @throws ForayException For errors creating the server.
*/
public static FoTreeFactory makeFOTreeFactory(
- final Logger logger,
final SessionConfig configuration,
final FontServer fontServer,
final GraphicServer graphicServer,
@@ -197,8 +195,7 @@
final FoOrthographyServer hyphenationServer)
throws ForayException {
final URL[] graphicSearchPath = buildGraphicSearchPath(configuration);
- return new FoTreeServer4a(logger, fontServer, hyphenationServer,
- graphicServer, graphicSearchPath,
+ return new FoTreeServer4a(fontServer, hyphenationServer, graphicServer, graphicSearchPath,
configuration.optionCacheGraphics());
}
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-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -43,8 +43,6 @@
import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.graphic.GraphicServer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.mockito.Mockito;
@@ -81,7 +79,6 @@
final String orthographyConfigPath = "../foray-orthography/src/test/resources/orthography-config.xml";
final URL orthographyFile = new URL("file", null, orthographyConfigPath);
- final Logger logger = LoggerFactory.getLogger(FoDocumentReader.class);
final SessionConfig sessionConfig = Mockito.mock(SessionConfig.class);
Mockito.when(sessionConfig.optionOrthographyConfiguration()).thenReturn(orthographyFile);
@@ -95,7 +92,7 @@
graphicSearchPath[0] = UrlFactory.createURL(testDirUrl, "fo/");
final boolean cachingGraphics = false;
- this.treeServer = new FoTreeServer4a(logger, fontServer, hyphenServer, graphicServer, graphicSearchPath,
+ this.treeServer = new FoTreeServer4a(fontServer, hyphenServer, graphicServer, graphicSearchPath,
cachingGraphics);
}
Modified: trunk/foray/foray-fotree/build.gradle
===================================================================
--- trunk/foray/foray-fotree/build.gradle 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/build.gradle 2022-02-28 14:34:34 UTC (rev 12633)
@@ -5,8 +5,7 @@
description = 'foray-fotree'
dependencies {
- /* TODO: Convert SLF4J "api" dependency to "implementation". */
- api group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j
+ implementation (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
api group: 'org.axsl.org.w3c.dom.svg', name: 'svg-dom-java', version: versions.svgDom
api group: 'org.axsl.org.w3c.dom.mathml', name: 'mathml-dom-java', version: versions.mathMlDom
@@ -18,7 +17,6 @@
api group: 'org.axsl', name: 'axsl-graphic', version: versions.axsl
api group: 'org.axsl', name: 'axsl-orthography', version: versions.axsl
api group: 'org.axsl', name: 'axsl-speech', version: versions.axsl
-// api group: 'org.axsl', name: 'axsl-linebreak', version: versions.axsl
api group: 'org.axsl', name: 'axsl-kp-model', version: versions.axsl
implementation group: 'org.axsl', name: 'axsl-unicode', version: versions.axsl
api group: 'org.axsl', name: 'axsl-value', version: versions.axsl
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -146,8 +146,6 @@
import org.axsl.value.WhiteSpaceTreatment;
import org.axsl.value.WrapOption;
-import org.slf4j.Logger;
-
import java.awt.Color;
import java.awt.Shape;
import java.net.URI;
@@ -329,14 +327,6 @@
}
/**
- * Return the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return getFoTree().getLogger();
- }
-
- /**
* Convenience method handling some details of throwing a parsing exception.
* @param message The message indicating the reason for the exception.
* @throws FoTreeException Always, as that is the purpose of this method.
@@ -677,7 +667,7 @@
* @param message The warning to be logged.
*/
public void logWarning(final String message) {
- getLogger().warn(message + "\n" + getContextMessage());
+ getFoTree().logWarning(message + "\n" + getContextMessage());
}
/**
@@ -2934,7 +2924,7 @@
final String[] familyList = getPropertyList().getVoiceFamily(this, context);
final Voice selectedVoice = speechServer.selectVoiceXsl(familyList);
if (selectedVoice == null) {
- this.getFoTree().getLogger().error("Error creating Voice.\n" + this.getContextMessage());
+ getFoTree().logError("Error creating Voice.\n" + this.getContextMessage());
}
return selectedVoice;
}
@@ -2966,7 +2956,7 @@
final FontUse resolvedFont = fontConsumer.selectFontXsl(strategy, fontFamily, style, weight, variant, stretch,
size, firstChar);
if (resolvedFont == null) {
- this.getFoTree().getLogger().error("Error creating Font.\n" + this.getContextMessage());
+ getFoTree().logError("Error creating Font.\n" + this.getContextMessage());
}
return resolvedFont;
}
@@ -2983,7 +2973,7 @@
this.traitFontSize(context),
codePoint);
if (secondaryFont == null) {
- getLogger().error("Error creating Font.\n" + this.getContextMessage());
+ getFoTree().logError("Error creating Font.\n" + this.getContextMessage());
}
return secondaryFont;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTree4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTree4a.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTree4a.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -250,14 +250,6 @@
}
/**
- * Returns the logger that should be used by this tree and its descendants.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.logger;
- }
-
- /**
* Indicates whether we wish to preserve the raw FO Tree content so that it can be round-tripped.
* Setting this value to true will generally increase the amount of memory consumed, the amount of processing time
* consumed, or both.
@@ -284,4 +276,49 @@
this.treeBuilder.deactivateForeignXML();
}
+ /**
+ * Logs an error message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logError(final String message, final Object... arguments) {
+ this.logger.error(message, arguments);
+ }
+
+ /**
+ * Logs a warning message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logWarning(final String message, final Object... arguments) {
+ this.logger.warn(message, arguments);
+ }
+
+ /**
+ * Logs an info message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logInfo(final String message, final Object... arguments) {
+ this.logger.info(message, arguments);
+ }
+
+ /**
+ * Logs a debug message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logDebug(final String message, final Object... arguments) {
+ this.logger.debug(message, arguments);
+ }
+
+ /**
+ * Logs a trace message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logTrace(final String message, final Object... arguments) {
+ this.logger.trace(message, arguments);
+ }
+
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeServer4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeServer4a.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoTreeServer4a.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -41,8 +41,6 @@
import org.axsl.fotree.text.FoOrthographyServer;
import org.axsl.graphic.GraphicServer;
-import org.slf4j.Logger;
-
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.HashMap;
@@ -56,9 +54,6 @@
*/
public class FoTreeServer4a implements FoTreeFactory {
- /** The logger. */
- private Logger logger;
-
/** The font server. */
private FontServer fontServer;
@@ -99,7 +94,6 @@
/**
* Constructor.
- * @param logger The logger.
* @param fontServer The font server.
* @param orthographyServer The hyphenation server.
* @param graphicServer The graphic server.
@@ -108,13 +102,12 @@
* @param cachingGraphics Indicates whether we are caching graphics for
* reuse.
*/
- public FoTreeServer4a(final Logger logger,
+ public FoTreeServer4a(
final FontServer fontServer,
final FoOrthographyServer orthographyServer,
final GraphicServer graphicServer,
final URL[] graphicSearchPath,
final boolean cachingGraphics) {
- this.logger = logger;
this.fontServer = fontServer;
this.graphicServer = graphicServer;
this.orthographyServer = orthographyServer;
@@ -278,14 +271,6 @@
}
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.logger;
- }
-
- /**
* Returns the font server.
* @return The font server.
*/
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -301,7 +301,7 @@
* If they are not the same object, then the user has specified the same property twice.
*/
if (existingProperty != null && property != existingProperty) {
- fobj.getLogger().error("Property "
+ fobj.getFoTree().logError("Property "
+ property.getPropertyType().toStringUnparsed()
+ " already exists.\n" + fobj.getContextMessage());
}
@@ -1315,8 +1315,7 @@
&& (getOverflow(fobj, context) == FoValue.SCROLL)) {
// recover by setting 'column-count' to 1. This is allowed but
// not required by the spec.
- fobj.getLogger().error("Setting 'column-count' to 1 because "
- + "'overflow' is set to 'scroll'");
+ fobj.getFoTree().logError("Setting 'column-count' to 1 because 'overflow' is set to 'scroll'");
columnCount = 1;
}
return columnCount;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Bookmark4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Bookmark4a.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Bookmark4a.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -81,11 +81,11 @@
protected void validateProperties() throws FoTreeException {
final String internalDestination = this.traitInternalDestination();
if (internalDestination == null || internalDestination.equals("")) {
- getLogger().warn(getFullName() + "requires an internal-destination.");
+ getFoTree().logWarning(getFullName() + "requires an internal-destination.");
}
final URI externalDestination = this.traitExternalDestination();
if (externalDestination != null && ! externalDestination.equals("")) {
- getLogger().warn(getFullName() + "external-destination not supported currently.");
+ getFoTree().logWarning(getFullName() + "external-destination not supported currently.");
}
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -130,8 +130,7 @@
getFoTree().getGraphicSearchPath(),
getFoTree().isCachingGraphics());
} catch (final GraphicException | MalformedURLException e) {
- getLogger().error(e.getMessage() + "\n"
- + this.getContextMessage());
+ getFoTree().logError(e.getMessage() + "\n" + this.getContextMessage());
}
}
return this.graphic;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/PageMasterResolver4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/PageMasterResolver4a.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/PageMasterResolver4a.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -105,9 +105,9 @@
if (nextSubSequence == null) {
final String basicMessage = "Subsequences exhausted in fo:page-sequence-master \"" +
psm.traitMasterName() + "\".";
- psm.getLogger().error(basicMessage + " Attempting to use previous subsequence.");
+ psm.getFoTree().logError(basicMessage + " Attempting to use previous subsequence.");
if (! canRecover) {
- psm.getLogger().error(basicMessage + " Cannot recover.");
+ psm.getFoTree().logError(basicMessage + " Cannot recover.");
return null;
}
canRecover = false;
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/PageSequence4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/PageSequence4a.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/PageSequence4a.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -162,9 +162,8 @@
if (!getLayoutMasterSet().regionNameExists(flowName)
&& !flowName.equals("xsl-before-float-separator")
&& !flowName.equals("xsl-footnote-separator")) {
- getLogger().error(
- "region-name '" + staticContent.traitFlowName()
- + "' doesn't exist in the layout-master-set.");
+ getFoTree().logError("region-name '" + staticContent.traitFlowName() +
+ "' doesn't exist in the layout-master-set.");
}
this.staticContentMap.put(staticContent.traitFlowName(), staticContent);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Table4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Table4a.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Table4a.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -161,9 +161,7 @@
for (int j = 0; j < numColumnsRepeated; j++) {
if (currentColumnNumber <= this.columns.size()) {
if (this.columns.get(currentColumnNumber - 1) != null) {
- getLogger().warn("More than one column object "
- + "assigned to column " +
- currentColumnNumber);
+ getFoTree().logWarning("More than one column object assigned to column " + currentColumnNumber);
}
this.columns.set(currentColumnNumber - 1, c);
} else {
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdBackgroundImage.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdBackgroundImage.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdBackgroundImage.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -141,8 +141,7 @@
fobj.getFoTree().isCachingGraphics());
} catch (final GraphicException | MalformedURLException imgex) {
backgroundImage = null;
- fobj.getLogger().error("Error creating background image: "
- + imgex.getMessage());
+ fobj.getFoTree().logError("Error creating background image: " + imgex.getMessage());
}
return backgroundImage;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdColumnNumber.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdColumnNumber.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdColumnNumber.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -91,7 +91,7 @@
if (fobj instanceof TableCell4a) {
return true;
}
- fobj.getLogger().warn("Property 'column-number' on invalid FO: "
+ fobj.getFoTree().logWarning("Property 'column-number' on invalid FO: "
+ fobj.getLine() + ":" + fobj.getColumn());
return false;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/math/obj/InstreamMathElement.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/math/obj/InstreamMathElement.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/math/obj/InstreamMathElement.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -108,9 +108,8 @@
return this.getMathGraphic().absoluteWidth(
ForayConstants.DEFAULT_SCREEN_RESOLUTION);
} catch (final GraphicException e) {
- final String message = "Error getting MathML width: "
- + e.getMessage();
- this.getLogger().error(this.getMessageWithContext(message));
+ final String message = "Error getting MathML width: " + e.getMessage();
+ getFoTree().logError(this.getMessageWithContext(message));
}
return -1;
}
@@ -124,9 +123,8 @@
return this.getMathGraphic().absoluteHeight(
ForayConstants.DEFAULT_SCREEN_RESOLUTION);
} catch (final GraphicException e) {
- final String message = "Error getting MathML height: "
- + e.getMessage();
- this.getLogger().error(this.getMessageWithContext(message));
+ final String message = "Error getting MathML height: " + e.getMessage();
+ getFoTree().logError(this.getMessageWithContext(message));
}
return -1;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/svg/obj/InstreamSvgElement.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/svg/obj/InstreamSvgElement.java 2022-02-28 13:42:59 UTC (rev 12632)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/svg/obj/InstreamSvgElement.java 2022-02-28 14:34:34 UTC (rev 12633)
@@ -104,9 +104,8 @@
return this.getSvgGraphic().absoluteWidth(
ForayConstants.DEFAULT_SCREEN_RESOLUTION);
} catch (final GraphicException e) {
- final String message = "Error getting SVG width: "
- + e.getMessage();
- this.getLogger().error(this.getMessageWithContext(message));
+ final String message = "Error getting SVG width: " + e.getMessage();
+ getFoTree().logError(this.getMessageWithContext(message));
}
return -1;
}
@@ -117,9 +116,8 @@
return this.getSvgGraphic().absoluteHeight(
ForayConstants.DEFAULT_SCREEN_RESOLUTION);
} catch (final GraphicException e) {
- final String message = "Error getting SVG height: "
- + e.getMessage();
- this.getLogger().error(this.getMessageWithContext(message));
+ final String message = "Error getting SVG height: " + e.getMessage();
+ getFoTree().logError(this.getMessageWithContext(message));
}
return -1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-28 13:43:02
|
Revision: 12632
http://sourceforge.net/p/foray/code/12632
Author: victormote
Date: 2022-02-28 13:42:59 +0000 (Mon, 28 Feb 2022)
Log Message:
-----------
Remove SLF4J references from Application Binary Interface of foray-pdf.
Modified Paths:
--------------
trunk/foray/foray-pdf/build.gradle
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
Modified: trunk/foray/foray-pdf/build.gradle
===================================================================
--- trunk/foray/foray-pdf/build.gradle 2022-02-28 13:28:13 UTC (rev 12631)
+++ trunk/foray/foray-pdf/build.gradle 2022-02-28 13:42:59 UTC (rev 12632)
@@ -5,8 +5,7 @@
description = 'foray-pdf'
dependencies {
- /* TODO: Convert SLF4J "api" dependency to "implementation". */
- api group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j
+ implementation (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
api group: 'org.apache.xmlgraphics', name: 'batik-awt-util', version: versions.batik
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2022-02-28 13:28:13 UTC (rev 12631)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2022-02-28 13:42:59 UTC (rev 12632)
@@ -82,9 +82,6 @@
import org.axsl.ps.PsServer;
import org.axsl.utility.sequence.IntPrimitiveIterator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.awt.Color;
import java.awt.LinearGradientPaint;
import java.awt.MultipleGradientPaint;
@@ -186,9 +183,6 @@
private char[] nextFontSubsetTag = new char[]
{'A', 'A', 'A', 'A', 'A', 'A'};
- /** The logger. */
- private Logger logger = LoggerFactory.getLogger(PdfDocument4a.class);
-
/** The default border style. */
private PdfBorderStyle defaultBorderStyle;
@@ -449,14 +443,6 @@
}
/**
- * Return the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.logger;
- }
-
- /**
* Returns the default border style for this document.
* @return Returns the default border style.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-28 13:28:16
|
Revision: 12631
http://sourceforge.net/p/foray/code/12631
Author: victormote
Date: 2022-02-28 13:28:13 +0000 (Mon, 28 Feb 2022)
Log Message:
-----------
Remove remaining SLF4J references from Application Binary Interface of foray-graphic.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/AbstractTextPainter.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/AbstractTextPainter.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/AbstractTextPainter.java 2022-02-28 13:19:09 UTC (rev 12630)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/AbstractTextPainter.java 2022-02-28 13:28:13 UTC (rev 12631)
@@ -45,8 +45,8 @@
//import org.apache.batik.gvt.text.BidiAttributedCharacterIterator;
//import org.apache.batik.gvt.text.TextPaintInfo;
import org.apache.batik.bridge.TextPainter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
//import java.awt.Graphics2D;
//import java.awt.Shape;
@@ -66,9 +66,9 @@
*/
public abstract class AbstractTextPainter /* extends StrokingTextPainter */ {
- /** The logger. */
- protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractTextPainter.class);
-
+// /** The logger. */
+// protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractTextPainter.class);
+//
// /** Static layout factory for complex scripts. */
// private static final TextLayoutFactory COMPLEX_SCRIPT_TEXT_LAYOUT_FACTORY =
// new TextLayoutFactory() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-28 13:19:13
|
Revision: 12630
http://sourceforge.net/p/foray/code/12630
Author: victormote
Date: 2022-02-28 13:19:09 +0000 (Mon, 28 Feb 2022)
Log Message:
-----------
Remove some SLF4J references from Application Binary Interface of foray-graphic.
Modified Paths:
--------------
trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java
trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java
trunk/foray/foray-graphic/build.gradle
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PsGraphics2D.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/GraphicFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TestAbstractGraphic.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TestGraphicServer4a.java
Modified: trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java
===================================================================
--- trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-app/src/main/java/org/foray/app/ForaySpecific.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -97,7 +97,7 @@
final Logger logger = LoggerFactory.getLogger(ForaySpecific.class);
final FontServer fontServer = ForaySpecific.makeFontServer(sessionConfig);
final FoOrthographyServer hyphenServer = ForaySpecific.makeHyphenationServer(sessionConfig);
- final GraphicServer graphicServer = ForaySpecific.makeGraphicServer(logger);
+ final GraphicServer graphicServer = ForaySpecific.makeGraphicServer();
final FoTreeFactory foTreeServer = ForaySpecific.makeFOTreeFactory(
logger, sessionConfig, fontServer, graphicServer, hyphenServer);
final AreaTreeFactory areaTreeFactory = ForaySpecific.makeAreaTreeFactory();
@@ -172,13 +172,11 @@
/**
* Make a standard GraphicServer instance for use in FOray.
- * @param logger The logger.
* @return The newly-created GraphicServer instance.
* @throws ForayException For errors creating the server.
*/
- public static GraphicServer makeGraphicServer(final Logger logger)
- throws ForayException {
- return new GraphicServer4a(logger);
+ public static GraphicServer makeGraphicServer() throws ForayException {
+ return new GraphicServer4a();
}
/**
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-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-app/src/test/java/org/foray/app/fo/FoDocumentReader.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -88,7 +88,7 @@
this.testDirectory = Environment.getTestDirectory();
final FontServer fontServer = ForaySpecific.makeFontServer(sessionConfig);
- final GraphicServer graphicServer = ForaySpecific.makeGraphicServer(logger);
+ final GraphicServer graphicServer = ForaySpecific.makeGraphicServer();
final FoOrthographyServer hyphenServer = ForaySpecific.makeHyphenationServer(sessionConfig);
final URL[] graphicSearchPath = new URL[1];
final URL testDirUrl = this.testDirectory.toURI().toURL();
Modified: trunk/foray/foray-graphic/build.gradle
===================================================================
--- trunk/foray/foray-graphic/build.gradle 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/build.gradle 2022-02-28 13:19:09 UTC (rev 12630)
@@ -5,8 +5,7 @@
description = 'foray-graphic'
dependencies {
- /* TODO: Convert SLF4J "api" dependency to "implementation". */
- api group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j
+ implementation (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
api (group: 'org.apache.xmlgraphics', name: 'xmlgraphics-commons', version: versions.xmlgraphicsCommons)
api (group: 'org.apache.xmlgraphics', name: 'batik-bridge', version: versions.batik)
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -37,8 +37,6 @@
import org.axsl.graphic.output.GraphicOutput;
import org.axsl.utility.sequence.ByteSequence;
-import org.slf4j.Logger;
-
import java.awt.color.ColorSpace;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -178,14 +176,6 @@
protected abstract void loadImage() throws GraphicException;
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.server.getLogger();
- }
-
- /**
* <p>This method handles some of the common housekeeping work for
* {@link #parseBasics()} so that it can focus on parsing. Specifically,
* this method is responsible to:</p>
@@ -453,7 +443,7 @@
try {
output = factory.createGraphicOutput(this);
} catch (final GraphicException e) {
- getLogger().error("Error creating Graphic output for: " + mimeType
+ this.server.logError("Error creating Graphic output for: " + mimeType
+ "\n" + e.getMessage());
}
return output;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -92,7 +92,7 @@
public class GraphicServer4a implements GraphicServer {
/** The logger that should be used by this server. */
- private Logger logger;
+ private Logger logger = LoggerFactory.getLogger(GraphicServer4a.class);
/**
* The name of the class that should be used to parse SVG documents.
@@ -123,13 +123,8 @@
/**
* Constructor.
- * @param logger The logger.
*/
- public GraphicServer4a(final Logger logger) {
- this.logger = logger;
- if (this.logger == null) {
- this.logger = LoggerFactory.getLogger(GraphicServer4a.class);
- }
+ public GraphicServer4a() {
this.svgParserClassName = SaxParser.getParserClassName();
registerStandardFactories();
registerStandardOutputFactories();
@@ -298,14 +293,6 @@
}
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.logger;
- }
-
- /**
* Returns the name of the class that should be used to parse SVG graphics.
* @return The name of the class that should be used to parse SVG graphics.
*/
@@ -332,8 +319,8 @@
try {
svgT.transcode(input, output);
} catch (final TranscoderException e) {
- getLogger().error("could not write svg file :" + e.getMessage());
- getLogger().error(e.getMessage());
+ logError("could not write svg file :" + e.getMessage());
+ logError(e.getMessage());
}
}
@@ -433,4 +420,49 @@
return (SVGDocument) dwd.getDocument();
}
+ /**
+ * Logs an error message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logError(final String message, final Object... arguments) {
+ this.logger.error(message, arguments);
+ }
+
+ /**
+ * Logs a warning message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logWarning(final String message, final Object... arguments) {
+ this.logger.warn(message, arguments);
+ }
+
+ /**
+ * Logs an info message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logInfo(final String message, final Object... arguments) {
+ this.logger.info(message, arguments);
+ }
+
+ /**
+ * Logs a debug message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logDebug(final String message, final Object... arguments) {
+ this.logger.debug(message, arguments);
+ }
+
+ /**
+ * Logs a trace message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logTrace(final String message, final Object... arguments) {
+ this.logger.trace(message, arguments);
+ }
+
}
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 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -105,8 +105,7 @@
getServer().getSVGParserClassName());
this.doc = factory.createSVGDocument(getUrl().toExternalForm());
} catch (final IOException e) {
- getLogger().error("Could not load external SVG: "
- + e.getMessage());
+ getServer().logError("Could not load external SVG: " + e.getMessage());
}
}
@@ -187,7 +186,7 @@
SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx);
this.pixelHeight = (int) pixelHeight;
} catch (final NoClassDefFoundError ncdfe) {
- getLogger().error("Batik not in class path");
+ getServer().logError("Batik not in class path");
return;
}
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -298,8 +298,7 @@
this.seekableInput.skip(this.stripOffset);
bytesRead = this.seekableInput.read(readBuf);
if (bytesRead != this.stripLength) {
- this.getLogger().error("Error while loading image: length "
- + "mismatch on read");
+ getServer().logError("Error while loading image: length mismatch on read");
return;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PsGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PsGraphics2D.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/batik/PsGraphics2D.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -44,6 +44,7 @@
import org.apache.xmlgraphics.java2d.AbstractGraphics2D;
import org.apache.xmlgraphics.java2d.GraphicContext;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
@@ -96,7 +97,7 @@
/** The output stream to which we are writing. */
private CharacterOutputStream out;
- /** The logger. */
+ /** The lazily-loaded logger. Use {@link #getLogger()} to obtain the instance. */
private Logger logger;
/** Used to create proper font metrics. */
@@ -114,23 +115,18 @@
* @param textAsShapes Indicates whether text should be treated as text
* (false), or whether it should be converted to its paths (true).
* @param out The output stream to which the content should be written.
- * @param logger The logger.
*/
- public PsGraphics2D(final boolean textAsShapes, final CharacterOutputStream out,
- final Logger logger) {
+ public PsGraphics2D(final boolean textAsShapes, final CharacterOutputStream out) {
super(textAsShapes);
this.out = out;
- this.logger = logger;
}
/**
* Constructor supporting the {@link #create()} method.
* @param g The wrapped graphic.
- * @param logger The logger.
*/
- public PsGraphics2D(final PsGraphics2D g, final Logger logger) {
+ public PsGraphics2D(final PsGraphics2D g) {
super(g);
- this.logger = logger;
}
/**
@@ -143,7 +139,7 @@
@Override
public Graphics create() {
- return new PsGraphics2D(this, this.logger);
+ return new PsGraphics2D(this);
}
@Override
@@ -232,7 +228,7 @@
// this.psRenderer.renderBitmap(graphic, x, -y, width, height);
this.out.write("grestore");
} catch (final IOException e) {
- this.logger.error(e.getMessage());
+ getLogger().error(e.getMessage());
}
return true;
}
@@ -301,7 +297,7 @@
doDrawing(false, true, false);
this.out.write("grestore");
} catch (final IOException e) {
- this.logger.error(e.getMessage());
+ getLogger().error(e.getMessage());
}
}
@@ -510,7 +506,7 @@
this.out.write("ET");
} catch (final IOException e) {
- this.logger.error(e.getMessage());
+ getLogger().error(e.getMessage());
}
}
@@ -541,7 +537,7 @@
this.out.write("ET");
} catch (final IOException e) {
- this.logger.error(e.getMessage());
+ getLogger().error(e.getMessage());
}
}
@@ -598,7 +594,7 @@
iter.getWindingRule() == PathIterator.WIND_EVEN_ODD);
this.out.write("grestore");
} catch (final IOException e) {
- this.logger.error(e.getMessage());
+ getLogger().error(e.getMessage());
}
}
@@ -651,4 +647,15 @@
final int height, final int dx, final int dy) {
}
+ /**
+ * Returns the logger, creating it if necessary.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ if (this.logger == null) {
+ this.logger = LoggerFactory.getLogger(getClass());
+ }
+ return this.logger;
+ }
+
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/GraphicFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/GraphicFactory.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/GraphicFactory.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -36,8 +36,6 @@
import org.foray.graphic.Graphic4a;
import org.foray.graphic.GraphicServer4a;
-import org.slf4j.Logger;
-
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
@@ -119,14 +117,6 @@
}
/**
- * Get the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.server.getLogger();
- }
-
- /**
* Returns the parent server.
* @return The parent server.
*/
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -37,7 +37,6 @@
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.ViewBox;
import org.apache.batik.gvt.GraphicsNode;
-import org.slf4j.Logger;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGSVGElement;
@@ -122,12 +121,4 @@
return new BridgeContext(userAgent);
}
- /**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.svg.getLogger();
- }
-
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -75,8 +75,7 @@
/* If not running in a graphical environment, log an error message
* and skip the SVG. */
if (! Environment.isGraphicalEnvironment()) {
- this.svg.getLogger().error("Unable to get Graphical Environment "
- + "required to process SVG. Skipping.");
+ this.svg.getServer().logError("Unable to get Graphical Environment required to process SVG. Skipping.");
return;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -41,7 +41,6 @@
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.xmlgraphics.java2d.GraphicContext;
-import org.slf4j.Logger;
import org.w3c.dom.svg.SVGDocument;
import java.awt.geom.AffineTransform;
@@ -78,8 +77,7 @@
try {
doc = this.svg.getSvgDocument();
} catch (final GraphicException e) {
- this.getLogger().error("Error getting SVGDocument in "
- + this.getClass().getName());
+ this.svg.getServer().logError("Error getting SVGDocument in " + this.getClass().getName());
return;
}
BridgeContext ctx = makeBridgeContext();
@@ -91,7 +89,7 @@
builder = null;
final CharacterOutputStream cos = new CharacterOutputStream(output, commentsEnabled);
- final PsGraphics2D graphics = new PsGraphics2D(false, cos, this.getLogger());
+ final PsGraphics2D graphics = new PsGraphics2D(false, cos);
graphics.setGraphicContext(new GraphicContext());
root.paint(graphics);
try {
@@ -111,12 +109,4 @@
return new BridgeContext(userAgent);
}
- /**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.getGraphic().getLogger();
- }
-
}
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TestAbstractGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TestAbstractGraphic.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TestAbstractGraphic.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -53,7 +53,7 @@
*/
@Before
public void setUp() throws IOException {
- this.server = new GraphicServer4a(null);
+ this.server = new GraphicServer4a();
final URI examplesDirectory = Environment.getExamplesDirectory().toURI();
final URI graphicsDirectory = examplesDirectory.resolve("graphics/");
final URL graphicsUrl = graphicsDirectory.toURL();
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TestGraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TestGraphicServer4a.java 2022-02-27 17:30:35 UTC (rev 12629)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TestGraphicServer4a.java 2022-02-28 13:19:09 UTC (rev 12630)
@@ -32,9 +32,6 @@
import org.axsl.graphic.GraphicException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.junit.Test;
import java.io.File;
@@ -55,8 +52,7 @@
*/
public static GraphicServer4a getServer() throws GraphicException {
if (TestGraphicServer4a.graphicServer == null) {
- final Logger logger = LoggerFactory.getLogger(TestGraphicServer4a.class);
- final GraphicServer4a graphicServer = new GraphicServer4a(logger);
+ final GraphicServer4a graphicServer = new GraphicServer4a();
TestGraphicServer4a.graphicServer = graphicServer;
}
return TestGraphicServer4a.graphicServer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-27 17:30:38
|
Revision: 12629
http://sourceforge.net/p/foray/code/12629
Author: victormote
Date: 2022-02-27 17:30:35 +0000 (Sun, 27 Feb 2022)
Log Message:
-----------
Remove remaining SLF4J references from Application Binary Interface of foray-output.
Modified Paths:
--------------
trunk/foray/foray-output/build.gradle
trunk/foray/foray-output/src/main/java/org/foray/output/MifConverter.java
trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget4a.java
trunk/foray/foray-render/build.gradle
trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
Modified: trunk/foray/foray-output/build.gradle
===================================================================
--- trunk/foray/foray-output/build.gradle 2022-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-output/build.gradle 2022-02-27 17:30:35 UTC (rev 12629)
@@ -5,17 +5,14 @@
description = 'foray-output'
dependencies {
- /* TODO: Convert SLF4J "api" dependency to "implementation". */
- api group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j
+ implementation (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
api (group: 'org.axsl', name: 'axsl-font', version: versions.axsl)
api (group: 'org.axsl', name: 'axsl-output', version: versions.axsl)
api (group: 'org.axsl', name: 'axsl-mif', version: versions.axsl)
api (group: 'org.axsl', name: 'axsl-fotree', version: versions.axsl)
-// api (group: 'org.axsl', name: 'axsl-value', version: versions.axsl)
implementation (project(':foray-common'))
-
}
javadoc {
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-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-output/src/main/java/org/foray/output/MifConverter.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -243,13 +243,13 @@
@Override
public void startOutput() throws OutputException {
- getLogger().info("rendering areas to MIF");
+ logInfo("rendering areas to MIF");
this.mifDoc.setDocumentHeightWidth(this.pageHeight, this.pageWidth);
}
@Override
public void stopOutput() throws OutputException {
- getLogger().info("writing out MIF");
+ logInfo("writing out MIF");
this.mifDoc.output(this.getOutputStream());
try {
this.getOutputStream().flush();
Modified: trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget4a.java
===================================================================
--- trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget4a.java 2022-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget4a.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -65,23 +65,12 @@
private boolean strokeSVGText;
/** The logger. */
- private Logger logger;
+ private Logger logger = LoggerFactory.getLogger(getClass());
/** The FontConsumer used by the document. */
private FontConsumer fontConsumer;
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- if (this.logger == null) {
- this.logger = LoggerFactory.getLogger(this.getClass());
- }
- return this.logger;
- }
-
- /**
* Returns the FontConsumer.
* @return The FontConsumer implementation which should be used by this
* Renderer.
@@ -196,4 +185,49 @@
*/
public abstract OutputConfiguration getOutputConfiguration();
+ /**
+ * Logs an error message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logError(final String message, final Object... arguments) {
+ this.logger.error(message, arguments);
+ }
+
+ /**
+ * Logs a warning message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logWarning(final String message, final Object... arguments) {
+ this.logger.warn(message, arguments);
+ }
+
+ /**
+ * Logs an info message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logInfo(final String message, final Object... arguments) {
+ this.logger.info(message, arguments);
+ }
+
+ /**
+ * Logs a debug message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logDebug(final String message, final Object... arguments) {
+ this.logger.debug(message, arguments);
+ }
+
+ /**
+ * Logs a trace message.
+ * @param message The message to be logged.
+ * @param arguments Parameters for the string template, if needed.
+ */
+ public void logTrace(final String message, final Object... arguments) {
+ this.logger.trace(message, arguments);
+ }
+
}
Modified: trunk/foray/foray-render/build.gradle
===================================================================
--- trunk/foray/foray-render/build.gradle 2022-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/build.gradle 2022-02-27 17:30:35 UTC (rev 12629)
@@ -5,8 +5,6 @@
description = 'foray-render'
dependencies {
- implementation group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j
-
implementation group: 'org.axsl.org.w3c.dom.svg', name: 'svg-dom-java', version: versions.svgDom
implementation (group: 'org.axsl', name: 'axsl-utility', version: versions.axsl)
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java 2022-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -175,8 +175,8 @@
imgW = backgroundImage.absoluteWidth(getPixelsPerInch());
imgH = backgroundImage.absoluteHeight(getPixelsPerInch());
} catch (final GraphicException fie) {
- getLogger().error("Error obtaining bg image width and height");
- getLogger().error(fie.getMessage());
+ logError("Error obtaining bg image width and height");
+ logError(fie.getMessage());
return;
}
@@ -399,8 +399,7 @@
public Void visit(final ForeignObjectAreaG5 area) throws GalleyVisitorException {
final ForeignContentG5 foreignContent = area.getContainedForeignObject();
if (foreignContent == null) {
- this.getLogger().warn("At rendering, ForeignContent area "
- + "has no parsed content");
+ logWarning("At rendering, ForeignContent area has no parsed content");
return null;
}
if (foreignContent instanceof ForeignContentSvgG5) {
@@ -412,8 +411,7 @@
(ForeignContentMathG5) foreignContent;
render(mathArea);
} else {
- this.getLogger().warn("At rendering, ForeignContent area "
- + "is of an unsupported type.");
+ logWarning("At rendering, ForeignContent area is of an unsupported type.");
}
return null;
}
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-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -482,8 +482,7 @@
final Graphic img = area.getGraphic();
if (img == null) {
- getLogger().error("Error while loading image : area.getImage() "
- + "is null");
+ logError("Error while loading image : area.getImage() is null");
// correct integer roundoff
// graphics.drawRect(x / 1000, pageHeight - y / 1000,
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java 2022-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -330,7 +330,7 @@
int xpos = this.xoffset + (x / WellKnownConstants.DECIPOINTS_PER_POINT);
if (xpos < 0) {
xpos = 0;
- getLogger().warn("Horizontal position out of bounds.");
+ logWarning("Horizontal position out of bounds.");
}
this.currentStream.add("\033*v1O\033&a" + xpos + "h"
@@ -348,7 +348,7 @@
/ WellKnownConstants.DECIPOINTS_PER_POINT);
if (xpos < 0) {
xpos = 0;
- getLogger().warn("Horizontal position out of bounds.");
+ logWarning("Horizontal position out of bounds.");
}
this.currentStream.add("\033&a" + xpos + "h"
+ (this.pageHeight - ((modifiedY
@@ -420,7 +420,7 @@
}
resolution = normalizeResolution(resolution);
- getLogger().debug("PclRenderer.printBMP() iscolor = " + iscolor);
+ logDebug("PclRenderer.printBMP() iscolor = " + iscolor);
// Setup for graphics
this.currentStream.add("\033*t" + resolution + "R\033*r0F\033*r1A");
@@ -530,7 +530,7 @@
int xpos = this.xoffset + (x / WellKnownConstants.DECIPOINTS_PER_POINT);
if (xpos < 0) {
xpos = 0;
- getLogger().warn("Horizontal position out of bounds.");
+ logWarning("Horizontal position out of bounds.");
}
this.currentStream.add("\033&a" + xpos + "h" + (this.pageHeight -
@@ -540,7 +540,7 @@
try {
printBMP(img, x, y, w, h);
} catch (final GraphicException e) {
- getLogger().error("PclRenderer.renderImageArea() Error printing "
+ logError("PclRenderer.renderImageArea() Error printing "
+ "BMP (" + e.toString() + ")");
}
return null;
@@ -548,7 +548,7 @@
@Override
public void render(final ForeignContentSvgG5 area) {
- getLogger().debug("PclRenderer.renderSVGArea(" + area + ")");
+ logDebug("PclRenderer.renderSVGArea(" + area + ")");
// int x = area.rrOriginX();
// int y = area.rrOriginY();
// SVGSVGElement svg = area.getSVGDocument().getRootElement();
@@ -721,7 +721,7 @@
@Override
public void startOutput() throws OutputException {
- getLogger().info("rendering areas to PCL");
+ logInfo("rendering areas to PCL");
this.currentStream = new PclStream(this.getOutputStream());
// Reset the margins.
@@ -730,7 +730,7 @@
@Override
public void stopOutput() throws OutputException {
- getLogger().info("writing out PCL");
+ logInfo("writing out PCL");
try {
this.getOutputStream().flush();
} catch (final IOException e) {
@@ -740,7 +740,7 @@
@Override
public void render(final PageG5 page) throws GalleyVisitorException {
- getLogger().debug("PclRenderer.renderPage() page.Height() = "
+ logDebug("PclRenderer.renderPage() page.Height() = "
+ page.getHeight());
/* FIXME: Set orientation. We made this assumption. It's not always
@@ -762,7 +762,7 @@
/ WellKnownConstants.DECIPOINTS_PER_POINT);
}
- getLogger().debug("PclRenderer.renderPage() paperheight="
+ logDebug("PclRenderer.renderPage() paperheight="
+ this.paperheight + " divisions=" + this.divisions);
// Set top margin.
@@ -773,7 +773,7 @@
if (this.topmargin > 0) {
this.fullmargin += this.topmargin;
}
- getLogger().debug("PclRenderer.renderPage() curdiv=" + this.curdiv
+ logDebug("PclRenderer.renderPage() curdiv=" + this.curdiv
+ " fullmargin=" + this.fullmargin);
if (this.paperheight > 0) {
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -523,7 +523,7 @@
@Override
public void render(final PageG5 galleyPage) throws GalleyVisitorException {
- getLogger().debug("Rendering single page to PDF.");
+ logDebug("Rendering single page to PDF.");
this.pageCount ++;
checkPageLabels(galleyPage);
this.currentAreaTreePage = galleyPage;
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 2022-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -516,7 +516,7 @@
w = svgGraphic.pixelWidth();
h = svgGraphic.pixelHeight();
} catch (final GraphicException e) {
- this.getLogger().error("Error getting graphic dimensions in "
+ logError("Error getting graphic dimensions in "
+ this.getClass().getName());
}
@@ -625,8 +625,8 @@
final Rectangle rect = new Rectangle(x, y, w, h);
drawGraphic(area, image, rect, null);
} catch (final GraphicException e) {
- getLogger().error("Error getting image extents");
- getLogger().error(e.getMessage());
+ logError("Error getting image extents");
+ logError(e.getMessage());
}
write("grestore");
} catch (final IOException e) {
@@ -833,9 +833,9 @@
write("");
write("grestore");
} catch (final GraphicException e) {
- getLogger().error("PSRenderer.renderImageArea(): Error rendering "
+ logError("PSRenderer.renderImageArea(): Error rendering "
+ "bitmap (" + e.getMessage() + ")");
- getLogger().error(e.getMessage());
+ logError(e.getMessage());
}
}
@@ -1100,11 +1100,11 @@
break;
case DOTS:
comment("% --- Leader dots NYI");
- getLogger().error("Leader dots: Not yet implemented");
+ logError("Leader dots: Not yet implemented");
break;
case USE_CONTENT:
comment("% --- Leader use-content NYI");
- getLogger().error("Leader use-content: Not yet implemented");
+ logError("Leader use-content: Not yet implemented");
break;
}
write(area.crIpd() + " 0 RM");
@@ -1190,7 +1190,7 @@
@Override
public void startOutput() throws OutputException {
- getLogger().debug("rendering areas to PostScript");
+ logDebug("rendering areas to PostScript");
this.pagecount = 0;
this.out = new CharacterOutputStream(this.getOutputStream(),
@@ -1282,7 +1282,7 @@
} catch (final IOException e) {
throw new OutputException(e);
}
- getLogger().debug("written out PostScript");
+ logDebug("written out PostScript");
}
@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-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -387,7 +387,7 @@
final Graphic img = area.getGraphic();
if (img == null) {
- getLogger().error("Error while loading image : area.getImage() "
+ logError("Error while loading image : area.getImage() "
+ "is null");
addRect(x, y, w, h, true); // use helper function
@@ -555,7 +555,7 @@
try {
doc = svgGraphic.getSvgDocument();
} catch (final GraphicException e) {
- this.getLogger().error("Error getting SVGDocument in "
+ logError("Error getting SVGDocument in "
+ this.getClass().getName());
return;
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java 2022-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -190,7 +190,7 @@
void addStr(final int row, final int col, final String str,
final boolean ischar) {
if (this.debug) {
- getLogger().info("TxtRenderer.addStr(" + row + ", " + col
+ logInfo("TxtRenderer.addStr(" + row + ", " + col
+ ", \"" + str + "\", " + ischar + ")");
}
if (this.suppressGraphics && ! ischar) {
@@ -224,13 +224,13 @@
for (int countr = sb.length(); countr < modifiedColumn; countr++) {
sb.append(' ');
}
- getLogger().debug("TxtRenderer.addStr() sb.length()=" + sb.length());
+ logDebug("TxtRenderer.addStr() sb.length()=" + sb.length());
for (int countr = modifiedColumn;
countr < (modifiedColumn + modifiedString.length()); countr++) {
if (countr >= sb.length()) {
sb.append(modifiedString.charAt(countr - modifiedColumn));
} else {
- getLogger().debug("TxtRenderer.addStr() sb.length()="
+ logDebug("TxtRenderer.addStr() sb.length()="
+ sb.length() + " countr=" + countr);
sb.setCharAt(countr, modifiedString.charAt(
countr - modifiedColumn));
@@ -337,7 +337,7 @@
final int lineshade = Renderer4a.shadingPercent(stroke);
final int fillshade = shadingPercent(fill);
- getLogger().debug("TxtRenderer.addRect(" + x + ", " + y + ", "
+ logDebug("TxtRenderer.addRect(" + x + ", " + y + ", "
+ w + ", " + height + ", " + stroke + ", " + fill
+ ") fillshade=" + fillshade);
char fillchar = ' ';
@@ -442,7 +442,7 @@
*/
void printBMP(final Graphic img, final int x, final int y, final int w,
final int h) throws GraphicException {
- getLogger().debug("TxtRenderer.printBMP(" + img + ", " + x
+ logDebug("TxtRenderer.printBMP(" + img + ", " + x
+ ", " + y + ", " + w + ", " + h + ")");
addRect(x, y, w, h, new Color(1f, 1f, 1f), new Color(0f, 0f, 0f));
final int nameh = (int) (h * this.yFactor / 2);
@@ -484,9 +484,9 @@
try {
printBMP(img, x, y, w, h);
} catch (final GraphicException e) {
- getLogger().error("TxtRenderer.renderImageArea() printing BMP ("
+ logError("TxtRenderer.renderImageArea() printing BMP ("
+ e.toString() + ").");
- getLogger().error(e.getMessage());
+ logError(e.getMessage());
}
return null;
}
@@ -493,7 +493,7 @@
@Override
public void render(final ForeignContentSvgG5 area) {
- getLogger().debug("TxtRenderer.renderSVGArea(" + area + ")");
+ logDebug("TxtRenderer.renderSVGArea(" + area + ")");
/* TODO: Implement this?? */
}
@@ -526,7 +526,7 @@
@Override
public void startOutput() {
- getLogger().info("rendering areas to TEXT");
+ logInfo("rendering areas to TEXT");
this.currentStream = new TxtStream(this.getOutputStream());
final Charset encoding;
if (this.getOutputConfiguration() != null) {
@@ -540,7 +540,7 @@
@Override
public void stopOutput() throws OutputException {
- getLogger().info("writing out TEXT");
+ logInfo("writing out TEXT");
try {
this.getOutputStream().flush();
} catch (final IOException e) {
@@ -555,7 +555,7 @@
} else {
this.currentStream.add(this.pageEnding);
}
- this.getLogger().debug("TxtRenderer.renderPage() page.getHeight() = "
+ logDebug("TxtRenderer.renderPage() page.getHeight() = "
+ page.getHeight());
this.maxX = (int) (this.textCPI * page.getWidth()
@@ -574,7 +574,7 @@
/ TxtRenderer.MILLIPOINTS_PER_DECIPOINT;
}
- this.getLogger().debug("TxtRenderer.renderPage() maxX=" + this.maxX
+ logDebug("TxtRenderer.renderPage() maxX=" + this.maxX
+ " maxY=" + this.maxY + " xFactor=" + this.xFactor
+ " yFactor=" + this.yFactor + " paperHeight="
+ this.pageHeight);
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-02-27 16:57:56 UTC (rev 12628)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java 2022-02-27 17:30:35 UTC (rev 12629)
@@ -443,7 +443,7 @@
@Override
public void startOutput() {
- getLogger().debug("rendering areas to XML");
+ logDebug("rendering areas to XML");
this.writer = new PrintWriter(this.getOutputStream());
final StringBuilder buffer = new StringBuilder();
buffer.append("<?xml version=\"1.0\"?>\n");
@@ -463,7 +463,7 @@
public void stopOutput() {
this.writer.write("</area-tree>");
this.writer.flush();
- getLogger().debug("written out XML");
+ logDebug("written out XML");
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-27 16:57:59
|
Revision: 12628
http://sourceforge.net/p/foray/code/12628
Author: victormote
Date: 2022-02-27 16:57:56 +0000 (Sun, 27 Feb 2022)
Log Message:
-----------
Rename classes for clarity.
Modified Paths:
--------------
trunk/foray/foray-output/src/main/java/org/foray/output/Converter.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/awt/viewer/PreviewDialogAboutBox.java
trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/svg/SvgRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/txt/TxtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/xml/XmlRenderer.java
trunk/foray/foray-render/src/test/java/org/foray/render/RendererTests.java
Added Paths:
-----------
trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java
Removed Paths:
-------------
trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget.java
trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java
Modified: trunk/foray/foray-output/src/main/java/org/foray/output/Converter.java
===================================================================
--- trunk/foray/foray-output/src/main/java/org/foray/output/Converter.java 2022-02-27 16:37:29 UTC (rev 12627)
+++ trunk/foray/foray-output/src/main/java/org/foray/output/Converter.java 2022-02-27 16:57:56 UTC (rev 12628)
@@ -29,9 +29,8 @@
package org.foray.output;
/**
- * Abstract superclass for all output targets that do no layout, instead
- * converting directly from the FO Tree.
+ * Abstract superclass for all output targets that do no layout, instead converting directly from the FO Tree.
*/
-public abstract class Converter extends OutputTarget {
+public abstract class Converter extends OutputTarget4a {
}
Deleted: trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget.java
===================================================================
--- trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget.java 2022-02-27 16:37:29 UTC (rev 12627)
+++ trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget.java 2022-02-27 16:57:56 UTC (rev 12628)
@@ -1,198 +0,0 @@
-/*
- * Copyright 2005 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.output;
-
-import org.axsl.font.FontConsumer;
-import org.axsl.output.OutputConfiguration;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.OutputStream;
-
-/**
- * Abstract superclass for all Renderers and Converters.
- */
-public abstract class OutputTarget implements org.axsl.output.OutputTarget {
-
- /** The stream to which output should be written. */
- private OutputStream outputStream;
-
- /** The name of the application generating the output (used in document
- * metadata). */
- private String applicationName;
-
- /** The short name of the application generating the output (used in
- * document metadata). */
- private String applicationNameShort;
-
- /** The version of the application generating the output (used in document
- * metadata). */
- private String applicationVersion;
-
- /** The short version of the URL of the developer organization creating the
- * output (used in document metadata). */
- private String developerURLShort;
-
- /** Indicates whether SVG text should be stroked in the output document. */
- private boolean strokeSVGText;
-
- /** The logger. */
- private Logger logger;
-
- /** The FontConsumer used by the document. */
- private FontConsumer fontConsumer;
-
- /**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- if (this.logger == null) {
- this.logger = LoggerFactory.getLogger(this.getClass());
- }
- return this.logger;
- }
-
- /**
- * Returns the FontConsumer.
- * @return The FontConsumer implementation which should be used by this
- * Renderer.
- */
- public FontConsumer getFontConsumer() {
- return this.fontConsumer;
- }
-
- @Override
- public void setOutputStream(final OutputStream stream) {
- this.outputStream = stream;
- }
-
- /**
- * Returns the OutputStream.
- * @return The OutputStream.
- */
- public OutputStream getOutputStream() {
- return this.outputStream;
- }
-
- /**
- * {@inheritDoc}
- * Subclasses that do not need an OutputStream should override this.
- */
- @Override
- public boolean outputStreamRequired() {
- return true;
- }
-
- /**
- * Returns the name of the application creating the output.
- * @return The name of the application creating the output.
- */
- public String getApplicationName() {
- return this.applicationName;
- }
-
- @Override
- public void setApplicationName(final String applicationName) {
- this.applicationName = applicationName;
- }
-
- /**
- * Returns the short name of the application creating the output.
- * @return The "short" name of the application that is creating the
- * output.
- * For example, if the name of the application is "XYZ Document Processor",
- * the short name might be "XYZ".
- */
- public String getApplicationNameShort() {
- return this.applicationNameShort;
- }
-
- @Override
- public void setApplicationNameShort(final String applicationNameShort) {
- this.applicationNameShort = applicationNameShort;
- }
-
- /**
- * Returna the current version of the application that is creating the
- * output.
- * @return The current version of the application that is creating the
- * output.
- */
- public String getApplicationVersion() {
- return this.applicationVersion;
- }
-
- @Override
- public void setApplicationVersion(final String applicationVersion) {
- this.applicationVersion = applicationVersion;
- }
-
- /**
- * Returns a short version of the URL of the developer.
- * @return The shortened version of the URL to the home-page of the
- * developer. For example, if the URL is "http://www.xyz.com", return
- * "www.xyz.com".
- */
- public String getDeveloperURLShort() {
- return this.developerURLShort;
- }
-
- @Override
- public void setDeveloperUrlShort(final String developerURLShort) {
- this.developerURLShort = developerURLShort;
- }
-
- @Override
- public void setStrokeText(final boolean stroke) {
- this.strokeSVGText = stroke;
- }
-
- /**
- * Indicates whether SVG text should be converted to strokes.
- * @return True if SVG text should be converted to strokes instead of
- * rendered as characters of a Font.
- */
- public boolean getStrokeSVGText() {
- return this.strokeSVGText;
- }
-
- @Override
- public void setFontConsumer(final FontConsumer fontConsumer) {
- this.fontConsumer = fontConsumer;
- }
-
- /**
- * Returns the output configuration for this renderer.
- * @return The output configuration for this renderer.
- */
- public abstract OutputConfiguration getOutputConfiguration();
-
-}
Copied: trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget4a.java (from rev 12602, trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget.java)
===================================================================
--- trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget4a.java (rev 0)
+++ trunk/foray/foray-output/src/main/java/org/foray/output/OutputTarget4a.java 2022-02-27 16:57:56 UTC (rev 12628)
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2005 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.output;
+
+import org.axsl.font.FontConsumer;
+import org.axsl.output.OutputConfiguration;
+import org.axsl.output.OutputTarget;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.OutputStream;
+
+/**
+ * Abstract superclass for all Renderers and Converters.
+ */
+public abstract class OutputTarget4a implements OutputTarget {
+
+ /** The stream to which output should be written. */
+ private OutputStream outputStream;
+
+ /** The name of the application generating the output (used in document
+ * metadata). */
+ private String applicationName;
+
+ /** The short name of the application generating the output (used in
+ * document metadata). */
+ private String applicationNameShort;
+
+ /** The version of the application generating the output (used in document
+ * metadata). */
+ private String applicationVersion;
+
+ /** The short version of the URL of the developer organization creating the
+ * output (used in document metadata). */
+ private String developerURLShort;
+
+ /** Indicates whether SVG text should be stroked in the output document. */
+ private boolean strokeSVGText;
+
+ /** The logger. */
+ private Logger logger;
+
+ /** The FontConsumer used by the document. */
+ private FontConsumer fontConsumer;
+
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ public Logger getLogger() {
+ if (this.logger == null) {
+ this.logger = LoggerFactory.getLogger(this.getClass());
+ }
+ return this.logger;
+ }
+
+ /**
+ * Returns the FontConsumer.
+ * @return The FontConsumer implementation which should be used by this
+ * Renderer.
+ */
+ public FontConsumer getFontConsumer() {
+ return this.fontConsumer;
+ }
+
+ @Override
+ public void setOutputStream(final OutputStream stream) {
+ this.outputStream = stream;
+ }
+
+ /**
+ * Returns the OutputStream.
+ * @return The OutputStream.
+ */
+ public OutputStream getOutputStream() {
+ return this.outputStream;
+ }
+
+ /**
+ * {@inheritDoc}
+ * Subclasses that do not need an OutputStream should override this.
+ */
+ @Override
+ public boolean outputStreamRequired() {
+ return true;
+ }
+
+ /**
+ * Returns the name of the application creating the output.
+ * @return The name of the application creating the output.
+ */
+ public String getApplicationName() {
+ return this.applicationName;
+ }
+
+ @Override
+ public void setApplicationName(final String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ /**
+ * Returns the short name of the application creating the output.
+ * @return The "short" name of the application that is creating the
+ * output.
+ * For example, if the name of the application is "XYZ Document Processor",
+ * the short name might be "XYZ".
+ */
+ public String getApplicationNameShort() {
+ return this.applicationNameShort;
+ }
+
+ @Override
+ public void setApplicationNameShort(final String applicationNameShort) {
+ this.applicationNameShort = applicationNameShort;
+ }
+
+ /**
+ * Returna the current version of the application that is creating the
+ * output.
+ * @return The current version of the application that is creating the
+ * output.
+ */
+ public String getApplicationVersion() {
+ return this.applicationVersion;
+ }
+
+ @Override
+ public void setApplicationVersion(final String applicationVersion) {
+ this.applicationVersion = applicationVersion;
+ }
+
+ /**
+ * Returns a short version of the URL of the developer.
+ * @return The shortened version of the URL to the home-page of the
+ * developer. For example, if the URL is "http://www.xyz.com", return
+ * "www.xyz.com".
+ */
+ public String getDeveloperURLShort() {
+ return this.developerURLShort;
+ }
+
+ @Override
+ public void setDeveloperUrlShort(final String developerURLShort) {
+ this.developerURLShort = developerURLShort;
+ }
+
+ @Override
+ public void setStrokeText(final boolean stroke) {
+ this.strokeSVGText = stroke;
+ }
+
+ /**
+ * Indicates whether SVG text should be converted to strokes.
+ * @return True if SVG text should be converted to strokes instead of
+ * rendered as characters of a Font.
+ */
+ public boolean getStrokeSVGText() {
+ return this.strokeSVGText;
+ }
+
+ @Override
+ public void setFontConsumer(final FontConsumer fontConsumer) {
+ this.fontConsumer = fontConsumer;
+ }
+
+ /**
+ * Returns the output configuration for this renderer.
+ * @return The output configuration for this renderer.
+ */
+ public abstract OutputConfiguration getOutputConfiguration();
+
+}
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-02-27 16:37:29 UTC (rev 12627)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/PrintRenderer.java 2022-02-27 16:57:56 UTC (rev 12628)
@@ -45,7 +45,7 @@
/**
* Abstract base class of "Print" type renderers.
*/
-public abstract class PrintRenderer extends Renderer {
+public abstract class PrintRenderer extends Renderer4a {
/** A magic-number constant used to compute the width of leaders when they
* are "double". Presumably the logic is that the width is divided into
Deleted: trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java 2022-02-27 16:37:29 UTC (rev 12627)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java 2022-02-27 16:57:56 UTC (rev 12628)
@@ -1,584 +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$
- */
-
-/*
- * Known contributors:
- * BoBoGi (graphics rendering)
- */
-
-package org.foray.render;
-
-import org.foray.common.ForayConstants;
-import org.foray.common.WellKnownConstants;
-import org.foray.output.OutputTarget;
-
-import org.axsl.galley.AreaG5;
-import org.axsl.galley.AreaNodeG5;
-import org.axsl.galley.BackgroundAreaG5;
-import org.axsl.galley.BlockContainerAreaG5;
-import org.axsl.galley.BorderPaddingAreaG5;
-import org.axsl.galley.ExternalGraphicAreaG5;
-import org.axsl.galley.ForeignContentG5;
-import org.axsl.galley.ForeignContentMathG5;
-import org.axsl.galley.ForeignContentSvgG5;
-import org.axsl.galley.ForeignObjectAreaG5;
-import org.axsl.galley.Galley;
-import org.axsl.galley.GlyphAreaSequenceG5;
-import org.axsl.galley.GraphicAreaG5;
-import org.axsl.galley.InlineAreaG5;
-import org.axsl.galley.LineAreaG5;
-import org.axsl.galley.NormalBlockAreaG5;
-import org.axsl.galley.PageCollectionG5;
-import org.axsl.galley.PageG5;
-import org.axsl.galley.RegionAreaG5;
-import org.axsl.galley.TableAreaG5;
-import org.axsl.galley.TableCellAreaG5;
-import org.axsl.galley.metadata.BookmarkTreeG5;
-import org.axsl.galley.render.GalleyVisitor;
-import org.axsl.galley.render.GalleyVisitorException;
-import org.axsl.graphic.Graphic;
-import org.axsl.graphic.GraphicException;
-import org.axsl.value.RuleStyle;
-
-import java.awt.Color;
-import java.awt.Rectangle;
-import java.awt.geom.Rectangle2D;
-
-/**
- * Abstract base class for all renderers.
- * Subclasses produce output in some format from an AreaTree or AreaTree
- * fragment.
- */
-public abstract class Renderer extends OutputTarget
- implements org.axsl.output.Renderer, GalleyVisitor<Void> {
-
- /** Magic-number constant used in the conversion of color to gray. */
- protected static final float SHADING_WEIGHT_RED = 0.3f;
- /* TODO: Replace these magic numbers for color-to-gray conversion with
- * AWT methods that convert from one colorspace to another. */
-
- /** Magic-number constant used in the conversion of color to gray. */
- protected static final float SHADING_WEIGHT_GREEN = 0.59f;
-
- /** Magic-number constant used in the conversion of color to gray. */
- protected static final float SHADING_WEIGHT_BLUE = 0.11f;
-
- /** The AreaTree being rendered. */
- private Galley areaTree;
-
- /**
- * Sets the AreaTree to be rendered.
- * @param areaTree The AreaTree to be rendered.
- */
- public void setGalley(final Galley areaTree) {
- this.areaTree = areaTree;
- }
-
- @Override
- public abstract void render(PageG5 page) throws GalleyVisitorException;
-
- /**
- * Marks the border, if any, for the given area.
- * @param area The area whose border is to be drawn.
- * @throws GalleyVisitorException For errors during rendering.
- */
- protected abstract void markBorder(BorderPaddingAreaG5 area) throws GalleyVisitorException;
-
- /**
- * Renders an area's background, both image and color.
- * @param area The area whose background should be rendered.
- * @throws GalleyVisitorException For errors during rendering.
- */
- protected void markBackground(final BackgroundAreaG5 area) throws GalleyVisitorException {
- markBackgroundColor(area);
- markBackgroundImage(area);
- }
-
- /**
- * Renders an area's background color, if any.
- * @param area The area whose background should be rendered.
- * @throws GalleyVisitorException For errors during rendering.
- */
- private void markBackgroundColor(final BackgroundAreaG5 area) throws GalleyVisitorException {
- final Color backgroundColor = area.traitBackgroundColor();
- /* If the background color is totally transparent, don't paint it. */
- if (backgroundColor.getAlpha() == 0) {
- return;
- }
-
- /*
- * Per XSL-FO Spec 1.0, Section 4.9.4, the background is rendered
- * inside the padding-rectangle.
- */
- final int x = area.prOriginX();
- final int y = area.prOriginY();
- final int w = area.prIpd();
- final int h = area.prBpd();
-
- if (h == 0 || w == 0) {
- return;
- }
-
- this.drawRectangle(x, y, w, -h, null, backgroundColor);
- }
-
- /**
- * Renders an area's background image, if any.
- * @param area The area whose background should be rendered.
- * @throws GalleyVisitorException For errors during rendering.
- */
- private void markBackgroundImage(final BackgroundAreaG5 area) throws GalleyVisitorException {
- final Graphic backgroundImage = area.traitBackgroundImage();
- if (backgroundImage == null) {
- return;
- }
- /*
- * Per XSL-FO Spec 1.0, Section 4.9.4, the background is rendered
- * inside the padding-rectangle.
- */
- final int x = area.prOriginX();
- final int y = area.prOriginY();
- final int w = area.prIpd();
- final int h = area.prBpd();
-
- if (h == 0 || w == 0) {
- return;
- }
-
- final int imgW;
- final int imgH;
- try {
- imgW = backgroundImage.absoluteWidth(getPixelsPerInch());
- imgH = backgroundImage.absoluteHeight(getPixelsPerInch());
- } catch (final GraphicException fie) {
- getLogger().error("Error obtaining bg image width and height");
- getLogger().error(fie.getMessage());
- return;
- }
-
- int currentX = x;
- int currentY = y;
- final int endX = x + w;
- final int endY = y - h;
- final int clipW = w % imgW;
- final int clipH = h % imgH;
-
- final boolean repeatX = area.traitBackgroundRepeat()
- .repeatsHorizontal();
- final boolean repeatY = area.traitBackgroundRepeat().repeatsVertical();
-
- Rectangle contentRectangle = null;
- Rectangle clipRectangle = null;
- while (currentY > endY) { // looping through rows
- while (currentX < endX) { // looping through cols
- if (currentX + imgW <= endX) {
- // no x clipping
- if (currentY - imgH >= endY) {
- // no x clipping, no y clipping
- contentRectangle = new Rectangle(currentX, currentY,
- imgW, imgH);
- drawGraphic(area, backgroundImage, contentRectangle,
- null);
- } else {
- // no x clipping, y clipping
- contentRectangle = new Rectangle(currentX, currentY,
- imgW, imgH);
- clipRectangle = new Rectangle(currentX,
- currentY - clipH, imgW, clipH);
- drawGraphic(area, backgroundImage, contentRectangle,
- clipRectangle);
- }
- } else {
- // x clipping
- if (currentY - imgH >= endY) {
- // x clipping, no y clipping
- contentRectangle = new Rectangle(currentX, currentY,
- imgW, imgH);
- clipRectangle = new Rectangle(currentX + clipW,
- currentY, clipW, imgH);
- drawGraphic(area, backgroundImage, contentRectangle,
- clipRectangle);
- } else {
- // x clipping, y clipping
- contentRectangle = new Rectangle(currentX, currentY,
- imgW, imgH);
- clipRectangle = new Rectangle(currentX + clipW,
- currentY - clipH, clipW, clipH);
- drawGraphic(area, backgroundImage, contentRectangle,
- clipRectangle);
- }
- }
-
- if (repeatX) {
- currentX += imgW;
- } else {
- break;
- }
- } // end looping through cols
-
- currentX = x;
-
- if (repeatY) {
- currentY -= imgH;
- } else {
- break;
- }
- } // end looping through rows
- }
-
- /**
- * The pixel density, per inch, that should be used to compute image
- * sizes when only the number of pixels is known.
- * @return The pixel density, per inch.
- */
- public int getPixelsPerInch() {
- return ForayConstants.DEFAULT_SCREEN_RESOLUTION;
- }
-
- /**
- * Draw a line in the output document.
- *
- * @param startX The start x location in millipoints.
- * @param startY The start y location in millipoints.
- * @param endX The end x location in millipoints.
- * @param endY The end y location in millipoints.
- * @param thickness The thickness in millipoints.
- * @param ruleStyle The rule style.
- * @param strokeColor The stroke color.
- * @throws GalleyVisitorException For errors during rendering.
- */
- protected abstract void drawLine(int startX, int startY, int endX, int endY,
- int thickness, RuleStyle ruleStyle, Color strokeColor) throws GalleyVisitorException;
-
- /**
- * Draw a rectangle in the output document.
- *
- * @param x The x position of left edge in millipoints.
- * @param y The y position of top edge in millipoints.
- * @param w The width in millipoints.
- * @param h The height in millipoints.
- * @param strokeColor The color to be used for the stroke.
- * Stroked means a box will be drawn around the rectangle.
- * Set to null if the rectangle should not be stroked.
- * @param fillColor The color to be used for the fill.
- * Set to null if the rectangle should not be filled.
- * @throws GalleyVisitorException For errors during rendering.
- */
- protected abstract void drawRectangle(int x, int y, int w, int h,
- Color strokeColor, Color fillColor) throws GalleyVisitorException;
-
- /**
- * Renders a Graphic to a given contentRectangle, and clipping it to a given
- * clip rectangle.
- * If the content rectangle is the same as the intrinsic dimensions of the
- * image, no scaling is done.
- * @param area The Area instance from which to obtain traits.
- * @param image The graphic to be rendered.
- * @param contentRectangle The rectangle to which the graphic should be
- * scaled during drawing.
- * @param clipRectangle The rectangle to which the content should be clipped
- * after any scaling.
- * @throws GalleyVisitorException For errors during rendering.
- * @see #drawGraphic(GraphicAreaG5, Graphic, Rectangle, Rectangle)
- */
- protected abstract void drawGraphic(GraphicAreaG5 area, Graphic image,
- Rectangle contentRectangle, Rectangle clipRectangle) throws GalleyVisitorException;
-
- @Override
- public Void visit(final AreaNodeG5 node) throws GalleyVisitorException {
- renderChildren(node);
- return null;
- }
-
- @Override
- public Void visit(final AreaG5 node) throws GalleyVisitorException {
- renderChildren(node);
- return null;
- }
-
- /**
- * Render a page's region areas.
- * @param page The page whose regions should be rendered.
- * @throws GalleyVisitorException For errors during rendering.
- */
- protected void renderRegions(final PageG5 page) throws GalleyVisitorException {
- for (int index = 0; index < page.qtyRegionBodies(); index ++) {
- final RegionAreaG5 regionBody = page.regionBodyAt(index);
- visit(regionBody);
- }
- if (page.getRegionBefore() != null) {
- visit(page.getRegionBefore());
- }
- if (page.getRegionAfter() != null) {
- visit(page.getRegionAfter());
- }
- if (page.getRegionStart() != null) {
- visit(page.getRegionStart());
- }
- if (page.getRegionEnd() != null) {
- visit(page.getRegionEnd());
- }
- }
-
- @Override
- public Void visit(final BlockContainerAreaG5 area) throws GalleyVisitorException {
- markBorder(area);
- markBackground(area);
- renderChildren(area);
- return null;
- }
-
- @Override
- public Void visit(final RegionAreaG5 area) throws GalleyVisitorException {
- markBackground(area);
- renderChildren(area);
- return null;
- }
-
- /**
- * Render the children of a given node.
- * @param area The area whose children should be rendered.
- * @return Void.
- * @throws GalleyVisitorException For errors during rendering.
- */
- public Void renderChildren(final AreaNodeG5 area) throws GalleyVisitorException {
- for (int i = 0; i < area.qtyAreaNodeChildren(); i++) {
- final AreaNodeG5 child = area.areaNodeChildAt(i);
- child.acceptVisitor(this);
- }
- return null;
- }
-
- @Override
- public Void visit(final NormalBlockAreaG5 area) throws GalleyVisitorException {
- markBorder(area);
- markBackground(area);
- renderChildren(area);
- return null;
- }
-
- /**
- * Render the SVG content of a {@link ForeignObjectAreaG5}.
- * @param svgContent The SVG content to be rendered.
- * @throws GalleyVisitorException For errors during rendering.
- */
- public abstract void render(ForeignContentSvgG5 svgContent) throws GalleyVisitorException;
-
- /**
- * Render the MathML content of a {@link ForeignObjectAreaG5}.
- * @param mathContent The MathML content to be rendered.
- * @throws GalleyVisitorException For errors during rendering.
- */
- public abstract void render(ForeignContentMathG5 mathContent) throws GalleyVisitorException;
-
- @Override
- public Void visit(final ForeignObjectAreaG5 area) throws GalleyVisitorException {
- final ForeignContentG5 foreignContent = area.getContainedForeignObject();
- if (foreignContent == null) {
- this.getLogger().warn("At rendering, ForeignContent area "
- + "has no parsed content");
- return null;
- }
- if (foreignContent instanceof ForeignContentSvgG5) {
- final ForeignContentSvgG5 svgArea =
- (ForeignContentSvgG5) foreignContent;
- render(svgArea);
- } else if (foreignContent instanceof ForeignContentMathG5) {
- final ForeignContentMathG5 mathArea =
- (ForeignContentMathG5) foreignContent;
- render(mathArea);
- } else {
- this.getLogger().warn("At rendering, ForeignContent area "
- + "is of an unsupported type.");
- }
- return null;
- }
-
- @Override
- public Void visit(final ExternalGraphicAreaG5 area) throws GalleyVisitorException {
- final Graphic graphic = area.getGraphic();
- if (graphic == null) {
- throw new NullPointerException("Null graphic.");
- }
- final Rectangle contentRect = new Rectangle(area.crOriginX(),
- area.crOriginY(), area.referenceIpd(), area.referenceBpd());
- final Rectangle clipRect = new Rectangle(area.crOriginX(),
- area.crOriginY(), area.crIpd(), area.crBpd());
- drawGraphic(area, graphic, contentRect, clipRect);
- return null;
- }
-
- @Override
- public Void visit(final TableAreaG5 area) throws GalleyVisitorException {
- /* Render background Areas for the table-related background-only
- * areas. */
- final BackgroundAreaG5[] backgroundAreas = area.getBackgroundAreas();
- if (backgroundAreas != null) {
- for (int i = 0; i < backgroundAreas.length; i++) {
- final BackgroundAreaG5 bga = backgroundAreas[i];
- markBackground(bga);
- }
- }
- /* TODO: Add logic that tries to paint the borders as efficiently
- * as possible. Contiguous cells that have identical borders should have
- * their borders painted at the same time. */
- markBorder(area);
- renderChildren(area);
- return null;
- }
-
- @Override
- public Void visit(final TableCellAreaG5 area) throws GalleyVisitorException {
- markBorder(area);
- markBackground(area);
- renderChildren(area);
- return null;
- }
-
- /**
- * Renders an arbitrary text chunk with attributes from an arbitrary Area.
- * Of course, ordinarily, the text will come from the Area, but the caller
- * should decide that.
- * @param area An Area instance that contains the traits that should be
- * used to render the text.
- * @param text The text content to be rendered.
- * @throws GalleyVisitorException For errors during rendering.
- */
- public abstract void renderTextSegment(GlyphAreaSequenceG5 area, CharSequence text)
- throws GalleyVisitorException;
-
- @Override
- public Void visit(final LineAreaG5 area) throws GalleyVisitorException {
- renderChildren(area);
- return null;
- }
-
- /**
- * Render the bookmark tree for this document.
- * @param bookmarkTree The bookmark tree to be rendered.
- * @throws GalleyVisitorException For invalid bookmark target.
- */
- public abstract void render(BookmarkTreeG5 bookmarkTree) throws GalleyVisitorException;
-
- @Override
- public Void visit(final InlineAreaG5 area) throws GalleyVisitorException {
- markBorder(area);
- markBackground(area);
- renderChildren(area);
- return null;
- }
-
- /**
- * Renders all of the non-area AreaNodes, i.e. those AreaTree nodes that
- * are direct children of AreaTree instead of a PageCollection. This
- * includes items like Destinations and Bookmarks.
- * @throws GalleyVisitorException For errors during rendering.
- */
- protected void renderDocumentNodes() throws GalleyVisitorException {
- final BookmarkTreeG5 bookmarkTree = this.areaTree.getBookmarkTree();
- if (bookmarkTree != null) {
- render(bookmarkTree);
- }
- for (int i = 0; i < this.areaTree.qtyAreaNodeChildren(); i++) {
- final AreaNodeG5 atNode = this.areaTree.areaNodeChildAt(i);
- if (! (atNode instanceof PageCollectionG5)) {
- atNode.acceptVisitor(this);
- }
- }
- }
-
- /**
- * Provides the Renderer with an opportunity to close any text objects that
- * are in progress.
- */
- public abstract void resetTextCursor();
-
- /**
- * Converts a Rectangle storing millipoints to one storing points.
- * @param input A rectangle whose dimensions are stored as millipoints.
- * @return A new rectangle whose dimensions are stored as points.
- */
- public static Rectangle2D.Float convertMillipointRectangle(
- final Rectangle input) {
- if (input == null) {
- return null;
- }
- return new Rectangle2D.Float(
- toPoints(input.x),
- toPoints(input.y),
- toPoints(input.width),
- toPoints(input.height));
- }
-
- /**
- * Converts millipoints to points.
- * @param millipoints The millipoint value to be converted to points.
- * @return The converted value in points.
- */
- public static float toPoints(final int millipoints) {
- return millipoints / (float) WellKnownConstants.MILLIPOINTS_PER_POINT;
- }
-
- /**
- * Converts a color value in the range 0 - 255 to its floating-point
- * equivalant, that is, a value in the range 0 - 1.
- * @param integralColorComponent The integral color value to be converted, a
- * value in the range 0 - 255.
- * @return The floating point value, a value in the range 0 - 1.
- */
- protected static float colorToFloat(final int integralColorComponent) {
- int colorValue = Math.max(integralColorComponent, 0);
- colorValue = Math.min(integralColorComponent,
- WellKnownConstants.MAXIMUM_INTEGRAL_COLOR_VALUE);
- return colorValue / WellKnownConstants.MAXIMUM_INTEGRAL_COLOR_VALUE;
- }
-
- /**
- * Converts a color to a percentage of black.
- * @param color The color to be converted.
- * @return A value in the range 0 to 100, representing a percentage of
- * black for this color.
- */
- protected static int shadingPercent(final Color color) {
- float lineshade = 0;
- lineshade += Renderer.SHADING_WEIGHT_RED * color.getRed();
- lineshade += Renderer.SHADING_WEIGHT_GREEN * color.getGreen();
- lineshade += Renderer.SHADING_WEIGHT_BLUE * color.getBlue();
- return WellKnownConstants.PERCENT_CONVERSION - (int) (lineshade
- * WellKnownConstants.PERCENT_CONVERSION);
- }
-
- /**
- * Returns the area tree being rendered.
- * @return The area tree being rendered.
- */
- protected Galley getAreaTree() {
- return this.areaTree;
- }
-
-}
Copied: trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java (from rev 12602, trunk/foray/foray-render/src/main/java/org/foray/render/Renderer.java)
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java (rev 0)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java 2022-02-27 16:57:56 UTC (rev 12628)
@@ -0,0 +1,583 @@
+/*
+ * 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$
+ */
+
+/*
+ * Known contributors:
+ * BoBoGi (graphics rendering)
+ */
+
+package org.foray.render;
+
+import org.foray.common.ForayConstants;
+import org.foray.common.WellKnownConstants;
+import org.foray.output.OutputTarget4a;
+
+import org.axsl.galley.AreaG5;
+import org.axsl.galley.AreaNodeG5;
+import org.axsl.galley.BackgroundAreaG5;
+import org.axsl.galley.BlockContainerAreaG5;
+import org.axsl.galley.BorderPaddingAreaG5;
+import org.axsl.galley.ExternalGraphicAreaG5;
+import org.axsl.galley.ForeignContentG5;
+import org.axsl.galley.ForeignContentMathG5;
+import org.axsl.galley.ForeignContentSvgG5;
+import org.axsl.galley.ForeignObjectAreaG5;
+import org.axsl.galley.Galley;
+import org.axsl.galley.GlyphAreaSequenceG5;
+import org.axsl.galley.GraphicAreaG5;
+import org.axsl.galley.InlineAreaG5;
+import org.axsl.galley.LineAreaG5;
+import org.axsl.galley.NormalBlockAreaG5;
+import org.axsl.galley.PageCollectionG5;
+import org.axsl.galley.PageG5;
+import org.axsl.galley.RegionAreaG5;
+import org.axsl.galley.TableAreaG5;
+import org.axsl.galley.TableCellAreaG5;
+import org.axsl.galley.metadata.BookmarkTreeG5;
+import org.axsl.galley.render.GalleyVisitor;
+import org.axsl.galley.render.GalleyVisitorException;
+import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicException;
+import org.axsl.output.Renderer;
+import org.axsl.value.RuleStyle;
+
+import java.awt.Color;
+import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Abstract base class for all renderers.
+ * Subclasses produce output in some format from an AreaTree or AreaTree fragment.
+ */
+public abstract class Renderer4a extends OutputTarget4a implements Renderer, GalleyVisitor<Void> {
+
+ /** Magic-number constant used in the conversion of color to gray. */
+ protected static final float SHADING_WEIGHT_RED = 0.3f;
+ /* TODO: Replace these magic numbers for color-to-gray conversion with
+ * AWT methods that convert from one colorspace to another. */
+
+ /** Magic-number constant used in the conversion of color to gray. */
+ protected static final float SHADING_WEIGHT_GREEN = 0.59f;
+
+ /** Magic-number constant used in the conversion of color to gray. */
+ protected static final float SHADING_WEIGHT_BLUE = 0.11f;
+
+ /** The AreaTree being rendered. */
+ private Galley areaTree;
+
+ /**
+ * Sets the AreaTree to be rendered.
+ * @param areaTree The AreaTree to be rendered.
+ */
+ public void setGalley(final Galley areaTree) {
+ this.areaTree = areaTree;
+ }
+
+ @Override
+ public abstract void render(PageG5 page) throws GalleyVisitorException;
+
+ /**
+ * Marks the border, if any, for the given area.
+ * @param area The area whose border is to be drawn.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ protected abstract void markBorder(BorderPaddingAreaG5 area) throws GalleyVisitorException;
+
+ /**
+ * Renders an area's background, both image and color.
+ * @param area The area whose background should be rendered.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ protected void markBackground(final BackgroundAreaG5 area) throws GalleyVisitorException {
+ markBackgroundColor(area);
+ markBackgroundImage(area);
+ }
+
+ /**
+ * Renders an area's background color, if any.
+ * @param area The area whose background should be rendered.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ private void markBackgroundColor(final BackgroundAreaG5 area) throws GalleyVisitorException {
+ final Color backgroundColor = area.traitBackgroundColor();
+ /* If the background color is totally transparent, don't paint it. */
+ if (backgroundColor.getAlpha() == 0) {
+ return;
+ }
+
+ /*
+ * Per XSL-FO Spec 1.0, Section 4.9.4, the background is rendered
+ * inside the padding-rectangle.
+ */
+ final int x = area.prOriginX();
+ final int y = area.prOriginY();
+ final int w = area.prIpd();
+ final int h = area.prBpd();
+
+ if (h == 0 || w == 0) {
+ return;
+ }
+
+ this.drawRectangle(x, y, w, -h, null, backgroundColor);
+ }
+
+ /**
+ * Renders an area's background image, if any.
+ * @param area The area whose background should be rendered.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ private void markBackgroundImage(final BackgroundAreaG5 area) throws GalleyVisitorException {
+ final Graphic backgroundImage = area.traitBackgroundImage();
+ if (backgroundImage == null) {
+ return;
+ }
+ /*
+ * Per XSL-FO Spec 1.0, Section 4.9.4, the background is rendered
+ * inside the padding-rectangle.
+ */
+ final int x = area.prOriginX();
+ final int y = area.prOriginY();
+ final int w = area.prIpd();
+ final int h = area.prBpd();
+
+ if (h == 0 || w == 0) {
+ return;
+ }
+
+ final int imgW;
+ final int imgH;
+ try {
+ imgW = backgroundImage.absoluteWidth(getPixelsPerInch());
+ imgH = backgroundImage.absoluteHeight(getPixelsPerInch());
+ } catch (final GraphicException fie) {
+ getLogger().error("Error obtaining bg image width and height");
+ getLogger().error(fie.getMessage());
+ return;
+ }
+
+ int currentX = x;
+ int currentY = y;
+ final int endX = x + w;
+ final int endY = y - h;
+ final int clipW = w % imgW;
+ final int clipH = h % imgH;
+
+ final boolean repeatX = area.traitBackgroundRepeat()
+ .repeatsHorizontal();
+ final boolean repeatY = area.traitBackgroundRepeat().repeatsVertical();
+
+ Rectangle contentRectangle = null;
+ Rectangle clipRectangle = null;
+ while (currentY > endY) { // looping through rows
+ while (currentX < endX) { // looping through cols
+ if (currentX + imgW <= endX) {
+ // no x clipping
+ if (currentY - imgH >= endY) {
+ // no x clipping, no y clipping
+ contentRectangle = new Rectangle(currentX, currentY,
+ imgW, imgH);
+ drawGraphic(area, backgroundImage, contentRectangle,
+ null);
+ } else {
+ // no x clipping, y clipping
+ contentRectangle = new Rectangle(currentX, currentY,
+ imgW, imgH);
+ clipRectangle = new Rectangle(currentX,
+ currentY - clipH, imgW, clipH);
+ drawGraphic(area, backgroundImage, contentRectangle,
+ clipRectangle);
+ }
+ } else {
+ // x clipping
+ if (currentY - imgH >= endY) {
+ // x clipping, no y clipping
+ contentRectangle = new Rectangle(currentX, currentY,
+ imgW, imgH);
+ clipRectangle = new Rectangle(currentX + clipW,
+ currentY, clipW, imgH);
+ drawGraphic(area, backgroundImage, contentRectangle,
+ clipRectangle);
+ } else {
+ // x clipping, y clipping
+ contentRectangle = new Rectangle(currentX, currentY,
+ imgW, imgH);
+ clipRectangle = new Rectangle(currentX + clipW,
+ currentY - clipH, clipW, clipH);
+ drawGraphic(area, backgroundImage, contentRectangle,
+ clipRectangle);
+ }
+ }
+
+ if (repeatX) {
+ currentX += imgW;
+ } else {
+ break;
+ }
+ } // end looping through cols
+
+ currentX = x;
+
+ if (repeatY) {
+ currentY -= imgH;
+ } else {
+ break;
+ }
+ } // end looping through rows
+ }
+
+ /**
+ * The pixel density, per inch, that should be used to compute image
+ * sizes when only the number of pixels is known.
+ * @return The pixel density, per inch.
+ */
+ public int getPixelsPerInch() {
+ return ForayConstants.DEFAULT_SCREEN_RESOLUTION;
+ }
+
+ /**
+ * Draw a line in the output document.
+ *
+ * @param startX The start x location in millipoints.
+ * @param startY The start y location in millipoints.
+ * @param endX The end x location in millipoints.
+ * @param endY The end y location in millipoints.
+ * @param thickness The thickness in millipoints.
+ * @param ruleStyle The rule style.
+ * @param strokeColor The stroke color.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ protected abstract void drawLine(int startX, int startY, int endX, int endY,
+ int thickness, RuleStyle ruleStyle, Color strokeColor) throws GalleyVisitorException;
+
+ /**
+ * Draw a rectangle in the output document.
+ *
+ * @param x The x position of left edge in millipoints.
+ * @param y The y position of top edge in millipoints.
+ * @param w The width in millipoints.
+ * @param h The height in millipoints.
+ * @param strokeColor The color to be used for the stroke.
+ * Stroked means a box will be drawn around the rectangle.
+ * Set to null if the rectangle should not be stroked.
+ * @param fillColor The color to be used for the fill.
+ * Set to null if the rectangle should not be filled.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ protected abstract void drawRectangle(int x, int y, int w, int h,
+ Color strokeColor, Color fillColor) throws GalleyVisitorException;
+
+ /**
+ * Renders a Graphic to a given contentRectangle, and clipping it to a given
+ * clip rectangle.
+ * If the content rectangle is the same as the intrinsic dimensions of the
+ * image, no scaling is done.
+ * @param area The Area instance from which to obtain traits.
+ * @param image The graphic to be rendered.
+ * @param contentRectangle The rectangle to which the graphic should be
+ * scaled during drawing.
+ * @param clipRectangle The rectangle to which the content should be clipped
+ * after any scaling.
+ * @throws GalleyVisitorException For errors during rendering.
+ * @see #drawGraphic(GraphicAreaG5, Graphic, Rectangle, Rectangle)
+ */
+ protected abstract void drawGraphic(GraphicAreaG5 area, Graphic image,
+ Rectangle contentRectangle, Rectangle clipRectangle) throws GalleyVisitorException;
+
+ @Override
+ public Void visit(final AreaNodeG5 node) throws GalleyVisitorException {
+ renderChildren(node);
+ return null;
+ }
+
+ @Override
+ public Void visit(final AreaG5 node) throws GalleyVisitorException {
+ renderChildren(node);
+ return null;
+ }
+
+ /**
+ * Render a page's region areas.
+ * @param page The page whose regions should be rendered.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ protected void renderRegions(final PageG5 page) throws GalleyVisitorException {
+ for (int index = 0; index < page.qtyRegionBodies(); index ++) {
+ final RegionAreaG5 regionBody = page.regionBodyAt(index);
+ visit(regionBody);
+ }
+ if (page.getRegionBefore() != null) {
+ visit(page.getRegionBefore());
+ }
+ if (page.getRegionAfter() != null) {
+ visit(page.getRegionAfter());
+ }
+ if (page.getRegionStart() != null) {
+ visit(page.getRegionStart());
+ }
+ if (page.getRegionEnd() != null) {
+ visit(page.getRegionEnd());
+ }
+ }
+
+ @Override
+ public Void visit(final BlockContainerAreaG5 area) throws GalleyVisitorException {
+ markBorder(area);
+ markBackground(area);
+ renderChildren(area);
+ return null;
+ }
+
+ @Override
+ public Void visit(final RegionAreaG5 area) throws GalleyVisitorException {
+ markBackground(area);
+ renderChildren(area);
+ return null;
+ }
+
+ /**
+ * Render the children of a given node.
+ * @param area The area whose children should be rendered.
+ * @return Void.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ public Void renderChildren(final AreaNodeG5 area) throws GalleyVisitorException {
+ for (int i = 0; i < area.qtyAreaNodeChildren(); i++) {
+ final AreaNodeG5 child = area.areaNodeChildAt(i);
+ child.acceptVisitor(this);
+ }
+ return null;
+ }
+
+ @Override
+ public Void visit(final NormalBlockAreaG5 area) throws GalleyVisitorException {
+ markBorder(area);
+ markBackground(area);
+ renderChildren(area);
+ return null;
+ }
+
+ /**
+ * Render the SVG content of a {@link ForeignObjectAreaG5}.
+ * @param svgContent The SVG content to be rendered.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ public abstract void render(ForeignContentSvgG5 svgContent) throws GalleyVisitorException;
+
+ /**
+ * Render the MathML content of a {@link ForeignObjectAreaG5}.
+ * @param mathContent The MathML content to be rendered.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ public abstract void render(ForeignContentMathG5 mathContent) throws GalleyVisitorException;
+
+ @Override
+ public Void visit(final ForeignObjectAreaG5 area) throws GalleyVisitorException {
+ final ForeignContentG5 foreignContent = area.getContainedForeignObject();
+ if (foreignContent == null) {
+ this.getLogger().warn("At rendering, ForeignContent area "
+ + "has no parsed content");
+ return null;
+ }
+ if (foreignContent instanceof ForeignContentSvgG5) {
+ final ForeignContentSvgG5 svgArea =
+ (ForeignContentSvgG5) foreignContent;
+ render(svgArea);
+ } else if (foreignContent instanceof ForeignContentMathG5) {
+ final ForeignContentMathG5 mathArea =
+ (ForeignContentMathG5) foreignContent;
+ render(mathArea);
+ } else {
+ this.getLogger().warn("At rendering, ForeignContent area "
+ + "is of an unsupported type.");
+ }
+ return null;
+ }
+
+ @Override
+ public Void visit(final ExternalGraphicAreaG5 area) throws GalleyVisitorException {
+ final Graphic graphic = area.getGraphic();
+ if (graphic == null) {
+ throw new NullPointerException("Null graphic.");
+ }
+ final Rectangle contentRect = new Rectangle(area.crOriginX(),
+ area.crOriginY(), area.referenceIpd(), area.referenceBpd());
+ final Rectangle clipRect = new Rectangle(area.crOriginX(),
+ area.crOriginY(), area.crIpd(), area.crBpd());
+ drawGraphic(area, graphic, contentRect, clipRect);
+ return null;
+ }
+
+ @Override
+ public Void visit(final TableAreaG5 area) throws GalleyVisitorException {
+ /* Render background Areas for the table-related background-only
+ * areas. */
+ final BackgroundAreaG5[] backgroundAreas = area.getBackgroundAreas();
+ if (backgroundAreas != null) {
+ for (int i = 0; i < backgroundAreas.length; i++) {
+ final BackgroundAreaG5 bga = backgroundAreas[i];
+ markBackground(bga);
+ }
+ }
+ /* TODO: Add logic that tries to paint the borders as efficiently
+ * as possible. Contiguous cells that have identical borders should have
+ * their borders painted at the same time. */
+ markBorder(area);
+ renderChildren(area);
+ return null;
+ }
+
+ @Override
+ public Void visit(final TableCellAreaG5 area) throws GalleyVisitorException {
+ markBorder(area);
+ markBackground(area);
+ renderChildren(area);
+ return null;
+ }
+
+ /**
+ * Renders an arbitrary text chunk with attributes from an arbitrary Area.
+ * Of course, ordinarily, the text will come from the Area, but the caller
+ * should decide that.
+ * @param area An Area instance that contains the traits that should be
+ * used to render the text.
+ * @param text The text content to be rendered.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ public abstract void renderTextSegment(GlyphAreaSequenceG5 area, CharSequence text)
+ throws GalleyVisitorException;
+
+ @Override
+ public Void visit(final LineAreaG5 area) throws GalleyVisitorException {
+ renderChildren(area);
+ return null;
+ }
+
+ /**
+ * Render the bookmark tree for this document.
+ * @param bookmarkTree The bookmark tree to be rendered.
+ * @throws GalleyVisitorException For invalid bookmark target.
+ */
+ public abstract void render(BookmarkTreeG5 bookmarkTree) throws GalleyVisitorException;
+
+ @Override
+ public Void visit(final InlineAreaG5 area) throws GalleyVisitorException {
+ markBorder(area);
+ markBackground(area);
+ renderChildren(area);
+ return null;
+ }
+
+ /**
+ * Renders all of the non-area AreaNodes, i.e. those AreaTree nodes that
+ * are direct children of AreaTree instead of a PageCollection. This
+ * includes items like Destinations and Bookmarks.
+ * @throws GalleyVisitorException For errors during rendering.
+ */
+ protected void renderDocumentNodes() throws GalleyVisitorException {
+ final BookmarkTreeG5 bookmarkTree = this.areaTree.getBookmarkTree();
+ if (bookmarkTree != null) {
+ render(bookmarkTree);
+ }
+ for (int i = 0; i < this.areaTree.qtyAreaNodeChildren(); i++) {
+ final AreaNodeG5 atNode = this.areaTree.areaNodeChildAt(i);
+ if (! (atNode instanceof PageCollectionG5)) {
+ atNode.acceptVisitor(this);
+ }
+ }
+ }
+
+ /**
+ * Provides the Renderer with an opportunity to close any text objects that
+ * are in progress.
+ */
+ public abstract void resetTextCursor();
+
+ /**
+ * Converts a Rectangle storing millipoints to one storing points.
+ * @param input A rectangle whose dimensions are stored as millipoints.
+ * @return A new rectangle whose dimensions are stored as points.
+ */
+ public static Rectangle2D.Float convertMillipointRectangle(
+ final Rectangle input) {
+ if (input == null) {
+ return null;
+ }
+ return new Rectangle2D.Float(
+ toPoints(input.x),
+ toPoints(input.y),
+ toPoints(input.width),
+ toPoints(input.height));
+ }
+
+ /**
+ * Converts millipoints to points.
+ * @param millipoints The millipoint value to be converted to points.
+ * @return The converted value in points.
+ */
+ public static float toPoints(final int millipoints) {
+ return millipoints / (float) WellKnownConstants.MILLIPOINTS_PER_POINT;
+ }
+
+ /**
+ * Converts a color value in the range 0 - 255 to its floating-point
+ * equivalant, that is, a value in the range 0 - 1.
+ * @param integralColorComponent The integral color value to be converted, a
+ * value in the range 0 - 255.
+ * @return The floating point value, a value in the range 0 - 1.
+ */
+ protected static float colorToFloat(final int integralColorComponent) {
+ int colorValue = Math.max(integralColorComponent, 0);
+ colorValue = Math.min(integralColorComponent,
+ WellKnownConstants.MAXIMUM_INTEGRAL_COLOR_VALUE);
+ return colorValue / WellKnownConstants.MAXIMUM_INTEGRAL_COLOR_VALUE;
+ }
+
+ /**
+ * Converts a color to a percentage of black.
+ * @param color The color to be converted.
+ * @return A value in the range 0 to 100, representing a percentage of
+ * black for this color.
+ */
+ protected static int shadingPercent(final Color color) {
+ float lineshade = 0;
+ lineshade += Renderer4a.SHADING_WEIGHT_RED * color.getRed();
+ lineshade += Renderer4a.SHADING_WEIGHT_GREEN * color.getGreen();
+ lineshade += Renderer4a.SHADING_WEIGHT_BLUE * color.getBlue();
+ r...
[truncated message content] |
|
From: <vic...@us...> - 2022-02-27 16:37:32
|
Revision: 12627
http://sourceforge.net/p/foray/code/12627
Author: victormote
Date: 2022-02-27 16:37:29 +0000 (Sun, 27 Feb 2022)
Log Message:
-----------
Remove remaining SLF4J references from Application Binary Interface of foray-orthography.
Modified Paths:
--------------
trunk/foray/foray-orthography/build.gradle
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DictionaryResource.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/HyphenationPatternsResource.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/OrthographyResource.java
trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternSerializer.java
Modified: trunk/foray/foray-orthography/build.gradle
===================================================================
--- trunk/foray/foray-orthography/build.gradle 2022-02-27 16:01:28 UTC (rev 12626)
+++ trunk/foray/foray-orthography/build.gradle 2022-02-27 16:37:29 UTC (rev 12627)
@@ -5,8 +5,7 @@
description = 'foray-orthography'
dependencies {
- /* TODO: Convert SLF4J "api" dependency to "implementation". */
- api group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j
+ implementation (group: 'org.slf4j', name: 'slf4j-api', version: versions.slf4j)
api group: 'commons-cli', name: 'commons-cli', version: versions.commonsCli
api group: 'commons-io', name: 'commons-io', version: versions.commonsIo
@@ -21,7 +20,7 @@
api (group: 'org.axsl', name: 'axsl-value', version: versions.axsl)
api project(':foray-common')
- api (project(':foray-xml'))
+ api project(':foray-xml')
testImplementation group: 'junit', name: 'junit', version: versions.junit
testImplementation group: 'org.mockito', name: 'mockito-core', version: versions.mockito
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DictionaryResource.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DictionaryResource.java 2022-02-27 16:01:28 UTC (rev 12626)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/DictionaryResource.java 2022-02-27 16:37:29 UTC (rev 12627)
@@ -32,6 +32,8 @@
import org.foray.common.resource.ResourceLocationUrl;
import org.foray.orthography.util.DictionaryParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -112,6 +114,7 @@
@Override
protected SegmentDictionary parseResource() {
+ final Logger logger = LoggerFactory.getLogger(getClass());
URL rawResource = null;
// for (int index = 0; index < this.unparsedWordList.size(); index ++) {
// final WordListElement element = this.unparsedWordList.get(index);
@@ -130,11 +133,11 @@
inputStream = rawResource.openStream();
} catch (final IOException e) {
/* The word list file does not exist. Do not try to parse it. */
- getLogger().debug("{} URL resource not found: {}", this.getTypeDescription(), rawResource.toExternalForm());
+ logger.debug("{} URL resource not found: {}", this.getTypeDescription(), rawResource.toExternalForm());
return null;
}
- getLogger().debug("Parsing {}", rawResource.toExternalForm());
+ logger.debug("Parsing {}", rawResource.toExternalForm());
final DictionaryParser parser = new DictionaryParser();
parser.setLogDictionaryProblems(true);
SegmentDictionary dictionary = null;
@@ -142,13 +145,13 @@
final InputSource source = new InputSource(rawResource.toExternalForm());
dictionary = parser.parse(source).get(0);
} catch (final IOException e) {
- getLogger().error("IOException", e);
+ logger.error("IOException", e);
return null;
} catch (final SAXException e) {
- getLogger().error("SAXException", e);
+ logger.error("SAXException", e);
return null;
} catch (final ParserConfigurationException e) {
- getLogger().error("ParserConfigurationException", e);
+ logger.error("ParserConfigurationException", e);
return null;
} finally {
if (inputStream != null) {
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/HyphenationPatternsResource.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/HyphenationPatternsResource.java 2022-02-27 16:01:28 UTC (rev 12626)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/HyphenationPatternsResource.java 2022-02-27 16:37:29 UTC (rev 12627)
@@ -31,6 +31,8 @@
import org.foray.common.resource.ResourceLocation;
import org.foray.orthography.util.PatternParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -66,17 +68,18 @@
if (this.unparsedPatternsLocation == null) {
return null;
}
+ final Logger logger = LoggerFactory.getLogger(getClass());
final URL url = this.unparsedPatternsLocation.toUrl();
final InputSource inputSource = new InputSource(url.toExternalForm());
- getLogger().debug("Parsing {}", this.unparsedPatternsLocation.getLocationDescription());
+ logger.debug("Parsing {}", this.unparsedPatternsLocation.getLocationDescription());
final PatternParser patternParser = new PatternParser();
PatternTree patternTree = null;
try {
patternTree = patternParser.parse(inputSource);
} catch (SAXException | ParserConfigurationException | IOException e) {
- getLogger().info("Error parsing: " + this.unparsedPatternsLocation.getLocationDescription(), e);
+ logger.info("Error parsing: " + this.unparsedPatternsLocation.getLocationDescription(), e);
}
return patternTree;
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/OrthographyResource.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/OrthographyResource.java 2022-02-27 16:01:28 UTC (rev 12626)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/OrthographyResource.java 2022-02-27 16:37:29 UTC (rev 12627)
@@ -183,7 +183,7 @@
* Returns the logger.
* @return The logger.
*/
- protected Logger getLogger() {
+ private Logger getLogger() {
return this.logger;
}
Modified: trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternSerializer.java
===================================================================
--- trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternSerializer.java 2022-02-27 16:01:28 UTC (rev 12626)
+++ trunk/foray/foray-orthography/src/main/java/org/foray/orthography/util/PatternSerializer.java 2022-02-27 16:37:29 UTC (rev 12627)
@@ -149,7 +149,7 @@
* Returns the logger.
* @return The logger.
*/
- public Logger getLogger() {
+ private Logger getLogger() {
if (this.logger == null) {
this.logger = LoggerFactory.getLogger(PatternSerializer.class);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2022-02-27 16:01:31
|
Revision: 12626
http://sourceforge.net/p/foray/code/12626
Author: victormote
Date: 2022-02-27 16:01:28 +0000 (Sun, 27 Feb 2022)
Log Message:
-----------
Remove remaining SLF4J references from Application Binary Interface.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeCollection.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeContainer.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/TrueTypeSingle.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfSubSetFile.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsSerializer.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -34,8 +34,6 @@
import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsServer;
-import org.slf4j.Logger;
-
import java.util.ArrayList;
import java.util.List;
@@ -134,14 +132,6 @@
}
/**
- * Return the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.consumer.getLogger();
- }
-
- /**
* Return the font server.
* @return The font server.
*/
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -38,8 +38,6 @@
import org.axsl.ps.CharSet;
import org.axsl.utility.sequence.IntSequence;
-import org.slf4j.Logger;
-
/**
* An implementation of the aXSL {@link Font4a} interface.
*/
@@ -318,14 +316,6 @@
}
/**
- * Return the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.registeredFont.getLogger();
- }
-
- /**
* Returns the number of glyphs in this font.
* @return The number of glyphs in this font.
*/
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-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontConsumer4a.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -89,12 +89,6 @@
/** The server that should be used to by this FontConsumer. */
private FontServer4a server;
- /**
- * The logger that should be used by this FontConsumer.
- * If null, the server's logger will be used.
- */
- private Logger logger;
-
/** The font selection constraints. */
private FontSelectionConstraints selectionConstraints;
@@ -141,28 +135,6 @@
}
/**
- * Use this method to set a logger for this font consumer. This will
- * override the logger used by FOrayFontServer.
- * @param logger The new logger.
- */
- public void setLogger(final Logger logger) {
- this.logger = logger;
- }
-
- /**
- * Provides the font system with the Log implementation which
- * should be used to log messages.
- * @return Commons Log implementation which should be used to log
- * messages for this FontConsumer.
- */
- public Logger getLogger() {
- if (this.logger == null) {
- this.logger = LoggerFactory.getLogger(this.getClass());
- }
- return this.logger;
- }
-
- /**
* Returns the font selection constraints.
* @return The font selection constraints.
*/
@@ -616,4 +588,13 @@
}
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
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-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontServer4a.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -786,7 +786,7 @@
* where the FontConsumer instance does not have a logger.
* @return The logger that should be used as a default logger.
*/
- public Logger getLogger() {
+ private Logger getLogger() {
return this.logger;
}
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 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -52,6 +52,7 @@
import org.axsl.utility.sequence.IntSequence;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -431,14 +432,6 @@
}
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.consumerFont.getLogger();
- }
-
- /**
* Returns the subset for this font use.
* @return The subset for this font use.
*/
@@ -838,4 +831,13 @@
return builder.toString();
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
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-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -40,6 +40,9 @@
import org.axsl.ps.CharSet;
import org.axsl.ps.Encoding;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.io.InputStream;
@@ -281,8 +284,7 @@
* @throws FontException For errors opening the input stream.
*/
protected InputStream getFontInputStream() throws FontException {
- final FontParser fontFileReader =
- this.getRegisteredFont().createFontFileReader();
+ final FontParser fontFileReader = this.getRegisteredFont().createFontFileReader();
if (fontFileReader == null) {
return null;
}
@@ -290,8 +292,7 @@
try {
instream = fontFileReader.getRandomInput().getInputStream();
} catch (final IOException e1) {
- this.getLogger().error("Unable to embed: "
- + fontFileReader.getRandomInput().getDescription());
+ getLogger().error("Unable to embed: " + fontFileReader.getRandomInput().getDescription());
}
return instream;
}
@@ -583,4 +584,13 @@
return Source.FREE_STANDING;
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -41,6 +41,9 @@
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.io.InputStream;
@@ -272,4 +275,13 @@
return new BoundingBoxShort(scaled);
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -45,6 +45,9 @@
import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -428,4 +431,13 @@
return BoundingBoxUtils.makeBoundingBox(scaled);
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
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-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -40,6 +40,9 @@
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.FontMetrics;
@@ -414,10 +417,7 @@
return null;
}
Font newFont = null;
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Create AWT font from: \n "
- + fontFileReader.getRandomInput().getDescription());
- }
+ getLogger().debug("Create AWT font from: \n " + fontFileReader.getRandomInput().getDescription());
InputStream fontStream = null;
try {
fontStream = fontFileReader.getRandomInput().getInputStream();
@@ -585,4 +585,13 @@
return Source.SYSTEM;
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
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 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -100,6 +100,9 @@
/** List of the font files to be tested. */
private List<ConfiguredFont> fontFiles = new ArrayList<ConfiguredFont>();
+ /** The logger. */
+ private Logger logger = LoggerFactory.getLogger(getClass());
+
/**
* Basic Constructor.
* @param fontServer The font server.
@@ -420,7 +423,7 @@
* @return The logger.
*/
private Logger getLogger() {
- return this.fontServer.getLogger();
+ return this.logger;
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFont.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -46,6 +46,7 @@
import org.axsl.ps.PsServer;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URL;
@@ -404,8 +405,9 @@
* Returns the logger.
* @return The logger.
*/
- public Logger getLogger() {
- return this.getFontServer().getLogger();
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
}
/**
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 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -41,9 +41,6 @@
import org.axsl.font.FontException;
import org.axsl.ps.PsServer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.io.InputStream;
@@ -116,9 +113,6 @@
/** The content to be parsed. */
private ByteSequenceParser randomInput;
- /** The logger for this parser. */
- private Logger logger = LoggerFactory.getLogger(getClass());
-
/**
* Constructor.
* @param parserClient The font parser client.
@@ -227,14 +221,6 @@
}
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.logger;
- }
-
- /**
* Returns the font server.
* @return The font server.
*/
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeCollection.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeCollection.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeCollection.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -32,6 +32,9 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.format.FontParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
/**
@@ -139,4 +142,13 @@
return fontArray;
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeContainer.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeContainer.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeContainer.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -33,8 +33,6 @@
import org.axsl.font.Font;
-import org.slf4j.Logger;
-
import java.io.IOException;
/**
@@ -102,14 +100,6 @@
public abstract TrueTypeFont[] getTTFFonts();
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.parser.getLogger();
- }
-
- /**
* Returns the format of this file.
* @return The format of this file.
*/
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeFont.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -41,6 +41,7 @@
import org.axsl.ps.Cmap;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.math.BigDecimal;
@@ -773,8 +774,9 @@
* Returns the logger.
* @return The logger.
*/
- public Logger getLogger() {
- return getTTFFile().getReader().getLogger();
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeSingle.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeSingle.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TrueTypeSingle.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -30,6 +30,9 @@
import org.foray.font.format.FontParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
/**
@@ -77,4 +80,13 @@
return returnArray;
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfSubSetFile.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfSubSetFile.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -33,6 +33,7 @@
import org.foray.font.format.FontParser;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -976,8 +977,9 @@
* Return the logger.
* @return The logger.
*/
- public Logger getLogger() {
- return this.ttfFont.getLogger();
+ private Logger getLogger() {
+ /* Not cached because not expected to get used much. */
+ return LoggerFactory.getLogger(getClass());
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParser.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParser.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -44,6 +44,9 @@
import org.axsl.ps.PsSystemDict;
import org.axsl.utility.sequence.ByteSequence;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.util.List;
@@ -150,7 +153,7 @@
try {
this.segments = computeSegmentBoundaries();
} catch (final IOException e) {
- this.parser.getLogger().error("Unable to parse basics of Type 1 file:\n"
+ getLogger().error("Unable to parse basics of Type 1 file:\n"
+ " " + getRandomInput().getDescription().toString());
throw new IllegalStateException(e);
}
@@ -201,12 +204,12 @@
final PsSystemDict systemDict = psServer.getReadOnlySystemDict();
interpreter = psServer.makeInterpreter(psInput, systemDict);
} catch (final PsException e) {
- this.parser.getLogger().error(e.getMessage());
+ getLogger().error(e.getMessage());
}
try {
interpreter.process();
} catch (final PsInterpreterException e1) {
- this.parser.getLogger().error(e1.getMessage()
+ getLogger().error(e1.getMessage()
+ "\n " /*+ getRandomInput().getDescription().toString()*/);
}
@@ -265,4 +268,13 @@
return this.parser.getFontParserClient();
}
+ /**
+ * Returns the logger.
+ * @return The logger.
+ */
+ private Logger getLogger() {
+ /* Not cached because not expected to get used in normal operations. */
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParser.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParser.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -34,8 +34,6 @@
import org.axsl.font.FontException;
-import org.slf4j.Logger;
-
import java.io.IOException;
import java.io.InputStream;
@@ -175,14 +173,6 @@
}
/**
- * Returns the logger.
- * @return The logger.
- */
- public Logger getLogger() {
- return this.fontServer.getLogger();
- }
-
- /**
* Returns the font server.
* @return The font server.
*/
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsSerializer.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsSerializer.java 2022-02-27 14:52:38 UTC (rev 12625)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsSerializer.java 2022-02-27 16:01:28 UTC (rev 12626)
@@ -74,6 +74,9 @@
/** The font server. This is created lazily, so use {@link #getFontServer()} to obtain the instance. */
private FontServer4a fontServer;
+ /** The logger. */
+ private Logger logger = LoggerFactory.getLogger(getClass());
+
/**
* Constructor.
* @param sourceDir The directory containing the files to be processed.
@@ -179,7 +182,7 @@
* @return The logger.
*/
private Logger getLogger() {
- return getFontServer().getLogger();
+ return this.logger;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|