/*
          __
         / /_______________  ____  ___
        / __/ ___/ ___/ __ \/ __ \/ _ \
       / /_(__  ) /__/ /_/ / /_/ /  __/
       \__/____/\___/\____/ .___/\___/
                         /_/

    graphics5.c
    setting the text font
*/

#include <tscope.h>

int main()
{
    ts_scrsize(SIZE1);
    ts_init();

    // print some text in default font
    ts_printf_centre(0, 120,
                     "default, Tscope uses an simple terminal font");

    // set a new font
    ts_font(ARIAL, 8, BOLD);
    ts_printf_centre(0, 80, "ts_font changes the font");
    ts_printf_centre(0, 60, "it takes three arguments: ");
    ts_printf_centre(0, 40, "font, size and style");

    // set another font and store return value
    int oldfont;
    oldfont = ts_font(COURIER, 12, IT);
    ts_printf_centre(0, 0, "when changing the font");
    ts_printf_centre(0, -20, "the old value can be restored");
    ts_printf_centre(0, -40, "by using the value returned by ts_font");

    // use return value to return to old font
    ts_setfont(oldfont);
    ts_printf_centre(0, -80, "in a call to a function called ts_setfont");

    // return to default font
    ts_setfont(0);
    ts_printf_centre(0, -120, "ts_setfont(0) returns to the default font");
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    // load a font from a file
    ts_loadfont("timesbi12.dat");
    ts_printf_centre(0, 80, "ts_loadfont can be used to load a font");
    ts_printf_centre(0, 60, "from a custom font file");

    // change the font
    oldfont = ts_font(COURIER, 12, BOLD);
    ts_printf_centre(0, 20, "how to make a custom font file");
    ts_printf_centre(0, 00, "is explained in the FAQ");

    // return to previous
    ts_setfont(oldfont);
    ts_printf_centre(0, -40, "the return value of ts_loadfont");
    ts_printf_centre(0, -60, "can also be used in a call to ts_setfont");
    ts_printf_centre(0, -80, "to return to the previous font again");

    ts_button(XMAX - 20, -YMAX + 20);
    return 0;
}

END_OF_MAIN();


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information