mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-25 12:58:21 +01:00
Fix widths for base fonts (was converting back to UTF-8 instead of preserving
the CP-1252 character set.
This commit is contained in:
parent
d3d6683041
commit
2e5319a623
@ -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
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user