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