Page MenuHomeMusing Studio

fonts.go
No OneTemporary

fonts.go

package config
import (
"fmt"
)
// postFont represents a valid post appearance value in the API.
type postFont string
// Valid appearance types for posts.
const (
PostFontNormal postFont = "norm"
PostFontSans = "sans"
PostFontMono = "mono"
PostFontWrap = "wrap"
PostFontCode = "code"
)
var postFontMap = map[string]postFont{
"norm": PostFontNormal,
"normal": PostFontNormal,
"serif": PostFontNormal,
"sans": PostFontSans,
"sansserif": PostFontSans,
"mono": PostFontMono,
"monospace": PostFontMono,
"wrap": PostFontWrap,
"code": PostFontCode,
}
func GetFont(code bool, font string) string {
if code {
if font != "" && font != DefaultFont {
fmt.Printf("A non-default font '%s' and --code flag given. 'code' type takes precedence.\n", font)
}
return "code"
}
// Validate font value
if f, ok := postFontMap[font]; ok {
return string(f)
}
fmt.Printf("Font '%s' invalid. Using default '%s'\n", font, DefaultFont)
return string(DefaultFont)
}

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 20, 1:19 AM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3135660

Event Timeline