diff --git a/shaperglot-web/src/lib.rs b/shaperglot-web/src/lib.rs
index 5679d4a..cecb788 100644
--- a/shaperglot-web/src/lib.rs
+++ b/shaperglot-web/src/lib.rs
@@ -1,5 +1,6 @@
use std::collections::HashMap;
+use skrifa::{raw::tables::name::NameId, FontRef, MetadataProvider};
use wasm_bindgen::prelude::*;
extern crate console_error_panic_hook;
use google_fonts_languages::{RegionProto, ScriptProto, REGIONS, SCRIPTS};
@@ -35,6 +36,16 @@ pub fn regions() -> Result {
serde_json::to_string(®ion_hash).map_err(|e| e.to_string().into())
}
+#[wasm_bindgen]
+pub fn family_name(font_data: &[u8]) -> Result {
+ let font = FontRef::new(font_data).map_err(|e| e.to_string())?;
+ Ok(font
+ .localized_strings(NameId::FAMILY_NAME)
+ .english_or_first()
+ .map(|s| s.chars().collect())
+ .unwrap_or_default())
+}
+
#[wasm_bindgen]
pub fn check_font(font_data: &[u8]) -> Result {
let checker = Checker::new(font_data).map_err(|e| e.to_string())?;
diff --git a/shaperglot-web/www/index.js b/shaperglot-web/www/index.js
index a578dae..82a7f38 100644
--- a/shaperglot-web/www/index.js
+++ b/shaperglot-web/www/index.js
@@ -72,6 +72,9 @@ class Shaperglot {
this.regions = message.regions;
} else if ("results" in message) {
$("#spinnerModal").hide();
+ if (message.family_name) {
+ $("#filename").text(message.family_name);
+ }
this.renderResults(message.results);
}
}
@@ -230,19 +233,24 @@ class Shaperglot {
let mark = status == "Pass" ? "✅" : "❌";
problem_html.append(
- `${check_name} ${mark} (${Math.round(
- score * weight * 100
- ) / 100}/${weight} points)`
+ `
+
+ ${check_name} ${mark} (${Math.round(
+ score * weight * 100
+ ) / 100}/${weight} points)
+
+ ${check_description}
+
+ `
);
let dd = $(`
- ${check_description}
-
+
`);
problem_html.append(dd);
if (problems.length > 0) {
dd.append(`Problems:
`);
} else {
- dd.append(``);
+ problem_html.find("details").last().append(``);
}
for (var problem of problems) {
let { check_name, message, fixes } = problem;
diff --git a/shaperglot-web/www/style.css b/shaperglot-web/www/style.css
index 868238f..1e6012f 100644
--- a/shaperglot-web/www/style.css
+++ b/shaperglot-web/www/style.css
@@ -108,4 +108,6 @@ button.nav-link {
color: #888;
}
-dd { margin: 10px 25px 10px 25px; }
\ No newline at end of file
+dd { margin: 10px 25px 10px 25px; }
+
+dt details blockquote { font-weight: 400; margin: 10px 25px 10px 25px; }
\ No newline at end of file
diff --git a/shaperglot-web/www/webworker.js b/shaperglot-web/www/webworker.js
index a8e2469..87e9447 100644
--- a/shaperglot-web/www/webworker.js
+++ b/shaperglot-web/www/webworker.js
@@ -14,7 +14,7 @@ async function init() {
const { font } = event.data;
try {
const results = JSON.parse(wasm.check_font(font));
- self.postMessage({ results: results });
+ self.postMessage({ results: results, family_name: wasm.family_name(font) });
} catch (error) {
self.postMessage({ error: error.message });
}