Top |
Testing the Appearance of StylesTesting the Appearance of Styles — Finding out how the library displays your style hints |
You can suggest the appearance of a window's style before the window is created; after the window is created, you can test the style's actual appearance. These functions do not test the style hints; they test the attribute of the style as it appears to the player.
Note that although you cannot change the appearance of a window's styles after the window is created, the library can. A platform may support dynamic preferences, which allow the player to change text formatting while your program is running.
Changes that affect window size (such as font size changes) will be
signalled by an evtype_Arrange
event. However, more subtle changes (such
as text color differences) are not signalled. If you test the appearance of
styles at the beginning of your program, you must keep in mind the
possibility that the player will change them later.
glui32 glk_style_distinguish (winid_t win
,glui32 styl1
,glui32 styl2
);
Decides whether two styles are visually distinguishable in the given window. The exact meaning of this is left for the library to determine.
glui32 glk_style_measure (winid_t win
,glui32 styl
,glui32 hint
,glui32 *result
);
Tries to test an attribute of one style in the given window win
. The library
may not be able to determine the attribute; if not, this returns FALSE
(0).
If it can, it returns TRUE
(1) and stores the value in the location pointed
at by result
.
As usual, it is legal for result
to be NULL
, although fairly pointless.
The meaning of the value depends on the hint which was tested:
The indentation and paragraph indentation. These are in a metric which is platform-dependent. Most likely either characters or pixels. |
|
One of the constants |
|
The font size. Again, this is in a platform-dependent metric. Pixels, points, or simply 1 if the library does not support varying font sizes. |
|
1 for heavy-weight fonts (boldface), 0 for normal weight, and -1 for light-weight fonts. |
|
1 for oblique fonts (italic), or 0 for normal angle. |
|
1 for proportional-width fonts, or 0 for fixed-width. |
|
These are values from 0x00000000 to 0x00FFFFFF, encoded as described in Suggesting the Appearance of Styles. |
|
0 for normal printing, 1 if the foreground and background colors are reversed. |
Signed values, such as the stylehint_Weight
value, are cast to glui32.
They may be cast to glsi32 to be dealt with in a more natural context.