diff options
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qabstracttextdocumentlayout.h | 2 | ||||
-rw-r--r-- | src/gui/text/qcssparser.cpp | 68 | ||||
-rw-r--r-- | src/gui/text/qcssparser_p.h | 3 | ||||
-rw-r--r-- | src/gui/text/qcssscanner.cpp | 847 | ||||
-rw-r--r-- | src/gui/text/qfont.cpp | 153 | ||||
-rw-r--r-- | src/gui/text/qfont.h | 19 | ||||
-rw-r--r-- | src/gui/text/qfont_p.h | 8 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 54 | ||||
-rw-r--r-- | src/gui/text/qfontengine.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qfontmetrics.cpp | 31 | ||||
-rw-r--r-- | src/gui/text/qfontmetrics.h | 33 | ||||
-rw-r--r-- | src/gui/text/qsyntaxhighlighter.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentfragment_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextformat.cpp | 48 | ||||
-rw-r--r-- | src/gui/text/qtextformat.h | 12 | ||||
-rw-r--r-- | src/gui/text/qtextformat_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtexthtmlparser.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 21 | ||||
-rw-r--r-- | src/gui/text/qtextlayout.h | 14 | ||||
-rw-r--r-- | src/gui/text/qtextodfwriter.cpp | 28 | ||||
-rw-r--r-- | src/gui/text/qzipreader_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qzipwriter_p.h | 2 |
22 files changed, 813 insertions, 543 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h index 8fea27f772..3371401420 100644 --- a/src/gui/text/qabstracttextdocumentlayout.h +++ b/src/gui/text/qabstracttextdocumentlayout.h @@ -143,7 +143,9 @@ public: virtual void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) = 0; }; +#ifndef Q_CLANG_QDOC Q_DECLARE_INTERFACE(QTextObjectInterface, "org.qt-project.Qt.QTextObjectInterface") +#endif QT_END_NAMESPACE diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 325fd26a31..dc7e128bcd 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -115,6 +115,7 @@ static const QCssKnownValue properties[NumProperties - 1] = { { "float", Float }, { "font", Font }, { "font-family", FontFamily }, + { "font-kerning", FontKerning }, { "font-size", FontSize }, { "font-style", FontStyle }, { "font-variant", FontVariant }, @@ -368,6 +369,7 @@ static inline bool isInheritable(Property propertyId) { switch (propertyId) { case Font: + case FontKerning: case FontFamily: case FontSize: case FontStyle: @@ -721,7 +723,8 @@ static ColorData parseColorValue(QCss::Value v) if (lst.count() != 2) return ColorData(); - if ((lst.at(0).compare(QLatin1String("palette"), Qt::CaseInsensitive)) == 0) { + const QString &identifier = lst.at(0); + if ((identifier.compare(QLatin1String("palette"), Qt::CaseInsensitive)) == 0) { int role = findKnownValue(lst.at(1).trimmed(), values, NumKnownValues); if (role >= Value_FirstColorRole && role <= Value_LastColorRole) return (QPalette::ColorRole)(role-Value_FirstColorRole); @@ -729,8 +732,16 @@ static ColorData parseColorValue(QCss::Value v) return ColorData(); } - bool rgb = lst.at(0).startsWith(QLatin1String("rgb")); - bool rgba = lst.at(0).startsWith(QLatin1String("rgba")); + const bool rgb = identifier.startsWith(QLatin1String("rgb")); + const bool hsv = !rgb && identifier.startsWith(QLatin1String("hsv")); + const bool hsl = !rgb && !hsv && identifier.startsWith(QLatin1String("hsl")); + + if (!rgb && !hsv && !hsl) + return ColorData(); + + const bool hasAlpha = identifier.size() == 4 && identifier.at(3) == QLatin1Char('a'); + if (identifier.size() > 3 && !hasAlpha) + return ColorData(); Parser p(lst.at(1)); if (!p.testExpr()) @@ -743,7 +754,8 @@ static ColorData parseColorValue(QCss::Value v) for (int i = 0; i < qMin(tokenCount, 7); i += 2) { if (colorDigits.at(i).type == Value::Percentage) { - colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (255. / 100.); + const qreal maxRange = (rgb || i != 0) ? 255. : 359.; + colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (maxRange / 100.); colorDigits[i].type = Value::Number; } else if (colorDigits.at(i).type != Value::Number) { return ColorData(); @@ -754,20 +766,29 @@ static ColorData parseColorValue(QCss::Value v) if (tokenCount < 5) return ColorData(); + // ### Qt6: replace this with a check and return invalid color when token count does not match + if (hasAlpha && tokenCount != 7) + qWarning("QCssParser::parseColorValue: Specified color with alpha value but no alpha given: '%s'", qPrintable(lst.join(QLatin1Char(' ')))); + if (!hasAlpha && tokenCount != 5) + qWarning("QCssParser::parseColorValue: Specified color without alpha value but alpha given: '%s'", qPrintable(lst.join(QLatin1Char(' ')))); + int v1 = colorDigits.at(0).variant.toInt(); int v2 = colorDigits.at(2).variant.toInt(); int v3 = colorDigits.at(4).variant.toInt(); int alpha = 255; - if (tokenCount >= 7) { + if (tokenCount == 7) { int alphaValue = colorDigits.at(6).variant.toInt(); - if (rgba && alphaValue <= 1) + if (alphaValue <= 1) alpha = colorDigits.at(6).variant.toReal() * 255.; else alpha = alphaValue; } - return rgb ? QColor::fromRgb(v1, v2, v3, alpha) - : QColor::fromHsv(v1, v2, v3, alpha); + if (rgb) + return QColor::fromRgb(v1, v2, v3, alpha); + if (hsv) + return QColor::fromHsv(v1, v2, v3, alpha); + return QColor::fromHsl(v1, v2, v3, alpha); } static QColor colorFromData(const ColorData& c, const QPalette &pal) @@ -1142,6 +1163,19 @@ static bool setFontStyleFromValue(const QCss::Value &value, QFont *font) return false; } +static bool setFontKerningFromValue(const QCss::Value &value, QFont *font) +{ + if (value.type != Value::KnownIdentifier) + return false ; + switch (value.variant.toInt()) { + case Value_Normal: font->setKerning(true); return true; + case Value_None: font->setKerning(false); return true; + case Value_Auto: return true; + default: break; + } + return false; +} + static bool setFontWeightFromValue(const QCss::Value &value, QFont *font) { if (value.type == Value::KnownIdentifier) { @@ -1166,11 +1200,13 @@ static bool setFontWeightFromValue(const QCss::Value &value, QFont *font) static bool setFontFamilyFromValues(const QVector<QCss::Value> &values, QFont *font, int start = 0) { QString family; + QStringList families; bool shouldAddSpace = false; for (int i = start; i < values.count(); ++i) { const QCss::Value &v = values.at(i); if (v.type == Value::TermOperatorComma) { - family += QLatin1Char(','); + families << family; + family.clear(); shouldAddSpace = false; continue; } @@ -1182,9 +1218,12 @@ static bool setFontFamilyFromValues(const QVector<QCss::Value> &values, QFont *f family += str; shouldAddSpace = true; } - if (family.isEmpty()) + if (!family.isEmpty()) + families << family; + if (families.isEmpty()) return false; - font->setFamily(family); + font->setFamily(families.at(0)); + font->setFamilies(families); return true; } @@ -1274,6 +1313,7 @@ bool ValueExtractor::extractFont(QFont *font, int *fontSizeAdjustment) case FontStyle: setFontStyleFromValue(val, font); break; case FontWeight: setFontWeightFromValue(val, font); break; case FontFamily: setFontFamilyFromValues(decl.d->values, font); break; + case FontKerning: setFontKerningFromValue(val, font); break; case TextDecoration: setTextDecorationFromValues(decl.d->values, font); break; case Font: parseShorthandFontProperty(decl.d->values, font, fontSizeAdjustment); break; case FontVariant: setFontVariantFromValue(val, font); break; @@ -1968,7 +2008,7 @@ bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node) } void StyleSelector::matchRule(NodePtr node, const StyleRule &rule, StyleSheetOrigin origin, - int depth, QMap<uint, StyleRule> *weightedRules) + int depth, QMultiMap<uint, StyleRule> *weightedRules) { for (int j = 0; j < rule.selectors.count(); ++j) { const Selector& selector = rule.selectors.at(j); @@ -1982,7 +2022,7 @@ void StyleSelector::matchRule(NodePtr node, const StyleRule &rule, StyleSheetOri newRule.selectors[0] = selector; } //We might have rules with the same weight if they came from a rule with several selectors - weightedRules->insertMulti(weight, newRule); + weightedRules->insert(weight, newRule); } } } @@ -1995,7 +2035,7 @@ QVector<StyleRule> StyleSelector::styleRulesForNode(NodePtr node) if (styleSheets.isEmpty()) return rules; - QMap<uint, StyleRule> weightedRules; // (spec, rule) that will be sorted below + QMultiMap<uint, StyleRule> weightedRules; // (spec, rule) that will be sorted below //prune using indexed stylesheet for (int sheetIdx = 0; sheetIdx < styleSheets.count(); ++sheetIdx) { diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index c1594531ea..860bbe382a 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -195,6 +195,7 @@ enum Property { QtListNumberSuffix, LineHeight, QtLineHeightType, + FontKerning, NumProperties }; @@ -673,7 +674,7 @@ public: Qt::CaseSensitivity nameCaseSensitivity; private: void matchRule(NodePtr node, const StyleRule &rules, StyleSheetOrigin origin, - int depth, QMap<uint, StyleRule> *weightedRules); + int depth, QMultiMap<uint, StyleRule> *weightedRules); bool selectorMatches(const Selector &rule, NodePtr node); bool basicSelectorMatches(const BasicSelector &rule, NodePtr node); }; diff --git a/src/gui/text/qcssscanner.cpp b/src/gui/text/qcssscanner.cpp index 33dc01c8bc..d48cbb71d7 100644 --- a/src/gui/text/qcssscanner.cpp +++ b/src/gui/text/qcssscanner.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -37,7 +37,7 @@ ** ****************************************************************************/ -// auto generated. DO NOT EDIT. +// auto generated by qtbase/util/lexgen/. DO NOT EDIT. class QCssScanner_Generated { public: @@ -75,23 +75,23 @@ int QCssScanner_Generated::lex() // initial state ch = next(); if (ch.unicode() >= 9 && ch.unicode() <= 10) - goto state_1; + goto state_4; if (ch.unicode() >= 12 && ch.unicode() <= 13) - goto state_1; + goto state_4; if (ch.unicode() == 32) - goto state_1; + goto state_4; if (ch.unicode() == 33) { token = QCss::EXCLAMATION_SYM; goto found; } if (ch.unicode() == 34) - goto state_3; + goto state_2; if (ch.unicode() == 35) - goto state_4; + goto state_1; if (ch.unicode() == 36) - goto state_5; - if (ch.unicode() == 39) goto state_6; + if (ch.unicode() == 39) + goto state_5; if (ch.unicode() == 40) { token = QCss::LPAREN; goto found; @@ -101,17 +101,17 @@ int QCssScanner_Generated::lex() goto found; } if (ch.unicode() == 42) - goto state_9; + goto state_8; if (ch.unicode() == 43) - goto state_10; + goto state_7; if (ch.unicode() == 44) - goto state_11; + goto state_14; if (ch.unicode() == 45) - goto state_12; - if (ch.unicode() == 46) goto state_13; + if (ch.unicode() == 46) + goto state_12; if (ch.unicode() == 47) - goto state_14; + goto state_11; if (ch.unicode() >= 48 && ch.unicode() <= 57) goto state_15; if (ch.unicode() == 58) { @@ -123,64 +123,56 @@ int QCssScanner_Generated::lex() goto found; } if (ch.unicode() == 60) - goto state_18; + goto state_20; if (ch.unicode() == 61) { token = QCss::EQUAL; goto found; } if (ch.unicode() == 62) - goto state_20; + goto state_18; if (ch.unicode() == 64) - goto state_21; + goto state_26; if (ch.unicode() == 91) { token = QCss::LBRACKET; goto found; } if (ch.unicode() == 92) - goto state_23; + goto state_30; if (ch.unicode() == 93) { token = QCss::RBRACKET; goto found; } if (ch.unicode() == 94) - goto state_25; + goto state_28; if (ch.unicode() == 95) - goto state_26; + goto state_21; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_26; + goto state_21; if (ch.unicode() == 123) - goto state_27; + goto state_22; if (ch.unicode() == 124) - goto state_28; + goto state_25; if (ch.unicode() == 125) { token = QCss::RBRACE; goto found; } if (ch.unicode() == 126) - goto state_30; + goto state_23; goto out; state_1: - lastAcceptingPos = pos; - token = QCss::S; ch = next(); - if (ch.unicode() >= 9 && ch.unicode() <= 10) - goto state_31; - if (ch.unicode() >= 12 && ch.unicode() <= 13) + if (ch.unicode() == 45) goto state_31; - if (ch.unicode() == 32) + if (ch.unicode() >= 48 && ch.unicode() <= 57) goto state_31; - if (ch.unicode() == 43) - goto state_10; - if (ch.unicode() == 44) - goto state_11; - if (ch.unicode() == 62) - goto state_20; - if (ch.unicode() == 123) - goto state_27; - if (ch.unicode() == 126) + if (ch.unicode() == 92) goto state_32; + if (ch.unicode() == 95) + goto state_31; + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) + goto state_31; goto out; - state_3: + state_2: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); @@ -204,93 +196,101 @@ int QCssScanner_Generated::lex() goto state_33; goto out; state_4: + lastAcceptingPos = pos; + token = QCss::S; ch = next(); - if (ch.unicode() == 45) - goto state_36; - if (ch.unicode() >= 48 && ch.unicode() <= 57) + if (ch.unicode() >= 9 && ch.unicode() <= 10) goto state_36; - if (ch.unicode() == 92) - goto state_37; - if (ch.unicode() == 95) + if (ch.unicode() >= 12 && ch.unicode() <= 13) goto state_36; - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) + if (ch.unicode() == 32) goto state_36; + if (ch.unicode() == 43) + goto state_7; + if (ch.unicode() == 44) + goto state_14; + if (ch.unicode() == 62) + goto state_18; + if (ch.unicode() == 123) + goto state_22; + if (ch.unicode() == 126) + goto state_37; goto out; state_5: - ch = next(); - if (ch.unicode() == 61) { - token = QCss::ENDSWITH; - goto found; - } - goto out; - state_6: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_39; + goto state_38; if (ch.unicode() == 11) - goto state_39; + goto state_38; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_39; + goto state_38; if (ch.unicode() == 39) - goto state_40; - if (ch.unicode() >= 40 && ch.unicode() <= 91) goto state_39; + if (ch.unicode() >= 40 && ch.unicode() <= 91) + goto state_38; if (ch.unicode() == 92) - goto state_41; + goto state_40; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_39; + goto state_38; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_39; + goto state_38; if (ch.unicode() >= 123) - goto state_39; + goto state_38; goto out; - state_9: - lastAcceptingPos = pos; - token = QCss::STAR; + state_6: ch = next(); if (ch.unicode() == 61) { - token = QCss::CONTAINS; + token = QCss::ENDSWITH; goto found; } goto out; - state_10: + state_7: lastAcceptingPos = pos; token = QCss::PLUS; goto out; + state_8: + lastAcceptingPos = pos; + token = QCss::STAR; + ch = next(); + if (ch.unicode() == 61) { + token = QCss::CONTAINS; + goto found; + } + goto out; state_11: lastAcceptingPos = pos; - token = QCss::COMMA; + token = QCss::SLASH; + ch = next(); + if (ch.unicode() == 42) { + token = handleCommentStart(); + goto found; + } goto out; state_12: lastAcceptingPos = pos; + token = QCss::DOT; + ch = next(); + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_44; + goto out; + state_13: + lastAcceptingPos = pos; token = QCss::MINUS; ch = next(); if (ch.unicode() == 45) - goto state_43; + goto state_45; if (ch.unicode() == 92) - goto state_23; + goto state_30; if (ch.unicode() == 95) - goto state_26; + goto state_21; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_26; - goto out; - state_13: - lastAcceptingPos = pos; - token = QCss::DOT; - ch = next(); - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_44; + goto state_21; goto out; state_14: lastAcceptingPos = pos; - token = QCss::SLASH; - ch = next(); - if (ch.unicode() == 42) { - token = handleCommentStart(); - goto found; - } + token = QCss::COMMA; goto out; state_15: lastAcceptingPos = pos; @@ -299,68 +299,70 @@ int QCssScanner_Generated::lex() if (ch.unicode() == 37) goto state_46; if (ch.unicode() == 45) - goto state_47; - if (ch.unicode() == 46) goto state_48; + if (ch.unicode() == 46) + goto state_47; if (ch.unicode() >= 48 && ch.unicode() <= 57) goto state_49; if (ch.unicode() == 92) - goto state_50; - if (ch.unicode() == 95) goto state_51; + if (ch.unicode() == 95) + goto state_50; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_51; + goto state_50; goto out; state_18: + lastAcceptingPos = pos; + token = QCss::GREATER; + goto out; + state_20: ch = next(); if (ch.unicode() == 33) goto state_52; goto out; - state_20: - lastAcceptingPos = pos; - token = QCss::GREATER; - goto out; state_21: + lastAcceptingPos = pos; + token = QCss::IDENT; ch = next(); - if (ch.unicode() == 45) + if (ch.unicode() == 40) goto state_53; - if (ch.unicode() == 92) + if (ch.unicode() == 45) goto state_54; - if (ch.unicode() == 95) + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_54; + if (ch.unicode() == 92) goto state_55; + if (ch.unicode() == 95) + goto state_54; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_55; + goto state_54; + goto out; + state_22: + lastAcceptingPos = pos; + token = QCss::LBRACE; goto out; state_23: + lastAcceptingPos = pos; + token = QCss::TILDE; ch = next(); - if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_56; - if (ch.unicode() == 11) - goto state_56; - if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_56; - if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_56; - if (ch.unicode() >= 103) - goto state_56; + if (ch.unicode() == 61) { + token = QCss::INCLUDES; + goto found; + } goto out; state_25: + lastAcceptingPos = pos; + token = QCss::OR; ch = next(); if (ch.unicode() == 61) { - token = QCss::BEGINSWITH; + token = QCss::DASHMATCH; goto found; } goto out; state_26: - lastAcceptingPos = pos; - token = QCss::IDENT; ch = next(); - if (ch.unicode() == 40) - goto state_58; if (ch.unicode() == 45) - goto state_59; - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_59; + goto state_58; if (ch.unicode() == 92) goto state_60; if (ch.unicode() == 95) @@ -368,52 +370,53 @@ int QCssScanner_Generated::lex() if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) goto state_59; goto out; - state_27: - lastAcceptingPos = pos; - token = QCss::LBRACE; - goto out; state_28: - lastAcceptingPos = pos; - token = QCss::OR; ch = next(); if (ch.unicode() == 61) { - token = QCss::DASHMATCH; + token = QCss::BEGINSWITH; goto found; } goto out; state_30: - lastAcceptingPos = pos; - token = QCss::TILDE; ch = next(); - if (ch.unicode() == 61) { - token = QCss::INCLUDES; - goto found; - } + if (ch.unicode() >= 1 && ch.unicode() <= 9) + goto state_62; + if (ch.unicode() == 11) + goto state_62; + if (ch.unicode() >= 14 && ch.unicode() <= 47) + goto state_62; + if (ch.unicode() >= 58 && ch.unicode() <= 96) + goto state_62; + if (ch.unicode() >= 103) + goto state_62; goto out; state_31: lastAcceptingPos = pos; - token = QCss::S; + token = QCss::HASH; ch = next(); - if (ch.unicode() >= 9 && ch.unicode() <= 10) - goto state_31; - if (ch.unicode() >= 12 && ch.unicode() <= 13) - goto state_31; - if (ch.unicode() == 32) - goto state_31; - if (ch.unicode() == 43) - goto state_10; - if (ch.unicode() == 44) - goto state_11; - if (ch.unicode() == 62) - goto state_20; - if (ch.unicode() == 123) - goto state_27; - if (ch.unicode() == 126) - goto state_32; + if (ch.unicode() == 45) + goto state_63; + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_63; + if (ch.unicode() == 92) + goto state_64; + if (ch.unicode() == 95) + goto state_63; + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) + goto state_63; goto out; state_32: - lastAcceptingPos = pos; - token = QCss::TILDE; + ch = next(); + if (ch.unicode() >= 1 && ch.unicode() <= 9) + goto state_65; + if (ch.unicode() == 11) + goto state_65; + if (ch.unicode() >= 14 && ch.unicode() <= 47) + goto state_65; + if (ch.unicode() >= 58 && ch.unicode() <= 96) + goto state_65; + if (ch.unicode() >= 103) + goto state_65; goto out; state_33: lastAcceptingPos = pos; @@ -445,78 +448,75 @@ int QCssScanner_Generated::lex() state_35: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_63; + goto state_66; if (ch.unicode() == 10) - goto state_64; + goto state_67; if (ch.unicode() == 11) - goto state_63; + goto state_66; if (ch.unicode() == 12) - goto state_65; + goto state_69; if (ch.unicode() == 13) - goto state_66; + goto state_68; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_63; + goto state_66; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_63; + goto state_66; if (ch.unicode() >= 103) - goto state_63; + goto state_66; goto out; state_36: lastAcceptingPos = pos; - token = QCss::HASH; + token = QCss::S; ch = next(); - if (ch.unicode() == 45) - goto state_67; - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_67; - if (ch.unicode() == 92) - goto state_68; - if (ch.unicode() == 95) - goto state_67; - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_67; + if (ch.unicode() >= 9 && ch.unicode() <= 10) + goto state_36; + if (ch.unicode() >= 12 && ch.unicode() <= 13) + goto state_36; + if (ch.unicode() == 32) + goto state_36; + if (ch.unicode() == 43) + goto state_7; + if (ch.unicode() == 44) + goto state_14; + if (ch.unicode() == 62) + goto state_18; + if (ch.unicode() == 123) + goto state_22; + if (ch.unicode() == 126) + goto state_37; goto out; state_37: - ch = next(); - if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_69; - if (ch.unicode() == 11) - goto state_69; - if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_69; - if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_69; - if (ch.unicode() >= 103) - goto state_69; + lastAcceptingPos = pos; + token = QCss::TILDE; goto out; - state_39: + state_38: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_39; + goto state_38; if (ch.unicode() == 11) - goto state_39; + goto state_38; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_39; + goto state_38; if (ch.unicode() == 39) - goto state_40; - if (ch.unicode() >= 40 && ch.unicode() <= 91) goto state_39; + if (ch.unicode() >= 40 && ch.unicode() <= 91) + goto state_38; if (ch.unicode() == 92) - goto state_41; + goto state_40; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_39; + goto state_38; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_39; + goto state_38; if (ch.unicode() >= 123) - goto state_39; + goto state_38; goto out; - state_40: + state_39: lastAcceptingPos = pos; token = QCss::STRING; goto out; - state_41: + state_40: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) goto state_70; @@ -525,9 +525,9 @@ int QCssScanner_Generated::lex() if (ch.unicode() == 11) goto state_70; if (ch.unicode() == 12) - goto state_72; - if (ch.unicode() == 13) goto state_73; + if (ch.unicode() == 13) + goto state_72; if (ch.unicode() >= 14 && ch.unicode() <= 47) goto state_70; if (ch.unicode() >= 58 && ch.unicode() <= 96) @@ -535,13 +535,6 @@ int QCssScanner_Generated::lex() if (ch.unicode() >= 103) goto state_70; goto out; - state_43: - ch = next(); - if (ch.unicode() == 62) { - token = QCss::CDC; - goto found; - } - goto out; state_44: lastAcceptingPos = pos; token = QCss::NUMBER; @@ -549,15 +542,22 @@ int QCssScanner_Generated::lex() if (ch.unicode() == 37) goto state_46; if (ch.unicode() == 45) - goto state_47; + goto state_48; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_74; if (ch.unicode() == 92) - goto state_50; - if (ch.unicode() == 95) goto state_51; + if (ch.unicode() == 95) + goto state_50; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_51; + goto state_50; + goto out; + state_45: + ch = next(); + if (ch.unicode() == 62) { + token = QCss::CDC; + goto found; + } goto out; state_46: lastAcceptingPos = pos; @@ -565,17 +565,17 @@ int QCssScanner_Generated::lex() goto out; state_47: ch = next(); - if (ch.unicode() == 92) - goto state_50; - if (ch.unicode() == 95) - goto state_51; - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_51; + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_44; goto out; state_48: ch = next(); - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_44; + if (ch.unicode() == 92) + goto state_51; + if (ch.unicode() == 95) + goto state_50; + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) + goto state_50; goto out; state_49: lastAcceptingPos = pos; @@ -584,45 +584,45 @@ int QCssScanner_Generated::lex() if (ch.unicode() == 37) goto state_46; if (ch.unicode() == 45) - goto state_47; - if (ch.unicode() == 46) goto state_48; + if (ch.unicode() == 46) + goto state_47; if (ch.unicode() >= 48 && ch.unicode() <= 57) goto state_49; if (ch.unicode() == 92) - goto state_50; - if (ch.unicode() == 95) goto state_51; + if (ch.unicode() == 95) + goto state_50; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_51; + goto state_50; goto out; state_50: + lastAcceptingPos = pos; + token = QCss::LENGTH; ch = next(); - if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_76; - if (ch.unicode() == 11) + if (ch.unicode() == 45) goto state_76; - if (ch.unicode() >= 14 && ch.unicode() <= 47) + if (ch.unicode() >= 48 && ch.unicode() <= 57) goto state_76; - if (ch.unicode() >= 58 && ch.unicode() <= 96) + if (ch.unicode() == 92) + goto state_77; + if (ch.unicode() == 95) goto state_76; - if (ch.unicode() >= 103) + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) goto state_76; goto out; state_51: - lastAcceptingPos = pos; - token = QCss::LENGTH; ch = next(); - if (ch.unicode() == 45) - goto state_77; - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_77; - if (ch.unicode() == 92) + if (ch.unicode() >= 1 && ch.unicode() <= 9) + goto state_78; + if (ch.unicode() == 11) + goto state_78; + if (ch.unicode() >= 14 && ch.unicode() <= 47) + goto state_78; + if (ch.unicode() >= 58 && ch.unicode() <= 96) + goto state_78; + if (ch.unicode() >= 103) goto state_78; - if (ch.unicode() == 95) - goto state_77; - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_77; goto out; state_52: ch = next(); @@ -630,15 +630,27 @@ int QCssScanner_Generated::lex() goto state_79; goto out; state_53: + lastAcceptingPos = pos; + token = QCss::FUNCTION; + goto out; + state_54: + lastAcceptingPos = pos; + token = QCss::IDENT; ch = next(); - if (ch.unicode() == 92) + if (ch.unicode() == 40) + goto state_53; + if (ch.unicode() == 45) goto state_54; - if (ch.unicode() == 95) + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_54; + if (ch.unicode() == 92) goto state_55; + if (ch.unicode() == 95) + goto state_54; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_55; + goto state_54; goto out; - state_54: + state_55: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) goto state_80; @@ -651,7 +663,16 @@ int QCssScanner_Generated::lex() if (ch.unicode() >= 103) goto state_80; goto out; - state_55: + state_58: + ch = next(); + if (ch.unicode() == 92) + goto state_60; + if (ch.unicode() == 95) + goto state_59; + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) + goto state_59; + goto out; + state_59: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); @@ -666,58 +687,80 @@ int QCssScanner_Generated::lex() if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) goto state_81; goto out; - state_56: + state_60: + ch = next(); + if (ch.unicode() >= 1 && ch.unicode() <= 9) + goto state_83; + if (ch.unicode() == 11) + goto state_83; + if (ch.unicode() >= 14 && ch.unicode() <= 47) + goto state_83; + if (ch.unicode() >= 58 && ch.unicode() <= 96) + goto state_83; + if (ch.unicode() >= 103) + goto state_83; + goto out; + state_62: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_58; + goto state_53; if (ch.unicode() == 45) - goto state_59; + goto state_54; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_59; + goto state_54; if (ch.unicode() == 92) - goto state_60; + goto state_55; if (ch.unicode() == 95) - goto state_59; + goto state_54; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_59; - goto out; - state_58: - lastAcceptingPos = pos; - token = QCss::FUNCTION; + goto state_54; goto out; - state_59: + state_63: lastAcceptingPos = pos; - token = QCss::IDENT; + token = QCss::HASH; ch = next(); - if (ch.unicode() == 40) - goto state_58; if (ch.unicode() == 45) - goto state_59; + goto state_63; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_59; + goto state_63; if (ch.unicode() == 92) - goto state_60; + goto state_64; if (ch.unicode() == 95) - goto state_59; + goto state_63; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_59; + goto state_63; goto out; - state_60: + state_64: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_83; + goto state_84; if (ch.unicode() == 11) - goto state_83; + goto state_84; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_83; + goto state_84; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_83; + goto state_84; if (ch.unicode() >= 103) - goto state_83; + goto state_84; goto out; - state_63: + state_65: + lastAcceptingPos = pos; + token = QCss::HASH; + ch = next(); + if (ch.unicode() == 45) + goto state_63; + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_63; + if (ch.unicode() == 92) + goto state_64; + if (ch.unicode() == 95) + goto state_63; + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) + goto state_63; + goto out; + state_66: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); @@ -740,7 +783,7 @@ int QCssScanner_Generated::lex() if (ch.unicode() >= 123) goto state_33; goto out; - state_64: + state_67: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); @@ -763,12 +806,14 @@ int QCssScanner_Generated::lex() if (ch.unicode() >= 123) goto state_33; goto out; - state_65: + state_68: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) goto state_33; + if (ch.unicode() == 10) + goto state_85; if (ch.unicode() == 11) goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) @@ -786,14 +831,12 @@ int QCssScanner_Generated::lex() if (ch.unicode() >= 123) goto state_33; goto out; - state_66: + state_69: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) goto state_33; - if (ch.unicode() == 10) - goto state_84; if (ch.unicode() == 11) goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) @@ -811,191 +854,133 @@ int QCssScanner_Generated::lex() if (ch.unicode() >= 123) goto state_33; goto out; - state_67: - lastAcceptingPos = pos; - token = QCss::HASH; - ch = next(); - if (ch.unicode() == 45) - goto state_67; - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_67; - if (ch.unicode() == 92) - goto state_68; - if (ch.unicode() == 95) - goto state_67; - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_67; - goto out; - state_68: - ch = next(); - if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_85; - if (ch.unicode() == 11) - goto state_85; - if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_85; - if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_85; - if (ch.unicode() >= 103) - goto state_85; - goto out; - state_69: - lastAcceptingPos = pos; - token = QCss::HASH; - ch = next(); - if (ch.unicode() == 45) - goto state_67; - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_67; - if (ch.unicode() == 92) - goto state_68; - if (ch.unicode() == 95) - goto state_67; - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_67; - goto out; state_70: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_39; + goto state_38; if (ch.unicode() == 11) - goto state_39; + goto state_38; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_39; + goto state_38; if (ch.unicode() == 39) - goto state_40; - if (ch.unicode() >= 40 && ch.unicode() <= 91) goto state_39; + if (ch.unicode() >= 40 && ch.unicode() <= 91) + goto state_38; if (ch.unicode() == 92) - goto state_41; + goto state_40; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_39; + goto state_38; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_39; + goto state_38; if (ch.unicode() >= 123) - goto state_39; + goto state_38; goto out; state_71: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_39; + goto state_38; if (ch.unicode() == 11) - goto state_39; + goto state_38; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_39; + goto state_38; if (ch.unicode() == 39) - goto state_40; - if (ch.unicode() >= 40 && ch.unicode() <= 91) goto state_39; + if (ch.unicode() >= 40 && ch.unicode() <= 91) + goto state_38; if (ch.unicode() == 92) - goto state_41; + goto state_40; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_39; + goto state_38; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_39; + goto state_38; if (ch.unicode() >= 123) - goto state_39; + goto state_38; goto out; state_72: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_39; + goto state_38; + if (ch.unicode() == 10) + goto state_86; if (ch.unicode() == 11) - goto state_39; + goto state_38; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_39; + goto state_38; if (ch.unicode() == 39) - goto state_40; - if (ch.unicode() >= 40 && ch.unicode() <= 91) goto state_39; + if (ch.unicode() >= 40 && ch.unicode() <= 91) + goto state_38; if (ch.unicode() == 92) - goto state_41; + goto state_40; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_39; + goto state_38; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_39; + goto state_38; if (ch.unicode() >= 123) - goto state_39; + goto state_38; goto out; state_73: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_39; - if (ch.unicode() == 10) - goto state_86; + goto state_38; if (ch.unicode() == 11) - goto state_39; + goto state_38; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_39; + goto state_38; if (ch.unicode() == 39) - goto state_40; - if (ch.unicode() >= 40 && ch.unicode() <= 91) goto state_39; + if (ch.unicode() >= 40 && ch.unicode() <= 91) + goto state_38; if (ch.unicode() == 92) - goto state_41; + goto state_40; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_39; + goto state_38; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_39; + goto state_38; if (ch.unicode() >= 123) - goto state_39; + goto state_38; goto out; - state_75: + state_74: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) goto state_46; if (ch.unicode() == 45) - goto state_47; + goto state_48; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_74; if (ch.unicode() == 92) - goto state_50; - if (ch.unicode() == 95) goto state_51; + if (ch.unicode() == 95) + goto state_50; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_51; + goto state_50; goto out; state_76: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_77; + goto state_76; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_77; + goto state_76; if (ch.unicode() == 92) - goto state_78; - if (ch.unicode() == 95) - goto state_77; - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_77; - goto out; - state_77: - lastAcceptingPos = pos; - token = QCss::LENGTH; - ch = next(); - if (ch.unicode() == 45) goto state_77; - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_77; - if (ch.unicode() == 92) - goto state_78; if (ch.unicode() == 95) - goto state_77; + goto state_76; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_77; + goto state_76; goto out; - state_78: + state_77: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) goto state_87; @@ -1008,6 +993,21 @@ int QCssScanner_Generated::lex() if (ch.unicode() >= 103) goto state_87; goto out; + state_78: + lastAcceptingPos = pos; + token = QCss::LENGTH; + ch = next(); + if (ch.unicode() == 45) + goto state_76; + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_76; + if (ch.unicode() == 92) + goto state_77; + if (ch.unicode() == 95) + goto state_76; + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) + goto state_76; + goto out; state_79: ch = next(); if (ch.unicode() == 45) { @@ -1017,18 +1017,20 @@ int QCssScanner_Generated::lex() goto out; state_80: lastAcceptingPos = pos; - token = QCss::ATKEYWORD_SYM; + token = QCss::IDENT; ch = next(); + if (ch.unicode() == 40) + goto state_53; if (ch.unicode() == 45) - goto state_81; + goto state_54; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_81; + goto state_54; if (ch.unicode() == 92) - goto state_82; + goto state_55; if (ch.unicode() == 95) - goto state_81; + goto state_54; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_81; + goto state_54; goto out; state_81: lastAcceptingPos = pos; @@ -1060,23 +1062,36 @@ int QCssScanner_Generated::lex() goto out; state_83: lastAcceptingPos = pos; - token = QCss::IDENT; + token = QCss::ATKEYWORD_SYM; ch = next(); - if (ch.unicode() == 40) - goto state_58; if (ch.unicode() == 45) - goto state_59; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_59; + goto state_81; if (ch.unicode() == 92) - goto state_60; + goto state_82; if (ch.unicode() == 95) - goto state_59; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_59; + goto state_81; goto out; state_84: lastAcceptingPos = pos; + token = QCss::HASH; + ch = next(); + if (ch.unicode() == 45) + goto state_63; + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_63; + if (ch.unicode() == 92) + goto state_64; + if (ch.unicode() == 95) + goto state_63; + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) + goto state_63; + goto out; + state_85: + lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) @@ -1098,58 +1113,43 @@ int QCssScanner_Generated::lex() if (ch.unicode() >= 123) goto state_33; goto out; - state_85: - lastAcceptingPos = pos; - token = QCss::HASH; - ch = next(); - if (ch.unicode() == 45) - goto state_67; - if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_67; - if (ch.unicode() == 92) - goto state_68; - if (ch.unicode() == 95) - goto state_67; - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_67; - goto out; state_86: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_39; + goto state_38; if (ch.unicode() == 11) - goto state_39; + goto state_38; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_39; + goto state_38; if (ch.unicode() == 39) - goto state_40; - if (ch.unicode() >= 40 && ch.unicode() <= 91) goto state_39; + if (ch.unicode() >= 40 && ch.unicode() <= 91) + goto state_38; if (ch.unicode() == 92) - goto state_41; + goto state_40; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_39; + goto state_38; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_39; + goto state_38; if (ch.unicode() >= 123) - goto state_39; + goto state_38; goto out; state_87: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_77; + goto state_76; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_77; + goto state_76; if (ch.unicode() == 92) - goto state_78; - if (ch.unicode() == 95) goto state_77; + if (ch.unicode() == 95) + goto state_76; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_77; + goto state_76; goto out; state_89: lastAcceptingPos = pos; @@ -1176,4 +1176,3 @@ int QCssScanner_Generated::lex() } return token; } - diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 69255fd59d..d879836572 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -116,7 +116,17 @@ bool QFontDef::exactMatch(const QFontDef &other) const if (stretch != 0 && other.stretch != 0 && stretch != other.stretch) return false; + if (families.size() != other.families.size()) + return false; + QString this_family, this_foundry, other_family, other_foundry; + for (int i = 0; i < families.size(); ++i) { + QFontDatabase::parseFontName(families.at(i), this_foundry, this_family); + QFontDatabase::parseFontName(other.families.at(i), other_foundry, other_family); + if (this_family != other_family || this_foundry != other_foundry) + return false; + } + QFontDatabase::parseFontName(family, this_foundry, this_family); QFontDatabase::parseFontName(other.family, other_foundry, other_family); @@ -261,6 +271,9 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other) if (! (mask & QFont::FamilyResolved)) request.family = other->request.family; + if (!(mask & QFont::FamiliesResolved)) + request.families = other->request.families; + if (! (mask & QFont::StyleNameResolved)) request.styleName = other->request.styleName; @@ -340,7 +353,7 @@ QFontEngineData::~QFontEngineData() \class QFont \reentrant - \brief The QFont class specifies a font used for drawing text. + \brief The QFont class specifies a query for a font used for drawing text. \ingroup painting \ingroup appearance @@ -348,6 +361,7 @@ QFontEngineData::~QFontEngineData() \ingroup richtext-processing \inmodule QtGui + QFont can be regarded as a query for one or more fonts on the system. When you create a QFont object you specify various attributes that you want the font to have. Qt will use the font with the specified @@ -355,9 +369,15 @@ QFontEngineData::~QFontEngineData() matching installed font. The attributes of the font that is actually used are retrievable from a QFontInfo object. If the window system provides an exact match exactMatch() returns \c true. - Use QFontMetrics to get measurements, e.g. the pixel length of a + Use QFontMetricsF to get measurements, e.g. the pixel length of a string using QFontMetrics::width(). + Attributes which are not specifically set will not affect the font + selection algorithm, and default values will be preferred instead. + + To load a specific physical font, typically represented by a single file, + use QRawFont instead. + Note that a QGuiApplication instance must exist before a QFont can be used. You can set the application's default font with QGuiApplication::setFont(). @@ -390,8 +410,6 @@ QFontEngineData::~QFontEngineData() setStyleHint(). The default family (corresponding to the current style hint) is returned by defaultFamily(). - The font-matching algorithm has a lastResortFamily() and - lastResortFont() in cases where a suitable match cannot be found. You can provide substitutions for font family names using insertSubstitution() and insertSubstitutions(). Substitutions can be removed with removeSubstitutions(). Use substitute() to retrieve @@ -419,18 +437,21 @@ QFontEngineData::~QFontEngineData() \target fontmatching The font matching algorithm works as follows: \list 1 - \li The specified font family is searched for. - \li If not found, the styleHint() is used to select a replacement - family. - \li Each replacement font family is searched for. - \li If none of these are found or there was no styleHint(), "helvetica" - will be searched for. - \li If "helvetica" isn't found Qt will try the lastResortFamily(). - \li If the lastResortFamily() isn't found Qt will try the - lastResortFont() which will always return a name of some kind. + \li The specified font families (set by setFamilies()) are searched for. + \li If not found, then if set the specified font family exists and can be used to represent + the writing system in use, it will be selected. + \li If not, a replacement font that supports the writing system is + selected. The font matching algorithm will try to find the + best match for all the properties set in the QFont. How this is + done varies from platform to platform. + \li If no font exists on the system that can support the text, + then special "missing character" boxes will be shown in its place. \endlist - Note that the actual font matching algorithm varies from platform to platform. + \note If the selected font, though supporting the writing system in general, + is missing glyphs for one or more specific characters, then Qt will try to + find a fallback font for this or these particular characters. This feature + can be disabled using QFont::NoFontMerging style strategy. In Windows a request for the "Courier" font is automatically changed to "Courier New", an improved version of Courier that allows for smooth scaling. @@ -499,6 +520,7 @@ QFontEngineData::~QFontEngineData() individually and then considered resolved. \value FamilyResolved + \value FamiliesResolved \value SizeResolved \value StyleHintResolved \value StyleStrategyResolved @@ -540,14 +562,25 @@ QFontEngineData::~QFontEngineData() \since 5.2 */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! + \obsolete Constructs a font from \a font for use on the paint device \a pd. */ QFont::QFont(const QFont &font, QPaintDevice *pd) + : QFont(font, static_cast<const QPaintDevice*>(pd)) +{} +#endif + +/*! + \since 5.13 + Constructs a font from \a font for use on the paint device \a pd. +*/ +QFont::QFont(const QFont &font, const QPaintDevice *pd) : resolve_mask(font.resolve_mask) { - Q_ASSERT(pd != 0); - int dpi = pd->logicalDpiY(); + Q_ASSERT(pd); + const int dpi = pd->logicalDpiY(); const int screen = 0; if (font.d->dpi != dpi || font.d->screen != screen ) { d = new QFontPrivate(*font.d); @@ -1684,6 +1717,7 @@ bool QFont::operator<(const QFont &f) const if (r1.stretch != r2.stretch) return r1.stretch < r2.stretch; if (r1.styleHint != r2.styleHint) return r1.styleHint < r2.styleHint; if (r1.styleStrategy != r2.styleStrategy) return r1.styleStrategy < r2.styleStrategy; + if (r1.families != r2.families) return r1.families < r2.families; if (r1.family != r2.family) return r1.family < r2.family; if (f.d->capital != d->capital) return f.d->capital < d->capital; @@ -2133,21 +2167,22 @@ void QFont::cacheStatistics() { } +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QString QFont::lastResortFamily() const - Returns the "last resort" font family name. + \obsolete - The current implementation tries a wide variety of common fonts, - returning the first one it finds. Is is possible that no family is - found in which case an empty string is returned. + This function is deprecated and is not in use by the font + selection algorithm in Qt 5. It always returns "helvetica". \sa lastResortFont() */ QString QFont::lastResortFamily() const { - return QString::fromLatin1("helvetica"); + return QStringLiteral("helvetica"); } +#endif extern QStringList qt_fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script); @@ -2169,34 +2204,63 @@ QString QFont::defaultFamily() const return QString(); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QString QFont::lastResortFont() const - Returns a "last resort" font name for the font matching algorithm. - This is used if the last resort family is not available. It will - always return a name, if necessary returning something like - "fixed" or "system". + \obsolete + + Deprecated function. Since Qt 5.0, this is not used by the font selection algorithm. For + compatibility it remains in the API, but will always return the same value as lastResortFamily(). +*/ +QString QFont::lastResortFont() const +{ + return lastResortFamily(); +} +#endif + +/*! + \since 5.13 + + Returns the requested font family names, i.e. the names set in the last + setFamilies() call or via the constructor. Otherwise it returns an + empty list. + + \sa setFamily(), setFamilies(), family(), substitutes(), substitute() +*/ + +QStringList QFont::families() const +{ + return d->request.families; +} - The current implementation tries a wide variety of common fonts, - returning the first one it finds. The implementation may change - at any time, but this function will always return a string - containing something. +/*! + \since 5.13 - It is theoretically possible that there really isn't a - lastResortFont() in which case Qt will abort with an error - message. We have not been able to identify a case where this - happens. Please \l{bughowto.html}{report it as a bug} if - it does, preferably with a list of the fonts you have installed. + Sets the list of family names for the font. The names are case + insensitive and may include a foundry name. The first family in + \a families will be set as the main family for the font. - \sa lastResortFamily() + Each family name entry in \a families may optionally also include a + foundry name, e.g. "Helvetica [Cronyx]". If the family is + available from more than one foundry and the foundry isn't + specified, an arbitrary foundry is chosen. If the family isn't + available a family will be set using the \l{QFont}{font matching} + algorithm. + + \sa family(), families(), setFamily(), setStyleHint(), QFontInfo */ -QString QFont::lastResortFont() const + +void QFont::setFamilies(const QStringList &families) { - qFatal("QFont::lastResortFont: Cannot find any reasonable font"); - // Shut compiler up - return QString(); + if ((resolve_mask & QFont::FamiliesResolved) && d->request.families == families) + return; + detach(); + d->request.families = families; + resolve_mask |= QFont::FamiliesResolved; } + /***************************************************************************** QFont stream functions *****************************************************************************/ @@ -2261,6 +2325,8 @@ QDataStream &operator<<(QDataStream &s, const QFont &font) s << (quint8)font.d->request.hintingPreference; if (s.version() >= QDataStream::Qt_5_6) s << (quint8)font.d->capital; + if (s.version() >= QDataStream::Qt_5_13) + s << font.d->request.families; return s; } @@ -2356,6 +2422,11 @@ QDataStream &operator>>(QDataStream &s, QFont &font) s >> value; font.d->capital = QFont::Capitalization(value); } + if (s.version() >= QDataStream::Qt_5_13) { + QStringList value; + s >> value; + font.d->request.families = value; + } return s; } @@ -2879,9 +2950,9 @@ void QFontCache::insertEngine(const Key &key, QFontEngine *engine, bool insertMu data.timestamp = ++current_timestamp; if (insertMulti) - engineCache.insertMulti(key, data); - else engineCache.insert(key, data); + else + engineCache.replace(key, data); // only increase the cost if this is the first time we insert the engine if (++engineCacheCount[engine] == 1) increaseCost(engine->cache_cost); diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 9c250c82c3..e86f06353a 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -164,13 +164,17 @@ public: WordSpacingResolved = 0x4000, HintingPreferenceResolved = 0x8000, StyleNameResolved = 0x10000, - AllPropertiesResolved = 0x1ffff + FamiliesResolved = 0x20000, + AllPropertiesResolved = 0x3ffff }; QFont(); QFont(const QString &family, int pointSize = -1, int weight = -1, bool italic = false); - QFont(const QFont &, QPaintDevice *pd); - QFont(const QFont &); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QFont(const QFont &font, QPaintDevice *pd); +#endif + QFont(const QFont &font, const QPaintDevice *pd); + QFont(const QFont &font); ~QFont(); void swap(QFont &other) @@ -179,6 +183,9 @@ public: QString family() const; void setFamily(const QString &); + QStringList families() const; + void setFamilies(const QStringList &); + QString styleName() const; void setStyleName(const QString &); @@ -282,8 +289,10 @@ public: static void cacheStatistics(); QString defaultFamily() const; - QString lastResortFamily() const; - QString lastResortFont() const; +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED QString lastResortFamily() const; + QT_DEPRECATED QString lastResortFont() const; +#endif QFont resolve(const QFont &) const; inline uint resolve() const { return resolve_mask; } diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index c5847f532b..e86ec31e47 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -78,6 +78,7 @@ struct QFontDef } QString family; + QStringList families; QString styleName; QStringList fallBackFamilies; @@ -109,6 +110,7 @@ struct QFontDef && styleStrategy == other.styleStrategy && ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch && family == other.family + && families == other.families && styleName == other.styleName && hintingPreference == other.hintingPreference ; @@ -122,6 +124,7 @@ struct QFontDef if (styleHint != other.styleHint) return styleHint < other.styleHint; if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy; if (family != other.family) return family < other.family; + if (families != other.families) return families < other.families; if (styleName != other.styleName) return styleName < other.styleName; if (hintingPreference != other.hintingPreference) return hintingPreference < other.hintingPreference; @@ -144,6 +147,7 @@ inline uint qHash(const QFontDef &fd, uint seed = 0) Q_DECL_NOTHROW ^ qHash(fd.ignorePitch) ^ qHash(fd.fixedPitch) ^ qHash(fd.family, seed) + ^ qHash(fd.families, seed) ^ qHash(fd.styleName) ^ qHash(fd.hintingPreference) ; @@ -161,7 +165,7 @@ public: QFontEngine *engines[QChar::ScriptCount]; private: - Q_DISABLE_COPY(QFontEngineData) + Q_DISABLE_COPY_MOVE(QFontEngineData) }; @@ -270,7 +274,7 @@ public: uint hits; }; - typedef QMap<Key,Engine> EngineCache; + typedef QMultiMap<Key,Engine> EngineCache; EngineCache engineCache; QHash<QFontEngine *, int> engineCacheCount; diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 196eebb353..fa9573441a 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -696,20 +696,20 @@ static QStringList familyList(const QFontDef &req) { // list of families to try QStringList family_list; - if (req.family.isEmpty()) - return family_list; - const auto list = req.family.splitRef(QLatin1Char(',')); - const int numFamilies = list.size(); - family_list.reserve(numFamilies); - for (int i = 0; i < numFamilies; ++i) { - QStringRef str = list.at(i).trimmed(); - if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"'))) - || (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\'')))) - str = str.mid(1, str.length() - 2); - family_list << str.toString(); + family_list << req.families; + if (!req.family.isEmpty()) { + const auto list = req.family.splitRef(QLatin1Char(',')); + const int numFamilies = list.size(); + family_list.reserve(numFamilies); + for (int i = 0; i < numFamilies; ++i) { + QStringRef str = list.at(i).trimmed(); + if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"'))) + || (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\'')))) + str = str.mid(1, str.length() - 2); + family_list << str.toString(); + } } - // append the substitute list for each family in family_list for (int i = 0, size = family_list.size(); i < size; ++i) family_list += QFont::substitutes(family_list.at(i)); @@ -2688,9 +2688,8 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script) } QString family_name, foundry_name; - - parseFontName(request.family, foundry_name, family_name); - + const QString requestFamily = request.families.size() > 0 ? request.families.at(0) : request.family; + parseFontName(requestFamily, foundry_name, family_name); QtFontDesc desc; QList<int> blackListed; int index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed); @@ -2703,8 +2702,8 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script) // Don't pass empty family names to the platform font database, since it will then invoke its own matching // and we will be out of sync with the matched font. - if (fontDef.family.isEmpty()) - fontDef.family = desc.family->name; + if (fontDef.families.isEmpty() && fontDef.family.isEmpty()) + fontDef.families = QStringList(desc.family->name); engine = loadEngine(script, fontDef, desc.family, desc.foundry, desc.style, desc.size); @@ -2717,13 +2716,13 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script) } if (!engine) { - if (!request.family.isEmpty()) { + if (!requestFamily.isEmpty()) { QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint); if (styleHint == QFont::AnyStyle && request.fixedPitch) styleHint = QFont::TypeWriter; QStringList fallbacks = request.fallBackFamilies - + fallbacksForFamily(request.family, + + fallbacksForFamily(requestFamily, QFont::Style(request.style), styleHint, QChar::Script(script)); @@ -2741,7 +2740,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script) index = match(multi ? QChar::Script_Common : script, def, def.family, QLatin1String(""), &desc, blackListed); if (index >= 0) { QFontDef loadDef = def; - if (loadDef.family.isEmpty()) + if (loadDef.families.isEmpty() && loadDef.family.isEmpty()) loadDef.family = desc.family->name; engine = loadEngine(script, loadDef, desc.family, desc.foundry, desc.style, desc.size); if (engine) @@ -2782,7 +2781,10 @@ void QFontDatabase::load(const QFontPrivate *d, int script) // look for the requested font in the engine data cache // note: fallBackFamilies are not respected in the EngineData cache key; // join them with the primary selection family to avoid cache misses - req.family = fallBackFamilies.join(QLatin1Char(',')); + if (!d->request.family.isEmpty()) + req.family = fallBackFamilies.join(QLatin1Char(',')); + if (!d->request.families.isEmpty()) + req.families = fallBackFamilies; d->engineData = fontCache->findEngineData(req); if (!d->engineData) { @@ -2803,14 +2805,14 @@ void QFontDatabase::load(const QFontPrivate *d, int script) req.fallBackFamilies = fallBackFamilies; if (!req.fallBackFamilies.isEmpty()) - req.family = req.fallBackFamilies.takeFirst(); + req.families = QStringList(req.fallBackFamilies.takeFirst()); // list of families to try QStringList family_list; - if (!req.family.isEmpty()) { + if (!req.families.isEmpty()) { // Add primary selection - family_list << req.family; + family_list << req.families.at(0); // add the default family QString defaultFamily = QGuiApplication::font().family(); @@ -2824,11 +2826,11 @@ void QFontDatabase::load(const QFontPrivate *d, int script) QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd(); for (; !fe && it != end; ++it) { - req.family = *it; + req.families = QStringList(*it); fe = QFontDatabase::findFont(req, script); if (fe) { - if (fe->type() == QFontEngine::Box && !req.family.isEmpty()) { + if (fe->type() == QFontEngine::Box && !req.families.at(0).isEmpty()) { if (fe->ref.load() == 0) delete fe; fe = 0; diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index eb7e416dd1..cab4ca0047 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1842,7 +1842,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) { QFontDef request(fontDef); request.styleStrategy |= QFont::NoFontMerging; - request.family = fallbackFamilyAt(at - 1); + request.families = QStringList(fallbackFamilyAt(at - 1)); // At this point, the main script of the text has already been considered // when fetching the list of fallback families from the database, and the diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 407559ad51..c8dc8d676e 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -156,6 +156,8 @@ QFontMetrics::QFontMetrics(const QFont &font) } /*! + \since 5.13 + \fn QFontMetrics::QFontMetrics(const QFont &font, const QPaintDevice *paintdevice) Constructs a font metrics object for \a font and \a paintdevice. The font metrics will be compatible with the paintdevice passed. @@ -168,9 +170,21 @@ QFontMetrics::QFontMetrics(const QFont &font) passed in the constructor at the time it is created, and is not updated if the font's attributes are changed later. */ + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/*! + \fn QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice) + \obsolete + Identical to QFontMetrics::QFontMetrics(const QFont &font, const QPaintDevice *paintdevice) +*/ + + QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice) +#else +QFontMetrics::QFontMetrics(const QFont &font, const QPaintDevice *paintdevice) +#endif { - int dpi = paintdevice ? paintdevice->logicalDpiY() : qt_defaultDpi(); + const int dpi = paintdevice ? paintdevice->logicalDpiY() : qt_defaultDpi(); const int screen = 0; if (font.d->dpi != dpi || font.d->screen != screen ) { d = new QFontPrivate(*font.d); @@ -1127,6 +1141,8 @@ QFontMetricsF::QFontMetricsF(const QFont &font) } /*! + \fn QFontMetricsF::QFontMetricsF(const QFont &font, const QPaintDevice *paintdevice) + \since 5.13 Constructs a font metrics object for \a font and \a paintdevice. The font metrics will be compatible with the paintdevice passed. @@ -1139,7 +1155,20 @@ QFontMetricsF::QFontMetricsF(const QFont &font) passed in the constructor at the time it is created, and is not updated if the font's attributes are changed later. */ + + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/*! + \fn QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice) + \obsolete + Identical to QFontMetricsF::QFontMetricsF(const QFont &font, const QPaintDevice *paintdevice) +*/ + + QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice) +#else +QFontMetricsF::QFontMetricsF(const QFont &font, const QPaintDevice *paintdevice) +#endif { int dpi = paintdevice ? paintdevice->logicalDpiY() : qt_defaultDpi(); const int screen = 0; diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index b6167a1d47..61931fa9bc 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -59,7 +59,19 @@ class Q_GUI_EXPORT QFontMetrics { public: explicit QFontMetrics(const QFont &); - QFontMetrics(const QFont &, QPaintDevice *pd); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QFontMetrics(const QFont &font, QPaintDevice *pd); +#ifndef Q_QDOC + // the template is necessary to make QFontMetrics(font,nullptr) and QFontMetrics(font,NULL) + // not ambiguous. Implementation detail that should not be documented. + template<char = 0> +#endif + QFontMetrics(const QFont &font, const QPaintDevice *pd) + : QFontMetrics(font, const_cast<QPaintDevice*>(pd)) + {} +#else + QFontMetrics(const QFont &font, const QPaintDevice *pd); +#endif QFontMetrics(const QFontMetrics &); ~QFontMetrics(); @@ -92,8 +104,11 @@ public: int rightBearing(QChar) const; #if QT_DEPRECATED_SINCE(5, 11) + QT_DEPRECATED_X("Use QFontMetrics::horizontalAdvance") int width(const QString &, int len = -1) const; + QT_DEPRECATED_X("Use QFontMetrics::horizontalAdvance") int width(const QString &, int len, int flags) const; + QT_DEPRECATED_X("Use QFontMetrics::horizontalAdvance") int width(QChar) const; #endif @@ -137,8 +152,20 @@ Q_DECLARE_SHARED(QFontMetrics) class Q_GUI_EXPORT QFontMetricsF { public: - explicit QFontMetricsF(const QFont &); - QFontMetricsF(const QFont &, QPaintDevice *pd); + explicit QFontMetricsF(const QFont &font); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QFontMetricsF(const QFont &font, QPaintDevice *pd); +#ifndef Q_QDOC + // the template is necessary to make QFontMetrics(font,nullptr) and QFontMetrics(font,NULL) + // not ambiguous. Implementation detail that should not be documented. + template<char = 0> +#endif + QFontMetricsF(const QFont &font, const QPaintDevice *pd) + : QFontMetricsF(font, const_cast<QPaintDevice*>(pd)) + {} +#else + QFontMetricsF(const QFont &font, const QPaintDevice *pd); +#endif QFontMetricsF(const QFontMetrics &); QFontMetricsF(const QFontMetricsF &); ~QFontMetricsF(); diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h index d87f89f0fd..ad0d50a4c0 100644 --- a/src/gui/text/qsyntaxhighlighter.h +++ b/src/gui/text/qsyntaxhighlighter.h @@ -64,7 +64,7 @@ class Q_GUI_EXPORT QSyntaxHighlighter : public QObject public: explicit QSyntaxHighlighter(QObject *parent); explicit QSyntaxHighlighter(QTextDocument *parent); - virtual ~QSyntaxHighlighter(); + ~QSyntaxHighlighter(); void setDocument(QTextDocument *doc); QTextDocument *document() const; diff --git a/src/gui/text/qtextdocumentfragment_p.h b/src/gui/text/qtextdocumentfragment_p.h index 02a6a429fa..de01a02fbb 100644 --- a/src/gui/text/qtextdocumentfragment_p.h +++ b/src/gui/text/qtextdocumentfragment_p.h @@ -109,7 +109,7 @@ public: uint importedFromPlainText : 1; private: - Q_DISABLE_COPY(QTextDocumentFragmentPrivate) + Q_DISABLE_COPY_MOVE(QTextDocumentFragmentPrivate) }; #ifndef QT_NO_TEXTHTMLPARSER diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index 919cdf3ff1..136e7dc140 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -361,6 +361,12 @@ void QTextFormatPrivate::recalcFont() const case QTextFormat::FontFamily: f.setFamily(props.at(i).value.toString()); break; + case QTextFormat::FontFamilies: + f.setFamilies(props.at(i).value.toStringList()); + break; + case QTextFormat::FontStyleName: + f.setStyleName(props.at(i).value.toString()); + break; case QTextFormat::FontPointSize: f.setPointSizeF(props.at(i).value.toReal()); break; @@ -562,6 +568,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt) Character properties \value FontFamily + \value FontFamilies + \value FontStyleName \value FontPointSize \value FontPixelSize \value FontSizeAdjustment Specifies the change in size given to the fontsize already set using @@ -1391,6 +1399,41 @@ QTextCharFormat::QTextCharFormat(const QTextFormat &fmt) \sa font() */ +/*! + \fn void QTextCharFormat::setFontFamilies(const QStringList &families) + \since 5.13 + + Sets the text format's font \a families. + + \sa setFont() +*/ + +/*! + \fn QStringList QTextCharFormat::fontFamilies() const + \since 5.13 + + Returns the text format's font families. + + \sa font() +*/ + +/*! + \fn void QTextCharFormat::setFontStyleName(const QString &styleName) + \since 5.13 + + Sets the text format's font \a style name. + + \sa setFont(), QFont::setStyleName() +*/ + +/*! + \fn QStringList QTextCharFormat::fontStyleName() const + \since 5.13 + + Returns the text format's font style name. + + \sa font(), QFont::styleName() +*/ /*! \fn void QTextCharFormat::setFontPointSize(qreal size) @@ -1920,6 +1963,11 @@ void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavi if (mask & QFont::FamilyResolved) setFontFamily(font.family()); + if (mask & QFont::FamiliesResolved) + setFontFamilies(font.families()); + if (mask & QFont::StyleNameResolved) + setFontStyleName(font.styleName()); + if (mask & QFont::SizeResolved) { const qreal pointSize = font.pointSizeF(); if (pointSize > 0) { diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index a8e573d5a4..f292feabe8 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -188,6 +188,8 @@ public: FontStyleStrategy = 0x1FE4, FontKerning = 0x1FE5, FontHintingPreference = 0x1FE6, + FontFamilies = 0x1FE7, + FontStyleName = 0x1FE8, FontFamily = 0x2000, FontPointSize = 0x2001, FontSizeAdjustment = 0x2002, @@ -428,6 +430,16 @@ public: inline QString fontFamily() const { return stringProperty(FontFamily); } + inline void setFontFamilies(const QStringList &families) + { setProperty(FontFamilies, QVariant(families)); } + inline QVariant fontFamilies() const + { return property(FontFamilies); } + + inline void setFontStyleName(const QString &styleName) + { setProperty(FontStyleName, styleName); } + inline QVariant fontStyleName() const + { return property(FontStyleName); } + inline void setFontPointSize(qreal size) { setProperty(FontPointSize, size); } inline qreal fontPointSize() const diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h index 3557c17a97..001a243e84 100644 --- a/src/gui/text/qtextformat_p.h +++ b/src/gui/text/qtextformat_p.h @@ -104,7 +104,7 @@ public: private: QFont defaultFnt; - Q_DISABLE_COPY(QTextFormatCollection) + Q_DISABLE_COPY_MOVE(QTextFormatCollection) }; QT_END_NAMESPACE diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index c9a2a33e5a..04300a4d22 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -861,7 +861,8 @@ QString QTextHtmlParser::parseWord() ++pos; while (pos < len) { QChar c = txt.at(pos++); - if (c == QLatin1Char('\'')) + // Allow for escaped single quotes as they may be part of the string + if (c == QLatin1Char('\'') && (txt.length() > 1 && txt.at(pos - 2) != QLatin1Char('\\'))) break; else word += c; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index f3f0caa379..a3e194f835 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -344,6 +344,8 @@ QTextLayout::QTextLayout(const QString& text) } /*! + \since 5.13 + \fn QTextLayout::QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice) Constructs a text layout to lay out the given \a text with the specified \a font. @@ -351,11 +353,20 @@ QTextLayout::QTextLayout(const QString& text) the paint device, \a paintdevice. If \a paintdevice is 0 the calculations will be done in screen metrics. */ -QTextLayout::QTextLayout(const QString& text, const QFont &font, QPaintDevice *paintdevice) + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/*! + \fn QTextLayout::QTextLayout(const QString &text, const QFont &font, QPaintDevice *paintdevice) + \obsolete + Identical to QTextLayout::QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice) +*/ + +QTextLayout::QTextLayout(const QString &text, const QFont &font, QPaintDevice *paintdevice) +#else +QTextLayout::QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice) +#endif { - QFont f(font); - if (paintdevice) - f = QFont(font, paintdevice); + const QFont f(paintdevice ? QFont(font, paintdevice) : font); d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f); } @@ -1127,8 +1138,6 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang QPainterPath textDoneRegion; for (int i = 0; i < selections.size(); ++i) { FormatRange selection = selections.at(i); - const QBrush bg = selection.format.background(); - QPainterPath region; region.setFillRule(Qt::WindingFill); diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index 67bc75a6b8..a29791534e 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -107,7 +107,19 @@ public: // does itemization QTextLayout(); QTextLayout(const QString& text); - QTextLayout(const QString& text, const QFont &font, QPaintDevice *paintdevice = nullptr); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QTextLayout(const QString &text, const QFont &font, QPaintDevice *paintdevice = nullptr); +#ifndef Q_QDOC + // the template is necessary to make QTextLayout(font,text,nullptr) and QTextLayout(font,text,NULL) + // not ambiguous. Implementation detail that should not be documented. + template<char = 0> +#endif + QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice) + : QTextLayout(text, font, const_cast<QPaintDevice*>(paintdevice)) + {} +#else + QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice = nullptr); +#endif QTextLayout(const QTextBlock &b); ~QTextLayout(); diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 103e0a8222..1a3f5309ae 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -89,7 +89,7 @@ public: contentStream = device; } - virtual ~QXmlStreamStrategy() + ~QXmlStreamStrategy() { if (contentStream) contentStream->close(); @@ -886,26 +886,30 @@ void QTextOdfWriter::tableCellStyleElement(QXmlStreamWriter &writer, const int & if (hasBorder) { writer.writeAttribute(foNS, QString::fromLatin1("border"), pixelToPoint(tableFormatTmp.border()) + QLatin1String(" ") - + borderStyleName(tableFormatTmp.borderStyle()) - + QLatin1String(" #000000")); //!! HARD-CODING color black + + borderStyleName(tableFormatTmp.borderStyle()) + QLatin1String(" ") + + tableFormatTmp.borderBrush().color().name(QColor::HexRgb)); } - qreal padding = format.topPadding(); - if (padding > 0 && padding == format.bottomPadding() - && padding == format.leftPadding() && padding == format.rightPadding()) { + qreal topPadding = format.topPadding(); + qreal padding = topPadding + tableFormatTmp.cellPadding(); + if (padding > 0 && topPadding == format.bottomPadding() + && topPadding == format.leftPadding() && topPadding == format.rightPadding()) { writer.writeAttribute(foNS, QString::fromLatin1("padding"), pixelToPoint(padding)); } else { if (padding > 0) writer.writeAttribute(foNS, QString::fromLatin1("padding-top"), pixelToPoint(padding)); - if (format.bottomPadding() > 0) + padding = format.bottomPadding() + tableFormatTmp.cellPadding(); + if (padding > 0) writer.writeAttribute(foNS, QString::fromLatin1("padding-bottom"), - pixelToPoint(format.bottomPadding())); - if (format.leftPadding() > 0) + pixelToPoint(padding)); + padding = format.leftPadding() + tableFormatTmp.cellPadding(); + if (padding > 0) writer.writeAttribute(foNS, QString::fromLatin1("padding-left"), - pixelToPoint(format.leftPadding())); - if (format.rightPadding() > 0) + pixelToPoint(padding)); + padding = format.rightPadding() + tableFormatTmp.cellPadding(); + if (padding > 0) writer.writeAttribute(foNS, QString::fromLatin1("padding-right"), - pixelToPoint(format.rightPadding())); + pixelToPoint(padding)); } if (format.hasProperty(QTextFormat::TextVerticalAlignment)) { diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h index eed6ee6a62..378072b366 100644 --- a/src/gui/text/qzipreader_p.h +++ b/src/gui/text/qzipreader_p.h @@ -116,7 +116,7 @@ public: private: QZipReaderPrivate *d; - Q_DISABLE_COPY(QZipReader) + Q_DISABLE_COPY_MOVE(QZipReader) }; Q_DECLARE_TYPEINFO(QZipReader::FileInfo, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QZipReader::Status, Q_PRIMITIVE_TYPE); diff --git a/src/gui/text/qzipwriter_p.h b/src/gui/text/qzipwriter_p.h index 433bbab31e..b3bb5929cf 100644 --- a/src/gui/text/qzipwriter_p.h +++ b/src/gui/text/qzipwriter_p.h @@ -108,7 +108,7 @@ public: void close(); private: QZipWriterPrivate *d; - Q_DISABLE_COPY(QZipWriter) + Q_DISABLE_COPY_MOVE(QZipWriter) }; QT_END_NAMESPACE |