From f48db730bc063809c8c86b4434a91facd2c4846c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 29 Jun 2018 14:28:46 +0200 Subject: Use real WinAnsi encoding when writing appearance stream text. --- source/pdf/pdf-encoding.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source/pdf/pdf-encoding.c') diff --git a/source/pdf/pdf-encoding.c b/source/pdf/pdf-encoding.c index 04874457..f4fe584c 100644 --- a/source/pdf/pdf-encoding.c +++ b/source/pdf/pdf-encoding.c @@ -123,3 +123,22 @@ int pdf_greek_from_unicode(int u) } return -1; } + +int pdf_winansi_from_unicode(int u) +{ + int l = 0; + int r = nelem(winansi_from_unicode) - 1; + if (u < 128) + return u; + while (l <= r) + { + int m = (l + r) >> 1; + if (u < winansi_from_unicode[m].u) + r = m - 1; + else if (u > winansi_from_unicode[m].u) + l = m + 1; + else + return winansi_from_unicode[m].c; + } + return -1; +} -- cgit v1.2.3