diff --git a/Cargo.lock b/Cargo.lock index 320adb4d..43ee10fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1558,7 +1558,6 @@ dependencies = [ "subsetter", "tiny-skia", "ttf-parser", - "unicode-properties", "usvg", ] diff --git a/Cargo.toml b/Cargo.toml index ff0b1470..2bb798db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,6 @@ pdfium-render = "0.8.6" termcolor = "1.2" usvg = { version = "0.42.0", default-features = false } tiny-skia = "0.11.4" -unicode-properties = "0.1.1" resvg = { version = "0.42.0", default-features = false } subsetter = {git = "https://github.com/typst/subsetter", rev = "4e0058b"} ttf-parser = { version = "0.21.1" } @@ -50,13 +49,12 @@ bench = false [features] default = ["image", "filters", "text"] text = ["usvg/text", "resvg/text", "dep:siphasher", - "dep:subsetter", "dep:ttf-parser", "dep:unicode-properties", + "dep:subsetter", "dep:ttf-parser", "dep:fontdb"] image = ["dep:image"] filters = ["image", "dep:tiny-skia", "resvg/raster-images"] [dependencies] -unicode-properties = { workspace = true, optional = true } miniz_oxide = { workspace = true } once_cell = { workspace = true } pdf-writer = { workspace = true } diff --git a/src/lib.rs b/src/lib.rs index b8f0f700..701e0715 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,8 +49,8 @@ Among the unsupported features are currently: - The `spreadMethod` attribute of gradients - Raster images are not color managed but use PDF's DeviceRGB color space - A number of features that were added in SVG2, See -[here](https://github.com/RazrFalcon/resvg/blob/master/docs/svg2-changelog.md) for a more -comprehensive list. + [here](https://github.com/RazrFalcon/resvg/blob/master/docs/svg2-changelog.md) for a more + comprehensive list. */ mod render; diff --git a/src/render/text.rs b/src/render/text.rs index 6626287b..45c79263 100644 --- a/src/render/text.rs +++ b/src/render/text.rs @@ -15,7 +15,6 @@ use std::hash::Hash; use std::sync::Arc; use subsetter::GlyphRemapper; use ttf_parser::{name_id, Face, GlyphId, PlatformId, Tag}; -use unicode_properties::{GeneralCategory, UnicodeGeneralCategory}; use usvg::{Fill, Group, ImageKind, Node, PaintOrder, Stroke, Transform}; const CFF: Tag = Tag::from_bytes(b"CFF "); @@ -154,8 +153,7 @@ pub fn write_font( font_descriptor.finish(); - let cmap = - create_cmap(&ttf, glyph_set, glyph_remapper).ok_or(SubsetError(font.id))?; + let cmap = create_cmap(glyph_set, glyph_remapper).ok_or(SubsetError(font.id))?; chunk.cmap(cmap_ref, &cmap.finish()); // Subset and write the font's bytes. @@ -173,33 +171,9 @@ pub fn write_font( /// Create a /ToUnicode CMap. fn create_cmap( - ttf: &Face, glyph_set: &mut BTreeMap, glyph_remapper: &GlyphRemapper, ) -> Option { - // For glyphs that have codepoints mapping to them in the font's cmap table, - // we prefer them over pre-existing text mappings from the document. Only - // things that don't have a corresponding codepoint (or only a private-use - // one) like the "Th" in Linux Libertine get the text of their first - // occurrences in the document instead. - for subtable in ttf.tables().cmap.into_iter().flat_map(|table| table.subtables) { - if !subtable.is_unicode() { - continue; - } - - subtable.codepoints(|n| { - let Some(c) = std::char::from_u32(n) else { return }; - if c.general_category() == GeneralCategory::PrivateUse { - return; - } - - let Some(GlyphId(g)) = ttf.glyph_index(c) else { return }; - if glyph_set.contains_key(&g) { - glyph_set.insert(g, c.into()); - } - }); - } - // Produce a reverse mapping from glyphs' CIDs to unicode strings. let mut cmap = UnicodeCmap::new(CMAP_NAME, SYSTEM_INFO); for (&g, text) in glyph_set.iter() {