* @see org.apache.fop.fonts.FontDescriptor#isEmbeddable()
*/
public boolean isEmbeddable() {
- return !(getEmbedFileName() == null && embedResourceName == null);
+ return !(getEmbedFileName() == null && embedResourceName == null);
}
/**
for (int i = 0; (i < bfentries.length) && retIdx == 0; i++) {
if (bfentries[i].getUnicodeStart() <= idx
&& bfentries[i].getUnicodeEnd() >= idx) {
-
- retIdx = bfentries[i].getGlyphStartIndex()
+
+ retIdx = bfentries[i].getGlyphStartIndex()
+ idx
- bfentries[i].getUnicodeStart();
}
new Integer(usedGlyphsCount));
usedGlyphsIndex.put(new Integer(usedGlyphsCount),
new Integer(retIdx));
+ usedCharsIndex.put(new Integer(usedGlyphsCount),
+ new Integer((int) c));
retIdx = usedGlyphsCount;
usedGlyphsCount++;
} else {
return usedGlyphs;
}
+ /** The invalid Unicode character, suitable as a return value in methods
+ * that need to return an invalid character. */
+ public static final char INVALID_UNICODE_CHAR = 0xFFFF;
+
+ public char[] getCharsUsed() {
+ if (! isEmbeddable()) {
+ return null;
+ }
+ char[] charArray = new char[usedGlyphsCount];
+ for (int i = 0; i < usedGlyphsCount; i++) {
+ Integer mapValue = (Integer)usedCharsIndex.get(new Integer(i));
+ if(mapValue != null) {
+ char arrayItem = (char) mapValue.intValue();
+ charArray[i] = arrayItem;
+ }
+ else {
+ charArray[i] = INVALID_UNICODE_CHAR;
+ }
+ }
+ return charArray;
+ }
}
package org.apache.fop.pdf;
+import java.io.IOException;
+import java.io.OutputStream;
+
/**
* Class representing the CMap encodings.
*
* @param p the string buffer to add the pdf data to
*/
public void fillInPDF(StringBuffer p) {
+ writePreStream(p);
+ writeStreamComments(p);
+ writeCIDInit(p);
+ writeCIDSystemInfo(p);
+ writeVersionTypeName(p);
+ writeCodeSpaceRange(p);
+ writeCIDRange(p);
+ writeBFEntries(p);
+ writeWrapUp(p);
+ writeStreamAfterComments(p);
+ writeUseCMap(p);
+ add(p.toString());
+ }
+
+ protected void writePreStream(StringBuffer p) {
// p.append("/Type /CMap\n");
// p.append(sysInfo.toPDFString());
- // p.append("/CMapName /" + name);
- // p.append("\n");
+ // p.append("/CMapName /" + name + EOL);
+ }
+
+ protected void writeStreamComments(StringBuffer p) {
p.append("%!PS-Adobe-3.0 Resource-CMap\n");
p.append("%%DocumentNeededResources: ProcSet (CIDInit)\n");
p.append("%%IncludeResource: ProcSet (CIDInit)\n");
p.append("%%BeginResource: CMap (" + name + ")\n");
p.append("%%EndComments\n");
+ }
+ protected void writeCIDInit(StringBuffer p) {
p.append("/CIDInit /ProcSet findresource begin\n");
p.append("12 dict begin\n");
p.append("begincmap\n");
+ }
+ protected void writeCIDSystemInfo(StringBuffer p) {
p.append("/CIDSystemInfo 3 dict dup begin\n");
p.append(" /Registry (Adobe) def\n");
p.append(" /Ordering (Identity) def\n");
p.append(" /Supplement 0 def\n");
p.append("end def\n");
+ }
+ protected void writeVersionTypeName(StringBuffer p) {
p.append("/CMapVersion 1 def\n");
p.append("/CMapType 1 def\n");
p.append("/CMapName /" + name + " def\n");
+ }
+ protected void writeCodeSpaceRange(StringBuffer p) {
p.append("1 begincodespacerange\n");
p.append("<0000> <FFFF>\n");
p.append("endcodespacerange\n");
+ }
+
+ protected void writeCIDRange(StringBuffer p) {
p.append("1 begincidrange\n");
p.append("<0000> <FFFF> 0\n");
p.append("endcidrange\n");
+ }
+ protected void writeBFEntries(StringBuffer p) {
// p.append("1 beginbfrange\n");
// p.append("<0020> <0100> <0000>\n");
// p.append("endbfrange\n");
+ }
+ protected void writeWrapUp(StringBuffer p) {
p.append("endcmap\n");
p.append("CMapName currentdict /CMap defineresource pop\n");
p.append("end\n");
p.append("end\n");
+ }
+
+ protected void writeStreamAfterComments(StringBuffer p) {
p.append("%%EndResource\n");
p.append("%%EOF\n");
+ }
+
+ protected void writeUseCMap(StringBuffer p) {
/*
- * p.append(" /Type /CMap\n/CMapName /" + name);
- * p.append("\n");
- * p.append("\n/WMode "); p.append(wMode);
+ * p.append(" /Type /CMap");
+ * p.append("/CMapName /" + name + EOL);
+ * p.append("/WMode " + wMode + EOL);
* if (base != null) {
- * p.append("\n/UseCMap ");
+ * p.append("/UseCMap ");
* if (base instanceof String) {
* p.append("/"+base);
* } else {// base instanceof PDFStream
*/
}
+ protected int output(OutputStream stream) throws IOException {
+ fillInPDF(new StringBuffer());
+ return super.output(stream);
+ }
}
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
-//W3C DOM
-import org.w3c.dom.Document;
-
// Apache libs
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
* @return the new PDF outline object
*/
public PDFOutline makeOutline(PDFOutline parent, String label,
- String destination, float yoffset,
+ String destination, float yoffset,
boolean showSubItems) {
String goToRef = getGoToReference(destination, yoffset);
(PDFCIDFontDescriptor)pdfdesc);
getDocument().registerObject(cidFont);
+ PDFCMap cmap = new PDFToUnicodeCMap(cidMetrics, "fop-ucs-H",
+ new PDFCIDSystemInfo("Adobe",
+ "Identity",
+ 0));
+ getDocument().registerObject(cmap);
+ ((PDFFontType0)font).setCMAP(cmap);
((PDFFontType0)font).setDescendantFonts(cidFont);
} else {
int firstChar = 0;