diff --git a/pdfio-content.c b/pdfio-content.c index 85837a9..191ff68 100644 --- a/pdfio-content.c +++ b/pdfio-content.c @@ -1462,7 +1462,6 @@ write_string(pdfio_stream_t *st, // I - Stream { // ASCII string... const char *start = s; // Start of fragment - int level = 0; // Paren level if (!pdfioStreamPuts(st, "(")) return (false); @@ -1500,16 +1499,16 @@ write_string(pdfio_stream_t *st, // I - Stream ptr ++; start = ptr + 1; } - else if (*ptr == '\\' || (*ptr == ')' && level == 0) || *ptr < ' ') + else if (*ptr == '\\' || *ptr == '(' || *ptr == ')' || *ptr < ' ') { if (ptr > start) { if (!pdfioStreamWrite(st, start, (size_t)(ptr - start))) return (false); - - start = ptr + 1; } + start = ptr + 1; + if (*ptr < ' ') { if (!pdfioStreamPrintf(st, "\\%03o", *ptr)) @@ -1518,10 +1517,6 @@ write_string(pdfio_stream_t *st, // I - Stream else if (!pdfioStreamPrintf(st, "\\%c", *ptr)) return (false); } - else if (*ptr == '(') - level ++; - else if (*ptr == ')') - level --; } if (ptr > start) diff --git a/testpdfio.c b/testpdfio.c index f2ed05a..4a48b12 100644 --- a/testpdfio.c +++ b/testpdfio.c @@ -987,8 +987,20 @@ write_text(pdfio_file_t *pdf, // I - PDF file else return (1); - fputs("pdfioContentTextMoveTo(550.0, 36.0): ", stdout); - if (pdfioContentTextMoveTo(st, 550.0, 36.0)) + fputs("pdfioContentTextMoveTo(36.0, 36.0): ", stdout); + if (pdfioContentTextMoveTo(st, 36, 36.0)) + puts("PASS"); + else + return (1); + + printf("pdfioContentTextShowf(\"\\\"%s\\\"\"): ", filename); + if (pdfioContentTextShowf(st, "\"%s\"", filename)) + puts("PASS"); + else + return (1); + + fputs("pdfioContentTextMoveTo(514.0, 0.0): ", stdout); + if (pdfioContentTextMoveTo(st, 514.0, 0.0)) puts("PASS"); else return (1); @@ -1026,8 +1038,8 @@ write_text(pdfio_file_t *pdf, // I - PDF file else return (1); - fputs("pdfioContentTextMoveTo(36.0, 746.0): ", stdout); - if (pdfioContentTextMoveTo(st, 36.0, 746.0)) + fputs("pdfioContentTextMoveTo(36.0, 756.0): ", stdout); + if (pdfioContentTextMoveTo(st, 36.0, 756.0)) puts("PASS"); else return (1);