Add tests for font metrics

This commit is contained in:
Sebastian Kügler 2014-03-26 00:11:30 +01:00
parent 78910dfa66
commit 0b4951c5b7
4 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,52 @@
/*
* Copyright 2014 Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
//import org.kde.plasma.components 2.0 as PlasmaComponents
//import org.kde.plasma.extras 2.0 as PlasmaExtras
//import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
Text {
renderType: Text.NativeRendering
font.pointSize: 22
font.family: theme.defaultFont.family
text: "Lesley. (" + font.family + ")"
height: paintedHeightCheck.checked ? paintedHeight : 22
//anchors.fill: parent
//spacing: units.smallSpacing/2
verticalAlignment: Text.AlignTop
Rectangle {
color: "transparent"
border.width: 1
border.color: "green"
visible: boxesCheck.checked
height: parent.paintedHeight
width: paintedWidth
anchors {
top: parent.top
left: parent.left
}
}
}

View File

@ -0,0 +1,110 @@
/*
* Copyright 2014 Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
// IconTab
Column {
width: 400
height: 400
spacing: units.gridUnit
id: themePage
anchors {
margins: units.largeSpacing
}
Row {
PlasmaComponents.CheckBox {
id: boxesCheck
text: "Show Boxes"
}
PlasmaComponents.CheckBox {
id: fontCheck
text: checked ? "Oxygen-Sans" : "Comme"
}
PlasmaComponents.CheckBox {
id: paintedHeightCheck
text: "Painted Height"
checked: true
visible: false
}
}
FontGizmo {
id: giz1
font.family: "Oxygen-Sans"
}
FontGizmo {
id: giz2
font.family: "Comme"
}
FontGizmo {
id: giz3
font.family: "Oxygen Mono"
}
Rectangle {
width: parent.width
height: units.gridUnit * 6
border.width: boxesCheck.checked ? 1 : 0
border.color: "red"
Rectangle {
id: img
color: "orange"
height: units.gridUnit * 2
width: height
anchors {
top: parent.top
left: parent.left
}
}
PlasmaComponents.Label {
font.family: fontCheck.text
font.pointSize: 24
verticalAlignment: Text.AlignTop
text: "That's a Headline"
//height: paintedHeight
height: units.gridUnit
font.pixelSize: height
anchors {
left: img.right
leftMargin: units.gridUnit
top: img.top
}
}
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright 2014 Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
// IconTab
Item {
property int cheight: 48
property int cwidth: themePage.width / 1.2
id: themePage
anchors {
margins: units.largeSpacing
}
FontTest {
anchors.fill: parent
}
}

View File

@ -46,6 +46,7 @@ Item {
}
height: _h
PlasmaComponents.TabButton { tab: fontsPage; text: i18n("Fonts"); iconSource: "preferences-desktop-font"}
PlasmaComponents.TabButton { tab: scalePage; text: i18n("Scaling"); iconSource: "preferences-system-windows"}
PlasmaComponents.TabButton { tab: unitsPage; text: i18n("Units"); iconSource: "preferences-desktop-appearance"}
}
@ -59,6 +60,10 @@ Item {
bottom: dprSlider.top
}
FontsPage {
id: fontsPage
}
ScalePage {
id: scalePage
}