Skip to content

Commit

Permalink
track marked content stack
Browse files Browse the repository at this point in the history
  • Loading branch information
connorskees committed Jun 16, 2023
1 parent 228d707 commit 2157eec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/font/true_type/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<'a> TrueTypeParser<'a> {
}

fn parse_compound_glyph(&mut self) -> anyhow::Result<Vec<CompoundGlyphPartDescription>> {
todo!()
todo!("ttf compound glyph")
}

pub fn parse_glyph(&mut self) -> anyhow::Result<TrueTypeGlyph> {
Expand Down
25 changes: 20 additions & 5 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub struct Renderer<'a, 'b: 'a> {
resources: Option<Rc<Resources<'b>>>,
current_path: Option<Path>,
pending_clip: Option<FillRule>,
marked_content_stack: Vec<MarkedContentMarker<'b>>,
}

impl<'a, 'b: 'a> Renderer<'a, 'b> {
Expand Down Expand Up @@ -135,6 +136,7 @@ impl<'a, 'b: 'a> Renderer<'a, 'b> {
page,
current_path: None,
pending_clip: None,
marked_content_stack: Vec::new(),
}
}

Expand Down Expand Up @@ -1374,7 +1376,10 @@ impl<'a, 'b: 'a> Renderer<'a, 'b> {
fn begin_marked_content_sequence(&mut self) -> PdfResult<()> {
let tag = self.pop_name()?;

println!("unimplemented marked content operator: BDC {}", tag);
self.marked_content_stack.push(MarkedContentMarker {
tag,
properties: None,
});

Ok(())
}
Expand All @@ -1386,17 +1391,20 @@ impl<'a, 'b: 'a> Renderer<'a, 'b> {
/// associated with it in the Properties subdictionary of the current
/// resource dictionary
fn begin_marked_content_sequence_with_property_list(&mut self) -> PdfResult<()> {
let _properties = self.pop::<Object<'b>>()?;
let _tag = self.pop_name()?;
let properties = self.pop::<Object<'b>>()?;
let tag = self.pop_name()?;

println!("todo: unimplemented marked content operator: BDC");
self.marked_content_stack.push(MarkedContentMarker {
tag,
properties: Some(properties),
});

Ok(())
}

/// End a marked-content sequence begun by a BMC or BDC operator.
fn end_marked_content_sequence(&mut self) -> PdfResult<()> {
println!("todo: unimplemented marked content operator: EMC");
self.marked_content_stack.pop();

Ok(())
}
Expand Down Expand Up @@ -1525,3 +1533,10 @@ impl FontMetrics for CidFontWidths {
/ 1000.0
}
}

#[derive(Debug, Clone)]
struct MarkedContentMarker<'a> {
tag: String,
// todo: type
properties: Option<Object<'a>>,
}

0 comments on commit 2157eec

Please sign in to comment.