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

Tilman Hausherr commented on PDFBOX-4565:
-----------------------------------------

Yeah, this surprised me, but my IDE doesn't complain about this dummy code:
{code}
package org.apache.pdfbox.pdmodel.font;

import java.util.ArrayList;
import java.util.List;
import org.apache.fontbox.FontBoxFont;

/**
 *
 * https://issues.apache.org/jira/browse/PDFBOX-4565
 *
 * @author Tilman
 */
public class MyFontProvider extends FontProvider
{
    class MyFontInfo extends FontInfo
    {

        @Override
        public String getPostScriptName()
        {
            throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
        }

        @Override
        public FontFormat getFormat()
        {
            throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
        }

        @Override
        public CIDSystemInfo getCIDSystemInfo()
        {
            return new CIDSystemInfo("", "", 0);
        }

        @Override
        public FontBoxFont getFont()
        {
            throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
        }

        @Override
        public int getFamilyClass()
        {
            throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
        }

        @Override
        public int getWeightClass()
        {
            throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
        }

        @Override
        public int getCodePageRange1()
        {
            throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
        }

        @Override
        public int getCodePageRange2()
        {
            throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
        }

        @Override
        public int getMacStyle()
        {
            throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
        }

        @Override
        public PDPanoseClassification getPanose()
        {
            byte[] ba = new byte[0];
            return new PDPanoseClassification(ba);
        }

    }

    @Override
    public String toDebugString()
    {
        return null;
    }

    @Override
    public List<? extends FontInfo> getFontInfo()
    {
        List<FontInfo> list = new ArrayList<>();
        FontInfo fi = new MyFontInfo();
        list.add(fi);
        fi = new FontInfo()
        {
            @Override
            public String getPostScriptName()
            {
                throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public FontFormat getFormat()
            {
                throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public CIDSystemInfo getCIDSystemInfo()
            {
                return new CIDSystemInfo("", "", 0);
            }

            @Override
            public FontBoxFont getFont()
            {
                throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public int getFamilyClass()
            {
                throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public int getWeightClass()
            {
                throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public int getCodePageRange1()
            {
                throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public int getCodePageRange2()
            {
                throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public int getMacStyle()
            {
                throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public PDPanoseClassification getPanose()
            {
                byte[] ba = new byte[0];
                return new PDPanoseClassification(ba);
            }
        };
        list.add(fi);
        return list;
    }

}
{code}
I wonder if there are troubles when packaging such code. It sortof feels 
unclean.

If we can't use the package as above, then don't see how it can be done without 
the wished changes - FontProvider returns a list of FontInfo objects. FontInfo 
returns CIDSystemInfo and PDPanoseClassification objects, so these must be 
constructed somehow.

> Make constructors PDPanoseClassification and CIDSystemInfo public
> -----------------------------------------------------------------
>
>                 Key: PDFBOX-4565
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4565
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: FontBox, PDModel
>    Affects Versions: 2.0.15
>            Reporter: Henning von Bargen
>            Priority: Trivial
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> The constructors for the classes PDPanoseClassification and CIDSystemInfo are 
> package-visible only (not public).
> This makes coding a different FontProvider similar to FileSystemFontProvider 
> an unnecessarily hard task.
> Background:
> I'm working on replacing iText with PDFBox for Eclipse BIRT. One task is to 
> support BIRTs fontconfig.xml for locating TTF fonts etc.
> Obviously I need something simlar to the FileSystemFontProvider, but instead 
> of using the file system directly, use the information in BIRTs 
> fontconfig.xml file.
> So I started with copying FileSystemFontProvider to a new class 
> ConfigFontProvider in a different package.
> Now this fails because the classes PDPanoseClassification and CIDSystemInfo 
> have non-public (package-only) constructors. So I'd have to copy a whole 
> bunch of source files in order to make this work.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to