|
Krita Source Code Documentation
|
#include <KoSvgText.h>
Inheritance diagram for KoSvgText::CssLengthPercentage:Public Types | |
| enum | UnitType { Absolute , Percentage , Em , Ex , Cap , Ch , Ic , Lh } |
Public Member Functions | |
| void | convertToAbsolute (const KoSvgText::FontMetrics metrics, const qreal fontSize, const UnitType percentageUnit=Em) |
| CssLengthPercentage () | |
| CssLengthPercentage (qreal value, UnitType unit=Absolute) | |
| bool | operator== (const CssLengthPercentage &other) const |
Public Attributes | |
| UnitType | unit = Absolute |
| qreal | value = 0.0 |
CssLengthPercentage is a struct that represents the CSS length-percentage, which is Css' way of saying that an attribute can be either a length (which are unit-based, including font-relative units) or a percentage (which is relative to a value on a case-by-case basis).
Most percentages in SVG are viewport based, which we just resolve during parsing, because KoShapes do not know anything about the doc they're in. A handful are font-size based, which we resolve to em, and this is also what this struct defaults to. A very small subset (text-indent and text path start-offset) are relative to other things, and these are solved during text-layout.
We currently use this for both Lengths and LengthPercentages (always saving as EM when it is a Length, in the case of TabSize). Whether and how a percentage should be resolved is defined in the CSS specs in the section a given property is specified.
Definition at line 406 of file KoSvgText.h.
Definition at line 407 of file KoSvgText.h.
|
inline |
Definition at line 418 of file KoSvgText.h.
|
inline |
Definition at line 419 of file KoSvgText.h.
| void KoSvgText::CssLengthPercentage::convertToAbsolute | ( | const KoSvgText::FontMetrics | metrics, |
| const qreal | fontSize, | ||
| const UnitType | percentageUnit = Em ) |
Definition at line 949 of file KoSvgText.cpp.
References Absolute, KoSvgText::FontMetrics::ascender, Cap, KoSvgText::FontMetrics::capHeight, Ch, KoSvgText::FontMetrics::descender, Em, Ex, KoSvgText::FontMetrics::fontSize, Ic, KoSvgText::FontMetrics::ideographicAdvance, Lh, KoSvgText::FontMetrics::lineGap, Percentage, u, unit, value, KoSvgText::FontMetrics::xHeight, and KoSvgText::FontMetrics::zeroAdvance.
|
inline |
Definition at line 426 of file KoSvgText.h.
References qFuzzyCompare(), unit, and value.
Definition at line 422 of file KoSvgText.h.
| qreal KoSvgText::CssLengthPercentage::value = 0.0 |
Definition at line 421 of file KoSvgText.h.