you can now set a custom font dir

This commit is contained in:
Felix Angell 2018-05-23 20:02:51 +01:00
parent 9fa60138b3
commit e6234ba706
2 changed files with 15 additions and 8 deletions

View File

@ -116,6 +116,7 @@ type EditorConfig struct {
Match_Braces bool
Maintain_Indentation bool
Highlight_Line bool
Font_Path string
Font_Face string
Font_Size int
Show_Line_Numbers bool

View File

@ -82,17 +82,23 @@ func configureAndValidate(conf *TomlConfig) {
// fonts
log.Println("Configuring fonts")
{
switch runtime.GOOS {
case "windows":
FONT_FOLDER = filepath.Join(os.Getenv("WINDIR"), "fonts")
case "darwin":
FONT_FOLDER = "/Library/Fonts/"
case "linux":
FONT_FOLDER = findFontFolder()
// the font path has not been set
// so we have to figure out what it is.
if len(conf.Editor.Font_Path) == 0 {
switch runtime.GOOS {
case "windows":
FONT_FOLDER = filepath.Join(os.Getenv("WINDIR"), "fonts")
case "darwin":
FONT_FOLDER = "/Library/Fonts/"
case "linux":
FONT_FOLDER = findFontFolder()
}
// and set it accordingly.
conf.Editor.Font_Path = FONT_FOLDER
}
// we only support ttf at the moment.
fontPath := filepath.Join(FONT_FOLDER, conf.Editor.Font_Face) + ".ttf"
fontPath := filepath.Join(conf.Editor.Font_Path, conf.Editor.Font_Face) + ".ttf"
if _, err := os.Stat(fontPath); os.IsNotExist(err) {
log.Fatal("No such font '" + fontPath + "'")
// TODO cool error messages for the toml format?