11#include <QPainterPath>
12#include <QTextCharFormat>
16#include <boost/operators.hpp>
17#include <boost/optional.hpp>
19#include <QSharedPointer>
23#include <QDomDocument>
25#include <kritaflake_export.h>
31class KoSvgTextChunkShape;
35 Q_NAMESPACE_EXPORT(KRITAFLAKE_EXPORT)
328 bool isVertical =
false;
371 FontMetrics (qreal fontSizeInPt,
bool isHorizontal);
375 int valueForBaselineValue(
Baseline baseline)
const;
377 void setBaselineValueByTag(
const QString &tag, int32_t
value);
379 void setMetricsValueByTag(
const QLatin1String &tag, int32_t
value);
381 void scaleBaselines(
const qreal multiplier);
383 void offsetMetricsToNewOrigin(
const Baseline baseline);
444struct AutoValue :
public boost::equality_comparable<AutoValue>
478 QFont::Style
style = QFont::StyleNormal;
494 return QVariant::fromValue(
value);
553 {
"xx-small",
"x-small",
"small",
"medium",
"large",
"x-large",
"xx-large"};
674struct TabSizeInfo :
public boost::equality_comparable<TabSizeInfo> {
702 return (toggles && val);
721 property->compareTo(rhs.
property.data()));
740 property->compareFillTo(rhs.
property.data()) &&
property->compareStyleTo(rhs.
property.data()));
790 return QString(
"Axis: %1 (%2), min: %3, default:%4, max: %5").arg(
tag).arg(label).arg(
min).arg(
value).arg(
max);
818 bool isItalic =
false;
819 bool isOblique =
false;
823 if (!localizedLabels.isEmpty()) {
824 label = localizedLabels.value(QLocale(QLocale::English), localizedLabels.values().first());
827 for (
int i = 0; i < instanceCoords.size(); i++) {
828 QString key = instanceCoords.keys().at(i);
829 coords.append(key+
"="+QString::number(instanceCoords.value(key)));
831 return QString(
"Instance: %1, coords: [ %2 ]").arg(label).arg(coords.join(
" "));
862 const QString
length = QString(
"[%1:%2]").arg(start).arg(end);
864 list <<
"clig" +
length +
"=0";
865 list <<
"liga" +
length +
"=0";
868 list <<
"dlig" +
length +
"=1";
871 list <<
"hlig" +
length +
"=1";
874 list <<
"calt" +
length +
"=0";
941 bool ordinals =
false;
942 bool slashedZero =
false;
944 return (other.
style == style
953 const QString
length = QString(
"[%1:%2]").arg(start).arg(end);
956 list <<
"lnum" +
length +
"=1";
959 list <<
"onum" +
length +
"=1";
966 list <<
"pnum" +
length +
"=1";
969 list <<
"tnum" +
length +
"=1";
976 list <<
"frac" +
length +
"=1";
979 list <<
"afrc" +
length +
"=1";
985 list <<
"ordn" +
length +
"=1";
988 list <<
"zero" +
length +
"=1";
1018 return (other.
variant == variant
1019 && other.
width == width
1020 && other.
ruby == ruby);
1025 const QString
length = QString(
"[%1:%2]").arg(start).arg(end);
1028 list <<
"jp78" +
length +
"=1";
1031 list <<
"jp83" +
length +
"=1";
1034 list <<
"jp90" +
length +
"=1";
1037 list <<
"jp04" +
length +
"=1";
1040 list <<
"smpl" +
length +
"=1";
1043 list <<
"trad" +
length +
"=1";
1050 list <<
"fwid" +
length +
"=1";
1053 list <<
"pwid" +
length +
"=1";
1059 list <<
"ruby" +
length +
"=1";
1086 ResolutionHandler(qreal _xRes = 72.0, qreal _yRes = 72.0,
bool _roundToPixelHorizontal =
false,
bool _roundToPixelVertical =
false)
1110 QPointF
adjust(
const QPointF point)
const;
1115 QPointF
adjustCeil(
const QPointF point)
const;
qreal length(const QPointF &vec)
float value(const T *src, size_t ch)
bool operator==(const KisRegion &lhs, const KisRegion &rhs)
Q_DECLARE_FLAGS(KisUpdaterContextSnapshotEx, KisUpdaterContextSnapshotExTag)
Contains data used for loading svg.
static bool qFuzzyCompare(half p1, half p2)
Q_DECLARE_OPERATORS_FOR_FLAGS(KisBaseRectsWalker::SubtreeVisitFlags)
Q_DECLARE_METATYPE(KisPaintopLodLimitations)
@ AlignCenter
Center text in line.
QString writeTextPathSide(TextPathSide value)
BaselineShiftMode parseBaselineShiftMode(const QString &value)
BaselineShiftMode
Mode of the baseline shift.
@ ShiftLineBottom
this handles css-inline-3 vertical-align:bottom. Not exposed to ui
@ ShiftSuper
Use parent font metric for 'superscript'.
@ ShiftLineTop
this handles css-inline-3 vertical-align:top. Not exposed to ui
@ ShiftLengthPercentage
Css Length Percentage, percentage is lh.
@ ShiftSub
Use parent font metric for 'subscript'.
FontFeatureCaps
Represents font-feature-caps.
bool xmlSpaceToLongHands(const QString &value, TextSpaceCollapse &collapseMethod)
xmlSpaceToLongHands This takes xml:space values and converts them to CSS-Text-4 properties.
AutoValue parseAutoValueY(const QString &value, const SvgLoadingContext &context, const QString &autoKeyword)
@ LineBreakStrict
Use strict method, language specific.
@ LineBreakLoose
Use loose method, language specific.
@ LineBreakAnywhere
Break between any typographic clusters.
@ LineBreakAuto
Use preferred method.
@ LineBreakNormal
Use normal method, language specific.
TextAnchor
Where the text is anchored for SVG 1.1 text and 'inline-size'.
@ AnchorEnd
Anchor right for LTR, left for RTL.
@ AnchorStart
Anchor left for LTR, right for RTL.
@ AnchorMiddle
Anchor to the middle.
QString writeWordBreak(WordBreak value)
FontFeaturePosition
The FontFeatureLigatures class This enum represents css font-variant-position.
TabSizeInfo parseTabSize(const QString &value, const SvgLoadingContext &context)
TextPathSide parseTextPathSide(const QString &value)
QDebug operator<<(QDebug dbg, const KoSvgText::AutoValue &value)
Baseline parseBaseline(const QString &value)
TextDecorationStyle
Style of the text-decoration.
@ Solid
Draw a solid line.Ex: --—.
@ Dashed
Draw a dashed line. Ex: - - - - -.
@ Double
Draw two lines. Ex: =====.
@ Wavy
Draw a wavy line. We currently make a zigzag, ex: ^^^^^.
@ Dotted
Draw a dotted line. Ex: .....
@ NumericFigureSpacingProportional
@ NumericFigureSpacingTabular
@ NumericFigureSpacingNormal
FontFeatureEastAsian parseFontFeatureEastAsian(const QString &value, FontFeatureEastAsian features)
TextAnchor parseTextAnchor(const QString &value)
OverflowWrap
What to do with words that cannot be broken, but still overflow.
@ OverflowWrapAnywhere
Break anywhere as soon as overflow happens.
TextOrientation parseTextOrientation(const QString &value)
TextDecorationUnderlinePosition
Which location to choose for the underline.
@ UnderlineUnder
Use the bottom of the text decoration bounding box.
@ UnderlineAuto
Use Font metrics.
TextPathSpacing parseTextPathSpacing(const QString &value)
WordBreak
Whether to break words.
@ WordBreakNormal
Set according to script. Also "break-word".
@ WordBreakBreakAll
Always break inside words.
@ WordBreakKeepAll
Never break inside words.
QString writeBaselineShiftMode(BaselineShiftMode value, CssLengthPercentage shift)
UnicodeBidi parseUnicodeBidi(const QString &value)
@ LengthAdjustSpacing
Only stretch the spaces.
@ LengthAdjustSpacingAndGlyphs
Stretches the glyphs as well.
WritingMode parseWritingMode(const QString &value)
QString writeTabSize(const TabSizeInfo tabSize)
LengthAdjust parseLengthAdjust(const QString &value)
TextWrap
Part of "white-space", in practice we only support wrap and nowrap.
@ NoWrap
Do not do any text wrapping.
AutoValue parseAutoValueX(const QString &value, const SvgLoadingContext &context, const QString &autoKeyword)
QString writeLineHeight(LineHeightInfo lineHeight)
TextDecoration
Flags for text-decoration, for underline, overline and strikethrough.
bool whiteSpaceValueToLongHands(const QString &value, TextSpaceCollapse &collapseMethod, TextWrap &wrapMethod, TextSpaceTrims &trimMethod)
whiteSpaceValueToLongHands CSS-Text-4 takes CSS-Text-3 whitespace values and treats them as a shortha...
CssFontStyleData parseFontStyle(const QString &value)
Direction
Base direction used by Bidi algorithm.
TextRendering parseTextRendering(const QString &value)
Baseline
Baseline values used by dominant-baseline and baseline-align.
@ BaselineAlphabetic
Use 'romn' or the baseline for LCG scripts.
@ BaselineTextBottom
Bottom side of the inline line-box.
@ BaselineNoChange
Use parent baseline table.
@ BaselineTextTop
Top side of the inline line-box.
@ BaselineCentral
Use the center between the ideographic over and under.
QString writeFontFeatureLigatures(const FontFeatureLigatures &feature)
QString writeUnicodeBidi(UnicodeBidi value)
@ EastAsianProportionalWidth
AutoValue parseAutoValueAngular(const QString &value, const SvgLoadingContext &context, const QString &autoKeyword)
TextOverflow
How to handle overflow.
@ OverFlowEllipse
Replace the last characters with "U+2026".
@ OverFlowClip
Clip the rendered content.
TextIndentInfo parseTextIndent(const QString &value, const SvgLoadingContext &context)
QString writeTextRendering(TextRendering value)
TextAlign parseTextAlign(const QString &value)
QString writeTextPathMethod(TextPathMethod value)
TextPathSide
Whether to reverse the path before laying out text.
Direction parseDirection(const QString &value)
LineHeightInfo parseLineHeight(const QString &value, const SvgLoadingContext &context)
QString writeLineBreak(LineBreak value)
QString writeLengthPercentage(const CssLengthPercentage &length, bool percentageAsEm)
QVariant fromAutoValue(const KoSvgText::AutoValue &value)
@ NumericFractionsDiagonal
@ NumericFractionsStacked
QString writeAutoLengthPercentage(const AutoLengthPercentage &value, const QString &autoKeyword, bool percentageToEm)
AutoValue parseAutoValueXY(const QString &value, const SvgLoadingContext &context, const QString &autoKeyword)
@ BidiNormal
No new bidi-level is started.
@ BidiIsolate
Content is ordered as if in a separate paragraph.
@ BidiEmbed
Opens an additional Bidi-reordering level.
QString writeFontFeatureCaps(const FontFeatureCaps &value)
QDataStream & operator>>(QDataStream &in, KoSvgText::FontFamilyAxis &axis)
FontFeaturePosition parseFontFeaturePosition(const QString &value, FontFeaturePosition feature)
QString writeFontFeatureEastAsian(const FontFeatureEastAsian &feature)
QString writeFontStyle(CssFontStyleData value)
QString writeTextAlign(TextAlign value)
LineBreak parseLineBreak(const QString &value)
QStringList fontFeaturesPosition(const FontFeaturePosition &feature, const int start, const int end)
QString writeFontFeatureNumeric(const FontFeatureNumeric &feature)
QString writeLengthAdjust(LengthAdjust value)
QString writeAlignmentBaseline(Baseline value)
TextSpaceTrim
Part of "white-space".
@ TrimInner
Discard white space at the beginning and end of element.
@ DiscardAfter
Trim white space after the end of the element.
@ DiscardBefore
Trim white space before the start of the element.
@ RenderingGeometricPrecision
@ RenderingOptimizeLegibility
int parseCSSFontWeight(const QString &value, int currentWeight)
TextOrientation parseTextOrientationFromGlyphOrientation(AutoValue value)
QString writeFontFeaturePosition(const FontFeaturePosition &value)
static const std::array< const char *, 9 > fontStretchNames
AutoLengthPercentage parseAutoLengthPercentageXY(const QString &value, const SvgLoadingContext &context, const QString &autoKeyword, QRectF bbox, bool percentageIsViewPort)
FontFeatureCaps parseFontFeatureCaps(const QString &value, FontFeatureCaps feature)
QString writeTextOrientation(TextOrientation orientation)
FontFeatureLigatures parseFontFeatureLigatures(const QString &value, FontFeatureLigatures features)
QString writeXmlSpace(TextSpaceCollapse collapseMethod)
QString writeTextPathSpacing(TextPathSpacing value)
TextPathMethod parseTextPathMethod(const QString &value)
int parseCSSFontStretch(const QString &value, int currentStretch)
parseCSSFontStretch For CSS3, the font-stretches were only given as keywords. In Css 4 and above,...
TextOrientation
Orientation of the glyphs, used for vertical writing modes.
@ OrientationUpright
Set all characters upright.
@ OrientationSideWays
Set all characters sideways.
@ TextTransformCapitalize
@ TextTransformUppercase
Convert all bicarmel text to upper-case, locale dependant.
@ TextTransformLowercase
Convert all bicarmel text to lower-case, locale dependant.
@ TextTransformNone
No transforms.
QString writeTextAnchor(TextAnchor value)
QString writeWritingMode(WritingMode value, bool svg1_1)
TextTransformInfo parseTextTransform(const QString &value)
@ HangForce
Whether to force hanging stops or commas.
@ HangLast
Hang closing brackets and quotes.
@ HangFirst
Hang opening brackets and quotes.
@ HangEnd
Hang stops and commas. Force/Allow is a separate boolean.
QString writeAutoValue(const AutoValue &value, const QString &autoKeyword)
QString writeDominantBaseline(Baseline value)
@ NumericFigureStyleLining
@ NumericFigureStyleNormal
@ Preserve
Do not collapse any space.
@ BreakSpaces
Same as preserve, except each white space and wordseperate is breakable.
@ Collapse
Collapse white space sequences into a single character.
@ Discard
Discard all Spaces.
@ PreserveSpaces
required for 'xml:space="preserve"' emulation.
QString writeTextTransform(const TextTransformInfo textTransform)
static const std::array< const char *, 7 > fontSizeNames
WordBreak parseWordBreak(const QString &value)
FontFeatureNumeric parseFontFeatureNumeric(const QString &value, FontFeatureNumeric features)
QString writeDirection(Direction value)
TextPathMethod
Whether to stretch the glyphs along a path.
@ TextPathAlign
Only align position and rotation of glyphs to the path.
QString writeWhiteSpaceValue(TextSpaceCollapse collapseMethod, TextWrap wrapMethod, TextSpaceTrims trimMethod)
QStringList fontFeaturesCaps(const FontFeatureCaps &feature, const int start, const int end)
QString writeTextIndent(const TextIndentInfo textIndent)
CssLengthPercentage length
bool operator==(const AutoLengthPercentage &other) const
AutoLengthPercentage(qreal _customValue, CssLengthPercentage::UnitType unit=CssLengthPercentage::Absolute)
AutoLengthPercentage(CssLengthPercentage _length)
bool operator==(const AutoValue &other) const
AutoValue(qreal _customValue)
BackgroundProperty is a special wrapper around KoShapeBackground for managing it in KoSvgTextProperti...
QSharedPointer< KoShapeBackground > property
BackgroundProperty(QSharedPointer< KoShapeBackground > p)
bool operator==(const BackgroundProperty &rhs) const
bool startsNewChunk() const
QPointF absolutePos() const
boost::optional< qreal > yPos
bool operator==(const CharTransformation &other) const
boost::optional< qreal > dxPos
boost::optional< qreal > dyPos
bool hasRelativeOffset() const
boost::optional< qreal > rotate
QPointF relativeOffset() const
void mergeInParentTransformation(const CharTransformation &t)
boost::optional< qreal > xPos
When style is oblique, a custom slant value can be specified for variable fonts.
bool operator==(const CssFontStyleData &other) const
KoSvgText::AutoValue slantValue
CssFontStyleData(QFont::Style _style)
CssLengthPercentage(qreal value, UnitType unit=Absolute)
bool operator==(const CssLengthPercentage &other) const
@ Cap
multiply by font-x-height.
@ Ch
multiply by font cap height
@ Absolute
Pt, everything needs to be converted to pt for this to work.
@ Lh
multiply by width of "U+6C34", represents average full width script advance.
@ Ex
multiply by Font-size
@ Ic
multiply by width of "0", represents average proportional script advance.
void convertToAbsolute(const KoSvgText::FontMetrics metrics, const qreal fontSize, const UnitType percentageUnit=Em)
static FontFamilyAxis weightAxis(qreal val)
QString debugInfo() const
Some variable fonts have axes that are not really supposed to be shown to the user.
static FontFamilyAxis slantAxis(qreal val)
FontFamilyAxis(QString _tag, qreal _value)
bool operator==(const FontFamilyAxis &other) const
QHash< QLocale, QString > localizedLabels
static FontFamilyAxis widthAxis(qreal val)
QHash< QString, float > instanceCoords
QHash< QLocale, QString > localizedLabels
bool operator==(const FontFamilyStyleInfo &other) const
QString debugInfo() const
bool operator==(const FontFeatureEastAsian &other) const
QStringList fontFeatures(const int start, const int end)
The FontFeatureLigatures class This struct represents css font-variant-ligatures.
QStringList fontFeatures(const int start, const int end)
bool contextualAlternates
'calt'
bool discretionaryLigatures
'dlig'
bool commonLigatures
'clig' and 'liga'
bool operator==(const FontFeatureLigatures &other) const
bool historicalLigatures
'hlig'
The FontFeatureLigatures class This struct represents css font-variant-numeric.
QStringList fontFeatures(const int start, const int end)
NumericFractions fractions
NumericFigureSpacing spacing
bool operator==(const FontFeatureNumeric &other) const
The FontMetrics class A class to keep track of a variety of font metrics. Note that values are in Fre...
qint32 ideographicCenterBaseline
default baseline for vertical, centered between over and under.
qint32 ideographicUnderBaseline
location of ideographic under baseline from origin, may fall back to descender.
QPair< qint32, qint32 > subScriptOffset
subscript baseline height, defaults to 1/5th em below alphabetic.
qint32 xHeight
height of X, defaults to 0.5 fontsize.
qint32 lineThroughThickness
strikethrough thickness, from font.
qint32 underlineThickness
underline thickness from font.
qint32 lineThroughOffset
offset of strike-through from alphabetic baseline.
qint32 lineGap
additional linegap between consecutive lines.
qint32 zeroAdvance
Advance of the character '0', CSS Unit 'ch', defaults to 0.5 em in horizontal and 1....
qint32 underlineOffset
underline offset from alphabetic, positive.
qint32 ideographicAdvance
Advance of the character '水' (U+6C34), CSS Unit ic, defaults to 1 em.
qint32 ideographicFaceOverBaseline
location of ideographic face over baseline, that is, the top of the glyphs.
qint32 ideographicOverBaseline
location of ideographic over baseline from origin.
qint32 fontSize
Currently set size, CSS unit 'em'.
qint32 ideographicFaceUnderBaseline
location of ideographic face under baseline, that is, the bottom of the glyphs.
qint32 caretRun
These are only used to determine the caret slant proportion.
qint32 alphabeticBaseline
location of alphabetic baseline from origin.
qint32 descender
distance for origin to bottom.
qint32 ascender
distance from origin to top.
qint32 mathematicalBaseline
location of mathematical baseline from origin.
qint32 capHeight
Height of capital letters, defaults to ascender.
qint32 hangingBaseline
location of the hanging baseline used in north brahmic scripts.
qint32 spaceAdvance
Advance of the character ' ', used by tabs.
QPair< qint32, qint32 > superScriptOffset
superscript baseline height, defaults to 2/3rd above alphabetic.
bool isNumber
Length or number.
bool operator==(const LineHeightInfo &rhs) const
The 'auto' value.
CssLengthPercentage length
bool isNormal
It's a number indicating the lineHeight;.
The ResolutionHandler class.
qreal freeTypePixelToPointFactor(const bool x=true) const
qreal pointToPixelFactor(const bool x=true) const
qreal pixelToPointFactor(const bool x=true) const
const qreal freeTypePixel
bool roundToPixelVertical
bool roundToPixelHorizontal
QTransform pixelToPoint() const
ResolutionHandler(qreal _xRes=72.0, qreal _yRes=72.0, bool _roundToPixelHorizontal=false, bool _roundToPixelVertical=false)
QTransform pointToPixel() const
QPointF adjustCeil(const QPointF point) const
Adjusts the point to ceiled pixel values.
QTransform freeTypeToPixelTransform() const
QTransform freeTypeToPointTransform() const
QPointF adjustWithOffset(const QPointF point, const QPointF offset) const
QPointF adjustFloor(const QPointF point) const
Adjusts the point to floored pixel values.
QPointF adjust(const QPointF point) const
Adjusts the point to rounded pixel values, based on whether roundToPixelHorizontal or roundToPixelVer...
StrokeProperty is a special wrapper around KoShapeStrokeModel for managing it in KoSvgTextProperties.
QSharedPointer< KoShapeStrokeModel > property
bool operator==(const StrokeProperty &rhs) const
StrokeProperty(QSharedPointer< KoShapeStrokeModel > p)
bool operator==(const TabSizeInfo &rhs) const
qreal value
A length or a number. Length is currently marked 'at-risk'.
CssLengthPercentage length
bool hanging
Flip the lines to which text-indent is applied.
bool eachLine
Apply the text-indent to each line following a hardbreak.
CssLengthPercentage length
bool operator==(const TextIndentInfo &rhs) const
bool startOffsetIsPercentage
TextTransformInfo()=default
bool operator==(const TextTransformInfo &rhs) const
TextTransform capitals
Text transform upper/lower/capitalize.
TextDecorationUnderlinePosition verticalPosition
TextDecorationUnderlinePosition horizontalPosition
bool operator==(const TextUnderlinePosition &other) const