@@ -15,7 +15,6 @@ use std::hash::Hash;
1515use std:: sync:: Arc ;
1616use subsetter:: GlyphRemapper ;
1717use ttf_parser:: { name_id, Face , GlyphId , PlatformId , Tag } ;
18- use unicode_properties:: { GeneralCategory , UnicodeGeneralCategory } ;
1918use usvg:: { Fill , Group , ImageKind , Node , PaintOrder , Stroke , Transform } ;
2019
2120const CFF : Tag = Tag :: from_bytes ( b"CFF " ) ;
@@ -154,8 +153,7 @@ pub fn write_font(
154153
155154 font_descriptor. finish ( ) ;
156155
157- let cmap =
158- create_cmap ( & ttf, glyph_set, glyph_remapper) . ok_or ( SubsetError ( font. id ) ) ?;
156+ let cmap = create_cmap ( glyph_set, glyph_remapper) . ok_or ( SubsetError ( font. id ) ) ?;
159157 chunk. cmap ( cmap_ref, & cmap. finish ( ) ) ;
160158
161159 // Subset and write the font's bytes.
@@ -173,33 +171,9 @@ pub fn write_font(
173171
174172/// Create a /ToUnicode CMap.
175173fn create_cmap (
176- ttf : & Face ,
177174 glyph_set : & mut BTreeMap < u16 , String > ,
178175 glyph_remapper : & GlyphRemapper ,
179176) -> Option < UnicodeCmap > {
180- // For glyphs that have codepoints mapping to them in the font's cmap table,
181- // we prefer them over pre-existing text mappings from the document. Only
182- // things that don't have a corresponding codepoint (or only a private-use
183- // one) like the "Th" in Linux Libertine get the text of their first
184- // occurrences in the document instead.
185- for subtable in ttf. tables ( ) . cmap . into_iter ( ) . flat_map ( |table| table. subtables ) {
186- if !subtable. is_unicode ( ) {
187- continue ;
188- }
189-
190- subtable. codepoints ( |n| {
191- let Some ( c) = std:: char:: from_u32 ( n) else { return } ;
192- if c. general_category ( ) == GeneralCategory :: PrivateUse {
193- return ;
194- }
195-
196- let Some ( GlyphId ( g) ) = ttf. glyph_index ( c) else { return } ;
197- if glyph_set. contains_key ( & g) {
198- glyph_set. insert ( g, c. into ( ) ) ;
199- }
200- } ) ;
201- }
202-
203177 // Produce a reverse mapping from glyphs' CIDs to unicode strings.
204178 let mut cmap = UnicodeCmap :: new ( CMAP_NAME , SYSTEM_INFO ) ;
205179 for ( & g, text) in glyph_set. iter ( ) {
0 commit comments