Skip to main content

charcode_from_unicode

Function charcode_from_unicode 

Source
pub fn charcode_from_unicode(cmap: &CMap, unicode: char) -> CharCode
Expand description

The character code that would draw unicode through this CMap, or CharCode(0) when none would.

A linear scan of the collection’s whole CID→Unicode table looking for a match, then a reverse table lookup — expensive, and only used when a CID font is asked to draw a character it can only identify by Unicode.

use pdfrum_cmap::{CharCode, charcode_from_unicode, predefined};
use pdfrum_object::Name;

let gb = predefined(&Name::from("GB-EUC-H")).unwrap();
// U+0020 is CID 0x1E24 in Adobe-GB1, which GB-EUC-H reaches from code 0x20.
assert_eq!(charcode_from_unicode(&gb, ' '), CharCode(0x20));