Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deref polymorphism #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 9 additions & 13 deletions src/hb/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use ttf_parser::gdef::GlyphClass;
use ttf_parser::{GlyphId, RgbaColor};

use super::buffer::GlyphPropsFlags;
use super::fonta;
use super::common::TagExt;
use super::fonta;
use super::ot_layout::TableIndex;
use crate::Variation;

Expand All @@ -22,15 +22,6 @@ pub struct hb_font_t<'a> {
pub(crate) points_per_em: Option<f32>,
}

impl<'a> core::ops::Deref for hb_font_t<'a> {
type Target = ttf_parser::Face<'a>;

#[inline]
fn deref(&self) -> &Self::Target {
&self.ttfp_face
}
}

impl<'a> hb_font_t<'a> {
/// Creates a new `Face` from data.
///
Expand Down Expand Up @@ -79,10 +70,15 @@ impl<'a> hb_font_t<'a> {
self.points_per_em = ptem;
}

pub(crate) fn tables(&self) -> &ttf_parser::FaceTables<'a> {
self.ttfp_face.tables()
}

/// Sets font variations.
pub fn set_variations(&mut self, variations: &[Variation]) {
for variation in variations {
self.ttfp_face.set_variation(ttf_parser::Tag(variation.tag.as_u32()), variation.value);
self.ttfp_face
.set_variation(ttf_parser::Tag(variation.tag.as_u32()), variation.value);
}
self.font.set_coords(self.ttfp_face.variation_coordinates());
}
Expand Down Expand Up @@ -215,7 +211,7 @@ impl<'a> hb_font_t<'a> {
return false;
}

if let Some(clip_box) = colr.clip_box(glyph, self.variation_coordinates()) {
if let Some(clip_box) = colr.clip_box(glyph, self.ttfp_face.variation_coordinates()) {
// Floor
glyph_extents.x_bearing = (clip_box.x_min).round() as i32;
glyph_extents.y_bearing = (clip_box.y_max).round() as i32;
Expand All @@ -230,7 +226,7 @@ impl<'a> hb_font_t<'a> {
glyph,
0,
&mut extents_data,
self.variation_coordinates(),
self.ttfp_face.variation_coordinates(),
RgbaColor::new(0, 0, 0, 0),
)
.is_some();
Expand Down
Loading