Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
yutannihilation committed Sep 26, 2023
1 parent 0017274 commit 19dfbde
Showing 1 changed file with 12 additions and 27 deletions.
39 changes: 12 additions & 27 deletions src/rust/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::builder::LyonPathBuilder;

use once_cell::sync::Lazy;

use std::{error::Error, fmt::Display};
use ttf_parser::GlyphId;

pub(crate) static FONTDB: Lazy<fontdb::Database> = Lazy::new(|| {
Expand All @@ -18,6 +17,18 @@ pub enum FontLoadingError {
NoAvailableFonts,
}

impl From<ttf_parser::FaceParsingError> for FontLoadingError {
fn from(err: ttf_parser::FaceParsingError) -> Self {
Self::FaceParsingError(err)
}
}

impl From<std::io::Error> for FontLoadingError {
fn from(err: std::io::Error) -> Self {
Self::IOError(err)
}
}

impl From<FontLoadingError> for savvy::Error {
fn from(value: FontLoadingError) -> Self {
let msg = match value {
Expand All @@ -32,32 +43,6 @@ impl From<FontLoadingError> for savvy::Error {
}
}

impl Display for FontLoadingError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
FontLoadingError::FaceParsingError(err) => err.fmt(f),
FontLoadingError::IOError(err) => err.fmt(f),
FontLoadingError::NoAvailableFonts => {
write!(f, "No available fonts is found on the machine")
}
}
}
}

impl Error for FontLoadingError {}

impl From<ttf_parser::FaceParsingError> for FontLoadingError {
fn from(err: ttf_parser::FaceParsingError) -> Self {
Self::FaceParsingError(err)
}
}

impl From<std::io::Error> for FontLoadingError {
fn from(err: std::io::Error) -> Self {
Self::IOError(err)
}
}

impl LyonPathBuilder {
pub fn outline(
&mut self,
Expand Down

0 comments on commit 19dfbde

Please sign in to comment.