?? font.h
字號(hào):
//param str: String to get the width of.
//param start: A starting iterator, inclusive.
//param end: An ending iterator, exclusive.
//param max_size: Same effect as the size of the dest rectangle passed to draw(), for word wrapping and height truncating.
int get_width(unsigned char letter) const;
int get_width(
const std::string &str,
CL_Size max_size = CL_Size(0,0)) const
{return get_size(str, max_size).width;}
int get_width(
std::string::const_iterator start,
std::string::const_iterator end,
CL_Size max_size = CL_Size(0,0)) const
{return get_size(start, end, max_size).width;}
//: Returns the drawn size of a string.
//return: The size in pixels.
//param letter: Character to get the size of. If unrecognized, returns space width.
//param str: String to get the size of.
//param start: A starting iterator, inclusive.
//param end: An ending iterator, exclusive.
//param max_size: Same effect as the size of the dest rectangle passed to draw(), for word wrapping and height truncating.
CL_Size get_size(unsigned char letter) const
{return CL_Size(get_width(letter), get_height());}
CL_Size get_size(
const std::string &str,
CL_Size max_size = CL_Size(0,0)) const
{return get_size(str.begin(), str.end(), max_size);}
CL_Size get_size(
std::string::const_iterator start,
std::string::const_iterator end,
CL_Size max_size = CL_Size(0,0)) const;
//: Calculate the rectangle that would be occupied by a draw operation.
//param str: The input string to process.
//param start: String position to begin processing at, inclusive.
//param end: String position to end processing at, exclusive.
//param x, y: Anchor position to simulate draw at. Actual position depends on the alignment mode.
//param dest: Rectangle to draw text in. The text will be word-wrapped against delimiters to fit inside the rectangle.
//- <p> You can specify a dest rectangle with a width or height of zero or less to disable word wrapping
//- or height truncating, respectively. </p>
CL_Rect bounding_rect(
int x,
int y,
const std::string &str) const
{return bounding_rect(CL_Rect(x, y, x, y), str.begin(), str.end());}
CL_Rect bounding_rect(
CL_Rect dest,
const std::string &str) const
{return bounding_rect(dest, str.begin(), str.end());}
CL_Rect bounding_rect(
int x,
int y,
std::string::const_iterator start,
std::string::const_iterator end) const
{return bounding_rect(CL_Rect(x, y, x, y), start, end);}
CL_Rect bounding_rect(
CL_Rect dest,
std::string::const_iterator start,
std::string::const_iterator end) const;
//: Returns whether or not a glyph exists for a given character
//- <p> This is the same as checking if get_width(chr) returns zero. </p>
bool is_glyph(unsigned char chr) const;
//: Resource owning this font, if any.
CL_Resource resource;
//! Operations:
public:
//: Copy assignment operator.
CL_Font &operator =(const CL_Font ©);
//: Return true if the CL_Font object is valid
operator bool() const;
//: Draws text to a graphic context.
//return: The number of glyphs that were drawn.
//param str: The input string to draw.
//param start: String position to begin drawing at, inclusive.
//param end: String position to end drawing at, exclusive.
//param x, y: Anchor position to draw at. Actual drawing position depends on the alignment mode.
//param gc: Graphic context on which to draw. If null, will use CL_Display's current graphic context.
//param dest: Rectangle to draw text in. The text will be word-wrapped against delimiters to fit inside the rectangle.
//- <p> You can specify a dest rectangle with a width or height of zero or less to disable word wrapping
//- or height truncating, respectively. </p>
int draw(
int x,
int y,
const std::string &str,
CL_GraphicContext *context = 0) const
{return draw(CL_Rect(x, y, x, y), str.begin(), str.end(), context);}
int draw(
CL_Rect dest,
const std::string &str,
CL_GraphicContext *context = 0) const
{return draw(dest, str.begin(), str.end(), context);}
int draw(
int x,
int y,
std::string::const_iterator start,
std::string::const_iterator end,
CL_GraphicContext *context = 0) const
{return draw(CL_Rect(x, y, x, y), start, end, context);}
int draw(
CL_Rect dest,
std::string::const_iterator start,
std::string::const_iterator end,
CL_GraphicContext *context = 0) const;
//: Inserts data into a CL_GlyphBuffer, treating the glyphs already there as part of a previous draw_to_gb().
//return: The number of glyphs that were inserted. This could be negative if it backtracks.
//param str: The input string to draw.
//param start: String position to begin drawing at, inclusive.
//param end: String position to end drawing at, exclusive.
//param max_size: Sets size for word wrapping and height truncating. Either can be zero to disable that feature.
//param gb: The glyph buffer to mess with.
//- <p> The CL_GlyphBuffer's contents (the glyphs vector, the font markers map, and the effects maps),
//- if any, must not have been created/altered by anything but CL_Font::draw_to_gb() and/or CL_TextStyler::draw_to_gb()
//- for this method to work.</p>
//- <p> If you are doing draw_to_gb several sequential times
//- to the same CL_GlyphBuffer, then you must pass the same maximum width to each call of
//- draw_to_gb. </p>
//- <p> Each glyph inserted into the CL_GlyphBuffer corresponds with exactly one character of the input string, with
//- the order in the vector and the order in the string being the same. That is, if you start out with an empty CL_GlyphBuffer,
//- run this method on it, and afterwords the CL_GlyphBuffer contains 100 glyphs, then you know the first 100 characters
//- of the source string range were processed. This includes whitespace and newline characters.</p>
//- <p> If you call this method on a CL_GlyphBuffer with a last line that is center-justified or left-justified, be aware
//- that there's no way for this function to differentiate that line from a left-justified line with an indent, and it
//- always assumes the latter. </p>
//- <p> You can tell when you've filled the buffer up to the height in max_size when a call to this method returns
//- anything less than the size of the string. There's also the chance that it will backtrack and return
//- a negative value if it runs out
//- of vertical space in the process of wrapping a just-completed word; this is still a sign that you've
//- ran out of vertical space.</p>
int draw_to_gb(
const std::string &str,
CL_GlyphBuffer &gb,
CL_Size max_size = CL_Size(0,0)) const
{return draw_to_gb(str.begin(), str.end(), gb, max_size);}
int draw_to_gb(
std::string::const_iterator start,
std::string::const_iterator end,
CL_GlyphBuffer &gb,
CL_Size max_size = CL_Size(0,0)) const;
//: Draws a single glyph to a given spot.
//param x, y: The upper-left coordinates of where to draw the glyph.
//param chr: The character to draw the glyph of.
//param ang: The amount to rotate the glyph by. The hotspot is set with CL_Font::set_glyph_rot_hotspot().
//- <p> If there is no glyph for the given character, then nothing is drawn. </p>
void draw_glyph(int x, int y, unsigned char chr, float ang = 0.0);
//: Sets delimiters string.
//- <p> This string contains characters (other than newline) that divide words apart.
//- Do not include newline in this string, it's an implicit delimiter.</p>
void set_delims(const std::string &delims);
//: Sets width offset.
//- <p> The width offset can be used to kern glyphs together or spread them apart. </p>
void set_width_offset(int offset);
//: Sets height offset.
//- <p> The height offset can be used to create space between lines, or to merge them together. </p>
void set_height_offset(int offset);
//: Sets scale for x and y directions individually.
//- <p> 1.0f is normal scale, 2.0f is twice the size, etc. </p>
void set_scale(float x, float y);
//: Sets transparency.
//- <p> 0.0f is full transparency, and 1.0f is full visibility. </p>
void set_alpha(float alpha);
//: Sets the color.
//- <p> Alpha 0.0f is full transparency, and 1.0f is full visibility (solid). </p>
void set_color(float r, float g, float b, float a = 1.0f);
void set_color(const CL_Color& c) {set_color(float(c.get_red())/255.0f,float(c.get_green())/255.0f,float(c.get_blue())/255.0f,float(c.get_alpha())/255.0f);}
//: Sets blending functions.
void set_blend_func(CL_BlendFunc src, CL_BlendFunc dest);
//: Sets glyph rotation hotspot.
//- <p> This is for the optional angle parameter to draw_glyphs(). </p>
void set_glyph_rot_hotspot(CL_Origin origin, int x = 0, int y = 0);
//: Sets translation hotspot.
void set_alignment(CL_Origin origin, int x = 0, int y = 0);
//! Implementation:
private:
CL_LazyCopyPtr<CL_Clonable, CL_Font_Generic> impl;
};
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -