mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-26 13:28:22 +01:00
Fix more of the text output code (paren handling).
Update unit tests to write lines from README.md.
This commit is contained in:
parent
05df5919cd
commit
cc250e7201
@ -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)
|
||||
|
20
testpdfio.c
20
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);
|
||||
|
Loading…
Reference in New Issue
Block a user