Skip to content

Commit

Permalink
swf: Add test for DefineFont2/3 roundtrips
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian17 committed Oct 8, 2023
1 parent 3e5482a commit cea0f1b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions swf/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2753,4 +2753,48 @@ mod tests {
assert_eq!(buf, expected);
}
}

#[test]
fn write_font_3() {
use crate::read::Reader;

let font = Font {
version: 3,
id: 1,
name: SwfStr::from_bytes(b"font"),
language: Language::Unknown,
layout: None,
glyphs: vec![Glyph {
shape_records: vec![
ShapeRecord::StraightEdge {
delta: PointDelta::new(Twips::ONE, -Twips::ONE),
},
ShapeRecord::CurvedEdge {
control_delta: PointDelta::new(Twips::ONE, Twips::ONE),
anchor_delta: PointDelta::new(Twips::ONE, -Twips::ONE),
},
ShapeRecord::StraightEdge {
delta: PointDelta::new(Twips::ZERO, Twips::ZERO),
},
ShapeRecord::CurvedEdge {
control_delta: PointDelta::new(Twips::ZERO, Twips::ZERO),
anchor_delta: PointDelta::new(Twips::ZERO, Twips::ZERO),
},
],
code: 1,
advance: 0,
bounds: None,
}],
flags: FontFlag::empty(),
};

let mut buf = Vec::new();
let mut writer = Writer::new(&mut buf, 13);
writer.write_define_font_2(&font).unwrap();

let mut reader = Reader::new(&buf, 13);
let tag = reader.read_tag().unwrap();

assert_eq!(tag, Tag::DefineFont2(Box::new(font)));
}
}

0 comments on commit cea0f1b

Please sign in to comment.