Skip to content

Commit

Permalink
Added SemiBold weight (closes #987)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Apr 5, 2020
1 parent 84f8fa6 commit 2a88d87
Show file tree
Hide file tree
Showing 12 changed files with 2,188 additions and 2,097 deletions.
4,130 changes: 2,064 additions & 2,066 deletions FiraCode.glyphs

Large diffs are not rendered by default.

71 changes: 41 additions & 30 deletions clojure/fira_code/calt.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
["parenleft" "question" "exclam"]
["parenleft" "question" "less" "exclam"]])


(defn gen-ignore-prefixes [liga]
(str/join
(for [prefix ignore-prefixes
Expand All @@ -28,6 +29,7 @@
" " (str/join " " (drop 1 liga))
";\n"))))


(def ignores
{ ["slash" "asterisk"]
(str
Expand Down Expand Up @@ -113,6 +115,7 @@
" ignore sub bar hyphen' bar;\n"
})


;; DO NOT generate ignores at all
(def skip-ignores? #{
;; #410 <<*>> <<+>> <<$>>
Expand All @@ -123,13 +126,15 @@
["f" "l"] ["F" "l"] ["T" "l"]
})


;; DO NOT generate ligature
(def manual? #{
;; /\ \/
["slash" "backslash"]
["backslash" "slash"]
})


(defn liga->rule
"[f f i] => { [LIG LIG i] f_f_i.liga
[LIG f i] LIG
Expand All @@ -138,42 +143,48 @@
(case (count liga)
2 (let [[a b] liga]
(str/replace
(str "lookup 1_2 {\n"
(when-not (skip-ignores? liga)
(str " ignore sub 1 1' 2;\n"
" ignore sub 1' 2 2;\n"))
(gen-ignore-prefixes liga)
(get ignores liga)
" sub 1.spacer 2' by 1_2.liga;\n"
" sub 1' 2 by 1.spacer;\n"
"} 1_2;")
(str
"lookup 1_2 {\n"
(when-not (skip-ignores? liga)
(str " ignore sub 1 1' 2;\n"
" ignore sub 1' 2 2;\n"))
(gen-ignore-prefixes liga)
(get ignores liga)
" sub 1.spacer 2' by 1_2.liga;\n"
" sub 1' 2 by 1.spacer;\n"
; "sub 1 2 by 1_2.liga;"
"} 1_2;")
#"\d" {"1" a "2" b}))
3 (let [[a b c] liga]
(str/replace
(str "lookup 1_2_3 {\n"
(when-not (skip-ignores? liga)
(str " ignore sub 1 1' 2 3;\n"
" ignore sub 1' 2 3 3;\n"))
(gen-ignore-prefixes liga)
(get ignores liga)
" sub 1.spacer 2.spacer 3' by 1_2_3.liga;\n"
" sub 1.spacer 2' 3 by 2.spacer;\n"
" sub 1' 2 3 by 1.spacer;\n"
"} 1_2_3;")
(str
"lookup 1_2_3 {\n"
(when-not (skip-ignores? liga)
(str " ignore sub 1 1' 2 3;\n"
" ignore sub 1' 2 3 3;\n"))
(gen-ignore-prefixes liga)
(get ignores liga)
" sub 1.spacer 2.spacer 3' by 1_2_3.liga;\n"
" sub 1.spacer 2' 3 by 2.spacer;\n"
" sub 1' 2 3 by 1.spacer;\n"
; "sub 1 2 3 by 1_2_3.liga;"
"} 1_2_3;")
#"\d" {"1" a "2" b "3" c}))
4 (let [[a b c d] liga]
(str/replace
(str "lookup 1_2_3_4 {\n"
(when-not (skip-ignores? liga)
(str " ignore sub 1 1' 2 3 4;\n"
" ignore sub 1' 2 3 4 4;\n"))
(gen-ignore-prefixes liga)
(get ignores liga)
" sub 1.spacer 2.spacer 3.spacer 4' by 1_2_3_4.liga;\n"
" sub 1.spacer 2.spacer 3' 4 by 3.spacer;\n"
" sub 1.spacer 2' 3 4 by 2.spacer;\n"
" sub 1' 2 3 4 by 1.spacer;\n"
"} 1_2_3_4;")
(str
"lookup 1_2_3_4 {\n"
(when-not (skip-ignores? liga)
(str " ignore sub 1 1' 2 3 4;\n"
" ignore sub 1' 2 3 4 4;\n"))
(gen-ignore-prefixes liga)
(get ignores liga)
" sub 1.spacer 2.spacer 3.spacer 4' by 1_2_3_4.liga;\n"
" sub 1.spacer 2.spacer 3' 4 by 3.spacer;\n"
" sub 1.spacer 2' 3 4 by 2.spacer;\n"
" sub 1' 2 3 4 by 1.spacer;\n"
; "sub 1 2 3 4 by 1_2_3_4.liga;"
"} 1_2_3_4;")
#"\d" {"1" a "2" b "3" c "4" d}))))


Expand Down
8 changes: 8 additions & 0 deletions distr/fira_code.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
font-style: normal;
}

@font-face {
font-family: 'Fira Code';
src: url('woff2/FiraCode-SemiBold.woff2') format('woff2'),
url("woff/FiraCode-SemiBold.woff") format("woff");
font-weight: 600;
font-style: normal;
}

@font-face {
font-family: 'Fira Code';
src: url('woff2/FiraCode-Bold.woff2') format('woff2'),
Expand Down
11 changes: 11 additions & 0 deletions distr/specimen.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
.light { font-weight: 300; }
.regular { font-weight: 400; }
.medium { font-weight: 500; }
.semibold { font-weight: 600; }
.bold { font-weight: 700; }
.variable { font-family: 'Fira Code VF'; font-variation-settings: 'wght' 400; }
i { font-style: normal; color: #c33; }
Expand Down Expand Up @@ -63,6 +64,16 @@
last3 = reverse <i>>></i> take 3 <i>>></i> reverse</div>


<div class="code semibold"><b># Fira Code Medium</b>

take = (n, [x, <i>...</i>xs]:list) <i>--></i>
| n <i><=</i> 0 <i>=></i> []
| empty list <i>=></i> []
| otherwise <i>=></i> [x] <i>++</i> take n-1, xs

last3 = reverse <i>>></i> take 3 <i>>></i> reverse</div>


<div class="code bold"><b># Fira Code Bold</b>

take = (n, [x, <i>...</i>xs]:list) <i>--></i>
Expand Down
Binary file modified distr/ttf/FiraCode-Bold.ttf
Binary file not shown.
Binary file modified distr/ttf/FiraCode-Light.ttf
Binary file not shown.
Binary file modified distr/ttf/FiraCode-Medium.ttf
Binary file not shown.
Binary file modified distr/ttf/FiraCode-Regular.ttf
Binary file not shown.
Binary file modified distr/ttf/FiraCode-Retina.ttf
Binary file not shown.
Binary file added distr/ttf/FiraCode-SemiBold.ttf
Binary file not shown.
63 changes: 63 additions & 0 deletions docs/calt_performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Time to shape text with different calt code

Baseline:

```
sub 1 2 3 4 by 1_2_3_4.liga;
```

Spacers:

```
sub 1.spacer 2.spacer 3.spacer 4' by 1_2_3_4.liga;
sub 1.spacer 2.spacer 3' 4 by 3.spacer;
sub 1.spacer 2' 3 4 by 2.spacer;
sub 1' 2 3 4 by 1.spacer;
```

Lookups:

```
lookup 1_2_3_4 {
sub 1.spacer 2.spacer 3.spacer 4' by 1_2_3_4.liga;
sub 1.spacer 2.spacer 3' 4 by 3.spacer;
sub 1.spacer 2' 3 4 by 2.spacer;
sub 1' 2 3 4 by 1.spacer;
} 1_2_3_4;
```

Ignores:

```
lookup 1_2_3_4 {
ignore sub 1 1' 2 3 4;
ignore sub 1' 2 3 4 4;
sub 1.spacer 2.spacer 3.spacer 4' by 1_2_3_4.liga;
sub 1.spacer 2.spacer 3' 4 by 3.spacer;
sub 1.spacer 2' 3 4 by 2.spacer;
sub 1' 2 3 4 by 1.spacer;
} 1_2_3_4;
```

Benchmark:

```
time hb-shape -n 100000 distr/ttf/FiraCode-Regular.ttf "Hello +++ /// !== <-> world"
```

Setup:

```
HarfBuzz 2.6.4
3,2 GHz 6-Core Intel Core i7
MacOS 10.15.3
```

Results:

```
Baseline 0.407s
Spacers 1.415s
Lookups 2.080s
Ignores 2.656s
```
2 changes: 1 addition & 1 deletion script/build_ttf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source venv/bin/activate

args=( "$@" )
default_weights=( "Light" "Regular" "Retina" "Medium" "Bold" )
default_weights=( "Light" "Regular" "Retina" "Medium" "SemiBold" "Bold" )
weights=( "${args[@]:-"${default_weights[@]}"}" )

for weight in "${weights[@]}"; do
Expand Down

0 comments on commit 2a88d87

Please sign in to comment.