kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.76k stars 990 forks source link

symbol_map being ignored? #2073

Closed qwattash closed 5 years ago

qwattash commented 5 years ago

Description

I am trying to apply a custom set of symbols for \ue0b0 and friends (in this context they are in a font file AnonymousProPowerlinePatch.ttf, which has family Anonymous Pro). The main font I use is Anonymous Pro, which does not include any powerline symbols by default. The AnonymousProPowerlinePatch font is configured to be used for the symbol_map, however it does seem to be used only for some of the symbols, indicating some sort of font fallback.

Setup

I will list what I did to try and debug that, if you have suggestions I'm happy to try them out. At this point I think there is some sort of font fallback problem but I'm not able to identify the exact cause.

This is my font configuration

font_family       Anonymous Pro
bold_font         auto
italic_font       auto
bold_italic_font  auto
font_size         11
adjust_line_height 4

symbol_map U+E0B0,U+E0B1,U+E0B2,U+E0B3 AnonymousProPowerlinePatch

window_padding_width 0.0
window_margin_width 0.0

cursor_shape block

The output of kitty --debug-font-fallback is

[291 00:03:38.540443] Preloaded font faces:
[291 00:03:38.540503] normal face: /usr/share/fonts/TTF/Anonymous Pro.ttf:0
[291 00:03:38.540534] bold face: /usr/share/fonts/TTF/Anonymous Pro.ttf:0
[291 00:03:38.540570] italic face: /usr/share/fonts/TTF/Anonymous Pro.ttf:0
[291 00:03:38.540608] bi face: /usr/share/fonts/TTF/Anonymous Pro.ttf:0
[291 00:03:38.540648] Symbol map faces:
[291 00:03:38.540676] /home/qwattash/.local/share/fonts/AnonymousProPowerlinePatch.ttf:0

echoing on the terminal gives

# this prints a character not from AnonymousProPowerlinePatch, possibly from Source Code Pro, but I have no way of directly verifying it for now.
echo "\ue0b0"
# this prints the correct character.
echo "\ue0b1"

Fontconfig tells me the following:

$ fc-match -s "Anonymous Pro"
Anonymous Pro.ttf: "Anonymous Pro" "Regular"
AnonymousProPowerlinePatch.ttf: "AnonymousPro" "PowerlinePatch"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"
DejaVuSans-Oblique.ttf: "DejaVu Sans" "Oblique"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
NimbusSans-Regular.otf: "Nimbus Sans" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
cour.pfa: "Courier" "Regular"
DejaVuMathTeXGyre.ttf: "DejaVu Math TeX Gyre" "Regular"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
SourceCodePro-Regular.otf: "Source Code Pro" "Regular"
D050000L.otf: "D050000L" "Regular"
Jena_Gotisch_Regular.ttf: "Jena Gotisch" "Regular"
Cardinal_Regular.ttf: "Cardinal" "Regular"
Olde_English_Regular.ttf: "Olde English" "Regular"
SyrCOMAdiabene.otf: "East Syriac Adiabene" "Regular"
SyrCOMKharput.otf: "Serto Kharput" "Regular"
MonAmourFraktur_Regular.ttf: "MonAmourFraktur" "Regular"
Cantarell-Regular.otf: "Cantarell" "Regular"
GohaTibebZemen.otf: "Goha-Tibeb Zemen" "Regular"
DejaVuSerif-Bold.ttf: "DejaVu Serif" "Bold"
DejaVuSerif-Italic.ttf: "DejaVu Serif" "Italic"
7x13-ISO8859-1.pcf.gz: "Misc Fixed" "Regular"
7x13.pcf.gz: "Misc Fixed" "Regular"
8x13.pcf.gz: "Misc Fixed" "Regular"
clR6x13.pcf.gz: "Schumacher Clean" "Regular"
12x13ja.pcf.gz: "Misc Fixed Wide" "ja"
6x12.pcf.gz: "Misc Fixed" "SemiCondensed"
6x13.pcf.gz: "Misc Fixed" "SemiCondensed"
9x15.pcf.gz: "Misc Fixed" "Regular"
cu12.pcf.gz: "MUTT ClearlyU Wide" "Regular"
cu-alt12.pcf.gz: "MUTT ClearlyU Alternate Glyphs Wide" "Regular"
cu-pua12.pcf.gz: "MUTT ClearlyU PUA" "Regular"
18x18ja.pcf.gz: "Misc Fixed Wide" "ja"
10x20.pcf.gz: "Misc Fixed" "Regular"
$ fc-match -s "Anonymous Pro:charset=e0b0"
AnonymousProPowerlinePatch.ttf: "AnonymousPro" "PowerlinePatch"
SourceCodePro-Regular.otf: "Source Code Pro" "Regular"
SourceCodeVariable-Roman.otf: "Source Code Variable" "Roman"
Anonymous Pro.ttf: "Anonymous Pro" "Regular"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"
DejaVuSans-Oblique.ttf: "DejaVu Sans" "Oblique"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
NimbusSans-Regular.otf: "Nimbus Sans" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
cour.pfa: "Courier" "Regular"
DejaVuMathTeXGyre.ttf: "DejaVu Math TeX Gyre" "Regular"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
D050000L.otf: "D050000L" "Regular"
Jena_Gotisch_Regular.ttf: "Jena Gotisch" "Regular"
Cardinal_Regular.ttf: "Cardinal" "Regular"
Olde_English_Regular.ttf: "Olde English" "Regular"
SyrCOMAdiabene.otf: "East Syriac Adiabene" "Regular"
SyrCOMKharput.otf: "Serto Kharput" "Regular"
MonAmourFraktur_Regular.ttf: "MonAmourFraktur" "Regular"
Cantarell-Regular.otf: "Cantarell" "Regular"
GohaTibebZemen.otf: "Goha-Tibeb Zemen" "Regular"
DejaVuSerif-Bold.ttf: "DejaVu Serif" "Bold"
DejaVuSerif-Italic.ttf: "DejaVu Serif" "Italic"
7x13-ISO8859-1.pcf.gz: "Misc Fixed" "Regular"
7x13.pcf.gz: "Misc Fixed" "Regular"
8x13.pcf.gz: "Misc Fixed" "Regular"
clR6x13.pcf.gz: "Schumacher Clean" "Regular"
12x13ja.pcf.gz: "Misc Fixed Wide" "ja"
6x12.pcf.gz: "Misc Fixed" "SemiCondensed"
6x13.pcf.gz: "Misc Fixed" "SemiCondensed"
9x15.pcf.gz: "Misc Fixed" "Regular"
cu12.pcf.gz: "MUTT ClearlyU Wide" "Regular"
cu-alt12.pcf.gz: "MUTT ClearlyU Alternate Glyphs Wide" "Regular"
cu-pua12.pcf.gz: "MUTT ClearlyU PUA" "Regular"
18x18ja.pcf.gz: "Misc Fixed Wide" "ja"
10x20.pcf.gz: "Misc Fixed" "Regular"
$ fc-match -s "Anonymous Pro:charset=e0b1"
AnonymousProPowerlinePatch.ttf: "AnonymousPro" "PowerlinePatch"
SourceCodePro-Regular.otf: "Source Code Pro" "Regular"
SourceCodeVariable-Roman.otf: "Source Code Variable" "Roman"
Anonymous Pro.ttf: "Anonymous Pro" "Regular"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"
DejaVuSans-Oblique.ttf: "DejaVu Sans" "Oblique"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
NimbusSans-Regular.otf: "Nimbus Sans" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
cour.pfa: "Courier" "Regular"
DejaVuMathTeXGyre.ttf: "DejaVu Math TeX Gyre" "Regular"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
D050000L.otf: "D050000L" "Regular"
Jena_Gotisch_Regular.ttf: "Jena Gotisch" "Regular"
Cardinal_Regular.ttf: "Cardinal" "Regular"
Olde_English_Regular.ttf: "Olde English" "Regular"
SyrCOMAdiabene.otf: "East Syriac Adiabene" "Regular"
SyrCOMKharput.otf: "Serto Kharput" "Regular"
MonAmourFraktur_Regular.ttf: "MonAmourFraktur" "Regular"
Cantarell-Regular.otf: "Cantarell" "Regular"
GohaTibebZemen.otf: "Goha-Tibeb Zemen" "Regular"
DejaVuSerif-Bold.ttf: "DejaVu Serif" "Bold"
DejaVuSerif-Italic.ttf: "DejaVu Serif" "Italic"
7x13-ISO8859-1.pcf.gz: "Misc Fixed" "Regular"
7x13.pcf.gz: "Misc Fixed" "Regular"
8x13.pcf.gz: "Misc Fixed" "Regular"
clR6x13.pcf.gz: "Schumacher Clean" "Regular"
12x13ja.pcf.gz: "Misc Fixed Wide" "ja"
6x12.pcf.gz: "Misc Fixed" "SemiCondensed"
6x13.pcf.gz: "Misc Fixed" "SemiCondensed"
9x15.pcf.gz: "Misc Fixed" "Regular"
cu12.pcf.gz: "MUTT ClearlyU Wide" "Regular"
cu-alt12.pcf.gz: "MUTT ClearlyU Alternate Glyphs Wide" "Regular"
cu-pua12.pcf.gz: "MUTT ClearlyU PUA" "Regular"
18x18ja.pcf.gz: "Misc Fixed Wide" "ja"
10x20.pcf.gz: "Misc Fixed" "Regular"

And kitty detects the following

$ kitty list-fonts
Anonymous Pro
    Anonymous Pro
    Anonymous Pro Bold
    Anonymous Pro Bold Italic
    Anonymous Pro Italic

Anonymous Pro Minus
    Anonymous Pro Minus
    Anonymous Pro Minus Bold
    Anonymous Pro Minus Bold Italic
    Anonymous Pro Minus Italic

AnonymousPro
    AnonymousPro patch for symbols support

Courier
    Courier Bold
    Courier Bold Italic
    Courier Italic
    Courier Regular

Courier 10 Pitch
    Courier 10 Pitch Bold
    Courier 10 Pitch Bold Italic
    Courier 10 Pitch Italic
    Courier 10 Pitch Regular

Cursor
    Cursor Regular

DejaVu Sans Mono
    DejaVu Sans Mono
    DejaVu Sans Mono Bold
    DejaVu Sans Mono Bold Oblique
    DejaVu Sans Mono Oblique

Droid Sans Mono
    Droid Sans Mono
Luxi Mono
    Luxi Mono Oblique
    Luxi Mono Regular

MyPatchedFont
    MyPatchedFont

Nimbus Mono PS
    NimbusMonoPS-Bold
    NimbusMonoPS-BoldItalic
    NimbusMonoPS-Italic
    NimbusMonoPS-Regular

Source Code Pro
    Source Code Pro
    Source Code Pro Black
    Source Code Pro Black Italic
    Source Code Pro Bold
    Source Code Pro Bold Italic
    Source Code Pro ExtraLight
    Source Code Pro ExtraLight Italic
    Source Code Pro Italic
    Source Code Pro Light
    Source Code Pro Light Italic
    Source Code Pro Medium
    Source Code Pro Medium Italic
    Source Code Pro Semibold
    Source Code Pro Semibold Italic

Source Code Variable
    Source Code Variable
    Source Code Variable
    Source Code Variable
    Source Code Variable
    Source Code Variable
    Source Code Variable
    Source Code Variable
    Source Code Variable
    Source Code Variable Italic
    Source Code Variable Italic
    Source Code Variable Italic
    Source Code Variable Italic
    Source Code Variable Italic
    Source Code Variable Italic
    Source Code Variable Italic
    Source Code Variable Italic
kovidgoyal commented 5 years ago

--debug-font-fallback gives you actual output showing you where each character is rendered from. Note that some box drawing characters such as the solid triangles and D from the powerline symbol set are rendered directly by kitty to ensure that they line up the cell boundaries, which is impossible to guarantee with font rendering.

Sherulez commented 4 years ago

If this is correct you should at least change your example in the kitty.conf # symbol_map U+E0A0-U+E0A2,U+E0B0-U+E0B3 PowerlineSymbols

Putting U+E0B0 in this example make no sense and it is misleading, since it is a box drawing char.


And to be honest, all these hard coded characters ... meh. Yes yes, I know, it facilitates alignment. But what if i want to use a custom made box-drawing char, mmh ?

ctrlcctrlv commented 4 years ago

If you want to disable them, you can apply my patch here:

https://github.com/kovidgoyal/kitty/issues/2240#issuecomment-580534887

I agree with Kovid though, his box drawing code is much better for most cases.

kovidgoyal commented 4 years ago

On Sat, Feb 15, 2020 at 12:00:54PM -0800, Sherulez wrote:

If this is correct you should at least change your example in the kitty.conf # symbol_map U+E0A0-U+E0A2,U+E0B0-U+E0B3 PowerlineSymbols

Putting U+E0B0 in this example make no sense and it is misleading, since it is a box drawing char.

What?? U+E0B0 is not a box drawing character it is a private use character, with NO defined shape.


And to be honest, all these hard coded characters ... meh. Yes yes, I know, it facilitates alignment. But what if i want to use a custom made box-drawing char, mmh ?

The goal of having properly aligned box drawing characters is far more important than that of allowing users to override their shapes. And if that was really desired it could actually be implemented easily in the current system by simply asking them to write a program that outputs the glyph for a codepoint at a specified size. kitty could then call the program to render the character.