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

    text3.c
    compute the pixel size of a string
*/

#include <tscope.h>

// prints some text and comutes width and height
void print_some_text()
{
    int w, h;

    ts_fgcolor(RED);
    w = ts_printf(100, 100, "this piece of text ");
    ts_fgcolor(WHITE);
    h = ts_textheight();

    ts_printf(100 + w, 100, "is %d pixels long", w);
    ts_printf(100, 100 + h * 2, "and %d pixels high", h);
}

int main()
{
    // init
    ts_scrsize(SIZE1);
    ts_init();
    ts_coordinates(STANDARD);

    // print text in standard font
    ts_printf_centre(SXMAX / 2, 20, "standard font:");
    print_some_text();
    ts_button(SXMAX - 20, SYMAX - 20);
    ts_clrscr();

    // print the same in Arial 20 bold
    ts_font(ARIAL, 20, BOLD);
    ts_printf_centre(SXMAX / 2, 20, "Arial 20 bold font:");
    print_some_text();

    ts_button(SXMAX - 20, SYMAX - 20);
    return 0;
}

END_OF_MAIN();


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