📄 psoutputdev.cc
字号:
break; } writePSChar(hexChar[(c >> 4) & 0x0f]); writePSChar(hexChar[c & 0x0f]); if (++i % 32 == 0) { writePSChar('\n'); } } if (i % 32 > 0) { writePSChar('\n'); } // already in ASCII format -- just copy it } else { for (i = 0; i < 4; ++i) { writePSChar(start[i]); } for (i = 4; i < length2; ++i) { if ((c = strObj.streamGetChar()) == EOF) { break; } writePSChar(c); } } // write padding and "cleartomark" for (i = 0; i < 8; ++i) { writePS("00000000000000000000000000000000" "00000000000000000000000000000000\n"); } writePS("cleartomark\n"); // ending comment writePS("%%EndResource\n"); err1: strObj.streamClose(); strObj.free();}//~ This doesn't handle .pfb files or binary eexec data (which only//~ happens in pfb files?).void PSOutputDev::setupExternalType1Font(GString *fileName, GString *psName) { FILE *fontFile; int c; int i; // check if font is already embedded for (i = 0; i < fontFileNameLen; ++i) { if (!fontFileNames[i]->cmp(fileName)) { return; } } // add entry to fontFileNames list if (fontFileNameLen >= fontFileNameSize) { fontFileNameSize += 64; fontFileNames = (GString **)greallocn(fontFileNames, fontFileNameSize, sizeof(GString *)); } fontFileNames[fontFileNameLen++] = fileName->copy(); // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // copy the font file if (!(fontFile = fopen(fileName->getCString(), "rb"))) { error(-1, "Couldn't open external font file"); return; } while ((c = fgetc(fontFile)) != EOF) { writePSChar(c); } fclose(fontFile); // ending comment writePS("%%EndResource\n");}void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id, GString *psName) { char *fontBuf; int fontLen; FoFiType1C *ffT1C; int i; // check if font is already embedded for (i = 0; i < fontFileIDLen; ++i) { if (fontFileIDs[i].num == id->num && fontFileIDs[i].gen == id->gen) return; } // add entry to fontFileIDs list if (fontFileIDLen >= fontFileIDSize) { fontFileIDSize += 64; fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref)); } fontFileIDs[fontFileIDLen++] = *id; // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // convert it to a Type 1 font fontBuf = font->readEmbFontFile(xref, &fontLen); if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { ffT1C->convertToType1(psName->getCString(), NULL, gTrue, outputFunc, outputStream); delete ffT1C; } gfree(fontBuf); // ending comment writePS("%%EndResource\n");}void PSOutputDev::setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, GString *psName) { char *fontBuf; int fontLen; FoFiTrueType *ffTT; int i; // check if font is already embedded for (i = 0; i < fontFileIDLen; ++i) { if (fontFileIDs[i].num == id->num && fontFileIDs[i].gen == id->gen) return; } // add entry to fontFileIDs list if (fontFileIDLen >= fontFileIDSize) { fontFileIDSize += 64; fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref)); } fontFileIDs[fontFileIDLen++] = *id; // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // convert it to a Type 1 font fontBuf = font->readEmbFontFile(xref, &fontLen); if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { if (ffTT->isOpenTypeCFF()) { ffTT->convertToType1(psName->getCString(), NULL, gTrue, outputFunc, outputStream); } delete ffTT; } gfree(fontBuf); // ending comment writePS("%%EndResource\n");}void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, GString *psName) { char *fontBuf; int fontLen; FoFiTrueType *ffTT; Gushort *codeToGID; int i; // check if font is already embedded for (i = 0; i < fontFileIDLen; ++i) { if (fontFileIDs[i].num == id->num && fontFileIDs[i].gen == id->gen) { psName->appendf("_{0:d}", nextTrueTypeNum++); break; } } // add entry to fontFileIDs list if (i == fontFileIDLen) { if (fontFileIDLen >= fontFileIDSize) { fontFileIDSize += 64; fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref)); } fontFileIDs[fontFileIDLen++] = *id; } // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // convert it to a Type 42 font fontBuf = font->readEmbFontFile(xref, &fontLen); if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT); ffTT->convertToType42(psName->getCString(), ((Gfx8BitFont *)font)->getHasEncoding() ? ((Gfx8BitFont *)font)->getEncoding() : (char **)NULL, codeToGID, outputFunc, outputStream); if (codeToGID) { if (font8InfoLen >= font8InfoSize) { font8InfoSize += 16; font8Info = (PSFont8Info *)greallocn(font8Info, font8InfoSize, sizeof(PSFont8Info)); } font8Info[font8InfoLen].fontID = *font->getID(); font8Info[font8InfoLen].codeToGID = codeToGID; ++font8InfoLen; } delete ffTT; } gfree(fontBuf); // ending comment writePS("%%EndResource\n");}void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, GString *psName) { GString *fileName; char *fontBuf; int fontLen; FoFiTrueType *ffTT; Gushort *codeToGID; int i; // check if font is already embedded fileName = font->getExtFontFile(); for (i = 0; i < fontFileNameLen; ++i) { if (!fontFileNames[i]->cmp(fileName)) { psName->appendf("_{0:d}", nextTrueTypeNum++); break; } } // add entry to fontFileNames list if (i == fontFileNameLen) { if (fontFileNameLen >= fontFileNameSize) { fontFileNameSize += 64; fontFileNames = (GString **)greallocn(fontFileNames, fontFileNameSize, sizeof(GString *)); } fontFileNames[fontFileNameLen++] = fileName->copy(); } // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // convert it to a Type 42 font fontBuf = font->readExtFontFile(&fontLen); if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT); ffTT->convertToType42(psName->getCString(), ((Gfx8BitFont *)font)->getHasEncoding() ? ((Gfx8BitFont *)font)->getEncoding() : (char **)NULL, codeToGID, outputFunc, outputStream); if (codeToGID) { if (font8InfoLen >= font8InfoSize) { font8InfoSize += 16; font8Info = (PSFont8Info *)greallocn(font8Info, font8InfoSize, sizeof(PSFont8Info)); } font8Info[font8InfoLen].fontID = *font->getID(); font8Info[font8InfoLen].codeToGID = codeToGID; ++font8InfoLen; } delete ffTT; } gfree(fontBuf); // ending comment writePS("%%EndResource\n");}void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, GString *psName) { char *fontBuf; int fontLen; FoFiType1C *ffT1C; int i; // check if font is already embedded for (i = 0; i < fontFileIDLen; ++i) { if (fontFileIDs[i].num == id->num && fontFileIDs[i].gen == id->gen) return; } // add entry to fontFileIDs list if (fontFileIDLen >= fontFileIDSize) { fontFileIDSize += 64; fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref)); } fontFileIDs[fontFileIDLen++] = *id; // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // convert it to a Type 0 font fontBuf = font->readEmbFontFile(xref, &fontLen); if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) { if (globalParams->getPSLevel() >= psLevel3) { // Level 3: use a CID font ffT1C->convertToCIDType0(psName->getCString(), outputFunc, outputStream); } else { // otherwise: use a non-CID composite font ffT1C->convertToType0(psName->getCString(), outputFunc, outputStream); } delete ffT1C; } gfree(fontBuf); // ending comment writePS("%%EndResource\n");}void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, GString *psName, GBool needVerticalMetrics) { char *fontBuf; int fontLen; FoFiTrueType *ffTT; int i; // check if font is already embedded for (i = 0; i < fontFileIDLen; ++i) { if (fontFileIDs[i].num == id->num && fontFileIDs[i].gen == id->gen) { psName->appendf("_{0:d}", nextTrueTypeNum++); break; } } // add entry to fontFileIDs list if (fontFileIDLen >= fontFileIDSize) { fontFileIDSize += 64; fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref)); } fontFileIDs[fontFileIDLen++] = *id; // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // convert it to a Type 0 font fontBuf = font->readEmbFontFile(xref, &fontLen); if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { if (globalParams->getPSLevel() >= psLevel3) { // Level 3: use a CID font ffTT->convertToCIDType2(psName->getCString(), ((GfxCIDFont *)font)->getCIDToGID(), ((GfxCIDFont *)font)->getCIDToGIDLen(), needVerticalMetrics, outputFunc, outputStream); } else { // otherwise: use a non-CID composite font ffTT->convertToType0(psName->getCString(), ((GfxCIDFont *)font)->getCIDToGID(), ((GfxCIDFont *)font)->getCIDToGIDLen(), needVerticalMetrics, outputFunc, outputStream); } delete ffTT; } gfree(fontBuf); // ending comment writePS("%%EndResource\n");}void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, GString *psName) { char *fontBuf; int fontLen; FoFiTrueType *ffTT; int i; // check if font is already embedded for (i = 0; i < fontFileIDLen; ++i) { if (fontFileIDs[i].num == id->num && fontFileIDs[i].gen == id->gen) return; } // add entry to fontFileIDs list if (fontFileIDLen >= fontFileIDSize) { fontFileIDSize += 64; fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref)); } fontFileIDs[fontFileIDLen++] = *id; // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // convert it to a Type 0 font fontBuf = font->readEmbFontFile(xref, &fontLen); if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) { if (ffTT->isOpenTypeCFF()) { if (globalParams->getPSLevel() >= psLevel3) { // Level 3: use a CID font ffTT->convertToCIDType0(psName->getCString(), outputFunc, outputStream); } else { // otherwise: use a non-CID composite font ffTT->convertToType0(psName->getCString(), outputFunc, outputStream); } } delete ffTT; } gfree(fontBuf); // ending comment writePS("%%EndResource\n");}void PSOutputDev::setupType3Font(GfxFont *font, GString *psName, Dict *parentResDict) { Dict *resDict; Dict *charProcs; Object charProc; Gfx *gfx; PDFRectangle box; double *m; GString *buf; int i; // set up resources used by font if ((resDict = ((Gfx8BitFont *)font)->getResources())) { inType3Char = gTrue; setupResources(resDict); inType3Char = gFalse; } else { resDict = parentResDict; } // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); embFontList->append("%%+ font "); embFontList->append(psName->getCString()); embFontList->append("\n"); // font dictionary writePS("8 dict begin\n"); writePS("/FontType 3 def\n"); m = font->getFontMatrix(); writePSFmt("/FontMatrix [{0:.4g} {1:.4g} {2:.4g} {3:.4g} {4:.4g} {5:.4g}] def\n", m[0], m[1], m[2], m[3], m[4], m[5]); m = font->getFontBBox(); writePSFmt("/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] def\n", m[0], m[1], m[2], m[3]); writePS("/Encoding 256 array def\n"); writePS(" 0 1 25
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -