Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added object parse to get_page_fonts #249

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,28 @@ impl Document {
fn collect_fonts_from_resources<'a>(
resources: &'a Dictionary, fonts: &mut BTreeMap<Vec<u8>, &'a Dictionary>, doc: &'a Document,
) {
if let Ok(font_dict) = resources.get(b"Font").and_then(Object::as_dict) {
for (name, value) in font_dict.iter() {
let font = match *value {
Object::Reference(id) => doc.get_dictionary(id).ok(),
Object::Dictionary(ref dict) => Some(dict),
_ => None,
};
if !fonts.contains_key(name) {
font.map(|font| fonts.insert(name.clone(), font));
if let Ok(font) = resources.get(b"Font") {
let font_dict = match font {
Object::Reference(ref id) => {
doc.get_object(*id).and_then(Object::as_dict).ok()
},
Object::Dictionary(ref dict) => {
Some(dict)
},
_ => {
None
}
};
if let Some(font_dict) = font_dict {
for (name, value) in font_dict.iter() {
let font = match *value {
Object::Reference(id) => doc.get_dictionary(id).ok(),
Object::Dictionary(ref dict) => Some(dict),
_ => None,
};
if !fonts.contains_key(name) {
font.map(|font| fonts.insert(name.clone(), font));
}
}
}
}
Expand Down