Fix widths for base fonts (was converting back to UTF-8 instead of preserving

the CP-1252 character set.
This commit is contained in:
Michael R Sweet 2024-12-13 19:56:00 -05:00
parent d3d6683041
commit 2e5319a623
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244
2 changed files with 5 additions and 20 deletions

View File

@ -138,7 +138,7 @@ typedef struct tablerow_s // Table row
// Constants...
//
#define USE_TRUETYPE 1 // Set to 1 to use Roboto TrueType fonts
#define USE_TRUETYPE 0 // Set to 1 to use Roboto TrueType fonts
#if USE_TRUETYPE
# define UNICODE_VALUE true // `true` for Unicode text, `false` for ISO-8859-1

View File

@ -1131,28 +1131,13 @@ pdfioContentTextMeasure(
break;
}
if (i >= (sizeof(_pdfio_cp1252) / sizeof(_pdfio_cp1252[0])))
if (i < (sizeof(_pdfio_cp1252) / sizeof(_pdfio_cp1252[0])))
ch = i + 0x80; // Extra characters from 0x80 to 0x9f
else
ch = '?'; // Unsupported chars map to ?
}
if (ch < 128)
{
// ASCII
*tempptr++ = (char)ch;
}
else if (ch < 2048)
{
// 2-byte UTF-8
*tempptr++ = (char)(0xc0 | ((ch >> 6) & 0x1f));
*tempptr++ = (char)(0x80 | (ch & 0x3f));
}
else
{
// 3-byte UTF-8
*tempptr++ = (char)(0xe0 | ((ch >> 12) & 0x0f));
*tempptr++ = (char)(0x80 | ((ch >> 6) & 0x3f));
*tempptr++ = (char)(0x80 | (ch & 0x3f));
}
*tempptr++ = (char)ch;
}
*tempptr = '\0';