summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/fonts/banner.qml18
-rw-r--r--examples/declarative/fonts/fonts.qml56
-rw-r--r--examples/declarative/fonts/hello.qml27
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp60
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h39
5 files changed, 174 insertions, 26 deletions
diff --git a/examples/declarative/fonts/banner.qml b/examples/declarative/fonts/banner.qml
new file mode 100644
index 0000000..ece481b
--- /dev/null
+++ b/examples/declarative/fonts/banner.qml
@@ -0,0 +1,18 @@
+import Qt 4.6
+
+Rectangle {
+ id: screen
+ width: 640; height: 320; color: "steelblue"
+
+ property int pixelSize: screen.height * 1.25
+ property color textColor: "lightsteelblue"
+ property string text: "Hello world! "
+
+ Row {
+ y: -screen.height / 4.5
+ x: NumberAnimation { from: 0; to: -text.width; duration: 6000; running: true; repeat: true }
+ Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ }
+}
diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml
index e68bdb6..80d82ad 100644
--- a/examples/declarative/fonts/fonts.qml
+++ b/examples/declarative/fonts/fonts.qml
@@ -1,12 +1,10 @@
import Qt 4.6
Rectangle {
- property string myText: "Lorem ipsum dolor sit amet, consectetur adipisicing elit"
+ property string myText: "The quick brown fox jumps over the lazy dog."
- width: 800; height: 600
- color: palette.base
-
- SystemPalette { id: palette; colorGroup: Qt.Active }
+ width: 800; height: 480
+ color: "steelblue"
FontLoader { id: fixedFont; name: "Courier" }
@@ -17,28 +15,36 @@ Rectangle {
FontLoader { id: webFont2; source: "http://wrong.address.org" }
Column {
- anchors.fill: parent
+ anchors.fill: parent; spacing: 10
anchors.leftMargin: 10; anchors.rightMargin: 10
Text {
- text: myText
- color: palette.windowText
+ text: myText; color: "lightsteelblue"
width: parent.width; elide: Text.ElideRight
- font.family: "Times"
- font.pointSize: 32
+ font.family: "Times"; font.pointSize: 36
}
Text {
- text: myText
- color: palette.windowText
- width: parent.width; elide: Text.ElideRight
- font.family: fixedFont.name
- font.pointSize: 32
+ text: myText; color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideLeft
+ font.family: "Times"; font.pointSize: 36
+ font.capitalization: "AllUppercase"
+ }
+ Text {
+ text: myText; color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideMiddle
+ font.family: fixedFont.name; font.pointSize: 36; font.weight: "Bold"
+ font.capitalization: "AllLowercase"
}
Text {
- text: myText
- color: palette.windowText
+ text: myText; color: "lightsteelblue"
width: parent.width; elide: Text.ElideRight
- font.family: localFont.name
- font.pointSize: 32
+ font.family: fixedFont.name; font.pointSize: 36; font.italic: true
+ font.capitalization: "SmallCaps"
+ }
+ Text {
+ text: myText; color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideLeft
+ font.family: localFont.name; font.pointSize: 36
+ font.capitalization: "Capitalize"
}
Text {
text: {
@@ -46,10 +52,9 @@ Rectangle {
else if (webFont.status == 2) "Loading..."
else if (webFont.status == 3) "Error loading font"
}
- color: palette.windowText
- width: parent.width; elide: Text.ElideRight
- font.family: webFont.name
- font.pointSize: 32
+ color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideMiddle
+ font.family: webFont.name; font.pointSize: 36
}
Text {
text: {
@@ -57,10 +62,9 @@ Rectangle {
else if (webFont2.status == 2) "Loading..."
else if (webFont2.status == 3) "Error loading font"
}
- color: palette.windowText
+ color: "lightsteelblue"
width: parent.width; elide: Text.ElideRight
- font.family: webFont2.name
- font.pointSize: 32
+ font.family: webFont2.name; font.pointSize: 36
}
}
}
diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml
new file mode 100644
index 0000000..6aef3e6
--- /dev/null
+++ b/examples/declarative/fonts/hello.qml
@@ -0,0 +1,27 @@
+import Qt 4.6
+
+Rectangle {
+ id: screen; width: 800; height: 480; color: "black"
+
+ Item {
+ id: container; x: screen.width / 2; y: screen.height / 2
+ Text {
+ id: text; color: "white"; anchors.centerIn: parent
+ text: "Hello world!"; font.pixelSize: 60
+
+ font.letterSpacing: SequentialAnimation {
+ repeat: true; running: true
+ NumberAnimation { from: 100; to: 300; easing: "easeInQuad"; duration: 3000 }
+ ScriptAction { script: {
+ container.y = (screen.height / 4) + (Math.random() * screen.height / 2)
+ container.x = (screen.width / 4) + (Math.random() * screen.width / 2)
+ } }
+ }
+ opacity: SequentialAnimation {
+ repeat: true; running: true
+ NumberAnimation { from: 1; to: 0; duration: 2600 }
+ PauseAnimation { duration: 400 }
+ }
+ }
+ }
+}
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp
index 1713205..859a93a 100644
--- a/src/declarative/qml/qmlvaluetype.cpp
+++ b/src/declarative/qml/qmlvaluetype.cpp
@@ -521,6 +521,16 @@ void QmlFontValueType::setBold(bool b)
font.setBold(b);
}
+QmlFontValueType::FontWeight QmlFontValueType::weight() const
+{
+ return (QmlFontValueType::FontWeight)font.weight();
+}
+
+void QmlFontValueType::setWeight(QmlFontValueType::FontWeight w)
+{
+ font.setWeight((QFont::Weight)w);
+}
+
bool QmlFontValueType::italic() const
{
return font.italic();
@@ -541,6 +551,26 @@ void QmlFontValueType::setUnderline(bool b)
font.setUnderline(b);
}
+bool QmlFontValueType::overline() const
+{
+ return font.overline();
+}
+
+void QmlFontValueType::setOverline(bool b)
+{
+ font.setOverline(b);
+}
+
+bool QmlFontValueType::strikeout() const
+{
+ return font.strikeOut();
+}
+
+void QmlFontValueType::setStrikeout(bool b)
+{
+ font.setStrikeOut(b);
+}
+
qreal QmlFontValueType::pointSize() const
{
return font.pointSizeF();
@@ -566,4 +596,34 @@ void QmlFontValueType::setPixelSize(int size)
hasPixelSize = true;
}
+QmlFontValueType::Capitalization QmlFontValueType::capitalization() const
+{
+ return (QmlFontValueType::Capitalization)font.capitalization();
+}
+
+void QmlFontValueType::setCapitalization(QmlFontValueType::Capitalization c)
+{
+ font.setCapitalization((QFont::Capitalization)c);
+}
+
+qreal QmlFontValueType::letterSpacing() const
+{
+ return font.letterSpacing();
+}
+
+void QmlFontValueType::setLetterSpacing(qreal size)
+{
+ font.setLetterSpacing(QFont::PercentageSpacing, size);
+}
+
+qreal QmlFontValueType::wordSpacing() const
+{
+ return font.wordSpacing();
+}
+
+void QmlFontValueType::setWordSpacing(qreal size)
+{
+ font.setWordSpacing(size);
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h
index 9842c02..0af3813 100644
--- a/src/declarative/qml/qmlvaluetype_p.h
+++ b/src/declarative/qml/qmlvaluetype_p.h
@@ -258,13 +258,34 @@ private:
class QmlFontValueType : public QmlValueType
{
Q_OBJECT
+ Q_ENUMS(FontWeight)
+ Q_ENUMS(Capitalization)
+
Q_PROPERTY(QString family READ family WRITE setFamily)
Q_PROPERTY(bool bold READ bold WRITE setBold)
+ Q_PROPERTY(FontWeight weight READ weight WRITE setWeight)
Q_PROPERTY(bool italic READ italic WRITE setItalic)
Q_PROPERTY(bool underline READ underline WRITE setUnderline)
+ Q_PROPERTY(bool overline READ overline WRITE setOverline)
+ Q_PROPERTY(bool strikeout READ strikeout WRITE setStrikeout)
Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize)
Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize)
+ Q_PROPERTY(Capitalization capitalization READ capitalization WRITE setCapitalization)
+ Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing)
+ Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing)
+
public:
+ enum FontWeight { Light = QFont::Light,
+ Normal = QFont::Normal,
+ DemiBold = QFont::DemiBold,
+ Bold = QFont::Bold,
+ Black = QFont::Black };
+ enum Capitalization { MixedCase = QFont::MixedCase,
+ AllUppercase = QFont::AllUppercase,
+ AllLowercase = QFont::AllLowercase,
+ SmallCaps = QFont::SmallCaps,
+ Capitalize = QFont::Capitalize };
+
QmlFontValueType(QObject *parent = 0);
virtual void read(QObject *, int);
@@ -278,18 +299,36 @@ public:
bool bold() const;
void setBold(bool b);
+ FontWeight weight() const;
+ void setWeight(FontWeight);
+
bool italic() const;
void setItalic(bool b);
bool underline() const;
void setUnderline(bool b);
+ bool overline() const;
+ void setOverline(bool b);
+
+ bool strikeout() const;
+ void setStrikeout(bool b);
+
qreal pointSize() const;
void setPointSize(qreal size);
int pixelSize() const;
void setPixelSize(int size);
+ Capitalization capitalization() const;
+ void setCapitalization(Capitalization);
+
+ qreal letterSpacing() const;
+ void setLetterSpacing(qreal spacing);
+
+ qreal wordSpacing() const;
+ void setWordSpacing(qreal spacing);
+
private:
QFont font;
bool hasPixelSize;