Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hj5m35Lj6Rt9vwwLGZ
This commit is contained in:
commit
15b7c3f0e3
4 files changed
+21
-7
No files matched your search
@@ -24,7 +24,7 @@ pub fn missing_font_message(env_path : String) -> String {
|
|||||||
"CHANDRA_EMOJI_FONT=" + env_path + " can't be read as a bitmap (CBDT) colour emoji font. " +
|
"CHANDRA_EMOJI_FONT=" + env_path + " can't be read as a bitmap (CBDT) colour emoji font. " +
|
||||||
"Unset it to use Chandra's own Noto Color Emoji."
|
"Unset it to use Chandra's own Noto Color Emoji."
|
||||||
} else {
|
} else {
|
||||||
"Chandra's emoji font is missing: " + font_path + " (Noto Color Emoji, bitmap edition). " +
|
"Chandra's emoji font is missing or unreadable: " + font_path + " (Noto Color Emoji, bitmap edition). " +
|
||||||
"Run `just install` (or `just emoji-font` in a checkout), then press Super+. again."
|
"Run `just install` (or `just emoji-font` in a checkout), then press Super+. again."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,12 +439,13 @@ pub fn EmojiSource::new() -> EmojiSource {
|
|||||||
{ state: None, images: {} }
|
{ state: None, images: {} }
|
||||||
}
|
}
|
||||||
|
|
||||||
///| Open the font: CHANDRA_EMOJI_FONT when set, else the first of `font_paths` that parses.
|
///| Open the font: CHANDRA_EMOJI_FONT when set, else `font_path`. The path, or what to tell the
|
||||||
/// The path, or what to tell the user. Logged once.
|
/// user. A failure is tried again on the next call (so fixing the file needs no new session) and
|
||||||
|
/// logged only when it changes.
|
||||||
pub fn EmojiSource::font(self : EmojiSource) -> Result[String, String] {
|
pub fn EmojiSource::font(self : EmojiSource) -> Result[String, String] {
|
||||||
let st = match self.state {
|
let st = match self.state {
|
||||||
Some(s) => s
|
Some(Ok(s)) => Ok(s)
|
||||||
None => {
|
previous => {
|
||||||
let env = @sys.getenv("CHANDRA_EMOJI_FONT")
|
let env = @sys.getenv("CHANDRA_EMOJI_FONT")
|
||||||
let p = if env.length() > 0 { env } else { font_path }
|
let p = if env.length() > 0 { env } else { font_path }
|
||||||
let data = @sys.read_file_bytes(p)
|
let data = @sys.read_file_bytes(p)
|
||||||
@@ -458,7 +459,11 @@ pub fn EmojiSource::font(self : EmojiSource) -> Result[String, String] {
|
|||||||
}
|
}
|
||||||
match found {
|
match found {
|
||||||
Ok((p, f)) => @sys.log("emoji: " + p + " (" + f.ppem.to_string() + " px pictures)")
|
Ok((p, f)) => @sys.log("emoji: " + p + " (" + f.ppem.to_string() + " px pictures)")
|
||||||
Err(m) => @sys.log("emoji: " + m)
|
Err(m) =>
|
||||||
|
match previous {
|
||||||
|
Some(Err(old)) if old == m => ()
|
||||||
|
_ => @sys.log("emoji: " + m)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.state = Some(found)
|
self.state = Some(found)
|
||||||
found
|
found
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ sha=72a635cb3d2f3524c51620cdde406b217204e8a6a06c6a096ff8ed4b5fd6e27b
|
|||||||
url=https://raw.githubusercontent.com/googlefonts/noto-emoji/$version/fonts/NotoColorEmoji.ttf
|
url=https://raw.githubusercontent.com/googlefonts/noto-emoji/$version/fonts/NotoColorEmoji.ttf
|
||||||
dst=assets/fonts/NotoColorEmoji.ttf
|
dst=assets/fonts/NotoColorEmoji.ttf
|
||||||
if [ -f "$dst" ] && echo "$sha $dst" | sha256sum --check --status; then
|
if [ -f "$dst" ] && echo "$sha $dst" | sha256sum --check --status; then
|
||||||
|
chmod 644 "$dst"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "fetching Noto Color Emoji $version (10 MB) from $url" >&2
|
echo "fetching Noto Color Emoji $version (10 MB) from $url" >&2
|
||||||
@@ -25,6 +26,7 @@ if ! echo "$sha $tmp" | sha256sum --check --status; then
|
|||||||
echo "error: $url is not the expected Noto Color Emoji $version (sha256 differs: $(sha256sum "$tmp" | cut -d' ' -f1))" >&2
|
echo "error: $url is not the expected Noto Color Emoji $version (sha256 differs: $(sha256sum "$tmp" | cut -d' ' -f1))" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
chmod 644 "$tmp" # mktemp made it 0600; the installed copy must be readable by the session's user
|
||||||
mv "$tmp" "$dst"
|
mv "$tmp" "$dst"
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
echo "installed $dst" >&2
|
echo "installed $dst" >&2
|
||||||
@@ -196,6 +196,13 @@ for d in ("config", "wit", "assets"):
|
|||||||
if os.path.lexists(dst):
|
if os.path.lexists(dst):
|
||||||
shutil.rmtree(dst) if os.path.isdir(dst) and not os.path.islink(dst) else os.remove(dst)
|
shutil.rmtree(dst) if os.path.isdir(dst) and not os.path.islink(dst) else os.remove(dst)
|
||||||
shutil.copytree(os.path.join(root, d), dst)
|
shutil.copytree(os.path.join(root, d), dst)
|
||||||
|
# copytree keeps the sources' modes; root installs these and every user's session reads them.
|
||||||
|
for top, _, files in os.walk(dst):
|
||||||
|
os.chmod(top, 0o755)
|
||||||
|
for f in files:
|
||||||
|
path = os.path.join(top, f)
|
||||||
|
if not os.path.islink(path):
|
||||||
|
os.chmod(path, 0o644)
|
||||||
print("installed", dst)
|
print("installed", dst)
|
||||||
mods = os.path.join(root, "build/components")
|
mods = os.path.join(root, "build/components")
|
||||||
dst = os.path.join(share, "modules")
|
dst = os.path.join(share, "modules")
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ pub fn Val::bytes(b : Bytes) -> Val {
|
|||||||
|
|
||||||
///| A `list<string>`.
|
///| A `list<string>`.
|
||||||
pub fn Val::strings(a : Array[String]) -> Val {
|
pub fn Val::strings(a : Array[String]) -> Val {
|
||||||
List(a.map(Str(_)))
|
List(a.map(s => Str(s)))
|
||||||
}
|
}
|
||||||
|
|
||||||
///| Record field `name` (records are looked up by name, not position).
|
///| Record field `name` (records are looked up by name, not position).
|
||||||
|
|||||||
Reference in new issue
Block a user