Skip to content

Commit

Permalink
Add NerdFonts (#720)
Browse files Browse the repository at this point in the history
Font has been reviewed by the devs and the NerdFonts folks

Closes #194
Closes #210
  • Loading branch information
aaronbell authored Apr 8, 2024
1 parent 6bda20b commit 65568db
Show file tree
Hide file tree
Showing 18,594 changed files with 1,542,585 additions and 2 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
114 changes: 112 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import cast
import xml.etree.cElementTree as ET
import tempfile
import glob

import cffsubr.__main__
import fontmake.instantiator
Expand Down Expand Up @@ -50,9 +51,16 @@ def step_set_font_name(name: str, source: ufoLib2.Font) -> None:


def step_merge_glyphs_from_ufo(path: Path, instance: ufoLib2.Font) -> None:
unicodes = []
for glyph in instance:
unicodes.append(glyph.unicode)
ufo = ufoLib2.Font.open(path)
for glyph in ufo:
if glyph.name not in instance:
if glyph.unicode:
if glyph.unicode not in unicodes:
newName = str(hex(glyph.unicode)).upper().replace("0X","uni")
instance.layers.defaultLayer.insertGlyph(ufo[glyph.name],newName, overwrite=False, copy=False)
else:
instance.addGlyph(ufo[glyph.name])


Expand Down Expand Up @@ -103,6 +111,8 @@ def step_set_feature_file(path: Path, name: str, instance: ufoLib2.Font) -> None
for item in featureList:
if "PL" in name and item == "rclt":
featureSet += Path(path / str("rclt_PL.fea")).read_text()
if "NF" in name and item == "rclt":
featureSet += Path(path / str("rclt_PL.fea")).read_text()
elif "Mono" in name and "calt" in item:
featureSet += Path(path / str(item+"_mono.fea")).read_text() #both Italic and Regular can use same mono
else:
Expand Down Expand Up @@ -165,6 +175,16 @@ def prepare_fonts(
NERDFONTS_DIR / "NerdfontsPL-Regular.ufo", source.font
)
step_set_font_name(name, source.font)
elif "NF" in name:
print(f"[{name} {source.styleName}] Merging NF glyphs")
step_merge_glyphs_from_ufo(
NERDFONTS_DIR / "NerdfontsPL-Regular.ufo", source.font
)
for ufo in Path(NERDFONTS_DIR/"full"/"processed").glob("*.ufo"):
step_merge_glyphs_from_ufo(
ufo, source.font
)
step_set_font_name(name, source.font)
elif "Cascadia Code" in name:
pass
else:
Expand Down Expand Up @@ -345,6 +365,7 @@ def ttfautohint(path: str) -> None:
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="build some fonts")
parser.add_argument("-P", "--no-powerline", action="store_false", dest="powerline")
parser.add_argument("-NF", "--no-nerdfonts", action="store_false", dest="nerdfonts")
parser.add_argument("-M", "--no-mono", action="store_false", dest="mono")
parser.add_argument("-S", "--static-fonts", action="store_true")
parser.add_argument("-I", "--no-italic", action="store_false", dest="italic")
Expand Down Expand Up @@ -379,7 +400,8 @@ def ttfautohint(path: str) -> None:
if s.lib.get("com.schriftgestaltung.export", True)
]

# Stage 1: Make all the things.

#Stage 1: Make all the things.
pool = multiprocessing.pool.Pool(processes=multiprocessing.cpu_count())
processes = []
processes.append(
Expand Down Expand Up @@ -469,6 +491,50 @@ def ttfautohint(path: str) -> None:
),
)
)
if args.nerdfonts:
processes.append(
pool.apply_async(
build_font_variable,
(
designspace,
"Cascadia Code NF",
args.vtt_compile,
),
)
)
if args.italic:
processes.append(
pool.apply_async(
build_font_variable,
(
designspaceItalic,
"Cascadia Code NF Italic",
args.vtt_compile,
),
)
)
if args.mono:
processes.append(
pool.apply_async(
build_font_variable,
(
designspace,
"Cascadia Mono NF",
args.vtt_compile,
),
)
)
if args.italic:
processes.append(
pool.apply_async(
build_font_variable,
(
designspaceItalic,
"Cascadia Mono NF Italic",
args.vtt_compile,
),
)
)

if args.static_fonts:
# Build the Regulars
Expand Down Expand Up @@ -516,6 +582,28 @@ def ttfautohint(path: str) -> None:
),
)
)
if args.nerdfonts:
processes.append(
pool.apply_async(
build_font_static,
(
designspace,
instance_descriptor,
"Cascadia Code NF",
),
)
)
if args.mono:
processes.append(
pool.apply_async(
build_font_static,
(
designspace,
instance_descriptor,
"Cascadia Mono NF",
),
)
)
if args.italic:
# Build the Regulars
for instance_descriptor in designspaceItalic.instances:
Expand Down Expand Up @@ -562,6 +650,28 @@ def ttfautohint(path: str) -> None:
),
)
)
if args.nerdfonts:
processes.append(
pool.apply_async(
build_font_static,
(
designspaceItalic,
instance_descriptor,
"Cascadia Code NF Italic",
),
)
)
if args.mono:
processes.append(
pool.apply_async(
build_font_static,
(
designspaceItalic,
instance_descriptor,
"Cascadia Mono NF Italic",
),
)
)

pool.close()
pool.join()
Expand Down
157 changes: 157 additions & 0 deletions sources/nerdfonts/full/PowerlineExtraSymbols.ufo/fontinfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ascender</key>
<integer>1567</integer>
<key>capHeight</key>
<integer>1462</integer>
<key>copyright</key>
<string>MIT © Ryan L McIntyre</string>
<key>descender</key>
<integer>-492</integer>
<key>familyName</key>
<string>Powerline Extra Symbols</string>
<key>guidelines</key>
<array/>
<key>italicAngle</key>
<integer>0</integer>
<key>openTypeHeadCreated</key>
<string>2007/01/08 12:28:04</string>
<key>openTypeHheaAscender</key>
<integer>1901</integer>
<key>openTypeHheaDescender</key>
<integer>-483</integer>
<key>openTypeNameDescription</key>
<string>Extra glyphs for your powerline separators</string>
<key>openTypeNameDesignerURL</key>
<string>https://github.com/ryanoasis/powerline-extra-symbols</string>
<key>openTypeNameLicense</key>
<string>MIT</string>
<key>openTypeNameLicenseURL</key>
<string>https://opensource.org/licenses/MIT</string>
<key>openTypeNameManufacturerURL</key>
<string>https://github.com/ryanoasis/powerline-extra-symbols</string>
<key>openTypeNamePreferredSubfamilyName</key>
<string>Regular</string>
<key>openTypeOS2Panose</key>
<array>
<integer>2</integer>
<integer>11</integer>
<integer>6</integer>
<integer>9</integer>
<integer>3</integer>
<integer>8</integer>
<integer>4</integer>
<integer>2</integer>
<integer>2</integer>
<integer>4</integer>
</array>
<key>openTypeOS2StrikeoutPosition</key>
<integer>498</integer>
<key>openTypeOS2StrikeoutSize</key>
<integer>102</integer>
<key>openTypeOS2TypoAscender</key>
<integer>1567</integer>
<key>openTypeOS2TypoDescender</key>
<integer>-492</integer>
<key>openTypeOS2TypoLineGap</key>
<integer>132</integer>
<key>openTypeOS2UnicodeRanges</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
<integer>3</integer>
<integer>5</integer>
<integer>6</integer>
<integer>7</integer>
<integer>9</integer>
<integer>29</integer>
<integer>30</integer>
<integer>31</integer>
<integer>32</integer>
<integer>33</integer>
<integer>35</integer>
<integer>36</integer>
<integer>38</integer>
<integer>45</integer>
<integer>62</integer>
<integer>67</integer>
<integer>69</integer>
</array>
<key>openTypeOS2VendorID</key>
<string>1ASC</string>
<key>openTypeOS2WeightClass</key>
<integer>400</integer>
<key>openTypeOS2WidthClass</key>
<integer>5</integer>
<key>openTypeOS2WinAscent</key>
<integer>1901</integer>
<key>openTypeOS2WinDescent</key>
<integer>483</integer>
<key>postscriptBlueScale</key>
<real>0.011</real>
<key>postscriptBlueShift</key>
<integer>10</integer>
<key>postscriptBlueValues</key>
<array>
<integer>-20</integer>
<integer>0</integer>
<integer>1098</integer>
<integer>1118</integer>
<integer>1462</integer>
<integer>1556</integer>
</array>
<key>postscriptFamilyBlues</key>
<array/>
<key>postscriptFamilyOtherBlues</key>
<array/>
<key>postscriptFontName</key>
<string>PowerlineExtraSymbols</string>
<key>postscriptOtherBlues</key>
<array/>
<key>postscriptStemSnapH</key>
<array>
<integer>12</integer>
<integer>20</integer>
<integer>44</integer>
<integer>48</integer>
<integer>68</integer>
<integer>76</integer>
<integer>116</integer>
<integer>120</integer>
<integer>126</integer>
<integer>202</integer>
</array>
<key>postscriptStemSnapV</key>
<array>
<integer>10</integer>
<integer>14</integer>
<integer>27</integer>
<integer>34</integer>
<integer>46</integer>
<integer>52</integer>
<integer>61</integer>
<integer>67</integer>
<integer>76</integer>
<integer>87</integer>
</array>
<key>postscriptUnderlinePosition</key>
<integer>-205</integer>
<key>postscriptUnderlineThickness</key>
<integer>102</integer>
<key>styleMapStyleName</key>
<string>regular</string>
<key>styleName</key>
<string>Regular</string>
<key>unitsPerEm</key>
<integer>2048</integer>
<key>versionMajor</key>
<integer>1</integer>
<key>versionMinor</key>
<integer>0</integer>
<key>xHeight</key>
<integer>1098</integer>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name=".notdef" format="2">
<advance width="1200"/>
<unicode hex="E0C9"/>
<unicode hex="E0CB"/>
<unicode hex="E0D3"/>
<note>
.notdef
</note>
<outline>
<contour>
<point x="1378" y="2857" type="line"/>
<point x="-178" y="2857" type="line"/>
<point x="-178" y="151" type="line"/>
<point x="1378" y="151" type="line"/>
</contour>
<contour>
<point x="1186" y="343" type="line"/>
<point x="14" y="343" type="line"/>
<point x="14" y="2665" type="line"/>
<point x="1186" y="2665" type="line"/>
</contour>
</outline>
</glyph>
Loading

0 comments on commit 65568db

Please sign in to comment.