github.com/kintar/etxt@v0.0.9/doc.go (about)

     1  // etxt is a package for font management and text rendering in Golang
     2  // designed to be used mainly with the Ebitengine game engine.
     3  //
     4  // While the API surface can look slightly intimidating at the beginning,
     5  // common usage depends only on a couple types and a few functions...
     6  //
     7  // First, you create a [FontLibrary] and parse the fonts:
     8  //
     9  //	fontLib := etxt.NewFontLibrary()
    10  //	_, _, err := fontLib.ParseDirFonts("path/to/fonts")
    11  //	if err != nil { ... }
    12  //
    13  // Then, you create a [Renderer]:
    14  //
    15  //	txtRenderer := etxt.NewStdRenderer()
    16  //	txtRenderer.SetFont(fontLib.GetFont("My Font Name"))
    17  //
    18  // Finally, you set a target and start drawing:
    19  //
    20  //	txtRenderer.SetTarget(screen)
    21  //	txtRenderer.Draw("Hello world!", x, y)
    22  //
    23  // There are a lot of parameters you can configure, but the critical ones
    24  // are font, size, align, color, cache and target. Take a good look at those
    25  // and have fun exploring the rest!
    26  package etxt