/usr/include/CEGUI/CEGUIFont.h is in libcegui-mk2-dev 0.7.5-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | /***********************************************************************
filename: CEGUIFont.h
created: 21/2/2004
author: Paul D Turner <paul@cegui.org.uk>
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIFont_h_
#define _CEGUIFont_h_
#include "CEGUIBase.h"
#include "CEGUIPropertySet.h"
#include "CEGUIString.h"
#include "CEGUIXMLSerializer.h"
#include "CEGUIFontGlyph.h"
#include <map>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4251)
#endif
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Class that encapsulates a typeface.
A Font object is created for each unique typeface required.
The Font class provides methods for loading typefaces from various sources,
and then for outputting text via the Renderer object.
This class is not specific to any font renderer, it just provides the
basic interfaces needed to manage fonts.
*/
class CEGUIEXPORT Font : public PropertySet
{
public:
//! Colour value used whenever a colour is not specified.
static const argb_t DefaultColour;
//! Destructor.
virtual ~Font();
//! Return the string holding the font name.
const String& getName() const;
//! Return the type of the font.
const String& getTypeName() const;
/*!
\brief
Return whether this Font can draw the specified code-point
\param cp
utf32 code point that is the subject of the query.
\return
true if the font contains a mapping for code point \a cp,
false if it does not contain a mapping for \a cp.
*/
bool isCodepointAvailable(utf32 cp) const
{ return (d_cp_map.find(cp) != d_cp_map.end()); }
/*!
\brief
Draw text into a specified area of the display.
\param buffer
GeometryBuffer object where the geometry for the text be queued.
\param text
String object containing the text to be drawn.
\param position
Reference to a Vector2 object describing the location at which the text
is to be drawn.
\param clip_rect
Rect object describing the clipping area for the drawing.
No drawing will occur outside this Rect.
\param colours
ColourRect object describing the colours to be applied when drawing the
text. NB: The colours specified in here are applied to each glyph,
rather than the text as a whole.
\param space_extra
Number of additional pixels of spacing to be added to space characters.
\param x_scale
Scaling factor to be applied to each glyph's x axis, where 1.0f is
considered to be 'normal'.
\param y_scale
Scaling factor to be applied to each glyph's y axis, where 1.0f is
considered to be 'normal'.
\return
Nothing.
*/
void drawText(GeometryBuffer& buffer, const String& text,
const Vector2& position, const Rect* clip_rect,
const ColourRect& colours, const float space_extra = 0.0f,
const float x_scale = 1.0f, const float y_scale = 1.0f);
/*!
\brief
Set the native resolution for this Font
\param size
Size object describing the new native screen resolution for this Font.
*/
void setNativeResolution(const Size& size);
/*!
\brief
Return the native display size for this Font. This is only relevant if
the Font is being auto-scaled.
\return
Size object describing the native display size for this Font.
*/
Size getNativeResolution() const;
/*!
\brief
Enable or disable auto-scaling for this Font.
\param auto_scaled
- true to enable auto-scaling.
- false to disable auto-scaling.
*/
void setAutoScaled(const bool auto_scaled);
/*!
\brief
Return whether this Font is auto-scaled.
\return
- true if Font is auto-scaled.
- false if Font is not auto-scaled.
*/
bool isAutoScaled() const;
/*!
\brief
Notify the Font that the display size may have changed.
\param size
Size object describing the display resolution
*/
virtual void notifyDisplaySizeChanged(const Size& size);
/*!
\brief
Return the pixel line spacing value for.
\param y_scale
Scaling factor to be applied to the line spacing, where 1.0f
is considered to be 'normal'.
\return
Number of pixels between vertical base lines, i.e. The minimum
pixel space between two lines of text.
*/
float getLineSpacing(float y_scale = 1.0f) const
{ return d_height * y_scale; }
/*!
\brief
return the exact pixel height of the font.
\param y_scale
Scaling factor to be applied to the height, where 1.0f
is considered to be 'normal'.
\return
float value describing the pixel height of the font without
any additional padding.
*/
float getFontHeight(float y_scale = 1.0f) const
{ return (d_ascender - d_descender) * y_scale; }
/*!
\brief
Return the number of pixels from the top of the highest glyph
to the baseline
\param y_scale
Scaling factor to be applied to the baseline distance, where 1.0f
is considered to be 'normal'.
\return
pixel spacing from top of front glyphs to baseline
*/
float getBaseline(float y_scale = 1.0f) const
{ return d_ascender * y_scale; }
/*!
\brief
Return the pixel width of the specified text if rendered with
this Font.
\param text
String object containing the text to return the rendered pixel
width for.
\param x_scale
Scaling factor to be applied to each glyph's x axis when
measuring the extent, where 1.0f is considered to be 'normal'.
\return
Number of pixels that \a text will occupy when rendered with
this Font.
*/
float getTextExtent(const String& text, float x_scale = 1.0f) const;
/*!
\brief
Return the index of the closest text character in String \a text
that corresponds to pixel location \a pixel if the text were rendered.
\param text
String object containing the text.
\param pixel
Specifies the (horizontal) pixel offset to return the character
index for.
\param x_scale
Scaling factor to be applied to each glyph's x axis when measuring
the text extent, where 1.0f is considered to be 'normal'.
\return
Returns a character index into String \a text for the character that
would be rendered closest to horizontal pixel offset \a pixel if the
text were to be rendered via this Font. Range of the return is from
0 to text.length(), so may actually return an index past the end of
the string, which indicates \a pixel was beyond the last character.
*/
size_t getCharAtPixel(const String& text, float pixel,
float x_scale = 1.0f) const
{ return getCharAtPixel(text, 0, pixel, x_scale); }
/*!
\brief
Return the index of the closest text character in String \a text,
starting at character index \a start_char, that corresponds
to pixel location \a pixel if the text were to be rendered.
\param text
String object containing the text.
\param start_char
index of the first character to consider. This is the lowest
value that will be returned from the call.
\param pixel
Specifies the (horizontal) pixel offset to return the character
index for.
\param x_scale
Scaling factor to be applied to each glyph's x axis when measuring
the text extent, where 1.0f is considered to be 'normal'.
\return
Returns a character index into String \a text for the character that
would be rendered closest to horizontal pixel offset \a pixel if the
text were to be rendered via this Font. Range of the return is from
0 to text.length(), so may actually return an index past the end of
the string, which indicates \a pixel was beyond the last character.
*/
size_t getCharAtPixel(const String& text, size_t start_char, float pixel,
float x_scale = 1.0f) const;
/*!
\brief
Sets the default resource group to be used when loading font data
\param resourceGroup
String describing the default resource group identifier to be used.
\return
Nothing.
*/
static void setDefaultResourceGroup(const String& resourceGroup)
{ d_defaultResourceGroup = resourceGroup; }
/*!
\brief
Returns the default resource group currently set for Fonts.
\return
String describing the default resource group identifier that will be
used when loading font data.
*/
static const String& getDefaultResourceGroup()
{ return d_defaultResourceGroup; }
/*!
\brief
Writes an xml representation of this Font to \a out_stream.
\param xml_stream
Stream where xml data should be output.
\return
Nothing.
*/
void writeXMLToStream(XMLSerializer& xml_stream) const;
/*!
\brief
Return a pointer to the glyphDat struct for the given codepoint,
or 0 if the codepoint does not have a glyph defined.
\param codepoint
utf32 codepoint to return the glyphDat structure for.
\return
Pointer to the glyphDat struct for \a codepoint, or 0 if no glyph
is defined for \a codepoint.
*/
const FontGlyph* getGlyphData(utf32 codepoint) const;
protected:
//! Constructor.
Font(const String& name, const String& type_name, const String& filename,
const String& resource_group, const bool auto_scaled,
const float native_horz_res, const float native_vert_res);
/*!
\brief
This function prepares a certain range of glyphs to be ready for
displaying. This means that after returning from this function
glyphs from d_cp_map[start_codepoint] to d_cp_map[end_codepoint]
should have their d_image member set. If there is an error
during rasterisation of some glyph, it's okay to leave the
d_image field set to NULL, in which case such glyphs will
be skipped from display.
\param start_codepoint
The lowest codepoint that should be rasterised
\param end_codepoint
The highest codepoint that should be rasterised
*/
virtual void rasterise(utf32 start_codepoint, utf32 end_codepoint) const;
//! Update the font as needed, according to the current parameters.
virtual void updateFont() = 0;
//! implementaion version of writeXMLToStream.
virtual void writeXMLToStream_impl(XMLSerializer& xml_stream) const = 0;
//! Register all properties of this class.
void addFontProperties();
/*!
\brief
Set the maximal glyph index. This reserves the respective
number of bits in the d_glyphPageLoaded array.
*/
void setMaxCodepoint(utf32 codepoint);
//! Name of this font.
String d_name;
//! Type name string for this font (not used internally)
String d_type;
//! Name of the file used to create this font (font file or imagset)
String d_filename;
//! Name of the font file's resource group.
String d_resourceGroup;
//! Holds default resource group for font loading.
static String d_defaultResourceGroup;
//! maximal font ascender (pixels above the baseline)
float d_ascender;
//! maximal font descender (negative pixels below the baseline)
float d_descender;
//! (ascender - descender) + linegap
float d_height;
//! true when auto-scaling is enabled.
bool d_autoScale;
//! native horizontal resolution for this Imageset.
float d_nativeHorzRes;
//! native vertical resolution for this Imageset.
float d_nativeVertRes;
//! current horizontal scaling factor.
float d_horzScaling;
//! current vertical scaling factor.
float d_vertScaling;
//! Maximal codepoint for font glyphs
utf32 d_maxCodepoint;
/*!
\brief
This bitmap holds information about loaded 'pages' of glyphs.
A glyph page is a set of 256 codepoints, starting at 256-multiples.
For example, the 1st glyph page is 0-255, fourth is 1024-1279 etc.
When a specific glyph is required for painting, the corresponding
bit is checked to see if the respective page has been rasterised.
If not, the rasterise() method is invoked, which prepares the
glyphs from the respective glyph page for being painted.
This array is big enough to hold at least max_codepoint bits.
If this member is NULL, all glyphs are considered pre-rasterised.
*/
uint* d_glyphPageLoaded;
//! Definition of CodepointMap type.
typedef std::map<utf32, FontGlyph> CodepointMap;
//! Contains mappings from code points to Image objects
CodepointMap d_cp_map;
};
} // End of CEGUI namespace section
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // end of guard _CEGUIFont_h_
|