private int subsetFontCounter = -1;
private Map<String, PDFDPart> dparts = new HashMap<String, PDFDPart>();
+ private EventBroadcaster eventBroadcaster;
/**
* Creates a new PDFFactory.
* @param encoding character encoding scheme used by the font
* @param metrics additional information about the font
* @param descriptor additional information about the font
- * @param eventBroadcaster Event broadcaster.
* @return the created /Font object
*/
public PDFFont makeFont(String fontname, String basefont,
String encoding, FontMetrics metrics,
- FontDescriptor descriptor, EventBroadcaster eventBroadcaster) {
+ FontDescriptor descriptor) {
PDFFont preRegisteredfont = getDocument().findFont(fontname);
if (preRegisteredfont != null) {
return preRegisteredfont;
Typeface tf = (Typeface)metrics;
mapping = CodePointMapping.getMapping(tf.getEncodingName());
}
- generateToUnicodeCmap(font, mapping, eventBroadcaster);
+ generateToUnicodeCmap(font, mapping);
}
return font;
} else {
}
} else {
cmap = new PDFToUnicodeCMap(cidMetrics.getCIDSet().getChars(), "fop-ucs-H",
- new PDFCIDSystemInfo("Adobe", "Identity", 0), false,
- eventBroadcaster);
+ new PDFCIDSystemInfo("Adobe", "Identity", 0), false, eventBroadcaster);
}
getDocument().registerObject(cmap);
assert font instanceof PDFFontType0;
if (singleByteFont.isSymbolicFont()) {
//no encoding, use the font's encoding
if (forceToUnicode) {
- generateToUnicodeCmap(nonBase14, mapping, eventBroadcaster);
+ generateToUnicodeCmap(nonBase14, mapping);
}
} else if (PDFEncoding.isPredefinedEncoding(mapping.getName())) {
font.setEncoding(mapping.getName());
pdfEncoding.setDifferences(differences);
font.setEncoding(pdfEncoding);
if (mapping.getUnicodeCharMap() != null) {
- generateToUnicodeCmap(nonBase14, mapping, eventBroadcaster);
+ generateToUnicodeCmap(nonBase14, mapping);
}
}
} else {
font.setEncoding((String)pdfEncoding);
}
if (forceToUnicode) {
- generateToUnicodeCmap(nonBase14, mapping, eventBroadcaster);
+ generateToUnicodeCmap(nonBase14, mapping);
}
}
getDocument().registerObject(addFont);
getDocument().getResources().addFont(addFont);
if (forceToUnicode) {
- generateToUnicodeCmap(addFont, addEncoding, eventBroadcaster);
+ generateToUnicodeCmap(addFont, addEncoding);
}
}
}
return additionalEncodings;
}
- private void generateToUnicodeCmap(PDFFont font, SingleByteEncoding encoding, EventBroadcaster eventBroadcaster) {
+ private void generateToUnicodeCmap(PDFFont font, SingleByteEncoding encoding) {
PDFCMap cmap = new PDFToUnicodeCMap(encoding.getUnicodeCharMap(),
"fop-ucs-H",
new PDFCIDSystemInfo("Adobe", "Identity", 0), true, eventBroadcaster);
getDocument().registerTrailerObject(pdfdPartRoot);
return pdfdPartRoot;
}
+
+ public void setEventBroadcaster(EventBroadcaster eventBroadcaster) {
+ this.eventBroadcaster = eventBroadcaster;
+ }
}
import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
-import org.apache.fop.events.EventBroadcaster;
import org.apache.fop.fonts.FontDescriptor;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.Typeface;
*
* @param doc PDF document to add fonts to
* @param fontInfo font info object to get font information from
- * @param eventBroadcaster Event broadcaster.
*/
- public void addFonts(PDFDocument doc, FontInfo fontInfo, EventBroadcaster eventBroadcaster) {
+ public void addFonts(PDFDocument doc, FontInfo fontInfo) {
Map<String, Typeface> usedFonts = fontInfo.getUsedFonts();
for (Map.Entry<String, Typeface> e : usedFonts.entrySet()) {
String f = e.getKey();
encoding = null; //Symbolic fonts shouldn't specify an encoding value in PDF
}
addFont(doc.getFactory().makeFont(
- f, font.getEmbedFontName(), encoding, font, desc, eventBroadcaster));
+ f, font.getEmbedFontName(), encoding, font, desc));
}
}
}
/** {@inheritDoc} */
public void endDocument() throws IFException {
documentNavigationHandler.registerIncompleteActions();
- pdfDoc.getResources().addFonts(pdfDoc, fontInfo, getUserAgent().getEventBroadcaster());
+ pdfDoc.getResources().addFonts(pdfDoc, fontInfo);
try {
if (pdfDoc.isLinearizationEnabled()) {
generator.flushPDFDoc();
= VersionController.getFixedVersionController(maxPDFVersion);
this.pdfDoc = new PDFDocument(producer, controller);
}
+ pdfDoc.getFactory().setEventBroadcaster(userAgent.getEventBroadcaster());
updateInfo();
updatePDFProfiles();
pdfDoc.setFilterMap(rendererConfig.getFilterMap());
closePage();
if (fontInfo != null) {
- pdfDoc.getResources().addFonts(pdfDoc, fontInfo, null);
+ pdfDoc.getResources().addFonts(pdfDoc, fontInfo);
}
this.pdfDoc.output(outputStream);
pdfDoc.outputTrailer(outputStream);
/** @todo see if pdfDoc and res can be linked here,
(currently res <> PDFDocument's resources) so addFonts()
can be moved to PDFDocument class */
- res.addFonts(pdfDoc, specialFontInfo, null);
+ res.addFonts(pdfDoc, specialFontInfo);
PDFPattern myPat = pdfDoc.getFactory().makePattern(
resourceContext, 1, res, 1, 1, bbox,
thisURI, resolver);
MockedFont font = new MockedFont(resourceResolver);
- PDFFont pdfDejaVu = pdfFactory.makeFont("DejaVu", "DejaVu", "TTF", font, font, null);
+ PDFFont pdfDejaVu = pdfFactory.makeFont("DejaVu", "DejaVu", "TTF", font, font);
assertEquals("/EAAAAA+DejaVu", pdfDejaVu.getBaseFont().toString());
- PDFFont pdfArial = pdfFactory.makeFont("Arial", "Arial", "TTF", font, font, null);
+ PDFFont pdfArial = pdfFactory.makeFont("Arial", "Arial", "TTF", font, font);
assertEquals("/EAAAAB+Arial", pdfArial.getBaseFont().toString());
}
sb.addUnencodedCharacter(new NamedCharacter("xyz", String.valueOf((char) 0x2202)), 0, new Rectangle());
sb.mapChar((char) 0x2202);
sb.setEncoding(new CodePointMapping("FOPPDFEncoding", new int[0]));
- PDFFont font = pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb, null);
+ PDFFont font = pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
font.output(bos);
assertTrue(bos.toString().contains("/BaseFont /EAAAAA+a"));
return new char[]{1};
}
});
- pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb, null);
+ pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
doc.outputTrailer(bos);
assertTrue(bos.toString().contains("/Differences [1 /a]"));
sb.setFlags(0);
sb.setEncoding(new CodePointMapping("FOPPDFEncoding", new int[0]));
String enc = "MacRomanEncoding";
- PDFFont font = pdfFactory.makeFont("a", "a", enc, sb, sb, null);
+ PDFFont font = pdfFactory.makeFont("a", "a", enc, sb, sb);
font.output(new ByteArrayOutputStream());
assertEquals(((PDFName)font.entries.get("Encoding")).getName(), enc);
}
for (char c = 0; c < 512; c++) {
sb.mapChar(c);
}
- pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb, null);
+ pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
doc.outputTrailer(bos);
for (char c = 0; c < 512; c++) {
sb.mapChar(c);
}
- pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb, null);
+ pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb);
PDFFont pdfFont = pdfFactory.getDocument().getFontMap().get("a_1");
PDFFontDescriptor fontDescriptor = (PDFFontDescriptor) pdfFont.get("FontDescriptor");
assertNull(fontDescriptor.getCIDSet());
public class PDFToUnicodeCMapTestCase {
- static final int UNICODE_CHAR_MAP_SIZE = 200;
+ private static final int UNICODE_CHAR_MAP_SIZE = 200;
- static final char[] S_UNICODE_CHAR_MAP = new char[UNICODE_CHAR_MAP_SIZE];
+ private static final char[] S_UNICODE_CHAR_MAP = new char[UNICODE_CHAR_MAP_SIZE];
- EventBroadcaster eventBroadcaster;
+ private EventBroadcaster eventBroadcaster;
@Before
public void initUnicodeChatMap() {