ref: 319752248ebdda696cc6cf81ddc058496575ba18
parent: 4ac213e298e696d4c0816bc824dc4914077cb0c6
author: glenda <[email protected]>
date: Wed Mar 30 14:50:40 EDT 2022
ctm: initialize from MediaBox, if found
--- a/op.c
+++ b/op.c
@@ -1193,14 +1193,26 @@
}
void
+ctminit(Page *p, double *ctm)
+{
+ Object *mediabox;
+ double mx, my;
+ matidentity(ctm);
+ /* TODO: check if it's legal for MediaBox to be absent */
+ if((mediabox = dictget(p->obj, "MediaBox")) == nil)
+ return;
+ mx = arrayget(mediabox, 2)->num.d;
+ my = arrayget(mediabox, 3)->num.d;
+ ctm[0] = 850 / mx;
+ ctm[3] = 1100 / my;
+}
+
+void
gsinit(Page *p, GS *gs)
{
USED(p);
/* todo: actually initialize the full state */
- /* CTM maps user coords to device coords.
- TODO: use mediabox and screen info to init CTM
- */
- matidentity(gs->CTM);
+ ctminit(p, gs->CTM);
gs->LW = 1;
gs->LC = 0;
gs->LJ = 0;