22 #ifndef STLL_LAYOUTER_CSS_H
23 #define STLL_LAYOUTER_CSS_H
31 #include "internal/xmllibraries.h"
32 #include "internal/layouterCSS_internal.h"
46 explicit XhtmlException_c(
const std::string & what_arg) : std::runtime_error(what_arg) {}
61 std::string attribute;
92 const std::string & style =
"normal",
93 const std::string & variant =
"normal",
94 const std::string & weight =
"normal",
95 const std::string & stretch =
"normal");
102 std::shared_ptr<FontFamily_c>
findFamily(
const std::string & family)
const
104 auto i = families.find(family);
106 if (i != families.end())
107 return families.find(family)->second;
122 void addRule(
const std::string sel,
const std::string attr,
const std::string val);
128 useOptimizingLayouter = on;
160 const std::string &
getValue(X node,
const std::string & attribute,
const std::string & def =
"")
const
166 while (!internal::xml_isEmpty(node))
171 for (
size_t i = 0; i < rules.size(); i++)
173 if ( rules[i].attribute == attribute
174 && internal::ruleFits(rules[i].selector, node)
175 && internal::rulePrio(rules[i].selector) > prio
178 prio = internal::rulePrio(rules[i].selector);
184 return rules[bestI].value;
186 if (!internal::isInheriting(attribute))
190 return internal::getDefault(attribute);
198 node = internal::xml_getParent(node);
201 return internal::getDefault(attribute);
205 std::vector<rule> rules;
206 std::map<std::string, std::shared_ptr<FontFamily_c> > families;
207 std::shared_ptr<FontCache_c> cache;
208 bool useOptimizingLayouter =
true;
209 bool hyphenate =
true;
This class represents a font resource.
Definition: layouterFont.h:87
bool getUseOptimizingLayouter(void) const
get status of optimizing layouter
Definition: layouterCSS.h:132
this class encapsulates information for how to format a text, just like the style sheets in html are ...
Definition: layouterCSS.h:56
void addRule(const std::string sel, const std::string attr, const std::string val)
add a rule to the stylesheet
void setUseOptimizingLayouter(bool on)
enable or disable usage of the optimizing layouter. See LayoutProperties_c for details ...
Definition: layouterCSS.h:126
std::shared_ptr< FontFamily_c > findFamily(const std::string &family) const
Get a font family from the CSS.
Definition: layouterCSS.h:102
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.
bool getHyphenate(void) const
get status of hyphenation setting
Definition: layouterCSS.h:142
The namespace for the library. Every function and class is within this namespace. ...
Definition: color.h:31
XhtmlException_c(const std::string &what_arg)
Definition: layouterCSS.h:46
TextStyleSheet_c(std::shared_ptr< FontCache_c > c=0)
create an empty style sheet only with default rules
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
Definition: layouterCSS.h:160
exception thrown on XHTML and CSS problems
Definition: layouterCSS.h:43
void setHyphenate(bool on)
enable or disable hyphenation. See LayoutProperties_c for details
Definition: layouterCSS.h:136