summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdv2pdf/xdv2pdf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/xdv2pdf/xdv2pdf.cpp')
-rwxr-xr-xBuild/source/texk/xdv2pdf/xdv2pdf.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/Build/source/texk/xdv2pdf/xdv2pdf.cpp b/Build/source/texk/xdv2pdf/xdv2pdf.cpp
index e51aa7fb216..277bfc0ff86 100755
--- a/Build/source/texk/xdv2pdf/xdv2pdf.cpp
+++ b/Build/source/texk/xdv2pdf/xdv2pdf.cpp
@@ -85,6 +85,8 @@ authorization from SIL International.
#define XDV_FLAG_COLORED 0x0200
#define XDV_FLAG_FEATURES 0x0400
#define XDV_FLAG_VARIATIONS 0x0800
+#define XDV_FLAG_EXTEND 0x1000
+#define XDV_FLAG_SLANT 0x2000
#define pdfbox_crop 1
#define pdfbox_media 2
@@ -154,8 +156,8 @@ paperSizeRec gPaperSizes[] =
{ 0, 0, 0 }
};
-static CGAffineTransform horizontalMatrix = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 };
-static CGAffineTransform verticalMatrix = { 0.0, 1.0, -1.0, 0.0, 0.0, 0.0 };
+static const CGAffineTransform kHorizontalMatrix = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 };
+static const CGAffineTransform kVerticalMatrix = { 0.0, 1.0, -1.0, 0.0, 0.0, 0.0 };
struct nativeFont {
nativeFont()
@@ -164,6 +166,7 @@ struct nativeFont {
, atsuStyleH(0)
, atsuStyleV(0)
, size(Long2Fix(10))
+ , matrix(kHorizontalMatrix)
, isColored(false)
, isVertical(false)
{
@@ -174,6 +177,7 @@ struct nativeFont {
ATSUStyle atsuStyleV;
Fixed size;
CGColorRef color;
+ CGAffineTransform matrix;
bool isColored;
bool isVertical;
};
@@ -454,7 +458,7 @@ setChar(UInt32 c, bool adv)
flushGlyphs();
CGContextSetFont(gCtx, gTeXFonts[f].cgFont);
CGContextSetFontSize(gCtx, Fix2X(gTeXFonts[f].size) * gMagScale);
- CGContextSetTextMatrix(gCtx, horizontalMatrix);
+ CGContextSetTextMatrix(gCtx, kHorizontalMatrix);
cur_cgFont = f;
}
@@ -545,8 +549,7 @@ doGlyphArray(FILE* xdv, bool yLocs)
if (f != cur_cgFont) {
CGContextSetFont(gCtx, sNativeFonts[f].cgFont);
CGContextSetFontSize(gCtx, Fix2X(sNativeFonts[f].size));
- CGContextSetTextMatrix(gCtx, sNativeFonts[f].isVertical
- ? verticalMatrix : horizontalMatrix);
+ CGContextSetTextMatrix(gCtx, sNativeFonts[f].matrix);
cur_cgFont = f;
}
@@ -1756,7 +1759,7 @@ doNativeFontDef(FILE* xdv)
delete[] axes;
}
}
-
+
nativeFont fontRec;
fontRec.cgFont = cgFont;
fontRec.atsFont = fontRef;
@@ -1789,6 +1792,23 @@ doNativeFontDef(FILE* xdv)
vert = kATSUStronglyVertical;
status = ATSUSetAttributes(style, numTags, tags, sizes, values);
fontRec.atsuStyleV = style;
+
+ fontRec.matrix = kVerticalMatrix;
+ }
+
+ if (flags & XDV_FLAG_EXTEND) {
+ Fixed x = readUnsigned(xdv, 4);
+ if (fontRec.isVertical)
+ fontRec.matrix.c *= Fix2X(x);
+ else
+ fontRec.matrix.a *= Fix2X(x);
+ }
+ if (flags & XDV_FLAG_SLANT) {
+ Fixed s = readSigned(xdv, 4);
+ if (fontRec.isVertical)
+ fontRec.matrix.d = Fix2X(s);
+ else
+ fontRec.matrix.c = Fix2X(s);
}
sNativeFonts.insert(std::pair<const UInt32,nativeFont>(f, fontRec));
@@ -2197,9 +2217,8 @@ xdv2pdf(int argc, char** argv)
gTagLevel = -1;
- double_t paperWd = 0.0;
- double_t paperHt = 0.0;
-
+ gPaperWd = gPaperHt = 0.0;
+
int ch;
while ((ch = getopt(argc, argv, "o:p:m:d:hv" /*r:*/)) != -1) {
switch (ch) {
@@ -2212,7 +2231,7 @@ xdv2pdf(int argc, char** argv)
break;
case 'p':
- if (!getPaperSize(optarg, paperWd, paperHt)) {
+ if (!getPaperSize(optarg, gPaperWd, gPaperHt)) {
fprintf(stderr, "*** unknown paper name: %s\n", optarg);
exit(1);
}
@@ -2236,7 +2255,7 @@ xdv2pdf(int argc, char** argv)
}
}
- if ((paperWd == 0.0) || (paperHt == 0.0)) {
+ if ((gPaperWd == 0.0) || (gPaperHt == 0.0)) {
// get default paper size from printing system
PMRect paperRect = { 0, 0, 792, 612 };
PMPrintSession printSession;
@@ -2257,12 +2276,12 @@ xdv2pdf(int argc, char** argv)
}
status = PMRelease(printSession);
}
- paperWd = paperRect.right - paperRect.left;
- paperHt = paperRect.bottom - paperRect.top;
+ gPaperWd = paperRect.right - paperRect.left;
+ gPaperHt = paperRect.bottom - paperRect.top;
}
// set the media box for PDF generation
- gMediaBox = CGRectMake(0, 0, paperWd, paperHt);
+ gMediaBox = CGRectMake(0, 0, gPaperWd, gPaperHt);
argc -= optind;
argv += optind;