In this section:
Text may be added to a %gr drawing surface by using DRAW_CHARACTERS@, for example,
CALL draw_characters@('Time (Secs)',350,380,RGB@(255,255,255))
The initial font is the current font in the format window, but it can be changed by using the following routines. These operate on the currently selected drawing surface.
Note that generally only TrueType fonts can have their appearance varied in all of the ways shown below.
Selects/deselects bold font. |
|
Displays a font selection dialog box. |
|
Can be repeatedly called to obtain the name of all installed fonts on the system. |
|
This returns the LOGFONT character width and height for a given font handle. |
|
Gets the dimensions of a given string. |
|
Gets the dimensions of a given string on a given control. |
|
Selects/deselects italic the font. |
|
Rotates the font anticlockwise by a given angle in degrees. |
|
Multiplies the font size. |
|
Selects a font by name. |
|
Specifies the font size in pixels. |
|
Specifies the font size in points. |
|
Selects/deselects underlined font. |
The following program demonstrates the use of these routines
WINAPP
INCLUDE <clearwin.ins>
INTEGER i,ictrl,s_width,s_depth,g_width,g_depth,colour
c--- Get width and height of screen
s_width = clearwin_info@('SCREEN_WIDTH')
s_depth = clearwin_info@('SCREEN_DEPTH')
c--- Size of graphics area
g_width = 2.0*s_width/3.0
g_depth = 2.0*s_depth/3.0
c--- Graphics window
i=winio@('%ww%ca[WINDOWS FONTS]&')
i=winio@('%mn[&Exit]&','EXIT')
i=winio@('%gr[black,rgb_colours]&',g_width,g_depth)
i=winio@('%lw',ictrl)
c--- Select Windows font 'Modern' (default attributes)
c--- Draw in intense white
CALL select_font@('Modern')
CALL draw_characters@('1: select_font:modern',
+ 350,380,RGB@(255,255,255))
c--- Multiply size of font by 2
c--- Draw in yellow
CALL scale_font@(2.0D0)
CALL draw_characters@('2: This is scale_font',
+ 300,300,RGB@(255,255,0))
c--- Underline font
c--- Draw in intense cyan
CALL underline_font@(1)
CALL draw_characters@('3: This is underline_font',
+ 280,200,RGB@(0,255,255))
c--- Italic font
c--- Draw in intense green
CALL italic_font@(1)
CALL draw_characters@('4: This is italic_font',
+ 300,100,RGB@(0,255,0))
c--- Specify the size of the font in pixels
c--- Draw in cyan
CALL size_in_pixels@(20,10)
CALL draw_characters@('5: This is size_in_pixels',
+ 350,50,RGB@(127,0,127))
c--- Specify the size of the font in points
c--- Draw in intense blue
CALL size_in_points@(20,10)
CALL draw_characters@('6: This is size_in_points',
+ 10,50,RGB@(0,0,255))
c--- Rotate the font by 70.0 degrees
c--- Draw in intense magenta
CALL rotate_font@(70.0D0)
CALL draw_characters@('7: This is rotate_font:70',
+ 80,450,RGB@(255,0,255))
c--- Undo underline font
c--- Draw in intense cyan
CALL underline_font@(0)
CALL draw_characters@('8: This is undo underline_font',
+ 150,450,RGB@(0,255,255))
c--- Embolden the font
c--- Draw in intense white
CALL bold_font@(1)
CALL draw_characters@('9: This is bold_font',
+ 220,350,RGB@(255,255,255))
c--- User selected font, default colour black (0)
c--- Draw in intense white
colour=0
CALL choose_font@(colour)
CALL draw_characters@('10: This is choose_font',
+ 300,450,colour)
END
Note how CHOOSE_FONT@ allows user selection of font style, underline, overstrike, size and colour.