os_font
|
 |
Font change characteristics for
enclosed text.
An os_font
defines font change characteristics for its enclosed text. Characteristics
include size, color, and typeface.
- Size-Font size is defined
either relative to the base font of the page or absolute. When specified in
a constructor or through the
size() member
function, a negative size value always indicates a relative size. Otherwise,
the size_type value indicates relative or
absolute.
- Relative sizes range from
-7 to 7. A relative size of less than -7 is set to -7; a size greater than
7 is set to 7. A relative size of 0 is ignored.
- Absolute sizes range from
1 to 7. An absolute size of less than 1 is set to 1; a size greater than 7
is set to 7.
When specified through the absolute_size()
and relative_size() member functions, the specified
size value is rounded to fit the appropriate range.
- Color-Font color is
specified as a hexadecimal RGB (red, green, blue) triplet of the form
#
RRGGBB , where RR is the red
component, GG is the green component, and BB
is the blue component. Color is specified in a constructor or through the color()
member function.
- Typeface-Font typeface is
specified as a Microsoft Windows font name, such as Arial or Times. Typeface
is specified through the
face() member
function. The typeface specification supports a Microsoft Internet Explorer
HTML extension.
Declaration
#include <ospace/web/font.h>
class os_font : public os_element_group
Enums
enum os_font::size_type
{
relative, // Font size is relative to the base font of the page.
absolute // Font size is absolute.
};
Interface
Constructor
os_font(
int size ,
size_type sz_type )
Constructs a font change
with size size and size type sz_type
(default relative ).
Constructor
os_font(
const string& color )
Constructs a font change
with color color .
Constructor
os_font(
int size ,
const string& color ,
size_type sz_type )
Constructs a font change
with size size , size type sz_type
(default relative ), and color
color.
absolute_size
os_font&
absolute_size( int size )
Sets the size to absolute
size size and returns a reference to the font
change.
clone
/*
virtual */ os_element* clone() const
Returns a base class
pointer to a heap-based deep copy of the font change.
color
string
color() const
Returns the font color, or
the empty string if the color is not set.
color
os_font&
color( const string& color )
Sets the color to color
and returns a reference to the font change.
face
os_font&
face( const string& face )
Sets the typeface to face
and returns a reference to the font change.
face
string
face() const
Returns the font typeface,
or the empty string if the typeface is not set.
is_absolute_size
bool
is_absolute_size( int& size )
const
Returns true
if the size is absolute and sets size to the
absolute font size.
is_relative_size
bool
is_relative_size( int& size )
const
Returns true
if the size is relative and sets size to the
relative font size.
relative_size
os_font&
relative_size( int size )
Sets the size to relative
size size and returns a reference to the font
change.
size
string
size() const
Returns size as a string.
A leading + or -
indicates a relative size.
size
os_font&
size( int size ,
size_type sz_type )
Sets the size
size and size type to sz_type , and returns a
reference to the font change.
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved