From e6234ba706185548126381a1313af6477945803c Mon Sep 17 00:00:00 2001 From: Felix Angell Date: Wed, 23 May 2018 20:02:51 +0100 Subject: [PATCH] you can now set a custom font dir --- cfg/config.go | 1 + cfg/loader.go | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cfg/config.go b/cfg/config.go index 6a1a0eb..6dc3f2f 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -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 diff --git a/cfg/loader.go b/cfg/loader.go index 13a16d4..5fe8c5e 100644 --- a/cfg/loader.go +++ b/cfg/loader.go @@ -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?