font

package
v1.0.1-0...-c7f6355 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2020 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

Package font provides support for Allegro's font addon.

Index

Constants

View Source
const (
	ALIGN_LEFT    DrawFlags = C.ALLEGRO_ALIGN_LEFT
	ALIGN_CENTRE            = C.ALLEGRO_ALIGN_CENTRE
	ALIGN_RIGHT             = C.ALLEGRO_ALIGN_RIGHT
	ALIGN_INTEGER           = C.ALLEGRO_ALIGN_INTEGER
)

Variables

This section is empty.

Functions

func DrawJustifiedText

func DrawJustifiedText(font *Font, color allegro.Color, x1, x2, y, diff float32, flags DrawFlags, text string)

Like al_draw_text, but justifies the string to the region x1-x2.

See https://liballeg.org/a5docs/5.2.6/font.html#al_draw_justified_text

func DrawJustifiedTextf

func DrawJustifiedTextf(font *Font, color allegro.Color, x1, x2, y, diff float32, flags DrawFlags, format string, a ...interface{})

func DrawText

func DrawText(font *Font, color allegro.Color, x, y float32, flags DrawFlags, text string)

Writes the NUL-terminated string text onto the target bitmap at position x, y, using the specified font.

See https://liballeg.org/a5docs/5.2.6/font.html#al_draw_text

func DrawTextf

func DrawTextf(font *Font, color allegro.Color, x, y float32, flags DrawFlags, format string, a ...interface{})

func Install

func Install()

Initialise the font addon.

See https://liballeg.org/a5docs/5.2.6/font.html#al_init_font_addon

func Installed

func Installed() bool

Returns true if the font addon is initialized, otherwise returns false.

See https://liballeg.org/a5docs/5.2.6/font.html#al_is_font_addon_initialized

func Uninstall

func Uninstall()

Shut down the font addon. This is done automatically at program exit, but can be called any time the user wishes as well.

See https://liballeg.org/a5docs/5.2.6/font.html#al_shutdown_font_addon

func Version

func Version() (major, minor, revision, release uint8)

Returns the (compiled) version of the addon, in the same format as al_get_allegro_version.

See https://liballeg.org/a5docs/5.2.6/font.html#al_get_allegro_font_version

Types

type DrawFlags

type DrawFlags int

type Font

type Font C.ALLEGRO_FONT

func Builtin

func Builtin() (*Font, error)

Creates a monochrome bitmap font (8x8 pixels per character).

See https://liballeg.org/a5docs/5.2.6/font.html#al_create_builtin_font

func GrabFontFromBitmap

func GrabFontFromBitmap(bmp *allegro.Bitmap, ranges [][2]int) (*Font, error)

Creates a new font from an Allegro bitmap. You can delete the bitmap after the function returns as the font will contain a copy for itself.

See https://liballeg.org/a5docs/5.2.6/font.html#al_grab_font_from_bitmap

func LoadBitmapFont

func LoadBitmapFont(filename string) (*Font, error)

Load a bitmap font from a file. This is done by first calling al_load_bitmap_flags and then al_grab_font_from_bitmap.

See https://liballeg.org/a5docs/5.2.6/font.html#al_load_bitmap_font

func LoadFont

func LoadFont(filename string, size, flags int) (*Font, error)

Loads a font from disk. This will use al_load_bitmap_font_flags if you pass the name of a known bitmap format, or else al_load_ttf_font.

See https://liballeg.org/a5docs/5.2.6/font.html#al_load_font

func (*Font) Ascent

func (f *Font) Ascent() int

Returns the ascent of the specified font.

See https://liballeg.org/a5docs/5.2.6/font.html#al_get_font_ascent

func (*Font) Descent

func (f *Font) Descent() int

Returns the descent of the specified font.

See https://liballeg.org/a5docs/5.2.6/font.html#al_get_font_descent

func (*Font) Destroy

func (f *Font) Destroy()

Frees the memory being used by a font structure. Does nothing if passed NULL.

See https://liballeg.org/a5docs/5.2.6/font.html#al_destroy_font

func (*Font) LineHeight

func (f *Font) LineHeight() int

Returns the usual height of a line of text in the specified font. For bitmap fonts this is simply the height of all glyph bitmaps. For truetype fonts it is whatever the font file specifies. In particular, some special glyphs may be higher than the height returned here.

See https://liballeg.org/a5docs/5.2.6/font.html#al_get_font_line_height

func (*Font) TextDimensions

func (f *Font) TextDimensions(text string) (bbx, bby, bbw, bbh int)

Sometimes, the al_get_text_width and al_get_font_line_height functions are not enough for exact text placement, so this function returns some additional information.

See https://liballeg.org/a5docs/5.2.6/font.html#al_get_text_dimensions

func (*Font) TextWidth

func (f *Font) TextWidth(text string) int

Calculates the length of a string in a particular font, in pixels.

See https://liballeg.org/a5docs/5.2.6/font.html#al_get_text_width

Directories

Path Synopsis
Package ttf provides support for Allegro's TTF font addon.
Package ttf provides support for Allegro's TTF font addon.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL