[ 
https://issues.apache.org/jira/browse/FOP-3062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519706#comment-17519706
 ] 

Richard Zowalla commented on FOP-3062:
--------------------------------------

Thanks for updating the documentation as well as your time.

I tested the sample code: If I hard-code the path to SFArabic via <font 
embed-url> the font is loaded and used (at least no exception / assertion error 
is thrown)
{code:java}
Apr. 08, 2022 6:47:05 PM org.apache.fop.fo.properties.CommonHyphenation 
getHyphChar
WARNUNG: Substituted specified hyphenation character (0x2d) with 0x20 because 
the font doesn't have the specified hyphenation character: SFArabic,normal,400
Apr. 08, 2022 6:47:05 PM org.apache.fop.events.LoggingEventListener processEvent
WARNUNG: Glyph "t" (0x74, t) not available in font ".SFArabic-Regular".
Apr. 08, 2022 6:47:05 PM org.apache.fop.events.LoggingEventListener processEvent
WARNUNG: Glyph "e" (0x65, e) not available in font ".SFArabic-Regular".
Apr. 08, 2022 6:47:05 PM org.apache.fop.events.LoggingEventListener processEvent
WARNUNG: Glyph "s" (0x73, s) not available in font ".SFArabic-Regular".
Apr. 08, 2022 6:47:05 PM org.apache.fop.events.LoggingEventListener processEvent
WARNUNG: Glyph "2" (0x32, two) not available in font ".SFArabic-Regular".
Apr. 08, 2022 6:47:05 PM org.apache.fop.events.LoggingEventListener processEvent
INFORMATION: Rendered page #1.{code}
My issue is, that I do +*not*+ want to use *SFArabic* at all (it is just a 
system font, which is available by default on an MacOS 12.3 and cannot be 
deleted), which is detected during auto scanning by fop.
So I am not quite sure, if specifying the specific font will help with the 
original issue which occurs during auto-scanning.

Is there a configuration option to exclude fonts from being scanned?

The good news: I was able to reproduce it on my Ubuntu 20.04 LTS machine by 
adjusting your code snippet as follows. 

Note: I installed the *SFArabic.ttf* system-wide and re-generated the Ubuntu 
font cache.

 

 
{code:java}
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopConfParser;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.FopFactoryBuilder;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
public class ComplexScript {
    public static void main(String[] args) throws Exception {
        String fo = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\"\n"; 
+
                "  
xmlns:fox=\"http://xmlgraphics.apache.org/fop/extensions\";>\n" +
                "  <fo:layout-master-set>\n" +
                "    <fo:simple-page-master master-name=\"simple\" 
page-height=\"27.9cm\" page-width=\"21.6cm\">\n" +
                "      <fo:region-body />\n" +
                "    </fo:simple-page-master>\n" +
                "  </fo:layout-master-set>\n" +
                "  <fo:page-sequence master-reference=\"simple\">\n" +
                "    <fo:flow flow-name=\"xsl-region-body\">\n" +
                " <fo:block font-family=\"SFArabic\">test2</fo:block>  \n" +
                "</fo:flow>\n" +
                "  </fo:page-sequence>\n" +
                "</fo:root>\n";
        String fopxconf = """
                <fop version="1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                     
xsi:noNamespaceSchemaLocation="http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd?view=co";>
                                
                    <!-- Renderer -->
                                
                    <renderers>        <!-- PDF Renderer -->
                                
                        <renderer mime="application/pdf">            <!-- 
Filter -->
                            <filterList>
                                <value>null</value>
                            </filterList>
                            <!-- Filter Image Settings-->
                            <filterList type="image">
                                <value>flate</value>
                                <value>ascii-85</value>
                            </filterList>
                                
                            <!-- Font Configuration -->
                            <fonts>           
                               <auto-detect/>
                            </fonts>
                                
                        </renderer>
                    </renderers>
                    <fonts>
                     <auto-detect/> 
                    </fonts>
                </fop>\s
                """;
        FopFactoryBuilder builder =
                new FopConfParser(new 
ByteArrayInputStream(fopxconf.getBytes()), new 
File(".").toURI()).getFopFactoryBuilder();
        builder.setComplexScriptFeatures(false);
        FopFactory fopFactory = builder.build();
        fopFactory.getFontManager().disableFontCache();
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        FileOutputStream fos = new FileOutputStream("/tmp/out.pdf");
        Fop fop = fopFactory.newFop("application/pdf", foUserAgent, fos);
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();
        Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes()));
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
        fos.close();
    }
}
{code}
 

> AssertionError in GlyphPositioningTable$DeviceTable with SFArabic.ttf
> ---------------------------------------------------------------------
>
>                 Key: FOP-3062
>                 URL: https://issues.apache.org/jira/browse/FOP-3062
>             Project: FOP
>          Issue Type: Bug
>          Components: unqualified
>    Affects Versions: 2.7
>            Reporter: Richard Zowalla
>            Priority: Major
>         Attachments: SFArabic.ttf, image-2022-04-08-16-09-21-254.png
>
>
> While working on a M1 Mac OS system:
>  
> {code:java}
> Java version: 17.0.2, vendor: Oracle Corporation, runtime: 
> /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/HomeDefault locale: 
> de_DE, platform encoding: UTF-8
> OS name: "mac os x", version: "12.3", arch: "aarch64", family: "mac"{code}
> I get the following AssertionError with a simple FOP config as follows:
> {code:java}
> <fop version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>      
> xsi:noNamespaceSchemaLocation="http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd?view=co";>
>     <!-- Renderer -->
>     <renderers>        <!-- PDF Renderer -->
>         <renderer mime="application/pdf">            <!-- Filter -->
>             <filterList>
>                 <value>null</value>
>             </filterList>
>             <!-- Filter Image Settings-->
>             <filterList type="image">
>                 <value>flate</value>
>                 <value>ascii-85</value>
>             </filterList>
>             <!-- Font Configuration -->
>             <fonts>                <!-- <auto-detect/> -->
>                 <directory>/Users/abc/uploads/fonts</directory>
>             </fonts>
>         </renderer>
>     </renderers>
>     <fonts>
>         <!-- <auto-detect/> -->
>         <directory>/Users/abc/uploads/fonts</directory>
>     </fonts>
> </fop> {code}
> The font, which violates the assertion in DeviceTable is:
> *[file:/System/Library/Fonts/SFArabic.ttf*|file:///System/Library/Fonts/SFArabic.ttf*]
>  
> *Stacktrace:*
> {code:java}
> java.lang.AssertionError at 
> org.apache.fop.complexscripts.fonts.GlyphPositioningTable$DeviceTable.<init>(GlyphPositioningTable.java:1774)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readPosDeviceTable(OTFAdvancedTypographicTableReader.java:1727)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readPosAnchor(OTFAdvancedTypographicTableReader.java:2051)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readMarkToLigaturePosTableFormat1(OTFAdvancedTypographicTableReader.java:2345)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readMarkToLigaturePosTable(OTFAdvancedTypographicTableReader.java:2371)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readGPOSSubtable(OTFAdvancedTypographicTableReader.java:3122)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readLookupTable(OTFAdvancedTypographicTableReader.java:3191)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readLookupList(OTFAdvancedTypographicTableReader.java:3218)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readCommonLayoutTables(OTFAdvancedTypographicTableReader.java:3239)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readGPOS(OTFAdvancedTypographicTableReader.java:3499)
>  at 
> org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readAll(OTFAdvancedTypographicTableReader.java:84)
>  at 
> org.apache.fop.fonts.truetype.OpenFont.handleCharacterSpacing(OpenFont.java:889)
>  at org.apache.fop.fonts.truetype.OpenFont.readFont(OpenFont.java:861) at 
> org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:119) at 
> org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:103) at 
> org.apache.fop.fonts.FontLoader.getFont(FontLoader.java:126) at 
> org.apache.fop.fonts.FontLoader.loadFont(FontLoader.java:110) at 
> org.apache.fop.fonts.autodetect.FontInfoFinder.find(FontInfoFinder.java:253) 
> at org.apache.fop.fonts.FontAdder.add(FontAdder.java:63) at 
> org.apache.fop.fonts.FontDetectorFactory$DefaultFontDetector.detect(FontDetectorFactory.java:105)
>  at org.apache.fop.fonts.FontManager.autoDetectFonts(FontManager.java:229) at 
> org.apache.fop.fonts.DefaultFontConfigurator.configure(DefaultFontConfigurator.java:82)
>  at 
> org.apache.fop.render.PrintRendererConfigurator.getCustomFontCollection(PrintRendererConfigurator.java:147)
>  at 
> org.apache.fop.render.PrintRendererConfigurator.setupFontInfo(PrintRendererConfigurator.java:127)
>  at org.apache.fop.render.intermediate.IFUtil.setupFonts(IFUtil.java:170) at 
> org.apache.fop.render.intermediate.IFRenderer.setupFontInfo(IFRenderer.java:187)
>  at org.apache.fop.area.RenderPagesModel.<init>(RenderPagesModel.java:75) at 
> org.apache.fop.area.AreaTreeHandler.setupModel(AreaTreeHandler.java:135) at 
> org.apache.fop.area.AreaTreeHandler.<init>(AreaTreeHandler.java:105) at 
> org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:363)
>  at org.apache.fop.fo.FOTreeBuilder.<init>(FOTreeBuilder.java:109) at 
> org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:104) at 
> org.apache.fop.apps.Fop.<init>(Fop.java:78) at 
> org.apache.fop.apps.FOUserAgent.newFop(FOUserAgent.java:184) at 
> org.apache.fop.apps.FopFactory.newFop(FopFactory.java:234){code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to