void drvJAVA::show_text(const TextInfo & textinfo) { unsigned int javaFontNumber = getFontNumber(textinfo.currentFontName.value()); outf << "\tcurrentpage.theObjects.addElement( new PSTextObject(" << endl; outf << "\t\t" << currentR() << "F," << currentG() << "F," << currentB() << "F," << endl; outf << "\t\t\""; // << textinfo.thetext for (const char *p = textinfo.thetext.value(); (*p) != 0; p++) { if ((*p) == '"') { outf << '\\' << *p; } else if ((*p) == '\\') { outf << '\\' << *p; } else if ((*p) == (char) 13) { // ^M outf << ' '; } else { outf << *p; } } outf << "\"," << (int) (textinfo.x + x_offset) << "," << (int) (currentDeviceHeight - textinfo.y + y_offset) << ',' << endl; #ifdef PASSFONTNAME const char *javaFname = JavaFonts[javaFontNumber].javaname; const char *javaFstyle = JavaFonts[javaFontNumber].javastyle; outf << "\t\t\"" << javaFname << "\"," << javaFstyle #else outf << "\t\t" << javaFontNumber; #endif outf << ',' << (int) (textinfo.currentFontSize + 0.5) << " )\n\t);" << endl; }
void drvJAVA2::show_text(const TextInfo & textinfo) { if (numberOfElements > limitNumberOfElements) continue_page(); unsigned int javaFontNumber = getFontNumber(textinfo.currentFontName.value()); outf << " currentPage.add(new PSTextObject(new Color("; outf << currentR() << "f, " << currentG() << "f, " << currentB() << "f)," << endl; outf << " \""; for (const char *p = textinfo.thetext.value(); (*p) != 0; p++) { if ((*p) == '"') { outf << '\\' << *p; } else if ((*p) == '\\') { outf << '\\' << *p; } else if ((*p) == (char) 13) { // ^M outf << ' '; } else { outf << *p; } } outf << "\"," << endl; outf << " " << (textinfo.x + x_offset) << "f, " << (currentDeviceHeight - textinfo.y + y_offset) << "f"; #ifdef PASSFONTNAME const char *javaFname = JavaFonts[javaFontNumber].javaname; const char *javaFstyle = JavaFonts[javaFontNumber].javastyle; outf << ", \"" << javaFname << "\", " << javaFstyle; #else outf << ", " << javaFontNumber; #endif const float *CTM = getCurrentFontMatrix(); if ((fabs(pythagoras(CTM[0], CTM[1] ) - textinfo.currentFontSize) < 1e-5) && (fabs(pythagoras(CTM[2] ,CTM[3] ) - textinfo.currentFontSize) < 1e-5) && (CTM[0] * CTM[3] - CTM[1] * CTM[2] >= 0)) { outf << ", " << textinfo.currentFontSize << "f"; if (textinfo.currentFontAngle) { outf << ", " << textinfo.currentFontAngle << "f"; } } else { outf << ", new AffineTransform(" << CTM[0] << "f, " << (-CTM[1]) << "f, "; outf << (-CTM[2]) << "f, " << CTM[3] << "f, 0f, 0f)"; } outf << "));" << endl; numberOfElements++; }
void drvPDF::show_text(const TextInfo & textinfo) { const float toRadians = 3.14159265359f / 180.0f; const float angleInRadians = textinfo.currentFontAngle * toRadians; int PDFFontNum = getFontNumber(textinfo.currentFontName.value()); if (PDFFontNum == -1) { PDFFontNum = getSubStringFontNumber(textinfo.currentFontName.value()); if (PDFFontNum == -1) { PDFFontNum = getSubStringFontNumber(defaultFontName); if (PDFFontNum == -1) { errf << "Warning, unsupported font " << textinfo. currentFontName.value() << ", using Courier instead" << endl; PDFFontNum = 0; // Courier } else { errf << "Warning, unsupported font " << textinfo. currentFontName.value() << ", using " << defaultFontName << " instead" << endl; } } else { errf << "Warning, unsupported font " << textinfo. currentFontName.value() << ", using " << PDFFonts[PDFFontNum] << " instead" << endl; } } starttext(); // define TFALWAYSONE // note TFALWAYSONE does not work correctly with awidthshow. See showex.ps #ifdef TFALWAYSONE const float Sx = textinfo.currentFontSize; const float Sy = textinfo.currentFontSize; buffer << "/F" << PDFFontNum << ' ' << 1 << " Tf" << endl; // use size 1 and scale via Tm #else // previously we used currentFontSize for SX and SY // and fontsize 1 in Tm, now we use the fontsize in tm and set // sx and sy to 1 const float Sx = 1.0f; const float Sy = 1.0f; buffer << "/F" << PDFFontNum << ' ' << textinfo.currentFontSize << " Tf" << endl; #endif const float cosphi = (float) cos(angleInRadians); const float sinphi = (float) sin(angleInRadians); // OK, we could get the real transformation matrix from the interpreter, // but this approximation should do it in most cases. // buffer.precision(3); // buffer.setf(ios::fixed); // buffer.width(0); // to force minimal width // buffer.unsetf(ios::showpoint); adjustbbox(textinfo.x + x_offset, textinfo.y + y_offset); buffer << RND3(Sx * cosphi) << " " << RND3(Sx * sinphi) << " " << RND3(-Sy * sinphi) << " " << RND3(Sy * cosphi) << " " << RND3(textinfo.x + x_offset) << " " << RND3(textinfo.y + y_offset) << " Tm" << endl; buffer << RND3(textinfo.currentR) << " " << RND3(textinfo. currentG) << " " << RND3(textinfo.currentB) << " rg" << endl; #ifdef TFALWAYSONE buffer << RND3(textinfo.cx / textinfo.currentFontSize) << ' ' << RND3(textinfo.ax / textinfo.currentFontSize) << ' '; #else buffer << RND3(textinfo.cx) << ' ' << RND3(textinfo.ax) << ' '; #endif buffer << "("; const char *start_of_text = textinfo.thetext.value(); while (*start_of_text) { if ((*start_of_text == '(') || (*start_of_text == ')') || (*start_of_text == '\\')) { buffer << '\\'; } buffer << *start_of_text; start_of_text++; } buffer << ") \"" << endl; // buffer << ") Tj" << endl; // endtext(); // not done here to avoid ET BT, done on demand }