Skip to content

Commit

Permalink
Use the supported settings API
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Sep 23, 2024
1 parent d751c7d commit 48a73ba
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions vello_encoding/src/glyph_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::{Encoding, StreamOffsets};

use peniko::{Font, Style};
use skrifa::instance::{NormalizedCoord, Size};
use skrifa::outline::{HintingInstance, HintingMode, LcdLayout, OutlineGlyphFormat};
use skrifa::outline::{HintingInstance, HintingOptions, OutlineGlyphFormat};
use skrifa::{GlyphId, MetadataProvider, OutlineGlyphCollection};

#[derive(Default)]
Expand Down Expand Up @@ -245,13 +245,19 @@ pub(crate) struct HintKey<'a> {

impl<'a> HintKey<'a> {
fn instance(&self) -> Option<HintingInstance> {
HintingInstance::new(self.outlines, self.size, self.coords, HINTING_MODE).ok()
HintingInstance::new(self.outlines, self.size, self.coords, HINTING_OPTIONS).ok()
}
}

const HINTING_MODE: HintingMode = HintingMode::Smooth {
lcd_subpixel: Some(LcdLayout::Horizontal),
preserve_linear_metrics: true,
const HINTING_OPTIONS: HintingOptions = HintingOptions {
engine: skrifa::outline::Engine::AutoFallback,
target: skrifa::outline::Target::Smooth {
mode: skrifa::outline::SmoothMode::Lcd,
// TODO: Set based on whether the anti-aliasing mode is Area?
symmetric_rendering: false,
// TODO: Does Parley handle layout in a hinting-aware way?
preserve_linear_metrics: true,
},
};

#[derive(Default)]
Expand All @@ -278,7 +284,7 @@ impl HintCache {
entry.font_index = key.font_index;
entry
.instance
.reconfigure(key.outlines, key.size, key.coords, HINTING_MODE)
.reconfigure(key.outlines, key.size, key.coords, HINTING_OPTIONS)
.ok()?;
}
Some(&entry.instance)
Expand Down

0 comments on commit 48a73ba

Please sign in to comment.