You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "tntim96 (Jira)" <ji...@apache.org> on 2022/02/28 04:36:00 UTC
[jira] [Comment Edited] (FOP-3054) FOP Font "embed-url" No Longer Supports "classpath" Protocol in version 2.7
[ https://issues.apache.org/jira/browse/FOP-3054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17498689#comment-17498689 ]
tntim96 edited comment on FOP-3054 at 2/28/22, 4:35 AM:
--------------------------------------------------------
After some digging I found we have a custom resource resolver which is no longer invoked. Should I update the summary and description?
{code:java}
ResourceResolver rr = ResourceResolverFactory
.createTempAwareResourceResolver(new InMemoryTempResourceResolver(), new CustomResolver());
{code}
{code:java}
class CustomResolver implements ResourceResolver {
public org.apache.xmlgraphics.io.Resource getResource(URI uri) throws IOException {
if (uri.toString().startsWith("classpath:")) {
String actualPath = uri.toString().substring("classpath:".length());
try {
ClassPathResource resource = new ClassPathResource(actualPath);
InputStream resourceAsStream = resource.getInputStream();
{code}
was (Author: tntim96):
After some digging I found we have a custom resource resolver which is no longer invoked. Should I update the summary and description?
{code:java}
ResourceResolver rr = ResourceResolverFactory
.createTempAwareResourceResolver(new InMemoryTempResourceResolver(), new CustomResolver());
{code}
{code:java}
class CustomResolver implements ResourceResolver {
private static final Logger log = LoggerFactory.getLogger(PdfHelper.class);
public org.apache.xmlgraphics.io.Resource getResource(URI uri) throws IOException {
if (uri.toString().startsWith("classpath:")) {
String actualPath = uri.toString().substring("classpath:".length());
try {
ClassPathResource resource = new ClassPathResource(actualPath);
InputStream resourceAsStream = resource.getInputStream();
{code}
> FOP Font "embed-url" No Longer Supports "classpath" Protocol in version 2.7
> ---------------------------------------------------------------------------
>
> Key: FOP-3054
> URL: https://issues.apache.org/jira/browse/FOP-3054
> Project: FOP
> Issue Type: Bug
> Affects Versions: 2.7
> Reporter: tntim96
> Priority: Major
>
> The following FOP config works with FOP 2.6
> {code:java}
> <?xml version="1.0" encoding="utf-8" ?>
> <fop>
> <renderers>
> <renderer mime="application/pdf">
> <fonts>
> <font kerning="yes" embed-url="classpath:/somepath/DejaVuSans-Regular.ttf">
> <font-triplet name="DejaVuSans" style="normal" weight="normal"/>
> </font>
> </fonts>
> </renderer>
> </renderers>
> </fop> {code}
> ...but with 2.7 we get the error:
> {noformat}
> 16:04:03.006 [main] ERROR org.apache.fop.fonts.LazyFont - Failed to read font file classpath:/somepath/DejaVuSans-Regular.ttf unknown protocol: classpath
> java.net.MalformedURLException: unknown protocol: classpath
> at java.net.URL.<init>(URL.java:600)
> at java.net.URL.<init>(URL.java:490)
> at java.net.URL.<init>(URL.java:439)
> at java.net.URI.toURL(URI.java:1089)
> at org.apache.fop.apps.io.ResourceResolverFactory$NormalResourceResolver.getResource(ResourceResolverFactory.java:224)
> at org.apache.fop.apps.io.ResourceResolverFactory$TempAwareResourceResolver.getResource(ResourceResolverFactory.java:152)
> at org.apache.fop.apps.io.ResourceResolverFactory$DefaultResourceResolver.getResource(ResourceResolverFactory.java:121)
> at org.apache.fop.apps.io.InternalResourceResolver.getResource(InternalResourceResolver.java:92)
> at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:113)
> 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.LazyFont.load(LazyFont.java:121)
> at org.apache.fop.fonts.LazyFont.getAscender(LazyFont.java:237)
> at org.apache.fop.fonts.Font.getAscender(Font.java:120)
> at org.apache.fop.layoutmgr.BlockLayoutManager.initialize(BlockLayoutManager.java:82)
> at org.apache.fop.layoutmgr.AbstractLayoutManager.getChildLM(AbstractLayoutManager.java:118)
> at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:128)
> at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:69)
> at org.apache.fop.layoutmgr.PageBreaker.getNextKnuthElements(PageBreaker.java:252)
> at org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:675)
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)