Font functions
Font and text functions. Fonts Fonts can be created from TTF-fonts by the command: vg4 font convert. ImageMagick or GraphicsMagick must be installed. Font-characters are in UTF-8. There are predefined system-fonts based on ISO-8859-1 characters: - sys:low: proportional font for low window-size (VG_WINDOW_SIZE_LOW) - sysw:low: non-proportional font for low window-size (VG_WINDOW_SIZE_LOW) - sys:high: proportional font for high window-size (VG_WINDOW_SIZE_HIGH) - sysw:high: non-proportional font high window-size (VG_WINDOW_SIZE_HIGH) Fonts are loaded from: - a user-defined path set via vg4->font->path() - the VgaGames system-path Text A text can have control-commands for formatting the text (see vg4->font->totext()). It can be loaded from file or created on the fly and is returned as an image. See also the command: vg4 font -h vg4 text -h
- Enumerations and Structures
- VG_ORIENTATIONS
- struct VG_Fontchar
- Font functions
- vg4->font->setdefault()
Set default fontname. - vg4->font->getdefault()
Get default fontname. - vg4->font->path()
Set path to user-created fonts. - vg4->font->load()
Load font. - vg4->font->maxsize()
Get greatest width and height of a font. - vg4->font->gaps()
Get number of empty pixel-lines at the top and the bottom of a font. - vg4->font->getname()
Get name of a font. - vg4->font->getchars()
Get all characters of a font. - vg4->font->destroy()
Destroy font. - vg4->font->destroyall()
Destroy all fonts. - Text functions
- vg4->font->loadtext()
Load text from a file. - vg4->font->totext()
Create text image.
Example 

/* show text file with two ways to show two lines with two text-boxes */ example.c /* load textfile and show it */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> #include <vgagames4.h> int main(int argc, char **argv) { struct VG_Image *imgp; (void)argc; (void)argv; /* initialize and open window */ if (!VG_init("test")) { exit(1); } if (!vg4->window->open(VG_WINDOW_SIZE_LOW, VG_WINDOW_SCALE_BEST)) { VG_dest(); exit(1); } /* create image from text-file */ imgp = vg4->font->loadtext("textfile", "[bgcolor=0x888888]", NULL, NULL); if (imgp == NULL) { VG_dest(); exit(1); } /* show text-image */ vg4->window->copy(imgp, NULL, NULL); vg4->window->flush(); sleep(5); vg4->image->destroy(imgp); /* destroy and exit */ VG_dest(); exit(0); } textfile %{box[boxwidth=80% bgcolor=0x880000]: # first line with two text boxes %{txt[boxwidth=45% orientation=left]: Lorem ipsum dolor sit amet%} %{box[boxwidth=10%]:%} %{txt[boxwidth=45% orientation=right]: consectetur adipiscing elit%} # second line with two text boxes %{txt[boxwidth=45% orientation=left]: sed do eiusmod tempor incididunt%} %{box[boxwidth=10%]:%} %{txt[boxwidth=45% orientation=right]: ut labore et dolore magna aliqua%} %} --- %{table[boxwidth=80% cells=45,10,45 fullraster=0xffff00 bgcolor=0x880000]: # first row %{cell[orientation=left]: Lorem ipsum dolor sit amet%} %{cell[bgcolor=0x008800]:%} %{cell[orientation=right]: consectetur adipiscing elit%} # second row %{cell[orientation=left]: sed do eiusmod tempor incididunt%} %{cell[bgcolor=0x008800]:%} %{cell[orientation=right]: ut labore et dolore magna aliqua%} %}