mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 19:51:26 -05:00
Fonts: text is hinted again, with skrifa taken from the craft-libs pin
adopt_context turned egui's font hinting off in both themes of every context it adopted (ui_fonts::hinting_off), because skrifa 0.44's automatic hinter never finished a tall narrow Hebrew letter in a face without hinting instructions and the font list stopped responding. craft-libs#5222 merged the blue-zone exit into craft-libs vendor/skrifa, and the craft-libs pin holds it. The skrifa entry in [patch.crates-io] now takes skrifa 0.44 from the pinned craft-libs rev (f9e5cecc9c) instead of the pull request's commit (37d0532f42); vendor/skrifa is the same at both revs. hinting_off and its call are removed, so interface text and the font list and picker samples are hinted as egui does by default. Type on the canvas is drawn from its own outlines and does not change. a_face_without_hinting_instructions_draws_its_sample now checks that a context the app adopts hints text in its global, light and dark styles, and still draws U+05D1 from a face without instructions.
This commit is contained in:
Generated
+1
-1
@@ -7618,7 +7618,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.44.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=37d0532f42eb3421769c8a454e3e25a20fbcff97#37d0532f42eb3421769c8a454e3e25a20fbcff97"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"read-fonts 0.41.0",
|
||||
|
||||
+1
-2
@@ -211,8 +211,7 @@ hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "f9e
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" }
|
||||
# skrifa 0.44 (epaint, glifo, usvg) with the automatic hinter's long blue-zone exit (craft-libs vendor/skrifa).
|
||||
# It stays at this rev until craft-libs#5222 merges.
|
||||
skrifa = { git = "https://github.com/storytold/craft-libs", rev = "37d0532f42eb3421769c8a454e3e25a20fbcff97" }
|
||||
skrifa = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
|
||||
|
||||
@@ -127,14 +127,13 @@ impl VectorcraftApp {
|
||||
/// after losing its graphics), everything uploaded to the old one is made again: the fonts and
|
||||
/// theme, the canvas, the place cursor's thumbnails and every [`TexCache`]. The host hands it
|
||||
/// the window's context when it creates the app, so the first frame's input has the app's
|
||||
/// commands. Each new context draws its text without hinting ([`crate::ui_fonts::hinting_off`]).
|
||||
/// commands.
|
||||
pub fn adopt_context(&mut self, ctx: &egui::Context) {
|
||||
let tag = context_tag(ctx);
|
||||
self.ui_ctx = Some(ctx.clone());
|
||||
if self.context == tag {
|
||||
return;
|
||||
}
|
||||
crate::ui_fonts::hinting_off(ctx);
|
||||
if self.context != 0 {
|
||||
log::info!("vectorcraft: new graphics context: uploading the UI again");
|
||||
forget_textures();
|
||||
|
||||
@@ -77,8 +77,9 @@ fn samples_show_the_text_in_the_family_or_a_generic_sample() {
|
||||
|
||||
/// A face with no hinting instructions draws a sample in a context the app has adopted, as the font list and the
|
||||
/// font picker draw each family's sample in its own face (a document face of the context): a Hebrew letter that is a
|
||||
/// bar 20 by 700 thousandths of an em, whose blue zones the automatic hinter of skrifa 0.44 never finishes measuring.
|
||||
/// The face is served to the fixture's context only, so the font database other tests read does not change. The
|
||||
/// bar 20 by 700 thousandths of an em. The context hints text in both themes, so the sample goes through skrifa's
|
||||
/// automatic hinter, whose long blue-zone search for such a letter ends with the vendored skrifa 0.44 from craft-libs
|
||||
/// (the `skrifa` entry in the workspace's `[patch.crates-io]`). The face is served to the fixture's context only, so the font database other tests read does not change. The
|
||||
/// sample is one rasterized glyph from that face. It is drawn on a thread of its own, and the test fails when it has
|
||||
/// not ended after 300 s.
|
||||
#[test]
|
||||
@@ -145,9 +146,9 @@ fn a_face_without_hinting_instructions_draws_its_sample() {
|
||||
let (texts, [hinting, light_hinting, dark_hinting], fixture_has_glyph, nonempty_glyph) =
|
||||
rx.recv_timeout(std::time::Duration::from_secs(300)).unwrap_or_else(|e| panic!("drawing the sample: {e}"));
|
||||
assert!(texts.iter().any(|t| t == "\u{5d1}"), "the sample is the letter, in the face: {texts:?}");
|
||||
assert!(!hinting, "a context the app adopts draws text without hinting");
|
||||
assert!(!light_hinting, "the light theme draws text without hinting");
|
||||
assert!(!dark_hinting, "the dark theme draws text without hinting");
|
||||
assert!(hinting, "a context the app adopts hints text");
|
||||
assert!(light_hinting, "the light theme hints text");
|
||||
assert!(dark_hinting, "the dark theme hints text");
|
||||
assert!(fixture_has_glyph, "the sample's face maps U+05D1");
|
||||
assert!(nonempty_glyph, "the sample is one rasterized glyph for U+05D1");
|
||||
}
|
||||
|
||||
@@ -24,17 +24,6 @@ pub fn ui_fonts() -> UiFonts<'static> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Turns font hinting off for all text `ctx` draws, in both themes. With hinting on, egui hints a TrueType face that
|
||||
/// has no hinting instructions (no `fpgm`, no `prep` and no glyph instructions) with skrifa 0.44's automatic hinter,
|
||||
/// whose blue-zone search never ends for some glyphs, such as a tall narrow Hebrew letter, so the font list stops
|
||||
/// responding when a row draws such a face. The font list and the samples get their faces through craft-libs, which
|
||||
/// sets no hinting option per face, so the switch covers every face of the context. Hinting stays off until the
|
||||
/// skrifa blue-zone exit (storytold/craft-libs#5222) is in the build; the craft-libs pin that brings it removes this
|
||||
/// function and its call.
|
||||
pub(crate) fn hinting_off(ctx: &egui::Context) {
|
||||
ctx.all_styles_mut(|style| style.visuals.text_options.font_hinting = false);
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct FontSelection {
|
||||
language: Lang,
|
||||
|
||||
Reference in New Issue
Block a user