STLL  0.0
Simple Text Layouting Library
STLL::TextStyleSheet_c Class Reference

this class encapsulates information for how to format a text, just like the style sheets in html are doing. More...

Public Member Functions

 TextStyleSheet_c (std::shared_ptr< FontCache_c > c=0)
 create an empty style sheet only with default rules More...
 
void addFont (const std::string &family, const FontResource_c &res, const std::string &style="normal", const std::string &variant="normal", const std::string &weight="normal", const std::string &stretch="normal")
 Add a font to a family. More...
 
std::shared_ptr< FontFamily_cfindFamily (const std::string &family) const
 Get a font family from the CSS. More...
 
void addRule (const std::string sel, const std::string attr, const std::string val)
 add a rule to the stylesheet More...
 
void setUseOptimizingLayouter (bool on)
 enable or disable usage of the optimizing layouter. See LayoutProperties_c for details More...
 
bool getUseOptimizingLayouter (void) const
 get status of optimizing layouter More...
 
void setHyphenate (bool on)
 enable or disable hyphenation. See LayoutProperties_c for details More...
 
bool getHyphenate (void) const
 get status of hyphenation setting More...
 
template<class X >
const std::string & getValue (X node, const std::string &attribute, const std::string &def="") const
 get the value for an attribute for a given xml-node More...
 

Detailed Description

this class encapsulates information for how to format a text, just like the style sheets in html are doing.

This class contains a list of normal CSS rules as well as a list of font families to use for outputting text.

Constructor & Destructor Documentation

STLL::TextStyleSheet_c::TextStyleSheet_c ( std::shared_ptr< FontCache_c c = 0)

create an empty style sheet only with default rules

If you do not specify a default cache, the style sheet will create its own cache with its own library instance

This cache will be used for all fonts of the style sheet.

Member Function Documentation

void STLL::TextStyleSheet_c::addFont ( const std::string &  family,
const FontResource_c res,
const std::string &  style = "normal",
const std::string &  variant = "normal",
const std::string &  weight = "normal",
const std::string &  stretch = "normal" 
)

Add a font to a family.

This function will add a new font to a family within this stylesheet. If the given family doesn't exist, it will be created

The class will use the same font cache and thus the same instance of the FreeType library for all the fonts. So you can only use it from one thread.

Parameters
familyThe name of the font family that gets a new member
resThe resource for the new family member
styleSee fontFamily_c::getFont()
variantSee fontFamily_c::getFont()
weightSee fontFamily_c::getFont()
stretchSee fontFamily_c::getFont()
void STLL::TextStyleSheet_c::addRule ( const std::string  sel,
const std::string  attr,
const std::string  val 
)

add a rule to the stylesheet

The rule will be checked as much as possible against syntactic and semantic Problems, when a problem is detected (e.g. invalid values) the XhtmlException_c is thrown.

Parameters
selThe CSS selector (see CSS for supported selectors)
attrThe attribute this rule applies to (see CSS for supported attributes)
valThe value for the attribute
std::shared_ptr<FontFamily_c> STLL::TextStyleSheet_c::findFamily ( const std::string &  family) const
inline

Get a font family from the CSS.

Parameters
familyThe family you want to get
Returns
The family of nullptr
bool STLL::TextStyleSheet_c::getHyphenate ( void  ) const
inline

get status of hyphenation setting

bool STLL::TextStyleSheet_c::getUseOptimizingLayouter ( void  ) const
inline

get status of optimizing layouter

template<class X >
const std::string& STLL::TextStyleSheet_c::getValue ( node,
const std::string &  attribute,
const std::string &  def = "" 
) const
inline

get the value for an attribute for a given xml-node

Parameters
nodeThe xml node that the attribute value is requested for
attributeThe attribute the value is requested for
defdefault value that will be returned, when there is no value set
Returns
The value of the attribute
Note
the default value is only used when it is not empty. When empty the CSS default will be used and if there is not CSS default an exception will be thrown
Attention
the function will return a reference to the string, when the default from the argument is returned, this will also be a reference to that argument, so the string containing the default must actually stay alive until the return value is handled
void STLL::TextStyleSheet_c::setHyphenate ( bool  on)
inline

enable or disable hyphenation. See LayoutProperties_c for details

void STLL::TextStyleSheet_c::setUseOptimizingLayouter ( bool  on)
inline

enable or disable usage of the optimizing layouter. See LayoutProperties_c for details


The documentation for this class was generated from the following file: