Skip to content

Commit

Permalink
now fonts are built into freja binary
Browse files Browse the repository at this point in the history
  • Loading branch information
saikyun committed Jun 20, 2021
1 parent 6bb9898 commit 4ba7486
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 21 deletions.
Binary file added fonts/TamzenForPowerline10x20b.ttf
Binary file not shown.
41 changes: 41 additions & 0 deletions fonts/TamzenForPowerline10x20b_LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

_____ __ _
|_ _|_ _ _ __ ___ ___ _ _ _ __ / _| ___ _ __ | |_
| |/ _` | '_ ` _ \/ __| | | | '_ \ | |_ / _ \| '_ \| __|
| | (_| | | | | | \__ \ |_| | | | | | _| (_) | | | | |_
|_|\__,_|_| |_| |_|___/\__, |_| |_| |_| \___/|_| |_|\__|
|___/


Copyright 2010 Scott Fial <http://www.fial.com/~scott/tamsyn-font/>

Tamsyn font is free. You are hereby granted permission to use, copy, modify,
and distribute it as you see fit.

Tamsyn font is provided "as is" without any express or implied warranty.

The author makes no representations about the suitability of this font for
a particular purpose.

In no event will the author be held liable for damages arising from the use
of this font.

_____ __ _
|_ _|_ _ _ __ ___ _______ _ __ / _| ___ _ __ | |_
| |/ _` | '_ ` _ \|_ / _ \ '_ \ | |_ / _ \| '_ \| __|
| | (_| | | | | | |/ / __/ | | | | _| (_) | | | | |_
|_|\__,_|_| |_| |_/___\___|_| |_| |_| \___/|_| |_|\__|


Copyright 2011 Suraj N. Kurapati <https://github.com/sunaku/tamzen-font>

Tamzen font is free. You are hereby granted permission to use, copy, modify,
and distribute it as you see fit.

Tamzen font is provided "as is" without any express or implied warranty.

The author makes no representations about the suitability of this font for
a particular purpose.

In no event will the author be held liable for damages arising from the use
of this font.
9 changes: 9 additions & 0 deletions freja/font.janet
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@
[font-path size]
(def [x-scale _] screen-scale)
(load-font-ex font-path (* x-scale size) default-glyphs))

(defn default-load-font-from-memory
[kind font-data size]
(def [x-scale _] screen-scale)
(load-font-from-memory kind
font-data
(length font-data)
(* x-scale size)
default-glyphs))
44 changes: 27 additions & 17 deletions freja/main.janet
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@
{:text t
:colors colors}))

(def mplus-font (slurp "fonts/MplusCodeLatin60-Medium.otf"))

(defn load-font-from-mem
[text-data opts]

(let [font (load-font-from-memory (opts :ext)
(opts :font-data)
(length (opts :font-data))
(opts :size)
(opts :glyphs))]

(put opts :font font)

(def t (freeze opts))

(put text-data :conf t)
(put text-data :sizes (glyphs->size-struct t (t :glyphs)))

{:text t
:colors colors}))

(defn run-init-file
[]
(def env (data :top-env))
Expand Down Expand Up @@ -179,36 +200,25 @@
(put screen-scale 1 ys))

(let [[x-scale y-scale] screen-scale
tc @{:font-path
#"fonts/FantasqueSansMono-Regular.otf"
#"fonts/TamzenForPowerline10x20b.ttf"
"fonts/MplusCodeLatin60-Medium.otf"
#"fonts/MplusCodeLatin60-Regular.otf"
#"fonts/EBGaramond12-Regular.otf"
tc @{:font-data mplus-font
:ext ".otf"
:size (* 20 x-scale)
:line-height 1.2
:mult (/ 1 x-scale)
:glyphs default-glyphs
:spacing 0.5}

tc2 @{:font-path (string state/freja-dir "fonts/Texturina-VariableFont_opsz,wght.ttf")
:line-height 1.1
:size (* 20 x-scale)
:mult (/ 1 x-scale)
:glyphs (string/bytes " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI\nJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmn\nopqrstuvwxyz{|}~\\")
:spacing 2}]
:spacing 0.5}]

(set conf (load-font state/gb-data tc))
(set conf (load-font-from-mem state/gb-data tc))
(put state/gb-data :context data)
(put state/gb-data :screen-scale [x-scale y-scale])
(put state/gb-data :colors colors)

(set conf (load-font state/search-data tc))
(set conf (load-font-from-mem state/search-data tc))
(put state/search-data :context data)
(put state/search-data :screen-scale [x-scale y-scale])
(put state/search-data :colors colors)

(set conf2 (load-font state/file-open-data tc))
(set conf2 (load-font-from-mem state/file-open-data tc))
(put state/file-open-data :context data)
(put state/file-open-data :screen-scale [x-scale y-scale])
(put state/file-open-data :colors colors)
Expand Down
11 changes: 7 additions & 4 deletions new_menu.janet
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
#
# stuff to add menu to deps

(def poppins-font (slurp "./fonts/Poppins-Regular.otf"))

(defn init
[]

Expand Down Expand Up @@ -340,11 +342,12 @@
|(:draw frp/caret)
|(:draw menu)])

(set menu-font (default-load-font #(string state/freja-dir "./fonts/FiraSans-Regular.ttf")
"./fonts/Poppins-Regular.otf"
font-size))
(set menu-font (default-load-font-from-memory
".otf"
poppins-font
font-size))
(put frp/deps :deps dependencies)
(put frp/deps :finally finally)
(put frp/deps :draws draws)

(e/put! state/focus123 :focus frp/text-area))
(e/put! state/focus123 :focus frp/text-area))

0 comments on commit 4ba7486

Please sign in to comment.