cidmap#
a JFLib library crate -- crate root lib/cidmap/src/lib.rs
cidmap -- the predefined CMaps of Adobe's Chinese, Japanese and Korean character collections
(character code -> CID) and their CID -> Unicode tables
predefined(name) -> Option<CMap> a CMap of ISO 32000-1 Table 118 by its name
(90ms-RKSJ-H, GBK-EUC-H, UniJIS-UTF16-V, ...)
names() -> Vec<&'static str> the CMaps this crate has (59)
CMap { name, collection, vertical, codespace }
code_len(bytes) -> usize the length of the code at the start (1 to 4 bytes)
cid(code, len) -> Option<u32> a code's CID (its CID range, else its notdef range)
ranges() -> &[CidRange] every code -> CID range, with what usecmap brings in
Collection { Gb1, Cns1, Japan1, Korea1 }
from_ordering(b"Japan1"), ordering(), lang() (zh-Hans, zh-Hant, ja, ko)
to_unicode(collection) -> ToUnicode CID -> text (Adobe's Adobe-Japan1-UCS2 and the like)
get(cid) -> Option<&str>, len()
The data (data/cidmap.bin, made by tools/cidmap_gen.py from Adobe's files, BSD-3-Clause:
licenses/adobe-cmap-resources-LICENSE.md) is one zstd frame per collection, unpacked when a
CMap or table of it is asked for; callers keep what they use. Identity-H and -V are not here:
their CID is the two-byte code, with no collection.
cidmap crate root#
enum Collectionone of Adobe's four CJK character collections (Registry "Adobe")Gb1-- Adobe-GB1: simplified ChineseCns1-- Adobe-CNS1: traditional ChineseJapan1-- Adobe-Japan1: JapaneseKorea1-- Adobe-Korea1: Korean
impl Collection
const ALL: [Collection; 4] = [Collection::Gb1, Collection::Cns1, Collection::Japan1, C ...fn from_ordering(o: &[u8]) -> Option<Collection>a CIDSystemInfo's Ordering (with Registry "Adobe")fn ordering(self) -> &'static strfn lang(self) -> &'static strthe language tag of its text, for choosing a font (Han characters take its forms)struct CodeSpacea range of the code space: codes oflenbytes whose every byte lies between that ofloandhilen: u8lo: [u8; 4]hi: [u8; 4]
struct CidRangethe codeslo..=hioflenbytes (big-endian, as u32) -> the CIDs fromcidonlen: u8lo: u32hi: u32cid: u32
struct CMapa predefined CMap, with what it takes in by usecmapname: &'static strcollection: Collectionvertical: bool-- WMode 1: vertical writingcodespace: Vec<CodeSpace>
impl CMap
fn code_len(&self, b: &[u8]) -> usizethe length of the code at the start ofb(1 to 4 bytes): the shortest the code space has for it, else the code space's shortest lengthfn cid(&self, code: u32, len: u8) -> Option<u32>the CID of a code oflenbytes: its CID range's, else its notdef range'sfn ranges(&self) -> &[CidRange]every code -> CID range, sorted by (len, lo)struct ToUnicodeCID -> Unicode text of a collection
impl ToUnicode
fn get(&self, cid: u32) -> Option<&str>a CID's text (a character, or a few of them)fn len(&self) -> usizethe number of CIDs (with text or not)fn is_empty(&self) -> boolfn predefined(name: &[u8]) -> Option<CMap>a predefined CMap by its name (ISO 32000-1 Table 118: GB-EUC-H to UniKS-UTF16-V)fn names() -> Vec<&'static str>the names of the CMaps this crate has, in the order of the data filefn to_unicode(c: Collection) -> ToUnicodea collection's CID -> Unicode table (empty if the data is damaged, which the tests rule out)