History

fix rendering!

Noam Preil committed 3 years ago

Commit a4a05ae1 parent b22596b1 file · +31 −20Browse files

Unified · Split

op.c+31−20
@@ -573,13 +573,10 @@ tobegin(Op *op, Page *p) · 572 unmodified lines
573 werrstr("Text objects must not be nested");573 werrstr("Text objects must not be nested");
574 return 0;574 return 0;
575 }575 }
576 matidentity(p->TS.Tm);
577 matidentity(p->TS.Tlm);
578 p->TS.inobj = 1;576 p->TS.inobj = 1;
579 p->TS.TL = 0;
580 p->TS.Tc = 0;
581 p->TS.Tw = 0;
582 p->GSactive->Font.font = nil;577 p->GSactive->Font.font = nil;
578 matidentity(p->TS.Tm);
579 matidentity(p->TS.Tlm);
583 return flagless(op);580 return flagless(op);
584}581}
585 582
@@ -723,12 +720,16 @@ writepatched(Page *p, uchar c) · 137 unmodified lines
723 return bufput(&p->buf, (uchar*)&c, 1) == 1;720 return bufput(&p->buf, (uchar*)&c, 1) == 1;
724}721}
725 722
723// Returns glyph width in TEXT SPACE units.
726static double724static double
727glyphwidth(Page *p, ulong c)725glyphwidth(Page *p, ulong c)
728{726{
729 if(c >= p->GSactive->Font.first && c <= p->GSactive->Font.last)727 // TODO: type 3 fonts have explicit metrics? See 9.2.4 / 9.6.5 of the spec.
730 return (double)p->GSactive->Font.widths[c - p->GSactive->Font.first] / 1000;728 // For all other fonts, units are 1/1000th of text space
731 return (double)p->GSactive->Font.defwidth / 1000;729 double gwidth = 420;
730// if(c >= p->GSactive->Font.first && c <= p->GSactive->Font.last)
731// gwidth = p->GSactive->Font.widths[c - p->GSactive->Font.first];
732 return gwidth / 1000;
732}733}
733 734
734static double735static double
@@ -757,11 +758,10 @@ tchar(Page *p, ulong c) · 22 unmodified lines
757 // Check if whitespace is needed758 // Check if whitespace is needed
758 if(p->buf.sz > 1){759 if(p->buf.sz > 1){
759 if(p->TS.y != Trm[5]){760 if(p->TS.y != Trm[5]){
760 for(i = 0; i < (int)((p->TS.y - Trm[5]) / p->GSactive->Font.size) && i < 1; i += 1)761 for(i = 0; i < (int)((Trm[5] - p->TS.y) / p->GSactive->Font.size / 1.5) && i < 2; i += 1)
761 if(bufput(&p->buf, (uchar*)"\n", 1) != 1)762 if(bufput(&p->buf, (uchar*)"\n", 1) != 1)
762 return 0;763 return 0;
763 }764 } else if(Trm[4] - p->TS.x > 5) {
764 if(Trm[4] - p->TS.x > 14){
765 if(bufput(&p->buf, (uchar*)" ", 1) != 1)765 if(bufput(&p->buf, (uchar*)" ", 1) != 1)
766 return 0;766 return 0;
767 }767 }
@@ -822,11 +822,13 @@ thshowarr(Op *op, Page *p) · 54 unmodified lines
822 int i;822 int i;
823 for(i = 0; i < arraylen(arr); i += 1){823 for(i = 0; i < arraylen(arr); i += 1){
824 o = arrayget(arr, i);824 o = arrayget(arr, i);
825 if(o->type == Ostr)825 if(o->type == Ostr){
826 if(!tstr(p, o->str, o->len))826 if(!tstr(p, o->str, o->len))
827 return 0;827 return 0;
828 else828 }
829 mattrans(p->TS.Tm, 0 - (o->num.d / 1000), 0, p->TS.Tm);829 else {
830 mattrans(p->TS.Tm, 0 - (p->GSactive->Font.size * o->num.d / 1000), 0, p->TS.Tm);
831 }
830 }832 }
831 return flagless(op);833 return flagless(op);
832}834}
@@ -1373,7 +1375,7 @@ pagecropbox(Page *p) · 540 unmodified lines
1373}1375}
1374 1376
1375void1377void
1376ctminit(Page *p, double *ctm)1378ctminit(Page *p, double *ctm, double w, double h)
1377{1379{
1378 Object *cropbox;1380 Object *cropbox;
1379 double mx, my;1381 double mx, my;
@@ -1381,9 +1383,17 @@ ctminit(Page *p, double *ctm) · 1 unmodified line
1381 cropbox = pagecropbox(p);1383 cropbox = pagecropbox(p);
1382 mx = arrayget(cropbox, 2)->num.d;1384 mx = arrayget(cropbox, 2)->num.d;
1383 my = arrayget(cropbox, 3)->num.d;1385 my = arrayget(cropbox, 3)->num.d;
1384 ctm[0] = 850 / mx;1386 ctm[0] = w / mx;
1385 ctm[3] = -1100 / my;1387 ctm[3] = 0-h / my;
1386 ctm[5] = 1100;1388 ctm[5] = h;
1389}
1390
1391static void
1392tsinit(Page *p)
1393{
1394 p->TS.TL = 0;
1395 p->TS.Tc = 0;
1396 p->TS.Tw = 0;
1387}1397}
1388 1398
1389void1399void
@@ -1391,7 +1401,8 @@ gsinit(Page *p, GS *gs) · 1 unmodified line
1391{1401{
1392 USED(p);1402 USED(p);
1393 /* todo: actually initialize the full state */1403 /* todo: actually initialize the full state */
1394 ctminit(p, gs->CTM);1404 ctminit(p, gs->CTM, 1100, 1300);
1405 tsinit(p);
1395 gs->LW = 1.0;1406 gs->LW = 1.0;
1396 gs->LC = CapButt;1407 gs->LC = CapButt;
1397 gs->LJ = JoinMiter;1408 gs->LJ = JoinMiter;
@@ -1506,7 +1517,7 @@ pagerender(Page *p) · 108 unmodified lines
1506 }1517 }
1507 p->GSactive = p->GS;1518 p->GSactive = p->GS;
1508 gsinit(p, p->GS);1519 gsinit(p, p->GS);
1509 if((p->image = allocmemimage(Rect(0,0,850,1100), strtochan("r8g8b8"))) == nil){1520 if((p->image = allocmemimage(Rect(0,0,1100,1300), strtochan("r8g8b8"))) == nil){
1510 werrstr("unable to allocate image: %r");1521 werrstr("unable to allocate image: %r");
1511 pagegsclean(p);1522 pagegsclean(p);
1512 return 0;1523 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t