Skip to content

Commit 2bf0c5a

Browse files
committed
Don't allow inserting empty codepoints
1 parent 326f159 commit 2bf0c5a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

crates/krilla/src/object/font/cid_font.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ impl CIDFont {
103103

104104
#[inline]
105105
pub(crate) fn set_codepoints(&mut self, cid: Cid, text: String) {
106-
self.cmap_entries.insert(cid, text);
106+
if !text.is_empty() {
107+
self.cmap_entries.insert(cid, text);
108+
}
107109
}
108110

109111
#[inline]
@@ -254,6 +256,7 @@ impl CIDFont {
254256
// For the .notdef glyph, it's fine if no mapping exists, since it is included
255257
// even if it was not referenced in the text.
256258
for g in 1..self.glyph_remapper.num_gids() {
259+
println!("{:?}", self.cmap_entries.get(&g));
257260
match self.cmap_entries.get(&g) {
258261
None => sc.register_validation_error(ValidationError::InvalidCodepointMapping(
259262
self.font.clone(),

crates/krilla/src/object/font/type3_font.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ impl Type3Font {
135135

136136
#[inline]
137137
pub(crate) fn set_codepoints(&mut self, gid: Gid, text: String) {
138-
self.cmap_entries.insert(gid, text);
138+
if !text.is_empty() {
139+
self.cmap_entries.insert(gid, text);
140+
}
139141
}
140142

141143
#[inline]

0 commit comments

Comments
 (0)