Browse Source

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
pull/16/head
Jeremias Maerki 18 years ago
parent
commit
5e5e7114fb

+ 5
- 1
src/java/org/apache/fop/fonts/FontReader.java View File

@@ -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)) {

+ 26
- 9
src/java/org/apache/fop/fonts/SingleByteFont.java View File

@@ -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;
}


+ 4
- 0
status.xml View File

@@ -27,6 +27,10 @@

<changes>
<release version="FOP Trunk">
<action context="Code" dev="JM" type="add">
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).
</action>
<action context="Code" dev="SP" type="update">
Improvements to the code for inline block content.
</action>

Loading…
Cancel
Save