Package d2fonts
import "oss.terrastruct.com/d2/d2renderers/d2fonts"
- Overview
- Index
Constants
const (
FONT_SIZE_XS = 13
FONT_SIZE_S = 14
FONT_SIZE_M = 16
FONT_SIZE_L = 20
FONT_SIZE_XL = 24
FONT_SIZE_XXL = 28
FONT_SIZE_XXXL = 32
FONT_STYLE_REGULAR FontStyle = "regular"
FONT_STYLE_BOLD FontStyle = "bold"
FONT_STYLE_SEMIBOLD FontStyle = "semibold"
FONT_STYLE_ITALIC FontStyle = "italic"
SourceSansPro FontFamily = "SourceSansPro"
SourceCodePro FontFamily = "SourceCodePro"
HandDrawn FontFamily = "HandDrawn"
)
Variables
var D2_FONT_TO_FAMILY = map[string]FontFamily{
"default": SourceSansPro,
"mono": SourceCodePro,
}
var FontEncodings syncmap.SyncMap[Font, string]
var FontFaces syncmap.SyncMap[Font, []byte]
var FontFamilies = []FontFamily{
SourceSansPro,
SourceCodePro,
HandDrawn,
}
var FontFamiliesMu sync.Mutex
var FontSizes = []int{
FONT_SIZE_XS,
FONT_SIZE_S,
FONT_SIZE_M,
FONT_SIZE_L,
FONT_SIZE_XL,
FONT_SIZE_XXL,
FONT_SIZE_XXXL,
}
var FontStyles = []FontStyle{
FONT_STYLE_REGULAR,
FONT_STYLE_BOLD,
FONT_STYLE_SEMIBOLD,
FONT_STYLE_ITALIC,
}
func AddFontStyle(font Font, style FontStyle, ttf []byte) error
type Font struct {
Family FontFamily
Style FontStyle
Size int
}
func (f Font) GetEncodedSubset(corpus string) string
type FontFamily string
func AddFontFamily(name string, regularTTF, italicTTF, boldTTF, semiboldTTF []byte) (*FontFamily, error)
func (FontFamily) Font
¶
func (f FontFamily) Font(size int, style FontStyle) Font
type FontStyle string