Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/cff/subroutines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<'a> SubroutineCollection<'a> {
}
}

pub fn get_handler(&self, fd_index: u8) -> Option<SubroutineHandler> {
pub fn get_handler(&self, fd_index: u8) -> Option<SubroutineHandler<'_>> {
self.subroutines.get(fd_index as usize).map(|s| s.get_handler())
}
}
Expand All @@ -29,7 +29,7 @@ impl<'a> SubroutineContainer<'a> {
Self { subroutines }
}

pub fn get_handler(&self) -> SubroutineHandler {
pub fn get_handler(&self) -> SubroutineHandler<'_> {
SubroutineHandler::new(self.subroutines.as_ref())
}
}
Expand Down
26 changes: 15 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ use crate::read::{Readable, Reader};
pub use crate::remapper::GlyphRemapper;
use crate::write::{Writeable, Writer};
use crate::Error::{MalformedFont, Unimplemented, UnknownKind};
use std::array::TryFromSliceError;
use std::borrow::Cow;
use std::fmt::{self, Debug, Display, Formatter};
use std::marker::PhantomData;
use std::str::FromStr;

/// Subset the font face to include only the necessary glyphs and tables.
///
Expand Down Expand Up @@ -169,7 +171,7 @@ fn prepare_context<'a>(
let _ = variation_coordinates;

#[cfg(not(feature = "variable-fonts"))]
let interjector = Interjector::Dummy(PhantomData::default());
let interjector = Interjector::Dummy(PhantomData);
// For CFF, we _always_ want to do normal subsetting, since CFF cannot have variations.
// For TrueType, we prefer normal subsetting in case no variation was requested. If we do have
// variations, we use `skrifa` to instance.
Expand All @@ -181,7 +183,7 @@ fn prepare_context<'a>(
{
// For TrueType and CFF, we are still best off using the normal subsetting logic in case no variation coordinates
// have been passed.
Interjector::Dummy(PhantomData::default())
Interjector::Dummy(PhantomData)
} else {
Interjector::Skrifa(
interjector::skrifa::SkrifaInterjector::new(
Expand Down Expand Up @@ -494,21 +496,23 @@ impl Tag {
Self(*tag)
}

/// Try to create a new tag from a string.
///
/// Return `None` if the string is not 4 bytes in size.
pub fn from_str(s: &str) -> Option<Self> {
let tag: [u8; 4] = s.as_bytes().try_into().ok()?;

Some(Self(tag))
}

/// Return the value of the tag.
pub fn get(&self) -> &[u8; 4] {
&self.0
}
}

impl FromStr for Tag {
type Err = TryFromSliceError;

/// Tries to create a new tag from a string.
///
/// Return `Err(_)` if the string is not 4 bytes in size.
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
s.as_bytes().try_into().map(Self)
}
}

#[allow(unused)]
impl Tag {
// General tables.
Expand Down
1 change: 1 addition & 0 deletions tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use skrifa::MetadataProvider;
use std::error::Error;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str::FromStr;
use subsetter::{subset, subset_with_variations, GlyphRemapper, Tag};
use ttf_parser::GlyphId;

Expand Down
Loading