Skip to content

Commit 2dc1579

Browse files
author
Yatao Li
committed
update to latest nerd fonts. cache wcwidth calculations
1 parent 3472085 commit 2dc1579

File tree

4 files changed

+63
-63
lines changed

4 files changed

+63
-63
lines changed

Fonts/nerd.ttf

4.99 MB
Binary file not shown.

nerdfont.txt

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
Extracted from https://github.com/ryanoasis/nerd-fonts/blob/4b87cdd656a093ab033f48a15cfa832de5ee851e/font-patcher#L516
1+
Extracted from: https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points
22

3-
Copies from [SymStart..SymEnd] to [SourceStart..SourceEnd]
4-
If SourceStart/SourceEnd are None, then copy exact code points (no shift)
3+
Glyph Sets (sorted)
54

6-
0x23FB, 0x23FE, "Power Symbols",
7-
0x2665, 0x2665, "Octicons",
8-
0x26A1, 0x26A1, "Octicons",
9-
0x2B58, 0x2B58, "Power Symbols",
10-
0xE000, 0xE00A, "Pomicons",
11-
0xE0A0, 0xE0A2, "Powerline Symbols",
12-
0xE0A3, 0xE0A3, "Powerline Extra Symbols",
13-
0xE0B0, 0xE0B3, "Powerline Symbols",
14-
0xE0B4, 0xE0C8, "Powerline Extra Symbols",
15-
0xE0CA, 0xE0CA, "Powerline Extra Symbols",
16-
0xE0CC, 0xE0D4, "Powerline Extra Symbols",
17-
0xE200, 0xE2A9, "Font Awesome Extension",
18-
0xE300, 0xE3EB, "Weather Icons",
19-
0xE5FA, 0xE62F, "Seti-UI + Custom",
20-
0xE700, 0xE7C5, "Devicons",
21-
0xF000, 0xF2E0, "Font Awesome",
22-
0xF300, 0xF31C, "Font Logos (Font Linux)",
23-
0xF400, 0xF505, "Octicons",
24-
0xF4A9, 0xF4A9, "Octicons",
25-
0xF500, 0xFD46, "Material",
5+
23FB-23FE,2B58 IEC Power Symbols Adding new characters into Unicode / (website)
6+
E000-E00A Pomicons 8 symbols for the "Pomodoro Technique"®. / (repo)
7+
E0A0-E0A2,E0B0-E0B3 [Powerline Symbols]
8+
E0A3,E0B4-E0C8,E0CA,E0CC-E0D4 Powerline glyphs. Provides extra Powerline separator glyphs and a column number glyph (CN). / (repo)
9+
E200-E2A9 Font Awesome Extension Simple Font Awesome Extension. / (repo) / (website)
10+
E300-E3EB Weather 215 Weather Themed Icons and CSS. / (repo) / (website is now dead)
11+
E5FA-E631 Seti-UI + Custom Based off of Seti-UI Icomoon with extra custom glyphs.
12+
E700-E7C5 Devicons An iconic font made for developers, code jedis, ninjas, HTTPsters, evangelists and nerds(sic). / (repo) / (website)
13+
EA60-EBEB Codicons The icon font for Visual Studio Code. / (repo)
14+
F000-F2E0 Font Awesome The iconic font and CSS toolkit. / (repo) / (website)
15+
F300-F32D Font Logos (Formerly Font Linux) Font-logos is an icon font containing logos of popular linux distributions and other open source software for inclusion in websites. / (repo)
16+
F400-F4A9,2665,26A1 Octicons GitHub's icons. / (repo) / (website) * To avoid conflicts between icon sets, these were modified in the 'Complete' fonts. To view the original codepoints see the Wiki.
17+
F500-FD46 Material Design Icons 2000+ Material Design Icons from the Community. / (repo) / (website)

ui.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ let DefaultFontEmoji =
143143
else "Noto Color Emoji"
144144

145145
let private nerd_typeface =
146-
let name = if RuntimeInformation.IsOSPlatform(OSPlatform.OSX) then "Iosevka Nerd Font"
146+
let name = if RuntimeInformation.IsOSPlatform(OSPlatform.OSX) then "Iosevka NF"
147147
else "Iosevka"
148148
Typeface($"resm:fvim.Fonts.nerd.ttf?assembly=FVim#{name}")
149149
let private emoji_typeface = Typeface(DefaultFontEmoji)

wcwidth.fs

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
module FVim.wcwidth
66

77
open def
8+
open common
89

910
// From https://github.com/jquast/wcwidth/blob/master/wcwidth/table_zero.py
1011
// at commit 0d7de112202cc8b2ebe9232ff4a5c954f19d561a (2016-07-02):
@@ -488,36 +489,28 @@ let WideEastAsian = [|
488489
|]
489490

490491
let Powerline = [|
491-
(0xE0A0u, 0xE0A2u) // Powerline Symbols
492-
(0xE0A3u, 0xE0A3u) // Powerline Extra Symbols
493-
(0xE0B0u, 0xE0B3u) // Powerline Symbols
494-
(0xE0B4u, 0xE0C8u) // Powerline Extra Symbols
495-
(0xE0CAu, 0xE0CAu) // Powerline Extra Symbols
496-
(0xE0CCu, 0xE0D4u) // Powerline Extra Symbols
492+
(0xE0A0u, 0xE0A3u)
493+
(0xE0B0u, 0xE0C8u)
494+
(0xE0CAu, 0xE0CAu)
495+
(0xE0CCu, 0xE0D4u)
497496
|]
498497

499498
// The complete set is recorded in nerdfont.txt
500499
let NerdFont = [|
501-
(0x23fbu, 0x23feu) // Power Symbols
500+
(0x23FBu, 0x23FEu) // Power Symbols
502501
(0x2665u, 0x2665u) // Octicons
503-
(0x26a1u, 0x26a1u) // Octicons
504-
(0x2b58u, 0x2b58u) // Power Symbols
505-
(0xe000u, 0xe00au) // Pomicons
506-
(0xe0a0u, 0xe0a2u) // Powerline Symbols
507-
(0xe0a3u, 0xe0a3u) // Powerline Extra Symbols
508-
(0xe0b0u, 0xe0b3u) // Powerline Symbols
509-
(0xe0b4u, 0xe0c8u) // Powerline Extra Symbols
510-
(0xe0cau, 0xe0cau) // Powerline Extra Symbols
511-
(0xe0ccu, 0xe0d4u) // Powerline Extra Symbols
512-
(0xe200u, 0xe2a9u) // Font Awesome Extension
513-
(0xe300u, 0xe3ebu) // Weather Icons
514-
(0xe5fau, 0xe62fu) // Seti-UI + Custom
515-
(0xe700u, 0xe7c5u) // Devicons
516-
(0xf000u, 0xf2e0u) // Font Awesome
517-
(0xf300u, 0xf31cu) // Font Logos (Font Linux)
518-
(0xf400u, 0xf505u) // Octicons
519-
(0xf4a9u, 0xf4a9u) // Octicons
520-
(0xf500u, 0xfd46u) // Material
502+
(0x26A1u, 0x26A1u) // Octicons
503+
(0x2B58u, 0x2B58u) // Power Symbols
504+
(0xE000u, 0xE00Au) // Pomicons
505+
(0xE200u, 0xE2A9u) // Font Awesome Extension
506+
(0xE300u, 0xE3EBu) // Weather Icons
507+
(0xE5FAu, 0xE631u) // Seti-UI + Custom
508+
(0xE700u, 0xE7C5u) // Devicons
509+
(0xEA60u, 0xEBEBu) // Codicons
510+
(0xF000u, 0xF2E0u) // Font Awesome
511+
(0xF300u, 0xF32Du) // Font Logos (Font Linux)
512+
(0xF400u, 0xF4A9u) // Octicons
513+
(0xF500u, 0xFD46u) // Material
521514
|]
522515

523516
let private intable (table: (uint*uint)[]) (ucs: uint) =
@@ -539,30 +532,46 @@ type CharType =
539532
| Wide = 3
540533
| Nerd = 4
541534
| Emoji = 5
535+
| Braille = 6
542536

543-
let wcwidth(ucs: uint) =
537+
let private _wcwidth_cache: hashmap<uint, CharType> = hashmap []
538+
539+
let private _wcwidth_impl =
540+
function
544541
// NOTE: created by hand, there isn't anything identifiable other than
545542
// general Cf category code to identify these, and some characters in Cf
546543
// category code are of non-zero width.
547-
if ucs = 0u || ucs = 0x034Fu || (0x200Bu <= ucs && ucs <= 0x200Fu) ||
548-
ucs = 0x2028u || ucs = 0x2029u || (0x202Au <= ucs && ucs <= 0x202Eu) ||
549-
(0x2060u <= ucs && ucs <= 0x2063u) then CharType.Invisible
544+
| 0x0000u | 0x034Fu | 0x2028u | 0x2029u -> CharType.Invisible
545+
| x when 0x200Bu <= x && x <= 0x200Fu
546+
|| 0x202Au <= x && x <= 0x202Eu
547+
|| 0x2060u <= x && x <= 0x2063u -> CharType.Invisible
550548
// C0/C1 control characters.
551-
elif ucs < 32u || (0x07Fu <= ucs && ucs < 0x0A0u) then CharType.Control
549+
| x when x < 0x0020u
550+
|| 0x007Fu <= x && x < 0x00A0u -> CharType.Control
552551
// neovim uses these in drawing the UI
553-
elif ucs = 0x2502u || ucs = 0x2630u || ucs = 0x2026u then CharType.Narrow
552+
| 0x2502u | 0x2630u | 0x2026u -> CharType.Narrow
554553
// ASCII-7
555-
elif ucs < 0x7Fu then CharType.Narrow
556-
elif intable Emoji ucs then CharType.Emoji
557-
elif intable Powerline ucs then CharType.Powerline
558-
elif intable NerdFont ucs then CharType.Nerd
559-
elif intable WideEastAsian ucs then CharType.Wide
554+
| x when x < 0x007Fu -> CharType.Narrow
555+
| x when intable Emoji x -> CharType.Emoji
556+
| x when intable Powerline x -> CharType.Powerline
557+
| x when intable NerdFont x -> CharType.Nerd
558+
| x when intable WideEastAsian x -> CharType.Wide
560559
// Combining characters with zero width.
561-
elif intable ZeroWidth ucs then CharType.Invisible
562-
else
560+
| x when intable ZeroWidth x -> CharType.Invisible
561+
// Braille patterns
562+
| x when 0x2800u <= x && x <= 0x28FFu -> CharType.Braille
563+
| _ ->
563564
(*trace "wcwidth" "unknown codepoint: %c (%X)" (char ucs) (ucs)*)
564565
CharType.Narrow
565566

567+
let wcwidth(ucs: uint) =
568+
match _wcwidth_cache.TryGetValue ucs with
569+
| true, ty -> ty
570+
| _ ->
571+
let ty = _wcwidth_impl ucs
572+
_wcwidth_cache.[ucs] <- ty
573+
ty
574+
566575
let wswidth (x: Rune) =
567576
match x with
568577
| SingleChar _
@@ -587,7 +596,6 @@ let isProgrammingSymbol =
587596
let CharTypeWidth(x: CharType): int =
588597
match x with
589598
| CharType.Control | CharType.Invisible -> 0
590-
| CharType.Narrow | CharType.Powerline -> 1
591599
| CharType.Wide | CharType.Nerd | CharType.Emoji -> 2
592600
| _ -> 1
593601

0 commit comments

Comments
 (0)