1use std::io::Read;
2
3use cff_parser::{StringId, Table, string_by_id};
4use cff_parser::charset::Charset;
5
6fn main() {
7 let path = std::env::args().nth(1).expect("no file given");
9 let file = std::fs::File::open(&path).expect("could not open file");
10 let mut reader = std::io::BufReader::new(file);
11 let mut buffer = Vec::new();
12 reader.read_to_end(&mut buffer).expect("could not read file");
13 let table = Table::parse(&buffer).unwrap();
14 dbg!(&table);
15 println!("full name: {:?}", table.full_name());
16 println!("family name: {:?}", table.family_name());
17 println!("version: {:?}", table.version());
18 println!("notice: {:?}", table.notice());
19 println!("number of glyphs: {:?}", table.number_of_glyphs());
20
21 println!("charset:");
22 match table.charset {
23
24 Charset::ISOAdobe => println!("ISOAdobe"),
25 Charset::Expert => println!("Expert"),
26 Charset::ExpertSubset => println!("ExpertSubset"),
27 Charset::Format0(ref array) => {
28 println!("Format0:");
29 for sid in array.clone() {
30 println!(" {:?}", string_by_id(&table, sid));
31 }
32 }
33 Charset::Format1(ref array) => {
34 println!("Format1:");
35 for range in array.clone() {
36 let sid = range.first;
37 let count = range.left;
38 println!(" {:?} {:?}", sid, count);
39 for i in 0..=count {
40 println!(" {:?}", string_by_id(&table, StringId(sid.0 + u16::from(i))));
41 }
42 }
43 }
44 Charset::Format2(ref array) => {
45 println!("Format2:");
46 for range in array.clone() {
47 let sid = range.first;
48 let count = range.left;
49 println!(" {:?} {:?}", sid, count);
50 for i in 0..=count {
51 println!(" {:?}", string_by_id(&table, StringId(sid.0 + i)));
52 }
53 }
54 }
55 }
56 println!("encoding:");
57 match table.encoding.kind {
58 cff_parser::EncodingKind::Standard => println!("Standard"),
59 cff_parser::EncodingKind::Expert => println!("Expert"),
60 cff_parser::EncodingKind::Format0(ref array) => {
61 println!("Format0:");
62 for code in array.clone() {
63 println!(" {:?}", code);
64 }
65 }
66 cff_parser::EncodingKind::Format1(ref array) => {
67 println!("Format1:");
68 for range in array.clone() {
69 println!(" {:?} {:?}", range.first, range.left);
70 }
71 }
72 }
73}