Improve font loading by using QRC instead of relative paths

This commit is contained in:
Zach Fox 2018-02-28 17:59:37 -08:00
parent 061a189e9f
commit 67034274fa
32 changed files with 92 additions and 40 deletions

View file

@ -34,7 +34,7 @@ Item {
height: parent.height height: parent.height
} }
FontLoader { id: ralewayRegular; source: pathToFonts + "fonts/Raleway-Regular.ttf"; } FontLoader { id: ralewayRegular; source: "qrc:/fonts/Raleway-Regular.ttf"; }
Timer { Timer {
id: updateList id: updateList

View file

@ -109,7 +109,7 @@ CheckBox {
contentItem: Text { contentItem: Text {
id: root id: root
FontLoader { id: ralewaySemiBold; source: pathToFonts + "fonts/Raleway-SemiBold.ttf"; } FontLoader { id: ralewaySemiBold; source: "qrc:/fonts/Raleway-SemiBold.ttf"; }
font.pixelSize: hifi.fontSizes.inputLabel font.pixelSize: hifi.fontSizes.inputLabel
font.family: ralewaySemiBold.name font.family: ralewaySemiBold.name
text: checkBox.text text: checkBox.text

View file

@ -125,7 +125,7 @@ Rectangle {
TextInput { TextInput {
id: mirrorText id: mirrorText
visible: showMirrorText visible: showMirrorText
FontLoader { id: font; source: "../../fonts/FiraSans-Regular.ttf"; } FontLoader { id: font; source: "qrc:/fonts/FiraSans-Regular.ttf"; }
font.family: font.name font.family: font.name
font.pixelSize: 20 font.pixelSize: 20
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
@ -165,7 +165,7 @@ Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: 0 anchors.bottomMargin: 0
FontLoader { id: hiFiGlyphs; source: pathToFonts + "fonts/hifi-glyphs.ttf"; } FontLoader { id: hiFiGlyphs; source: "qrc:/fonts/hifi-glyphs.ttf"; }
Column { Column {
id: columnAlpha id: columnAlpha

View file

@ -25,7 +25,7 @@ SpinBox {
property color colorLabelInside: hifi.colors.white property color colorLabelInside: hifi.colors.white
property real controlHeight: height + (spinBoxLabel.visible ? spinBoxLabel.height + spinBoxLabel.anchors.bottomMargin : 0) property real controlHeight: height + (spinBoxLabel.visible ? spinBoxLabel.height + spinBoxLabel.anchors.bottomMargin : 0)
FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
font.family: firaSansSemiBold.name font.family: firaSansSemiBold.name
font.pixelSize: hifi.fontSizes.textFieldInput font.pixelSize: hifi.fontSizes.textFieldInput
height: hifi.fontSizes.textFieldInput + 13 // Match height of TextField control. height: hifi.fontSizes.textFieldInput + 13 // Match height of TextField control.

View file

@ -17,7 +17,7 @@ TextEdit {
property real size: 32 property real size: 32
FontLoader { id: ralewaySemiBold; source: "../../fonts/Raleway-SemiBold.ttf"; } FontLoader { id: ralewaySemiBold; source: "qrc:/fonts/Raleway-SemiBold.ttf"; }
font.family: ralewaySemiBold.name font.family: ralewaySemiBold.name
font.pointSize: size font.pointSize: size
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View file

@ -34,8 +34,8 @@ TextField {
placeholderText: textField.placeholderText placeholderText: textField.placeholderText
FontLoader { id: firaSansRegular; source: "../../fonts/FiraSans-Regular.ttf"; } FontLoader { id: firaSansRegular; source: "qrc:/fonts/FiraSans-Regular.ttf"; }
FontLoader { id: hifiGlyphs; source: "../../fonts/hifi-glyphs.ttf"; } FontLoader { id: hifiGlyphs; source: "qrc:/fonts/hifi-glyphs.ttf"; }
font.family: firaSansRegular.name font.family: firaSansRegular.name
font.pixelSize: hifi.fontSizes.textFieldInput font.pixelSize: hifi.fontSizes.textFieldInput
height: implicitHeight + 3 // Make surrounding box higher so that highlight is vertically centered. height: implicitHeight + 3 // Make surrounding box higher so that highlight is vertically centered.

View file

@ -0,0 +1,33 @@
module controlsUit
AttachmentsTable 1.0 AttachmentsTable.qml
BaseWebView 1.0 BaseWebView.qml
Button 1.0 Button.qml
CheckBox 1.0 CheckBox.qml
CheckBoxQQC2 1.0 CheckBoxQQC2.qml
ComboBox 1.0 ComboBox.qml
ContentSection 1.0 ContentSection.qml
GlyphButton 1.0 GlyphButton.qml
HorizontalRule 1.0 HorizontalRule.qml
HorizontalSpacer 1.0 HorizontalSpacer.qml
ImageMessageBox 1.0 ImageMessageBox.qml
Key 1.0 Key.qml
Keyboard 1.0 Keyboard.qml
Label 1.0 Label.qml
QueuedButton 1.0 QueuedButton.qml
RadioButton 1.0 RadioButton.qml
Separator 1.0 Separator.qml
Slider 1.0 Slider.qml
SpinBox 1.0 SpinBox.qml
Switch 1.0 Switch.qml
Table 1.0 Table.qml
TabletContentSection 1.0 TabletContentSection.qml
TabletHeader 1.0 TabletHeader.qml
TextAction 1.0 TextAction.qml
TextEdit 1.0 TextEdit.qml
TextField 1.0 TextField.qml
ToolTip 1.0 ToolTip.qml
Tree 1.0 Tree.qml
VerticalSpacer 1.0 VerticalSpacer.qml
WebGlyphButton 1.0 WebGlyphButton.qml
WebSpinner 1.0 WebSpinner.qml
WebView 1.0 WebView.qml

View file

@ -4,7 +4,7 @@ import QtQuick.Controls.Styles 1.3
Text { Text {
id: root id: root
FontLoader { id: iconFont; source: "../../fonts/fontawesome-webfont.ttf"; } FontLoader { id: iconFont; source: "qrc:/fonts/fontawesome-webfont.ttf"; }
property int size: 32 property int size: 32
width: size width: size
height: size height: size

View file

@ -532,8 +532,8 @@ ModalWindow {
itemDelegate: Item { itemDelegate: Item {
clip: true clip: true
FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
FontLoader { id: firaSansRegular; source: "../../fonts/FiraSans-Regular.ttf"; } FontLoader { id: firaSansRegular; source: "qrc:/fonts/FiraSans-Regular.ttf"; }
FiraSansSemiBold { FiraSansSemiBold {
text: getText(); text: getText();

View file

@ -496,8 +496,8 @@ TabletModalWindow {
itemDelegate: Item { itemDelegate: Item {
clip: true clip: true
//FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } //FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
//FontLoader { id: firaSansRegular; source: "../../fonts/FiraSans-Regular.ttf"; } //FontLoader { id: firaSansRegular; source: "qrc:/fonts/FiraSans-Regular.ttf"; }
FiraSansSemiBold { FiraSansSemiBold {
text: getText(); text: getText();

View file

@ -345,8 +345,8 @@ Item {
itemDelegate: Item { itemDelegate: Item {
clip: true clip: true
FontLoader { id: firaSansSemiBold; source: "../../../fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
FontLoader { id: firaSansRegular; source: "../../../fonts/FiraSans-Regular.ttf"; } FontLoader { id: firaSansRegular; source: "qrc:/fonts/FiraSans-Regular.ttf"; }
FiraSansSemiBold { FiraSansSemiBold {
text: styleData.value text: styleData.value

View file

@ -657,7 +657,7 @@ Windows.ScrollingWindow {
text: styleData.value text: styleData.value
FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
font.family: firaSansSemiBold.name font.family: firaSansSemiBold.name
font.pixelSize: hifi.fontSizes.textFieldInput font.pixelSize: hifi.fontSizes.textFieldInput
height: hifi.dimensions.tableRowHeight height: hifi.dimensions.tableRowHeight

View file

@ -25,8 +25,8 @@ Item {
property int dialogHeight; property int dialogHeight;
property int comboOptionTextSize: 16; property int comboOptionTextSize: 16;
property int comboBodyTextSize: 16; property int comboBodyTextSize: 16;
FontLoader { id: ralewayRegular; source: "../../fonts/Raleway-Regular.ttf"; } FontLoader { id: ralewayRegular; source: "qrc:/fonts/Raleway-Regular.ttf"; }
FontLoader { id: ralewaySemiBold; source: "../../fonts/Raleway-SemiBold.ttf"; } FontLoader { id: ralewaySemiBold; source: "qrc:/fonts/Raleway-SemiBold.ttf"; }
visible: false; visible: false;
id: combo; id: combo;
anchors.fill: parent; anchors.fill: parent;

View file

@ -24,8 +24,8 @@ Item {
property real headerTextMargin: -5 property real headerTextMargin: -5
property real headerGlyphMargin: -15 property real headerGlyphMargin: -15
property bool isDesktop: false property bool isDesktop: false
FontLoader { id: ralewayRegular; source: "../../fonts/Raleway-Regular.ttf"; } FontLoader { id: ralewayRegular; source: "qrc:/fonts/Raleway-Regular.ttf"; }
FontLoader { id: ralewaySemiBold; source: "../../fonts/Raleway-SemiBold.ttf"; } FontLoader { id: ralewaySemiBold; source: "qrc:/fonts/Raleway-SemiBold.ttf"; }
visible: false visible: false
id: letterbox id: letterbox
anchors.fill: parent anchors.fill: parent

View file

@ -23,8 +23,8 @@ Item {
property real popupTextPixelSize: 16 property real popupTextPixelSize: 16
property real headerTextMargin: -5 property real headerTextMargin: -5
property real headerGlyphMargin: -15 property real headerGlyphMargin: -15
FontLoader { id: ralewayRegular; source: "../../fonts/Raleway-Regular.ttf"; } FontLoader { id: ralewayRegular; source: "qrc:/fonts/Raleway-Regular.ttf"; }
FontLoader { id: ralewaySemiBold; source: "../../fonts/Raleway-SemiBold.ttf"; } FontLoader { id: ralewaySemiBold; source: "qrc:/fonts/Raleway-SemiBold.ttf"; }
visible: false visible: false
id: letterbox id: letterbox
anchors.fill: parent anchors.fill: parent

View file

@ -177,7 +177,7 @@ Item {
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: editGlyph.width + editGlyph.anchors.rightMargin anchors.rightMargin: editGlyph.width + editGlyph.anchors.rightMargin
// Style // Style
FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
font.family: firaSansSemiBold.name font.family: firaSansSemiBold.name
font.pixelSize: displayNameTextPixelSize font.pixelSize: displayNameTextPixelSize
selectionColor: hifi.colors.blueAccent selectionColor: hifi.colors.blueAccent

View file

@ -908,7 +908,7 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter; anchors.horizontalCenter: parent.horizontalCenter;
} }
FontLoader { id: ralewayRegular; source: "../../fonts/Raleway-Regular.ttf"; } FontLoader { id: ralewayRegular; source: "qrc:/fonts/Raleway-Regular.ttf"; }
Text { Text {
id: connectionHelpText; id: connectionHelpText;
// Anchors // Anchors

View file

@ -141,7 +141,7 @@ Item {
} }
} }
FontLoader { id: ralewayRegular; source: "../../../../fonts/Raleway-Regular.ttf"; } FontLoader { id: ralewayRegular; source: "qrc:/fonts/Raleway-Regular.ttf"; }
TextMetrics { TextMetrics {
id: textMetrics; id: textMetrics;
font.family: ralewayRegular.name font.family: ralewayRegular.name

View file

@ -925,7 +925,7 @@ Item {
anchors.rightMargin: 20; anchors.rightMargin: 20;
height: 95; height: 95;
FontLoader { id: firaSansSemiBold; source: "../../../../../fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
TextArea { TextArea {
id: optionalMessage; id: optionalMessage;
property int maximumLength: 72; property int maximumLength: 72;

View file

@ -656,7 +656,7 @@ Rectangle {
text: styleData.value text: styleData.value
FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
font.family: firaSansSemiBold.name font.family: firaSansSemiBold.name
font.pixelSize: hifi.fontSizes.textFieldInput font.pixelSize: hifi.fontSizes.textFieldInput
height: hifi.dimensions.tableRowHeight height: hifi.dimensions.tableRowHeight

View file

@ -478,8 +478,8 @@ Rectangle {
itemDelegate: Item { itemDelegate: Item {
clip: true clip: true
//FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } //FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
//FontLoader { id: firaSansRegular; source: "../../fonts/FiraSans-Regular.ttf"; } //FontLoader { id: firaSansRegular; source: "qrc:/fonts/FiraSans-Regular.ttf"; }
FiraSansSemiBold { FiraSansSemiBold {
text: getText(); text: getText();

View file

@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4
Text { Text {
id: root id: root
FontLoader { id: anonymousProRegular; source: "../../fonts/AnonymousPro-Regular.ttf"; } FontLoader { id: anonymousProRegular; source: "qrc:/fonts/AnonymousPro-Regular.ttf"; }
property real size: 32 property real size: 32
font.pixelSize: size font.pixelSize: size
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View file

@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4
Text { Text {
id: root id: root
FontLoader { id: firaSansRegular; source: "../../fonts/FiraSans-Regular.ttf"; } FontLoader { id: firaSansRegular; source: "qrc:/fonts/FiraSans-Regular.ttf"; }
property real size: 32 property real size: 32
font.pixelSize: size font.pixelSize: size
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View file

@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4
Text { Text {
id: root id: root
FontLoader { id: firaSansSemiBold; source: pathToFonts + "fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "qrc:/fonts/FiraSans-SemiBold.ttf"; }
property real size: 32 property real size: 32
font.pixelSize: size font.pixelSize: size
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View file

@ -12,7 +12,7 @@ import QtQuick 2.5
Text { Text {
id: root id: root
FontLoader { id: hiFiGlyphs; source: pathToFonts + "fonts/hifi-glyphs.ttf"; } FontLoader { id: hiFiGlyphs; source: "qrc:/fonts/hifi-glyphs.ttf"; }
property int size: 32 property int size: 32
font.pixelSize: size font.pixelSize: size
width: size width: size

View file

@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4
Text { Text {
id: root id: root
FontLoader { id: ralewayBold; source: pathToFonts + "fonts/Raleway-Bold.ttf"; } FontLoader { id: ralewayBold; source: "qrc:/fonts/Raleway-Bold.ttf"; }
property real size: 32 property real size: 32
font.pixelSize: size font.pixelSize: size
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View file

@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4
Text { Text {
id: root id: root
FontLoader { id: ralewayLight; source: "../../fonts/Raleway-Light.ttf"; } FontLoader { id: ralewayLight; source: "qrc:/fonts/Raleway-Light.ttf"; }
property real size: 32 property real size: 32
font.pixelSize: size font.pixelSize: size
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View file

@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4
Text { Text {
id: root id: root
FontLoader { id: ralewayRegular; source: pathToFonts + "fonts/Raleway-Regular.ttf"; } FontLoader { id: ralewayRegular; source: "qrc:/fonts/Raleway-Regular.ttf"; }
property real size: 32 property real size: 32
font.pixelSize: size font.pixelSize: size
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View file

@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4
Text { Text {
id: root id: root
FontLoader { id: ralewaySemiBold; source: pathToFonts + "fonts/Raleway-SemiBold.ttf"; } FontLoader { id: ralewaySemiBold; source: "qrc:/fonts/Raleway-SemiBold.ttf"; }
property real size: 32 property real size: 32
font.pixelSize: size font.pixelSize: size
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter

View file

@ -0,0 +1,22 @@
module stylesUit
AnonymousProRegular 1.0 AnonymousProRegular.qml
ButtonLabel 1.0 ButtonLabel.qml
FiraSansRegular 1.0 FiraSansRegular.qml
FiraSansSemiBold 1.0 FiraSansSemiBold.qml
HifiConstants 1.0 HifiConstants.qml
HiFiGlyphs 1.0 HiFiGlyphs.qml
IconButton 1.0 IconButton.qml
InfoItem 1.0 InfoItem.qml
InputLabel 1.0 InputLabel.qml
ListItem 1.0 ListItem.qml
Logs 1.0 Logs.qml
OverlayTitle 1.0 OverlayTitle.qml
RalewayBold 1.0 RalewayBold.qml
RalewayLight 1.0 RalewayLight.qml
RalewayRegular 1.0 RalewayRegular.qml
RalewaySemiBold 1.0 RalewaySemiBold.qml
SectionName 1.0 SectionName.qml
Separator 1.0 Separator.qml
ShortcutText 1.0 ShortcutText.qml
TabName 1.0 TabName.qml
TextFieldInput 1.0 TextFieldInput.qml

View file

@ -236,8 +236,6 @@ void Web3DOverlay::setupQmlSurface() {
_webSurface->getSurfaceContext()->setContextProperty("Web3DOverlay", this); _webSurface->getSurfaceContext()->setContextProperty("Web3DOverlay", this);
_webSurface->getSurfaceContext()->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data()); _webSurface->getSurfaceContext()->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data());
_webSurface->getSurfaceContext()->setContextProperty("pathToFonts", "../../");
// Override min fps for tablet UI, for silky smooth scrolling // Override min fps for tablet UI, for silky smooth scrolling
setMaxFPS(90); setMaxFPS(90);
} }

View file

@ -248,7 +248,6 @@ void OffscreenQmlSurface::initializeEngine(QQmlEngine* engine) {
rootContext->setContextProperty("GL", ::getGLContextData()); rootContext->setContextProperty("GL", ::getGLContextData());
rootContext->setContextProperty("urlHandler", new UrlHandler()); rootContext->setContextProperty("urlHandler", new UrlHandler());
rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath())); rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath()));
rootContext->setContextProperty("pathToFonts", "../../");
rootContext->setContextProperty("ApplicationInterface", qApp); rootContext->setContextProperty("ApplicationInterface", qApp);
auto javaScriptToInject = getEventBridgeJavascript(); auto javaScriptToInject = getEventBridgeJavascript();
if (!javaScriptToInject.isEmpty()) { if (!javaScriptToInject.isEmpty()) {