@@ -15,7 +15,6 @@ use std::hash::Hash;
15
15
use std:: sync:: Arc ;
16
16
use subsetter:: GlyphRemapper ;
17
17
use ttf_parser:: { name_id, Face , GlyphId , PlatformId , Tag } ;
18
- use unicode_properties:: { GeneralCategory , UnicodeGeneralCategory } ;
19
18
use usvg:: { Fill , Group , ImageKind , Node , PaintOrder , Stroke , Transform } ;
20
19
21
20
const CFF : Tag = Tag :: from_bytes ( b"CFF " ) ;
@@ -154,8 +153,7 @@ pub fn write_font(
154
153
155
154
font_descriptor. finish ( ) ;
156
155
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 ) ) ?;
159
157
chunk. cmap ( cmap_ref, & cmap. finish ( ) ) ;
160
158
161
159
// Subset and write the font's bytes.
@@ -173,33 +171,9 @@ pub fn write_font(
173
171
174
172
/// Create a /ToUnicode CMap.
175
173
fn create_cmap (
176
- ttf : & Face ,
177
174
glyph_set : & mut BTreeMap < u16 , String > ,
178
175
glyph_remapper : & GlyphRemapper ,
179
176
) -> 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
-
203
177
// Produce a reverse mapping from glyphs' CIDs to unicode strings.
204
178
let mut cmap = UnicodeCmap :: new ( CMAP_NAME , SYSTEM_INFO ) ;
205
179
for ( & g, text) in glyph_set. iter ( ) {
0 commit comments