diff options
author | aavit <qt-info@nokia.com> | 2011-04-07 12:32:19 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2011-04-07 12:32:19 (GMT) |
commit | 6a1a3378d2eaf854e4f62f637bd0f3c4c1ad017b (patch) | |
tree | 6fb53f747d8dcb41d9d8c00767d623cfb9fe11c7 /tests/arthur | |
parent | a5416489043c985d62e5d22bf00f81d174f4605d (diff) | |
download | Qt-6a1a3378d2eaf854e4f62f637bd0f3c4c1ad017b.zip Qt-6a1a3378d2eaf854e4f62f637bd0f3c4c1ad017b.tar.gz Qt-6a1a3378d2eaf854e4f62f637bd0f3c4c1ad017b.tar.bz2 |
Make it possible to test the new font hinting in lance[elot]
A rudimentary test script is also included, showing the use of the new
parameter to the qps setFont command.
Diffstat (limited to 'tests/arthur')
-rw-r--r-- | tests/arthur/common/paintcommands.cpp | 31 | ||||
-rw-r--r-- | tests/arthur/common/paintcommands.h | 1 |
2 files changed, 26 insertions, 6 deletions
diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index b00ce81..527f710 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -96,6 +96,13 @@ const char *PaintCommands::fontWeightTable[] = { "Black" }; +const char *PaintCommands::fontHintingTable[] = { + "Default", + "None", + "Vertical", + "Full" +}; + const char *PaintCommands::clipOperationTable[] = { "NoClip", "ReplaceClip", @@ -287,9 +294,9 @@ void PaintCommands::staticInit() "setCompositionMode <composition mode enum>", "setCompositionMode SourceOver"); DECL_PAINTCOMMAND("setFont", command_setFont, - "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$", - "setFont <fontFace> [size] [font weight|font weight enum] [italic]\n - font weight is an integer between 0 and 99", - "setFont \"times\" normal"); + "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$", + "setFont <fontFace> [size] [font weight|font weight enum] [italic] [hinting enum]\n - font weight is an integer between 0 and 99", + "setFont \"times\" 12"); DECL_PAINTCOMMAND("setPen", command_setPen, "^setPen\\s+#?(\\w*)$", "setPen <color>\nsetPen <pen style enum>\nsetPen brush", @@ -641,6 +648,7 @@ void PaintCommands::staticInit() ADD_ENUMLIST("brush styles", brushStyleTable); ADD_ENUMLIST("pen styles", penStyleTable); ADD_ENUMLIST("font weights", fontWeightTable); + ADD_ENUMLIST("font hintings", fontHintingTable); ADD_ENUMLIST("clip operations", clipOperationTable); ADD_ENUMLIST("spread methods", spreadMethodTable); ADD_ENUMLIST("composition modes", compositionModeTable); @@ -2061,11 +2069,22 @@ void PaintCommands::command_setFont(QRegExp re) bool italic = caps.at(4).toLower() == "true" || caps.at(4).toLower() == "italic"; + QFont font(family, size, weight, italic); + +#if QT_VERSION >= 0x040800 + int hinting = translateEnum(fontHintingTable, caps.at(5), 4); + if (hinting == -1) + hinting = 0; + else + font.setHintingPreference(QFont::HintingPreference(hinting)); +#else + int hinting = 1; +#endif if (m_verboseMode) - printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d\n", - qPrintable(family), size, weight, italic); + printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d hinting=%s\n", + qPrintable(family), size, weight, italic, fontHintingTable[hinting]); - m_painter->setFont(QFont(family, size, weight, italic)); + m_painter->setFont(font); } /***************************************************************************************************/ diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h index b2516e1..2740412 100644 --- a/tests/arthur/common/paintcommands.h +++ b/tests/arthur/common/paintcommands.h @@ -290,6 +290,7 @@ private: static const char *brushStyleTable[]; static const char *penStyleTable[]; static const char *fontWeightTable[]; + static const char *fontHintingTable[]; static const char *clipOperationTable[]; static const char *spreadMethodTable[]; static const char *coordinateMethodTable[]; |