From a2247e269485af984c3712debf23836caa92733d Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 3 Jan 2006 13:08:45 +0000 Subject: [PATCH] The font loading code now reads the encoding value from the XML font metrics file so that Type 1 fonts like Symbol and ZapfDingbats can be embedded explicitely (Required by PDF/A). Note that it is necessary to set the encoding value in the font metrics file manually since it cannot be extracted from the PFM file reliably, i.e. for "Symbol" use "SymbolEncoding" and for "ZapfDingbats" use "ZapfDingbatsEncoding". git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@365623 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fonts/FontReader.java | 6 +++- .../org/apache/fop/fonts/SingleByteFont.java | 35 ++++++++++++++----- status.xml | 4 +++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java index 131f50a6a..5953c91fb 100644 --- a/src/java/org/apache/fop/fonts/FontReader.java +++ b/src/java/org/apache/fop/fonts/FontReader.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2004,2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -218,6 +218,10 @@ public class FontReader extends DefaultHandler { returnFont.setFontName(content); } else if ("ttc-name".equals(localName) && isCID) { multiFont.setTTCName(content); + } else if ("encoding".equals(localName)) { + if (singleFont != null && singleFont.getFontType() == FontType.TYPE1) { + singleFont.setEncoding(content); + } } else if ("cap-height".equals(localName)) { returnFont.setCapHeight(getInt(content)); } else if ("x-height".equals(localName)) { diff --git a/src/java/org/apache/fop/fonts/SingleByteFont.java b/src/java/org/apache/fop/fonts/SingleByteFont.java index 26bba54a6..f03f6f7b5 100644 --- a/src/java/org/apache/fop/fonts/SingleByteFont.java +++ b/src/java/org/apache/fop/fonts/SingleByteFont.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2004,2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +23,26 @@ package org.apache.fop.fonts; */ public class SingleByteFont extends CustomFont { - private final CodePointMapping mapping - = CodePointMapping.getMapping("WinAnsiEncoding"); + private CodePointMapping mapping; private String encoding = "WinAnsiEncoding"; - private int width[] = null; - + private int[] width = null; + /** + * Main constructor. + */ + public SingleByteFont() { + updateMapping(); + } + + /** + * Updates the mapping variable based on the encoding. + */ + protected void updateMapping() { + mapping = CodePointMapping.getMapping(getEncoding()); + } + /** * @see org.apache.fop.fonts.FontDescriptor#isEmbeddable() */ @@ -46,6 +58,15 @@ public class SingleByteFont extends CustomFont { return encoding; } + /** + * Sets the encoding of the font. + * @param encoding the encoding (ex. "WinAnsiEncoding" or "SymbolEncoding") + */ + public void setEncoding(String encoding) { + this.encoding = encoding; + updateMapping(); + } + /** * @see org.apache.fop.fonts.FontMetrics#getWidth(int, int) */ @@ -59,10 +80,6 @@ public class SingleByteFont extends CustomFont { public int[] getWidths() { int[] arr = new int[width.length]; System.arraycopy(width, 0, arr, 0, width.length - 1); - /* - for (int i = 0; i < arr.length; i++) - arr[i] *= size; - */ return arr; } diff --git a/status.xml b/status.xml index df86f5002..41c1e55b7 100644 --- a/status.xml +++ b/status.xml @@ -27,6 +27,10 @@ + + The font loading code now reads the encoding value from the XML font metrics file + so that fonts like Symbol and ZapfDingbats can be embedded explicitely (Required by PDF/A). + Improvements to the code for inline block content. -- 2.39.5