Tscope5
Main Page
Related Pages
Files
Examples
textio03.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// textio03.c
// - Get the dimension of a piece of text that is printed on the display.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
void
print_some_text()
{
double
w, h;
w =
ts5_printf
(0.0, 40.0,
"this piece of text "
);
h =
ts5_get_font_size
();
ts5_printf
(0.0, 0.0,
"is %5.2f pixels long"
, w);
ts5_printf
(0.0, -40.0,
"and %5.2f pixels high"
, h);
w =
ts5_get_text_width
(
"M"
);
ts5_printf
(0.0, -80,
"the letter \"M\" is %5.2f pixels long"
, w);
ts5_draw_mouse_button
(ax(0.9), ay(-0.8));
}
int
main()
{
ts5_install_display
();
ts5_printf
(0.0, 120.0,
"standard font"
);
print_some_text();
ts5_clear_display
();
ts5_set_font_type
(TS5_ARIAL);
ts5_set_font_style
(TS5_BOLD);
ts5_set_font_size
(35);
ts5_printf
(0.0, 120.0,
"Arial 35 Bold font"
);
print_some_text();
return
0;
}