summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/pdf/pdfpage.w')
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfpage.w172
1 files changed, 86 insertions, 86 deletions
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
index 3fc698a9ec7..73c83c64234 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfpage.w
@@ -19,7 +19,6 @@
@ @c
-
#include "ptexlib.h"
#include <stdlib.h>
@@ -27,16 +26,16 @@
#include <assert.h>
#include <math.h>
-@ eternal constants
+@ eternal constant: number of sp per 1bp
+
@c
-#define one_bp ((double) 65536 * (double) 72.27 / 72) /* number of sp per 1bp */
+#define one_bp ((double) 65536 * (double) 72.27 / 72)
@ @c
void init_pdf_pagecalculations(PDF pdf)
{
pdfstructure *p;
int decimal_digits = pdf->decimal_digits;
- assert(pdf != NULL);
if (pdf->pstruct == NULL)
pdf->pstruct = xmalloc(sizeof(pdfstructure));
p = pdf->pstruct;
@@ -52,10 +51,10 @@ void init_pdf_pagecalculations(PDF pdf)
setpdffloat(p->cm[4], 0, decimal_digits); /* horizontal movement on page */
setpdffloat(p->cm[5], 0, decimal_digits); /* vertical movement on page */
/* for placement inside BT...ET */
- setpdffloat(p->tm0_cur, 0, 6); /* mantissa holds HZ expand * ExtendFont */
+ setpdffloat(p->tm0_cur, 0, 6); /* mantissa holds HZ expand * ExtendFont */
setpdffloat(p->tm[0], ten_pow[6], 6); /* mantissa holds HZ expand * ExtendFont */
setpdffloat(p->tm[1], 0, 0);
- setpdffloat(p->tm[2], 0, 3); /* mantissa holds SlantFont, 0 = default */
+ setpdffloat(p->tm[2], 0, 3); /* mantissa holds SlantFont, 0 = default */
setpdffloat(p->tm[3], ten_pow[6], 6);
setpdffloat(p->tm[4], 0, decimal_digits); /* mantissa holds delta from |pdf_bt_pos.h| */
setpdffloat(p->tm[5], 0, decimal_digits); /* mantissa holds delta from |pdf_bt_pos.v| */
@@ -71,28 +70,31 @@ void init_pdf_pagecalculations(PDF pdf)
}
@ @c
-void synch_pos_with_cur(posstructure * pos, posstructure * refpos,
- scaledpos cur)
+void synch_pos_with_cur(posstructure * pos, posstructure * refpos, scaledpos cur)
{
switch (pos->dir) {
- case dir_TLT:
- pos->pos.h = refpos->pos.h + cur.h;
- pos->pos.v = refpos->pos.v - cur.v;
- break;
- case dir_TRT:
- pos->pos.h = refpos->pos.h - cur.h;
- pos->pos.v = refpos->pos.v - cur.v;
- break;
- case dir_LTL:
- pos->pos.h = refpos->pos.h + cur.v;
- pos->pos.v = refpos->pos.v - cur.h;
- break;
- case dir_RTT:
- pos->pos.h = refpos->pos.h - cur.v;
- pos->pos.v = refpos->pos.v - cur.h;
- break;
- default:
- assert(0);
+ case dir_TLT:
+ pos->pos.h = refpos->pos.h + cur.h;
+ pos->pos.v = refpos->pos.v - cur.v;
+ break;
+ case dir_TRT:
+ pos->pos.h = refpos->pos.h - cur.h;
+ pos->pos.v = refpos->pos.v - cur.v;
+ break;
+ case dir_LTL:
+ pos->pos.h = refpos->pos.h + cur.v;
+ pos->pos.v = refpos->pos.v - cur.h;
+ break;
+ case dir_RTT:
+ pos->pos.h = refpos->pos.h - cur.v;
+ pos->pos.v = refpos->pos.v - cur.h;
+ break;
+ default:
+ formatted_warning("pdf backend","forcing bad dir %i to TLT in synch_pos_with_cur",pos->dir);
+ pos->dir = dir_TLT;
+ pos->pos.h = refpos->pos.h + cur.h;
+ pos->pos.v = refpos->pos.v - cur.v;
+ break;
}
}
@@ -102,55 +104,48 @@ boolean calc_pdfpos(pdfstructure * p, scaledpos pos)
scaledpos new;
boolean move_pdfpos = false;
switch (p->mode) {
- case PMODE_PAGE:
- new.h = i32round(pos.h * p->k1);
- new.v = i32round(pos.v * p->k1);
- p->cm[4].m = new.h - p->pdf.h.m; /* cm is concatenated */
- p->cm[5].m = new.v - p->pdf.v.m;
- if (new.h != p->pdf.h.m || new.v != p->pdf.v.m)
- move_pdfpos = true;
- break;
- case PMODE_TEXT:
- new.h = i32round(pos.h * p->k1);
- new.v = i32round(pos.v * p->k1);
- p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* Tm replaces */
- p->tm[5].m = new.v - p->pdf_bt_pos.v.m;
- if (new.h != p->pdf.h.m || new.v != p->pdf.v.m)
- move_pdfpos = true;
- break;
- case PMODE_CHAR:
- case PMODE_CHARARRAY:
- switch (p->wmode) {
- case WMODE_H:
- new.h =
- i32round((pos.h * p->k1 - (double) p->pdf_tj_pos.h.m) * p->k2);
+ case PMODE_PAGE:
+ new.h = i32round(pos.h * p->k1);
new.v = i32round(pos.v * p->k1);
- p->tj_delta.m = -i64round((double)
- ((new.h - p->cw.m) / ten_pow[p->cw.e -
- p->tj_delta.
- e]));
- p->tm[5].m = new.v - p->pdf_bt_pos.v.m; /* p->tm[4] is meaningless */
- if (p->tj_delta.m != 0 || new.v != p->pdf.v.m)
+ p->cm[4].m = new.h - p->pdf.h.m; /* cm is concatenated */
+ p->cm[5].m = new.v - p->pdf.v.m;
+ if (new.h != p->pdf.h.m || new.v != p->pdf.v.m)
move_pdfpos = true;
break;
- case WMODE_V:
+ case PMODE_TEXT:
new.h = i32round(pos.h * p->k1);
- new.v =
- i32round(((double) p->pdf_tj_pos.v.m - pos.v * p->k1) * p->k2);
- p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* p->tm[5] is meaningless */
- p->tj_delta.m = -i64round((double)
- ((new.v - p->cw.m) / ten_pow[p->cw.e -
- p->tj_delta.
- e]));
- if (p->tj_delta.m != 0 || new.h != p->pdf.h.m)
+ new.v = i32round(pos.v * p->k1);
+ p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* Tm replaces */
+ p->tm[5].m = new.v - p->pdf_bt_pos.v.m;
+ if (new.h != p->pdf.h.m || new.v != p->pdf.v.m)
move_pdfpos = true;
break;
+ case PMODE_CHAR:
+ case PMODE_CHARARRAY:
+ switch (p->wmode) {
+ case WMODE_H:
+ new.h = i32round((pos.h * p->k1 - (double) p->pdf_tj_pos.h.m) * p->k2);
+ new.v = i32round(pos.v * p->k1);
+ p->tj_delta.m = -i64round((double) ((new.h - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e]));
+ p->tm[5].m = new.v - p->pdf_bt_pos.v.m; /* p->tm[4] is meaningless */
+ if (p->tj_delta.m != 0 || new.v != p->pdf.v.m)
+ move_pdfpos = true;
+ break;
+ case WMODE_V:
+ new.h = i32round(pos.h * p->k1);
+ new.v = i32round(((double) p->pdf_tj_pos.v.m - pos.v * p->k1) * p->k2);
+ p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* p->tm[5] is meaningless */
+ p->tj_delta.m = -i64round((double) ((new.v - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e]));
+ if (p->tj_delta.m != 0 || new.h != p->pdf.h.m)
+ move_pdfpos = true;
+ break;
+ default:
+ normal_error("pdf backend","unknown mode in char array in calc_pos");
+ break;
+ }
+ break;
default:
- assert(0);
- }
- break;
- default:
- assert(0);
+ normal_error("pdf backend","unknown mode in calc_pos");
}
return move_pdfpos;
}
@@ -178,7 +173,8 @@ void pdf_set_pos(PDF pdf, scaledpos pos)
{
boolean move;
pdfstructure *p = pdf->pstruct;
- assert(is_pagemode(p));
+ if (!is_pagemode(p))
+ normal_error("pdf backend","page mode expected in set_pos");
move = calc_pdfpos(p, pos);
if (move) {
pdf_print_cm(pdf, p->cm);
@@ -192,17 +188,20 @@ void pdf_set_pos_temp(PDF pdf, scaledpos pos)
{
boolean move;
pdfstructure *p = pdf->pstruct;
- assert(is_pagemode(p));
+ if (!is_pagemode(p))
+ normal_error("pdf backend","page mode expected in set_pos_temp");
move = calc_pdfpos(p, pos);
- if (move)
+ if (move) {
pdf_print_cm(pdf, p->cm);
+ }
}
@ @c
static void begin_text(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(is_pagemode(p));
+ if (!is_pagemode(p))
+ normal_error("pdf backend","page mode expected in begin_text");
p->pdf_bt_pos = p->pdf;
pdf_puts(pdf, "BT\n");
p->mode = PMODE_TEXT;
@@ -212,7 +211,8 @@ static void begin_text(PDF pdf)
static void end_text(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(is_textmode(p));
+ if (!is_textmode(p))
+ normal_error("pdf backend","text mode expected in end_text");
pdf_puts(pdf, "ET\n");
p->pdf = p->pdf_bt_pos;
p->mode = PMODE_PAGE;
@@ -231,7 +231,6 @@ void pdf_end_string_nl(PDF pdf)
void pdf_goto_pagemode(PDF pdf)
{
pdfstructure *p = pdf->pstruct;
- assert(p != NULL);
if (!is_pagemode(p)) {
if (is_charmode(p))
end_charmode(pdf);
@@ -239,8 +238,9 @@ void pdf_goto_pagemode(PDF pdf)
end_chararray(pdf);
if (is_textmode(p))
end_text(pdf);
+ if (!is_pagemode(p))
+ normal_error("pdf backend","page mode expected in goto_page_mode");
}
- assert(is_pagemode(p));
}
void pdf_goto_textmode(PDF pdf)
@@ -249,16 +249,16 @@ void pdf_goto_textmode(PDF pdf)
const scaledpos origin = {
0, 0
};
- if (!is_textmode(p)) {
- if (is_pagemode(p)) {
- pdf_set_pos(pdf, origin); /* reset to page origin */
- begin_text(pdf);
- } else {
- if (is_charmode(p))
- end_charmode(pdf);
- if (is_chararraymode(p))
- end_chararray(pdf);
- }
+ if (is_pagemode(p)) {
+ /* reset to page origin */
+ pdf_set_pos(pdf, origin);
+ begin_text(pdf);
+ } else if (!is_textmode(p)) {
+ if (is_charmode(p))
+ end_charmode(pdf);
+ if (is_chararraymode(p))
+ end_chararray(pdf);
+ if (!is_textmode(p))
+ normal_error("pdf backend","text mode expected in goto_text_mode");
}
- assert(is_textmode(p));
}