Skip to content

Commit

Permalink
Add New Font (#72)
Browse files Browse the repository at this point in the history
* Use upstream go-bdf library instead of our fork.

The zachomedia/go-bdf has our changes merged and it has fixes to the
bounds of the glyphs, which renders fonts much more nicely using pixlet.
For example, a colon now has the appropriate spacing.

* Added font embedding to the Makefile.

This commit adds the font embedding utility to the make file so that we
can embed new fonts on build.

* Added a font preview example.

This commit adds a preview to examples to preview new fonts in the repo.

* Added tom-thumb font.

This commit adds the Tom Thumb font found here: https://robey.lag.net/2010/01/23/tiny-monospace-font.html

This font is supy tiny and allows for packing some serious information
onto a display.

* Fixed false comment.

The all uppercase comment can be true, but we'd need to modify this
font. I honestly think we should add a tom-thumb-upper that has all
lowercase characters removed and the height set to 5.
  • Loading branch information
betterengineering authored Oct 19, 2021
1 parent 8165bef commit 1ddc377
Show file tree
Hide file tree
Showing 9 changed files with 2,420 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ clean:
bench:
go test -benchmem -benchtime=20s -bench BenchmarkRunAndRender tidbyt.dev/pixlet/encode

build: clean
go build -o build/out/pixlet tidbyt.dev/pixlet
build: clean embedfonts
go build -o build/out/pixlet tidbyt.dev/pixlet

embedfonts:
go run render/gen/embedfonts.go
11 changes: 11 additions & 0 deletions doc/fonts.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ including the runic code block. 4121 code points in total.
- Ascent: 11
- Descent: 2

### tom-thumb
By [Robey Pointer](https://robey.lag.net/2010/01/23/tiny-monospace-font.html)

A very tiny, monospace, bitmap font. It's a 4x6 font (3x5 usable pixels) that's
great for packing in information on your display.

- Advance: 4
- Height: 6
- Cap height: 4
- Ascent: 5
- Descent: 1
43 changes: 43 additions & 0 deletions examples/font-preview.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
load("render.star", "render")

def main(config):
font = config.get("font", "tb-8")
print("Using font: '{}'".format(font))
return render.Root(
child = render.Column(
children = [
render.Box(
width = 64,
height = 1,
color = "#78DECC",
),
render.Marquee(
width = 64,
child = render.Text("The quick brown fox jumps over the lazy dog", font = font),
),
render.Box(
width = 64,
height = 1,
color = "#78DECC",
),
render.Marquee(
width = 64,
child = render.Text("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG", font = font),
),
render.Box(
width = 64,
height = 1,
color = "#78DECC",
),
render.Marquee(
width = 64,
child = render.Text("!@#$%^&*()_+:?><~`", font = font),
),
render.Box(
width = 64,
height = 1,
color = "#78DECC",
),
],
),
)
Loading

0 comments on commit 1ddc377

Please sign in to comment.