TextStyle
#include <bb/cascades/TextStyle>
Represents a text style that defines how a text is rendered.
Each text style has a different set of visual characteristics associated with it like weight, font style etc. If set to other values than their default values, these values will override the default characteristic of controls that they are applied on. For example setting fontFamily to "helvetica" on a textstyle applied to a label will override the default system font with a font from the Helvetica family.
BlackBerry 10.0.0
Inheritance
| bb::cascades::Resource | ||
| bb::cascades::TextStyle | ||
Public Functions Index
| TextStyle () | |
| virtual | ~TextStyle () |
| TextStyle (const TextStyle &other) | |
| TextStyle & | operator= (const TextStyle &other) |
| void | setFontFamily (const QString &fontFamily) |
| QString | fontFamily () const |
| void | resetFontFamily () |
| void | setFontStyle (FontStyle::Type fontStyle) |
| FontStyle::Type | fontStyle () const |
| void | resetFontStyle () |
| void | setFontWeight (bb::cascades::FontWeight::Type fontWeight) |
| bb::cascades::FontWeight::Type | fontWeight () const |
| void | resetFontWeight () |
| void | setColor (const bb::cascades::ColorPaint &color) |
| void | setColor (const QVariant &color) |
| QVariant | color () const |
| void | resetColor () |
| void | setLineHeight (float lineHeight) |
| float | lineHeight () const |
| void | resetLineHeight () |
| void | setFontSizeValue (float size) |
| float | fontSizeValue () const |
| void | resetFontSizeValue () |
| void | setFontSize (FontSize::Type size) |
| FontSize::Type | fontSize () const |
| void | resetFontSize () |
| void | setTextAlign (bb::cascades::TextAlign::Type alignment) |
| bb::cascades::TextAlign::Type | textAlign () const |
| void | resetTextAlign () |
| bool | isNull () const |
Public Functions
Constructs a null TextStyle.
BlackBerry 10.0.0
virtual
Destructor.
Constructs a copy of another TextStyle.
TextStyle a = SystemDefaults::TextStyles::bigText(); TextStyle b(a);
| Parameters | |
|---|---|
| other |
The TextStyle to be copied. |
BlackBerry 10.0.0
TextStyle &
Assigns another TextStyle to this TextStyle.
| Parameters | |
|---|---|
| other |
The TextStyle to be assigned. |
A reference to the TextStyle.
BlackBerry 10.0.0
void
Sets the font family name to use for font matching in the TextStyle.
For example setting font family to "helvetica" will make the TextStyle try to find a font of the helvetica family. The font family name can be specified with multiple fallbacks specified as either ordinary font familys (times, arial etc.) or generic family names (serif, sans-serif) The names should be separated by a comma and family names containing multiple word like Times New Roman should be enclosed by quotations. Start by specifying specific font families and end with generic font families. Currently only one specific font family is supported.
style.setFontFamily("\"Times New Roman\", serif");
| Parameters | |
|---|---|
| fontFamily |
The font family name. |
BlackBerry 10.0.0
QString
Returns the font family for the TextStyle.
The font family if set, otherwise QString::null is returned.
BlackBerry 10.0.0
void
Resets the font family to its default.
The default value is a QString::null.
BlackBerry 10.0.0
void
Sets the font style.
| Parameters | |
|---|---|
| fontStyle |
The style to use. |
BlackBerry 10.0.0
FontStyle::Type
Returns the font style.
The font style if set, otherwise FontStyle::Default is returned.
BlackBerry 10.0.0
void
Resets the font style to its default value.
BlackBerry 10.0.0
void
Set the font weight.
| Parameters | |
|---|---|
| fontWeight |
The weight to use. |
BlackBerry 10.0.0
bb::cascades::FontWeight::Type
Returns the font weight.
The weight if set, otherwise FontWeight::Default is returned.
BlackBerry 10.0.0
void
Resets the font weight to its default value.
BlackBerry 10.0.0
void
Sets the text color.
Setting an invalid color is equivalent to calling resetColor().
| Parameters | |
|---|---|
| color |
The color to use. |
BlackBerry 10.0.0
void
Convenience method for setting the text color for colors wrapped in QVariant.
Passed QVariant can either be invalid or contain values of type Color or PaintColor or it will be ignored.
Setting an invalid QVariant or a QVariant containing invalid color is equivalent to calling resetColor().
QVariant
Returns the text color.
Returned QVariant will be either invalid or contain values of type Color or ColorPaint. Invalid QVariant signifies an unset color.
Use QVariant::canConvert<Type T>() to find actual type, and then QVariant::value<Type T>() to get the value.
QVariant v = style->textColor();
if (v.canConvert<Color>()) {
Color c = v.value<Color>();
} else if (v.canConvert<ColorPaint>()) {
ColorPaint cp = v.value<ColorPaint>();
}
void
Sets the line height.
Distance between rows of text. 1.0 is equal to 1 ordinary row height. 1.5 would make the distance between rows 1.5 ordinary row heights. The default value is -1.0.
| Parameters | |
|---|---|
| lineHeight |
The line height to use. |
BlackBerry 10.0.0
float
Returns the line height.
The default value is -1.0.
Line height if set. If not set the default value will be returned.
BlackBerry 10.0.0
void
Resets the line height to its default value of -1.0.
BlackBerry 10.0.0
void
Sets the font size value.
Font size in post script units or percent, depending on the FontSize setting. Valid ranges are >= 0. Sizes < 0 will be clamped to 0 The default value is 0.0.
If FontSize is set to PercentageValue, size value 100.0 corresponds to the size of the parent style element. If there is no parent element, the size will be in relation to the system default size, which typically matches the logical size Medium. Note, this value will take effect only when font size is set to FontSize::PointValue or FontSize::PercentageValue
| Parameters | |
|---|---|
| size |
The font size value to use. |
BlackBerry 10.0.0
float
Returns the font size value in points or percent The unit of the return value depends on the current setting of the fontSize property.
If it is set to FontSize::PointValue, the unit is post script points. If it is set to FontSize::PercentageValue, the unit is percent and the size is relative to the point size of parent style element. If there is no parent element, the size will be in relation to the system default size, which typically matches the logical size Medium.
Font size value.
BlackBerry 10.0.0
void
Resets the font size value to its default value 0.0.
BlackBerry 10.0.0
void
Sets the logical font size.
Logical font size will be translated to actual font size according to font size set in accessibility settings.
| Parameters | |
|---|---|
| size |
The font size to use. |
BlackBerry 10.0.0
void
Resets the logical font size to its default value.
BlackBerry 10.0.0
void
Sets the horizontal alignment for the text.
| Parameters | |
|---|---|
| alignment |
The horizontal text alignment to use. |
BlackBerry 10.0.0
bb::cascades::TextAlign::Type
Returns the horizontal alignment for the text.
The text alignment if set, otherwise TextAlign::Default is returned.
BlackBerry 10.0.0
void
Resets the horizontal alignment to its default value.
BlackBerry 10.0.0
bool 
Returns true if the resource is null.
true if this resource is null, false otherwise.
BlackBerry 10.0.0