raphamorim / rio

A hardware-accelerated GPU terminal emulator focusing to run in desktops and browsers.
https://raphamorim.io/rio
MIT License
3.65k stars 115 forks source link

Problem with fonts in NixOS #642

Closed tukanoidd closed 1 month ago

tukanoidd commented 2 months ago

@raphamorim hey, having this isuse with a different font, "JetBrainsMono NerdFont", on NixOS. The fonts did indeed change, I used fc-list to ensure I changed to the right names/weights/styles, but it still can't find them.

Here's my nix config snippet:

      fonts = let
        family = "JetBrainsMono NF";
        otherFamily = "Iosevka Comfy Fixed";
      in {
        inherit family;
        size = 18;

        extras = [{family = otherFamily;}];

        bold = {
          inherit family;
          style = "Bold";
          weight = 200;
        };

        italic = {
          inherit family;
          style = "Italic";
          weight = 80;
        };

        regular = {
          inherit family;
          style = "Regular";
          weight = 80;
        };
      };

To make it easier for myself, I created this nushell function:

def "fonts info weight" [family: string --path = false, --names = false --styles = false] {
  let no_filters  = (not $path) and (not $names) and (not $styles);
  let filters = {path: $path, names: $names, styles: $styles}

  (fc-list :family=($family) weight) 
    | split row "\n"
    | each {$in | split row "=" | get 1 | str trim}
    | each {|$weight| 
      let weight_fonts = (fc-list :weight=($weight)) 
        | split row "\n" 
        | filter {$in | str contains $family}
        | each {
          let path_names_styles = $in | split row ": "
          let path = $path_names_styles | get 0 
          let names_styles = $path_names_styles | get 1 | split row ":style="
          let names = $names_styles | get 0 | split row ","
          let styles = $names_styles | get 1 | split row ","

          if $no_filters {
            return {path: $path, names: $names, styles: $styles}
          }

          mut res = {}

          if $filters.path {
            $res = $res | insert path {$path} 
          }

          if $filters.names {
            $res = $res | insert names {$names}
          }

          if $filters.styles {
            $res = $res | insert styles {$styles}
          }

          $res
        }

      {weight: $weight, fonts: $weight_fonts}
    }
}

That, with fonts info weight "JetBrainsMono NF" --styles=true --names=true | to json returns:

[
  {
    "weight": "0",
    "fonts": [
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP Thin"
        ],
        "styles": [
          "Thin Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF Thin"
        ],
        "styles": [
          "Thin",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP Thin"
        ],
        "styles": [
          "Thin",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM Thin"
        ],
        "styles": [
          "Thin",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF Thin"
        ],
        "styles": [
          "Thin Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM Thin"
        ],
        "styles": [
          "Thin Italic",
          "Italic"
        ]
      }
    ]
  },
  {
    "weight": "40",
    "fonts": [
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM ExtraLight"
        ],
        "styles": [
          "ExtraLight Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF ExtraLight"
        ],
        "styles": [
          "ExtraLight Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF ExtraLight"
        ],
        "styles": [
          "ExtraLight",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP ExtraLight"
        ],
        "styles": [
          "ExtraLight Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM ExtraLight"
        ],
        "styles": [
          "ExtraLight",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP ExtraLight"
        ],
        "styles": [
          "ExtraLight",
          "Regular"
        ]
      }
    ]
  },
  {
    "weight": "50",
    "fonts": [
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF Light"
        ],
        "styles": [
          "Light Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP Light"
        ],
        "styles": [
          "Light Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF Light"
        ],
        "styles": [
          "Light",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP Light"
        ],
        "styles": [
          "Light",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM Light"
        ],
        "styles": [
          "Light Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM Light"
        ],
        "styles": [
          "Light",
          "Regular"
        ]
      }
    ]
  },
  {
    "weight": "80",
    "fonts": [
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM"
        ],
        "styles": [
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP"
        ],
        "styles": [
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF"
        ],
        "styles": [
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM"
        ],
        "styles": [
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP"
        ],
        "styles": [
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF"
        ],
        "styles": [
          "Italic"
        ]
      }
    ]
  },
  {
    "weight": "100",
    "fonts": [
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM Medium"
        ],
        "styles": [
          "Medium Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP Medium"
        ],
        "styles": [
          "Medium",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF Medium"
        ],
        "styles": [
          "Medium",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP Medium"
        ],
        "styles": [
          "Medium Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM Medium"
        ],
        "styles": [
          "Medium",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF Medium"
        ],
        "styles": [
          "Medium Italic",
          "Italic"
        ]
      }
    ]
  },
  {
    "weight": "180",
    "fonts": [
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF SemiBold"
        ],
        "styles": [
          "SemiBold Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP SemiBold"
        ],
        "styles": [
          "SemiBold Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP SemiBold"
        ],
        "styles": [
          "SemiBold",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM SemiBold"
        ],
        "styles": [
          "SemiBold Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM SemiBold"
        ],
        "styles": [
          "SemiBold",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF SemiBold"
        ],
        "styles": [
          "SemiBold",
          "Regular"
        ]
      }
    ]
  },
  {
    "weight": "200",
    "fonts": [
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP"
        ],
        "styles": [
          "Bold Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM"
        ],
        "styles": [
          "Bold"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM"
        ],
        "styles": [
          "Bold Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF"
        ],
        "styles": [
          "Bold"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF"
        ],
        "styles": [
          "Bold Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP"
        ],
        "styles": [
          "Bold"
        ]
      }
    ]
  },
  {
    "weight": "205",
    "fonts": [
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM ExtraBold"
        ],
        "styles": [
          "ExtraBold Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP ExtraBold"
        ],
        "styles": [
          "ExtraBold Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Mono",
          "JetBrainsMono NFM",
          "JetBrainsMono NFM ExtraBold"
        ],
        "styles": [
          "ExtraBold",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font Propo",
          "JetBrainsMono NFP",
          "JetBrainsMono NFP ExtraBold"
        ],
        "styles": [
          "ExtraBold",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF ExtraBold"
        ],
        "styles": [
          "ExtraBold",
          "Regular"
        ]
      },
      {
        "names": [
          "JetBrainsMono Nerd Font",
          "JetBrainsMono NF",
          "JetBrainsMono NF ExtraBold"
        ],
        "styles": [
          "ExtraBold Italic",
          "Italic"
        ]
      }
    ]
  }
]

Tried both Nerd Font and NF variant, both fail.

I also made sure it's not coming from Iosevka font, if I run fonts info weight "Iosevka Comfy Fixed" --styles=true --names=true | to json:

[
  {
    "weight": "50",
    "fonts": [
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed Light"
        ],
        "styles": [
          "Light",
          "Regular"
        ]
      },
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed Light"
        ],
        "styles": [
          "Light Italic",
          "Italic"
        ]
      }
    ]
  },
  {
    "weight": "55",
    "fonts": [
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed SemiLight"
        ],
        "styles": [
          "SemiLight Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed SemiLight"
        ],
        "styles": [
          "SemiLight",
          "Regular"
        ]
      }
    ]
  },
  {
    "weight": "80",
    "fonts": [
      {
        "names": [
          "Iosevka Comfy Fixed"
        ],
        "styles": [
          "Italic"
        ]
      },
      {
        "names": [
          "Iosevka Comfy Fixed"
        ],
        "styles": [
          "Regular"
        ]
      }
    ]
  },
  {
    "weight": "100",
    "fonts": [
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed Medium"
        ],
        "styles": [
          "Medium",
          "Regular"
        ]
      },
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed Medium"
        ],
        "styles": [
          "Medium Italic",
          "Italic"
        ]
      }
    ]
  },
  {
    "weight": "180",
    "fonts": [
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed Semibold"
        ],
        "styles": [
          "Semibold",
          "Regular"
        ]
      },
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed Semibold"
        ],
        "styles": [
          "Semibold Italic",
          "Italic"
        ]
      }
    ]
  },
  {
    "weight": "200",
    "fonts": [
      {
        "names": [
          "Iosevka Comfy Fixed"
        ],
        "styles": [
          "Bold Italic"
        ]
      },
      {
        "names": [
          "Iosevka Comfy Fixed"
        ],
        "styles": [
          "Bold"
        ]
      }
    ]
  },
  {
    "weight": "205",
    "fonts": [
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed Extrabold"
        ],
        "styles": [
          "Extrabold Italic",
          "Italic"
        ]
      },
      {
        "names": [
          "Iosevka Comfy Fixed",
          "Iosevka Comfy Fixed Extrabold"
        ],
        "styles": [
          "Extrabold",
          "Regular"
        ]
      }
    ]
  }
]

the font is found without an issue.

Does it have something to do with weights being so small compared to the ones used in the docs? Before i did use to have 400/800 but since fc-list showed be smaller values, I used them. Or are those values from fc-list inaccurate?

Edit after checking info regarding weights reported by fc-list: based on the mappings described here https://stackoverflow.com/questions/50662370/font-weights-as-reported-by-fc-list-not-expected-what-do-i-use-for-google-fonts, I changed Regular & Italic to 400, Bold to 700, same error.

Also, here's a screenshot of the error just in case if that can somehow help with determining the issue (me doing a dumb typo or using wrong casing for styles etc) image

tukanoidd commented 2 months ago

Rio version 0.1.10 (using repo flake, updated today, locked at 8e424d429076714d1462e8e88a3e64f6dd33aa1e)

Fonts - nixpkgs#nerdfonts & nixpkgs#iosevka-comfy.comfy-fixed

tukanoidd commented 2 months ago

In case you decide to use my nushell function to check for the needed info, here's an updated version that has some filtering of which font data to display (/nix/store/path/to/font's are too long) can also automatically convert weights to non-fc values

def "fonts weight non-fc" [weight:int] {
  let weight_non_fc_converter = [
    {from: 0, to: 100},
    {from: 40, to: 200},
    {from: 50, to: 300},
    {from: 55, to: 350},
    {from: 75, to: 380},
    {from: 80, to: 400},
    {from: 100, to: 500},
    {from: 180, to: 600},
    {from: 200, to: 700},
    {from: 205, to: 800},
    {from: 210, to: 900},
    {from: 215, to: 1000},
  ];

  let convert = $weight_non_fc_converter | find -c ["from"] $weight

  if ($convert | is-empty) {
    $weight
  } else {
    $convert.to | get 0
  }

}

def "fonts info weight" [
  family: string 
  --path = false, 
  --names = false 
  --styles = false 
  --non-fc-values=false
] {
  let no_filters  = (not $path) and (not $names) and (not $styles);
  let filters = {path: $path, names: $names, styles: $styles}

  (fc-list :family=($family) weight) 
    | split row "\n"
    | each {$in | split row "=" | get 1 | str trim}
    | each {|$weight_str| 
      let weight = if ($weight_str | str starts-with '[') {
        let last = ($weight_str | str length) - 2
        let weights = $weight_str | str substring 1..$last | split row " "

        let weight = $weights | each {$in | into int}

        if $non_fc_values {
          $weight | each {fonts weight non-fc $in}
        } else {
          $weight
        }
      } else { 
        let weight = $weight_str | into int 

        if $non_fc_values {
          fonts weight non-fc $weight
        } else {
          $weight
        }
      };

      let weight_fonts = (fc-list :weight=($weight_str)) 
        | split row "\n" 
        | filter {$in | str contains $family}
        | each {
          let path_names_styles = $in | split row ": "
          let path = $path_names_styles | get 0 
          let names_styles = $path_names_styles | get 1 | split row ":style="
          let names = $names_styles | get 0 | split row ","
          let styles = $names_styles | get 1 | split row ","

          if $no_filters {
            return {path: $path, names: $names, styles: $styles}
          }

          mut res = {}

          if $filters.path {
            $res = $res | insert path {$path} 
          }

          if $filters.names {
            $res = $res | insert names {$names}
          }

          if $filters.styles {
            $res = $res | insert styles {$styles}
          }

          $res
        }

      {weight: $weight, fonts: $weight_fonts}
    }
}
tukanoidd commented 2 months ago

Ok, based on this issue i found out about this, so might not be an issue inside rio

tukanoidd commented 2 months ago

tried setting session variables as was said in the issue, but didnt seem to do anything

tukanoidd commented 1 month ago

Found this (tracking to the PR with SOME font fixes), when it lands in nixpkgs-unstable (can't risk with using master branch, im not that crazy :laughing: )

raphamorim commented 1 month ago

Thanks for the heads up and debug @tukanoidd ! Question: When do specify weight in other fonts, does it works? or is only this one

tukanoidd commented 1 month ago

uh, i cant tell atm, i tried to update my system again in hopes the issue was fixed (b4 i found out about the tracker) and currently fc-list shows only 1 DejaVu font available for some reason, and none from these image image which is confusing, as it was showing them yesterday

tukanoidd commented 1 month ago

Ok, thats weird, they only show up with sudo now? What

tukanoidd commented 1 month ago

Finally managed to get it working, have to use nixos-unstable-small nixpkgs branch until the fixes land in nixos-unstable finally, sorry for creating this issue without doing proper research first

raphamorim commented 1 month ago

No worries at all @tukanoidd Just glad is working now

tukanoidd commented 1 month ago

No worries at all @tukanoidd Just glad is working now

Same, I really like the terminal, been following since 0.0.x days, just couldn't use it in my environment until it hit 0.1 (prolly better compat with Wayland in Sugarloaf?), very happy with it.

raphamorim commented 1 month ago

❤️