embed font in binary

Amolith created

Change summary

main.go | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

Detailed changes

main.go 🔗

@@ -1,6 +1,7 @@
 package main
 
 import (
+	_ "embed"
 	"fmt"
 	"os"
 	"strings"
@@ -15,12 +16,13 @@ var (
 	flagHelp          *bool   = flag.BoolP("help", "h", false, "Show the help message")
 	flagInput         *string = flag.StringP("input", "i", "", "Path to input Markdown")
 	flagOutput        *string = flag.StringP("output", "o", "", "Path to output PNG")
-	flagFont          *string = flag.StringP("font", "f", "", "Name of font used in the cover image")
 	flagMetaSize      *int    = flag.IntP("metasize", "m", 12, "Size of font for meta information")
 	flagPostTitleSize *int    = flag.IntP("posttitlesize", "p", 14, "Size of font for post title")
 	flagSiteTitleSize *int    = flag.IntP("sitetitlesize", "s", 10, "Size of font for site title")
 )
 
+//go:embed font.otf
+
 func main() {
 	flag.Parse()
 
@@ -46,7 +48,7 @@ func help() {
 	fmt.Println("\nOptions:")
 	flag.PrintDefaults()
 	fmt.Print(`
-example: p2c -i input.md -o output.png -f "Liberation Sans"
+example: p2c -i input.md -o output.png
 
 p2c is meant for use with Hugo.
 
@@ -72,10 +74,6 @@ func validateFlags() {
 		fmt.Println("Error: No output file specified")
 		os.Exit(1)
 	}
-	if *flagFont == "" {
-		fmt.Println("Error: No font specified")
-		os.Exit(1)
-	}
 }
 
 // Get the post's title, subtitle, and date