package d2fonts
import (
"embed"
_ "embed"
"strings"
"oss.terrastruct.com/d2/lib/syncmap"
)
var sourceSansProRegularBase64 string
var sourceSansProBoldBase64 string
var sourceSansProSemiboldBase64 string
var sourceSansProItalicBase64 string
var sourceCodeProRegularBase64 string
var sourceCodeProBoldBase64 string
var sourceCodeProSemiboldBase64 string
var sourceCodeProItalicBase64 string
var fuzzyBubblesRegularBase64 string
var fuzzyBubblesBoldBase64 string
var fontFacesFS embed .FS
func init() {
FontEncodings = syncmap .New [Font , string ]()
FontEncodings .Set (
Font {
Family : SourceSansPro ,
Style : FONT_STYLE_REGULAR ,
},
sourceSansProRegularBase64 )
FontEncodings .Set (
Font {
Family : SourceSansPro ,
Style : FONT_STYLE_BOLD ,
},
sourceSansProBoldBase64 )
FontEncodings .Set (
Font {
Family : SourceSansPro ,
Style : FONT_STYLE_SEMIBOLD ,
},
sourceSansProSemiboldBase64 )
FontEncodings .Set (
Font {
Family : SourceSansPro ,
Style : FONT_STYLE_ITALIC ,
},
sourceSansProItalicBase64 )
FontEncodings .Set (
Font {
Family : SourceCodePro ,
Style : FONT_STYLE_REGULAR ,
},
sourceCodeProRegularBase64 )
FontEncodings .Set (
Font {
Family : SourceCodePro ,
Style : FONT_STYLE_BOLD ,
},
sourceCodeProBoldBase64 )
FontEncodings .Set (
Font {
Family : SourceCodePro ,
Style : FONT_STYLE_SEMIBOLD ,
},
sourceCodeProSemiboldBase64 )
FontEncodings .Set (
Font {
Family : SourceCodePro ,
Style : FONT_STYLE_ITALIC ,
},
sourceCodeProItalicBase64 )
FontEncodings .Set (
Font {
Family : HandDrawn ,
Style : FONT_STYLE_REGULAR ,
},
fuzzyBubblesRegularBase64 )
FontEncodings .Set (
Font {
Family : HandDrawn ,
Style : FONT_STYLE_ITALIC ,
}, fuzzyBubblesRegularBase64 )
FontEncodings .Set (
Font {
Family : HandDrawn ,
Style : FONT_STYLE_BOLD ,
}, fuzzyBubblesBoldBase64 )
FontEncodings .Set (
Font {
Family : HandDrawn ,
Style : FONT_STYLE_SEMIBOLD ,
}, fuzzyBubblesBoldBase64 )
FontEncodings .Range (func (k Font , v string ) bool {
FontEncodings .Set (k , strings .TrimSuffix (v , "\n" ))
return true
})
FontFaces = syncmap .New [Font , []byte ]()
b , err := fontFacesFS .ReadFile ("ttf/SourceSansPro-Regular.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : SourceSansPro ,
Style : FONT_STYLE_REGULAR ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/SourceCodePro-Regular.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : SourceCodePro ,
Style : FONT_STYLE_REGULAR ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/SourceCodePro-Bold.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : SourceCodePro ,
Style : FONT_STYLE_BOLD ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/SourceCodePro-Semibold.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : SourceCodePro ,
Style : FONT_STYLE_SEMIBOLD ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/SourceCodePro-Italic.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : SourceCodePro ,
Style : FONT_STYLE_ITALIC ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/SourceSansPro-Bold.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : SourceSansPro ,
Style : FONT_STYLE_BOLD ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/SourceSansPro-Semibold.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : SourceSansPro ,
Style : FONT_STYLE_SEMIBOLD ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/SourceSansPro-Italic.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : SourceSansPro ,
Style : FONT_STYLE_ITALIC ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/FuzzyBubbles-Regular.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : HandDrawn ,
Style : FONT_STYLE_REGULAR ,
}, b )
FontFaces .Set (Font {
Family : HandDrawn ,
Style : FONT_STYLE_ITALIC ,
}, b )
b , err = fontFacesFS .ReadFile ("ttf/FuzzyBubbles-Bold.ttf" )
if err != nil {
panic (err )
}
FontFaces .Set (Font {
Family : HandDrawn ,
Style : FONT_STYLE_BOLD ,
}, b )
FontFaces .Set (Font {
Family : HandDrawn ,
Style : FONT_STYLE_SEMIBOLD ,
}, b )
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .