Fix font subsetting for webring

This commit is contained in:
Shadowfacts 2025-02-12 10:50:38 -05:00
parent e2abb6873f
commit 86bd8a39ee
5 changed files with 13 additions and 5 deletions

View File

@ -6,6 +6,8 @@
{% block content -%}
<h1>Archive</h1>
{% for year in years %}
<div class="archive-list">
{% for entry in posts_by_year[year] %}

View File

@ -359,8 +359,6 @@ footer {
);
background: var(--webring-gradient);
background-clip: text;
font-variant: small-caps;
font-weight: bold;
position: relative;
&::after {
content: "";

View File

@ -206,7 +206,7 @@ impl std::fmt::Debug for CharacterSets {
}
bitflags! {
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Debug)]
pub struct FontKey: u8 {
const BOLD = 1;
const ITALIC = 1 << 1;

View File

@ -4,6 +4,7 @@ use compute_graph::{
rule::Rule,
synchronicity::Asynchronous,
};
use log::debug;
use pyftsubset::subset;
use super::character_sets::{CharacterSets, FontKey};
@ -18,7 +19,11 @@ pub fn make_graph(
sets: character_sets,
key,
});
builder.add_rule(SubsetFont { font, characters })
builder.add_rule(SubsetFont {
key,
font,
characters,
})
}
#[derive(InputVisitable)]
@ -36,12 +41,15 @@ impl Rule for GetCharacterSet {
#[derive(InputVisitable)]
struct SubsetFont {
#[skip_visit]
key: FontKey,
font: Input<Vec<u8>>,
characters: Input<ahash::HashSet<char>>,
}
impl Rule for SubsetFont {
type Output = Vec<u8>;
fn evaluate(&mut self) -> Self::Output {
debug!("Subsetting font {:?}", self.key);
let unicodes = self
.characters()
.iter()

View File

@ -208,7 +208,7 @@ impl Rule for RenderTemplate {
}
Err(e) => {
error!("Error rendering template {:?}: {:?}", self.name, e);
return String::new();
String::new()
}
}
}