ref: 0614e3e0afb7f1d7997b16679c9f58e868a168cf
parent: 262b5d112994da35f04092dfcc43fdf7acface77
author: Noam Preil <noam@pixelhero.dev>
date: Thu Apr 7 10:27:06 EDT 2022
op: implement Tc
--- a/op.c
+++ b/op.c
@@ -355,8 +355,8 @@
static int
tsspace(Op *op, Page *p)
{
- USED(op, p);
- return 0;
+ p->TS.Tc = arrayget(p->stack, 0)->num.d;
+ return 1;
}
static int
@@ -447,6 +447,8 @@
matidentity(p->TS.Tm);
matidentity(p->TS.Tlm);
p->TS.inobj = 1;
+ p->TS.TL = 0;
+ p->TS.Tc = 0;
p->GSactive->Font.font = nil;
return flagless(op);
}
@@ -606,15 +608,15 @@
tchar(Page *p, ulong c)
{
double Trm[6] = {p->GSactive->Font.size, 0, 0, p->GSactive->Font.size, 0, 0};
- double tx;
+ double tx, w0;
int i;
matmult(Trm, p->TS.Tm, Trm);
matmult(Trm, p->GSactive->CTM, Trm);
- tx = p->GSactive->Font.size / 1000;
if(c >= p->GSactive->Font.first && c <= p->GSactive->Font.last)
- tx = tx * (double)p->GSactive->Font.widths[c - p->GSactive->Font.first];
+ w0 = (double)p->GSactive->Font.widths[c - p->GSactive->Font.first] / 1000;
else
- tx = tx * (double)p->GSactive->Font.defwidth;
+ w0 = (double)p->GSactive->Font.defwidth / 1000;
+ tx = w0 * p->GSactive->Font.size + p->TS.Tc;
// Check if whitespace is needed
if(p->buf.sz > 1){
if(p->TS.y != Trm[5]){
--- a/pdf.h
+++ b/pdf.h
@@ -142,7 +142,7 @@
double Tlm[6]; /* text line matrix */
/* Tracks if we're in a text object; nesting is verboten */
int inobj;
- double TL;
+ double TL, Tc;
/* Temporary, for pdf2txt functionality: tracks the last character's position so we know whether whitespace is needed */
double x, y;
};