73 int handle()
const {
return _font_ref->handle;}
79 bool is_valid()
const {
return (_font_ref->handle != 0);}
98 enum PaintFlags {FPF_NONE = 0, FPF_JUSTIFY=1, FPF_RUBOUT= 2, FPF_OSUNITS=16};
99 void paint(
int x,
int y,
const std::string &text,
int flags = Font::FPF_NONE)
const;
100 void paint(
int x,
int y,
const char *text,
int length = -1,
int flags = Font::FPF_NONE)
const;
107 int string_height_os(
const char *text,
int length = -1,
int max_width = -1)
const;
134 void add_ref() {ref_count++;}
142 static FontRef *s_invalid_font_ref;
143 static FontRef *s_desktop_font_ref;
233 enum PaintFlags {WFPF_NONE, WFPF_VCENTRE = (1<<30), WFPF_RJUSTIFY = (1<<31)};
234 void paint(
int x,
int y,
const std::string &text,
int flags = WimpFont::WFPF_NONE)
const;
235 void paint(
int x,
int y,
const char *text,
int length = -1,
int flags = WimpFont::WFPF_NONE)
const;
251 std::string t(
"\x09xxx");
253 t[2] = (move & 0xFF00) >> 8;
254 t[3] = (move & 0xFF0000) >> 16;
273 std::string t(
"\x0bxxx");
275 t[2] = (move & 0xFF00) >> 8;
276 t[3] = (move & 0xFF0000) >> 16;
297 std::string t(
"\x13rgbRGBo");
298 t[1] = char(back.
red());
299 t[2] = char(back.
green());
300 t[3] = char(back.
blue());
301 t[4] = char(fore.
red());
302 t[5] = char(fore.
green());
303 t[6] = char(fore.
blue());
316 std::string t(
"0x19bt");
318 t[2] = char(thickness);
330 std::string t(
"0x1af");
331 t[1] = char(fnt.
handle());
std::string identifier
Full font identifier string.
Definition: font.h:54
int string_width_mp(const std::string &text) const
Get the width of a string.
Definition: font.cc:210
std::string identifier() const
Return full font identifier string for this font.
Definition: font.cc:747
int string_width_os(const std::string &text, int num_chars=0)
Get the width of the text in OS units.
Definition: font.cc:968
void get_bounding_box(BBox &bounds) const
Get the bounding box (in os coordinates) of the font.
Definition: font.cc:908
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
void read_details(FontDetails &details) const
Read the details of the font.
Definition: font.cc:689
void paint(int x, int y, const std::string &text, int flags=WimpFont::WFPF_NONE) const
Paint the wimp font at the given screen coordinates.
Definition: font.cc:993
void blue(int b)
Change the blue component of the colour.
Definition: colour.h:90
std::string underline(int base, int thickness)
Turn on or off underlining.
Definition: font.h:314
int os_to_points_16th(int os)
Definition: font.h:180
int x_point_size
x point size in 16th of a point
Definition: font.h:40
tbx::BBox string_bounds_os(const std::string &text, int max_width=-1) const
Get bounding box of a string in os units.
Definition: font.cc:441
void set_colours(Colour fore, Colour back, int colourOffset=14)
Set the colours used to paint this font.
Definition: font.cc:591
bool operator!=(const Font &other)
Check if this object does not refer to the same OS font as another object.
Definition: font.cc:635
Class to handle painting and measuring text using an outline font.
Definition: font.h:61
Structure used to return details of a font.
Definition: font.h:39
bool find(const std::string &font_name, int width, int height=-1)
Find the specified font and attach it to this object.
Definition: font.cc:102
std::string move_x(int move)
Move position horizontally.
Definition: font.h:249
int usage_count
usage count of font
Definition: font.h:45
bool operator==(const Font &other)
Check if this object refers to the same OS font as another object.
Definition: font.cc:624
BBox bounding_box() const
Get the bounding box (in os coordinates) of the font.
Definition: font.cc:894
Size size_os() const
Get the size of the font.
Definition: font.cc:832
int height() const
Definition: font.cc:794
Font()
Construct an uninitialised font.
Definition: font.cc:47
void green(int g)
Change the green component of the colour.
Definition: colour.h:84
int height_os() const
Definition: font.cc:855
int width() const
Definition: font.cc:813
Font & operator=(const Font &other)
Assign a font to the same OS font as another Font object.
Definition: font.cc:609
int points_to_os(int points)
Definition: font.h:169
bool desktop_font()
Sets font to current desktop font.
Definition: font.cc:134
void set_colours(Colour foreground, Colour background)
Set the foreground and background colour for the WIMP font.
Definition: font.cc:955
int font_age
age of font
Definition: font.h:44
void get_char_bounds_os(BBox &bounds, char c)
Get bounding box for a character in OS Units.
Definition: font.cc:668
Class to represent a RGB colour.
Definition: colour.h:44
int y_point_size
y point size in 16th of a point
Definition: font.h:41
Size size() const
Get the size of the font.
Definition: font.cc:771
void get_char_bounds_mp(BBox &bounds, char c)
Get bounding box for a character in millipoints.
Definition: font.cc:646
int x_resolution
x resolution in dots per inch
Definition: font.h:42
int string_height_os(const std::string &text, int max_width=-1) const
Get height of string in os units.
Definition: font.cc:329
Class to represent a two dimensional bounding box.
Definition: bbox.h:38
tbx::Size string_size_os(const std::string &text, int max_width=-1) const
Get size of string in os units.
Definition: font.cc:366
Class to represent a two-dimensional size.
Definition: size.h:35
std::string move_x_os(int move)
Move position horizontally in OS units.
Definition: font.h:263
virtual ~Font()
Destructor release the OS Font if no other font objects are using it.
Definition: font.cc:86
int y_resolution
y resolution in dots per inch
Definition: font.h:43
int handle() const
Get RISC OS font handle.
Definition: font.h:73
int string_width_os(const std::string &text) const
Get the width of a string.
Definition: font.cc:255
std::string colour(tbx::Colour fore, tbx::Colour back, int offset=14)
Set foreground and background font colours.
Definition: font.h:295
std::string move_y_os(int move)
Move position vertically in OS units.
Definition: font.h:285
int find_split_os(const char *text, int length, int width, int split_char=-1)
Find index where to split a string to fit in the given width.
Definition: font.cc:520
std::string move_y(int move)
Move position vertically.
Definition: font.h:271
int millipoints_to_os(int millipoint)
Definition: font.h:211
int find_index_xy_os(const char *text, int length, int x, int y)
Find index in a string of the given co-ordinate, rounded to the nearest caret position.
Definition: font.cc:558
bool is_valid() const
Check if this object is assigned to an outline font on the system.
Definition: font.h:79
PaintFlags
Flags used for painting the WimpFont.
Definition: font.h:233
PaintFlags
Flags to control font painting operation.
Definition: font.h:98
Class to display and measure text using the current desktop font.
Definition: font.h:218
int points_16th_to_os(int point16th)
Definition: font.h:190
int os_to_points(int os)
Definition: font.h:159
void paint(int x, int y, const std::string &text, int flags=Font::FPF_NONE) const
Paint the font to the screen.
Definition: font.cc:160
Structure used to return full details of the font which also includes the font identifier.
Definition: font.h:53
std::string font(const tbx::Font &fnt)
Change font in the string.
Definition: font.h:328
void red(int r)
Change the red component of the colour.
Definition: colour.h:78
int width_os() const
Definition: font.cc:874
int os_to_millipoints(int os)
Definition: font.h:201
int height_os() const
Return height of the font.
Definition: font.h:227