From bf5f7f6db51ef1ddc3fb002d12bfb597c0a748f8 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 31 Jul 2009 12:49:59 +1000 Subject: Add an example using FontFamily. --- examples/declarative/fonts/fonts.qml | 66 +++++++++++++++++++++++ examples/declarative/fonts/fonts/Fontin-Bold.ttf | Bin 0 -> 30916 bytes 2 files changed, 66 insertions(+) create mode 100644 examples/declarative/fonts/fonts.qml create mode 100644 examples/declarative/fonts/fonts/Fontin-Bold.ttf diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml new file mode 100644 index 0000000..eb8cfef --- /dev/null +++ b/examples/declarative/fonts/fonts.qml @@ -0,0 +1,66 @@ +import Qt 4.6 + +Rect { + property string myText: "Lorem ipsum dolor sit amet, consectetur adipisicing elit" + + width: 800; height: 600 + color: Palette.base + + Palette { id: Palette; colorGroup: "Active" } + + FontFamily { id: FixedFont; name: "Courier" } + + FontFamily { id: LocalFont; source: "fonts/Fontin-Bold.ttf" } + /* A font by Jos Buivenga (exljbris) -> www.exljbris.nl */ + + FontFamily { id: WebFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } + FontFamily { id: WebFont2; source: "http://wrong.address.org" } + + VerticalLayout { + anchors.fill: parent + anchors.leftMargin: 10; anchors.rightMargin: 10 + Text { + text: myText + color: Palette.windowText + width: parent.width; elide: "ElideRight" + font.family: "Times" + font.size: 32 + } + Text { + text: myText + color: Palette.windowText + width: parent.width; elide: "ElideRight" + font.family: FixedFont.name + font.size: 32 + } + Text { + text: myText + color: Palette.windowText + width: parent.width; elide: "ElideRight" + font.family: LocalFont.name + font.size: 32 + } + Text { + text: { + if (WebFont.status == 1) myText + else if (WebFont.status == 2) "Loading..." + else if (WebFont.status == 3) "Error loading font" + } + color: Palette.windowText + width: parent.width; elide: "ElideRight" + font.family: WebFont.name + font.size: 32 + } + Text { + text: { + if (WebFont2.status == 1) myText + else if (WebFont2.status == 2) "Loading..." + else if (WebFont2.status == 3) "Error loading font" + } + color: Palette.windowText + width: parent.width; elide: "ElideRight" + font.family: WebFont2.name + font.size: 32 + } + } +} diff --git a/examples/declarative/fonts/fonts/Fontin-Bold.ttf b/examples/declarative/fonts/fonts/Fontin-Bold.ttf new file mode 100644 index 0000000..f6a33b0 Binary files /dev/null and b/examples/declarative/fonts/fonts/Fontin-Bold.ttf differ -- cgit v0.12