summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-encoding.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-03-15 11:55:06 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-03-16 14:51:41 +0100
commit1cd2046b3cce264a3d13481652868fd1c31537fc (patch)
tree8ba181113cc22f2ffe4ba1a3ed549926b747bc8c /source/pdf/pdf-encoding.c
parent2612c20b725319833caeef36ccf4240f34e0e24b (diff)
downloadmupdf-1cd2046b3cce264a3d13481652868fd1c31537fc.tar.xz
Add simple fonts with 8-bit greek and cyrillic encodings.
Use KOI8-U for Cyrillic, and ISO 8859-7 for Greek. Use with 'mutool create' using an extra argument to the %%Font directive: %%Font TmRmC Times-Roman Cyrillic BT /TmRmC 16 Tf 10 10 Td <fa c4 d2 c1 d7 d3 d4 d7 d5 ca d4 c5 21> Tj ET The alternatives are "Latin", "Greek", and "Cyrillic".
Diffstat (limited to 'source/pdf/pdf-encoding.c')
-rw-r--r--source/pdf/pdf-encoding.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source/pdf/pdf-encoding.c b/source/pdf/pdf-encoding.c
index 0b2cdfca..04874457 100644
--- a/source/pdf/pdf-encoding.c
+++ b/source/pdf/pdf-encoding.c
@@ -85,3 +85,41 @@ pdf_lookup_agl_duplicates(int ucs)
}
return empty_dup_list;
}
+
+int pdf_cyrillic_from_unicode(int u)
+{
+ int l = 0;
+ int r = nelem(koi8u_from_unicode) - 1;
+ if (u < 128)
+ return u;
+ while (l <= r)
+ {
+ int m = (l + r) >> 1;
+ if (u < koi8u_from_unicode[m].u)
+ r = m - 1;
+ else if (u > koi8u_from_unicode[m].u)
+ l = m + 1;
+ else
+ return koi8u_from_unicode[m].c;
+ }
+ return -1;
+}
+
+int pdf_greek_from_unicode(int u)
+{
+ int l = 0;
+ int r = nelem(iso8859_7_from_unicode) - 1;
+ if (u < 128)
+ return u;
+ while (l <= r)
+ {
+ int m = (l + r) >> 1;
+ if (u < iso8859_7_from_unicode[m].u)
+ r = m - 1;
+ else if (u > iso8859_7_from_unicode[m].u)
+ l = m + 1;
+ else
+ return iso8859_7_from_unicode[m].c;
+ }
+ return -1;
+}