Skip to content

Commit

Permalink
Normalise font file names, integrate font generation into CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Oct 11, 2023
1 parent efb3f8e commit 8574c2d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
index.html linguist-vendored
promptfont.sfd text
4 changes: 2 additions & 2 deletions .github/workflows/rebuild-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
run: |
git config --global user.name "CI"
git config --global user.email "[email protected]"
sudo apt-get -qq install sbcl curl
sudo apt-get -qq install sbcl curl fontforge
curl -o ~/quicklisp.lisp https://beta.quicklisp.org/quicklisp.lisp
sbcl --load ~/quicklisp.lisp \
--eval '(quicklisp-quickstart:install)' \
Expand All @@ -32,4 +32,4 @@ jobs:
git -C ~/gh-pages commit -qm "CI index rebuild." || echo "Nothing to commit."
git -C ~/gh-pages push -q origin gh-pages
env:
FILES: LICENSE.txt README.md index.html glyphs.json chars.txt PromptFont.ttf PromptFont.otf PromptFont.css
FILES: LICENSE.txt README.md index.html glyphs.json chars.txt promptfont.ttf promptfont.otf promptfont.css
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*.sfd-*
index.html
chars.txt
PromptFont.css
promptfont.css
promptfont.ttf
promptfont.otf
promptfont.afm
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Once you've added the glyphs, please open a pull request and we will handle impo
# Allocating Glyphs
If you want to actually allocate new glyphs into the font yourself, you'll need FontForge to import the SVG files and SBCL to fix up the json file and generate the ancillary files.

1. Open the PromptFont.sfd file with FontForge
1. Open the promptfont.sfd file with FontForge
2. Find suitable spaces for your glyphs and import the SVGs. Preferably group the glyphs together with the existing ones, and for the generic icons use the appropriate Unicode codepoint if there is one
3. Export the TrueType and OpenType font versions, save the SFD file
3. Save the SFD file
4. Update the `glyphs.json` file with your new entries. Add your new entries to the bottom of the file as follows:
```json
{
Expand Down
16 changes: 13 additions & 3 deletions compile.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ exec sbcl \
(process (char-name char)))))))
(process name)))))

(defun css (&optional (file (file "glyphs" "json")) (output (file "PromptFont" "css")))
(defun css (&optional (file (file "glyphs" "json")) (output (file "promptfont" "css")))
(with-open-file (stream output :direction :output :if-exists :supersede)
(format stream "~&@font-face{font-family:'promptfont'; src:url('PromptFont.ttf');}~%")
(format stream "~&@font-face{font-family:'promptfont'; src:url('promptfont.ttf');}~%")
(format stream "~&.pf{font-family:promptfont;}~%")
(loop for entry across (with-open-file (stream file)
(shasht:read-json stream))
Expand All @@ -86,8 +86,17 @@ exec sbcl \
(with-open-file (stream file :direction :output :if-exists :supersede)
(shasht:write-json data stream))))

(defun fonts (&optional (file (file "promptfont" "sfd")))
(uiop:run-program (list "fontforge" "-c" "fnt = fontforge.open(argv[1])
for file in argv[1:]:
fnt.generate(file)"
(uiop:native-namestring file)
(uiop:native-namestring (make-pathname :type "ttf" :defaults file))
(uiop:native-namestring (make-pathname :type "otf" :defaults file)))))

(defun all ()
(fixup)
(fonts)
(txt)
(css)
(web))
Expand All @@ -99,8 +108,9 @@ Commands:
help --- Show this help screen
all --- Performs all below commands. This is run by default
fixup --- Fixes up the glyphs.json file
fonts --- Generates the promptfont.ttf and .otf files
txt --- Generates the chars.txt file
css --- Generates the PromptFont.css file
css --- Generates the promptfont.css file
web --- Generates the index.html file
You typically do not need this utility as it is run automatically by
Expand Down
2 changes: 1 addition & 1 deletion index.ctml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<style type="text/css">
@font-face {
font-family: 'promptfont';
src: url('PromptFont.ttf');
src: url('promptfont.ttf');
}
@keyframes fadeOut {
0% { opacity: 1;}
Expand Down

0 comments on commit 8574c2d

Please sign in to comment.