summaryrefslogtreecommitdiffstats
path: root/examples/declarative/fonts/fonts.qml
blob: f7ed4949fea125f62a7e8c259607d383658b63e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import Qt 4.6

Rectangle {
    property string myText: "Lorem ipsum dolor sit amet, consectetur adipisicing elit"

    width: 800; height: 600
    color: Palette.base

    SystemPalette { id: Palette; colorGroup: Qt.Active }

    FontLoader { id: FixedFont; name: "Courier" }

    FontLoader { id: LocalFont; source: "fonts/Fontin-Bold.ttf" }
    /* A font by Jos Buivenga (exljbris) -> www.exljbris.nl */

    FontLoader { id: WebFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" }
    FontLoader { id: WebFont2; source: "http://wrong.address.org" }

    Column {
        anchors.fill: parent
        anchors.leftMargin: 10; anchors.rightMargin: 10
        Text {
            text: myText
            color: Palette.windowText
            width: parent.width; elide: "ElideRight"
            font.family: "Times"
            font.pointSize: 32
        }
        Text {
            text: myText
            color: Palette.windowText
            width: parent.width; elide: "ElideRight"
            font.family: FixedFont.name
            font.pointSize: 32
        }
        Text {
            text: myText
            color: Palette.windowText
            width: parent.width; elide: "ElideRight"
            font.family: LocalFont.name
            font.pointSize: 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.pointSize: 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.pointSize: 32
        }
    }
}