diff --git a/pdf.c b/pdf.c index e6ef7d021861007b48f28b5fde38c6eda2175089..e55b1828681289fb49516fd8d4b99d92c76a6563 100644 --- a/pdf.c +++ b/pdf.c @@ -1997,12 +1997,14 @@ act_txtobj(const HParseResult *p, void *u) textlen += 1; case TW_Tj: textlen += txte->tstr.nchars; - *px += txte->tstr.nchars * node->ts.font->fref.fontsize; // TODO:: handle character width from font description + if (node->ts.font != NULL) + *px += txte->tstr.nchars * node->ts.font->fref.fontsize; // TODO:: handle character width from font description break; case TW_TJ: textlen += txte->tarray.flattened.nchars; - *px += txte->tarray.flattened.nchars * node->ts.font->fref.fontsize; // TODO:: handle character width from font description + if (node->ts.font != NULL) + *px += txte->tarray.flattened.nchars * node->ts.font->fref.fontsize; // TODO:: handle character width from font description break; default: @@ -2098,14 +2100,16 @@ act_txtobj(const HParseResult *p, void *u) case TW_Tj: memcpy(&tstr[idx], txte->tstr.text, txte->tstr.nchars); idx += txte->tstr.nchars; - *px += txte->tarray.flattened.nchars * node->ts.font->fref.fontsize; // TODO:: handle character width from font description + if (node->ts.font != NULL) + *px += txte->tarray.flattened.nchars * node->ts.font->fref.fontsize; // TODO:: handle character width from font description break; case TW_TJ: memcpy(&tstr[idx], txte->tarray.flattened.text, txte->tarray.flattened.nchars); idx += txte->tarray.flattened.nchars; - *px += txte->tarray.flattened.nchars * node->ts.font->fref.fontsize; // TODO:: handle character width from font description + if (node->ts.font != NULL) + *px += txte->tarray.flattened.nchars * node->ts.font->fref.fontsize; // TODO:: handle character width from font description break; default: