@@ -23,23 +23,40 @@ export function isRestrictedPowerlineGlyph(codepoint: number): boolean {
23
23
return 0xE0B0 <= codepoint && codepoint <= 0xE0B7 ;
24
24
}
25
25
26
+ function isNerdFontGlyph ( codepoint : number ) : boolean {
27
+ return 0xE000 <= codepoint && codepoint <= 0xF8FF ;
28
+ }
29
+
26
30
function isBoxOrBlockGlyph ( codepoint : number ) : boolean {
27
31
return 0x2500 <= codepoint && codepoint <= 0x259F ;
28
32
}
29
33
30
34
export function isEmoji ( codepoint : number ) : boolean {
31
35
return (
32
36
codepoint >= 0x1F600 && codepoint <= 0x1F64F || // Emoticons
33
- codepoint >= 0x1F300 && codepoint <= 0x1F5FF || // Misc Symbols and Pictographs
34
- codepoint >= 0x1F680 && codepoint <= 0x1F6FF || // Transport and Map
35
- codepoint >= 0x2600 && codepoint <= 0x26FF || // Misc symbols
36
- codepoint >= 0x2700 && codepoint <= 0x27BF || // Dingbats
37
- codepoint >= 0xFE00 && codepoint <= 0xFE0F || // Variation Selectors
38
- codepoint >= 0x1F900 && codepoint <= 0x1F9FF || // Supplemental Symbols and Pictographs
37
+ codepoint >= 0x1F300 && codepoint <= 0x1F5FF || // Misc Symbols and Pictographs
38
+ codepoint >= 0x1F680 && codepoint <= 0x1F6FF || // Transport and Map
39
+ codepoint >= 0x2600 && codepoint <= 0x26FF || // Misc symbols
40
+ codepoint >= 0x2700 && codepoint <= 0x27BF || // Dingbats
41
+ codepoint >= 0xFE00 && codepoint <= 0xFE0F || // Variation Selectors
42
+ codepoint >= 0x1F900 && codepoint <= 0x1F9FF || // Supplemental Symbols and Pictographs
39
43
codepoint >= 0x1F1E6 && codepoint <= 0x1F1FF
40
44
) ;
41
45
}
42
46
47
+ export function allowRescaling ( codepoint : number | undefined , width : number , glyphSizeX : number , deviceCellWidth : number ) : boolean {
48
+ return (
49
+ // Is single cell width
50
+ width === 1 &&
51
+ // Glyph exceeds cell bounds, + 1 to avoid hurting readability
52
+ glyphSizeX > deviceCellWidth + 1 &&
53
+ // Never rescale emoji
54
+ codepoint !== undefined && ! isEmoji ( codepoint ) &&
55
+ // Never rescale powerline or nerd fonts
56
+ ! isPowerlineGlyph ( codepoint ) && ! isNerdFontGlyph ( codepoint )
57
+ ) ;
58
+ }
59
+
43
60
export function treatGlyphAsBackgroundColor ( codepoint : number ) : boolean {
44
61
return isPowerlineGlyph ( codepoint ) || isBoxOrBlockGlyph ( codepoint ) ;
45
62
}
0 commit comments