mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-29 20:10:56 -08:00
fix(fonts): register user fonts correctly on Windows
Previously on Windows, fonts installed with `oh-my-posh font install --user` would not show up in the Control Panel nor as an option in program font menus. Now, fonts are correctly registered.
This commit is contained in:
parent
2d2af929a9
commit
a711f9b7f7
|
@ -42,9 +42,11 @@ func install(font *Font, admin bool) error {
|
|||
}
|
||||
|
||||
// Add registry entry
|
||||
reg := registry.LOCAL_MACHINE
|
||||
var reg = registry.LOCAL_MACHINE
|
||||
var regValue = font.FileName
|
||||
if !admin {
|
||||
reg = registry.CURRENT_USER
|
||||
regValue = fullPath
|
||||
}
|
||||
|
||||
k, err := registry.OpenKey(reg, `SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts`, registry.WRITE)
|
||||
|
@ -59,7 +61,7 @@ func install(font *Font, admin bool) error {
|
|||
defer k.Close()
|
||||
|
||||
name := fmt.Sprintf("%v (TrueType)", font.Name)
|
||||
if err = k.SetStringValue(name, font.FileName); err != nil {
|
||||
if err = k.SetStringValue(name, regValue); err != nil {
|
||||
// If this fails, remove the font file as well.
|
||||
if nexterr := os.Remove(fullPath); nexterr != nil {
|
||||
return errors.New("Unable to delete font file after registry key set error")
|
||||
|
|
Loading…
Reference in a new issue