diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-03-11 18:02:47 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-03-11 18:02:47 +0100 |
| commit | 77e52996673e1c3aa7a8beae4d1ee7eb9be0bafb (patch) | |
| tree | 19184c9a2ebfae58fe422a290e8678b6317729f2 /src/font.rs | |
| parent | 67281c4f469716c7f2341676f2ad656d8c544ea3 (diff) | |
Tidy up PDF crate 🧹
Diffstat (limited to 'src/font.rs')
| -rw-r--r-- | src/font.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/font.rs b/src/font.rs index 1e22e47d..2f6e2b6a 100644 --- a/src/font.rs +++ b/src/font.rs @@ -1,9 +1,9 @@ //! Font utility and subsetting. +use std::collections::HashMap; use std::error; use std::fmt; use std::io::{self, Cursor, Seek, SeekFrom}; -use std::collections::HashMap; use byteorder::{BE, ReadBytesExt, WriteBytesExt}; use opentype::{OpenTypeReader, Outlines, TableRecord, Tag}; use opentype::tables::{Header, Name, NameEntry, CharMap, MaximumProfile, HorizontalMetrics, OS2}; @@ -49,11 +49,13 @@ impl Font { } /// Map a character to it's glyph index. + #[inline] pub fn map(&self, c: char) -> u16 { self.mapping.get(&c).map(|&g| g).unwrap_or(self.default_glyph) } /// Encode the given text for our font (into glyph ids). + #[inline] pub fn encode(&self, text: &str) -> Vec<u8> { println!("encoding {} with {:?}", text, self.mapping); let mut bytes = Vec::with_capacity(2 * text.len()); @@ -457,7 +459,8 @@ impl<'p> Subsetter<'p> { Err(_) => return Err(SubsettingError::MissingTable(tag.to_string())), }; - self.font.program.get(record.offset as usize .. (record.offset + record.length) as usize) + self.font.program + .get(record.offset as usize .. (record.offset + record.length) as usize) .take_bytes() } @@ -552,6 +555,7 @@ pub enum SubsettingError { } impl error::Error for SubsettingError { + #[inline] fn source(&self) -> Option<&(dyn error::Error + 'static)> { match self { SubsettingError::Opentype(err) => Some(err), |
