diff options
author | Koji Otani <sho@bbr.jp> | 2007-12-10 23:24:14 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2007-12-10 23:24:14 +0100 |
commit | f24259cddb9c5e02cf9d2071bfa0106f3e88bd59 (patch) | |
tree | f54e51bb721573b2f364f28dfcbe497d592bd52e /fofi | |
parent | 7cbabbf378cf5a9c0411558ff02b44dec2040ea1 (diff) |
Display characters outside of unicode BMP with TT font
Diffstat (limited to 'fofi')
-rw-r--r-- | fofi/FoFiTrueType.cc | 33 | ||||
-rw-r--r-- | fofi/FoFiTrueType.h | 2 |
2 files changed, 30 insertions, 5 deletions
diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc index 77a7ad2c..d702123f 100644 --- a/fofi/FoFiTrueType.cc +++ b/fofi/FoFiTrueType.cc @@ -321,10 +321,10 @@ int FoFiTrueType::findCmap(int platform, int encoding) { return -1; } -Gushort FoFiTrueType::mapCodeToGID(int i, int c) { +Gushort FoFiTrueType::mapCodeToGID(int i, Guint c) { Gushort gid; - int segCnt, segEnd, segStart, segDelta, segOffset; - int cmapFirst, cmapLen; + Guint segCnt, segEnd, segStart, segDelta, segOffset; + Guint cmapFirst, cmapLen; int pos, a, b, m; GBool ok; @@ -335,7 +335,7 @@ Gushort FoFiTrueType::mapCodeToGID(int i, int c) { pos = cmaps[i].offset; switch (cmaps[i].fmt) { case 0: - if (c < 0 || c >= cmaps[i].len - 6) { + if (c >= cmaps[i].len - 6) { return 0; } gid = getU8(cmaps[i].offset + 6 + c, &ok); @@ -384,6 +384,31 @@ Gushort FoFiTrueType::mapCodeToGID(int i, int c) { } gid = getU16BE(pos + 10 + 2 * (c - cmapFirst), &ok); break; + case 12: + segCnt = getU32BE(pos + 12, &ok); + a = -1; + b = segCnt - 1; + segEnd = getU32BE(pos + 16 + 12*b+4, &ok); + if (c > segEnd) { + return 0; + } + // invariant: seg[a].end < code <= seg[b].end + while (b - a > 1 && ok) { + m = (a + b) / 2; + segEnd = getU32BE(pos + 16 + 12*m+4, &ok); + if (segEnd < c) { + a = m; + } else { + b = m; + } + } + segStart = getU32BE(pos + 16 + 12*b, &ok); + segDelta = getU32BE(pos + 16 + 12*b+8, &ok); + if (c < segStart) { + return 0; + } + gid = segDelta + (c-segStart); + break; default: return 0; } diff --git a/fofi/FoFiTrueType.h b/fofi/FoFiTrueType.h index 2ef5ebcf..af6dac28 100644 --- a/fofi/FoFiTrueType.h +++ b/fofi/FoFiTrueType.h @@ -54,7 +54,7 @@ public: int findCmap(int platform, int encoding); // Return the GID corresponding to <c> according to the <i>th cmap. - Gushort mapCodeToGID(int i, int c); + Gushort mapCodeToGID(int i, Guint c); // map gid to vertical glyph gid if exist. // if not exist return original gid |