1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-15 08:42:47 -04:00

fonts: native rendering + add settings to override renderType

fixes #2371
This commit is contained in:
bbedward
2026-05-11 10:49:29 -04:00
parent 676219bc09
commit 2690305724
14 changed files with 209 additions and 4 deletions
+16
View File
@@ -61,6 +61,20 @@ Singleton {
Colorful Colorful
} }
enum TextRenderType {
Qt,
Native,
Curve
}
enum TextRenderQuality {
Default,
Low,
Normal,
High,
VeryHigh
}
readonly property string _homeUrl: StandardPaths.writableLocation(StandardPaths.HomeLocation) readonly property string _homeUrl: StandardPaths.writableLocation(StandardPaths.HomeLocation)
readonly property string _configUrl: StandardPaths.writableLocation(StandardPaths.ConfigLocation) readonly property string _configUrl: StandardPaths.writableLocation(StandardPaths.ConfigLocation)
readonly property string _configDir: Paths.strip(_configUrl) readonly property string _configDir: Paths.strip(_configUrl)
@@ -483,6 +497,8 @@ Singleton {
property int fontWeight: Font.Normal property int fontWeight: Font.Normal
property real fontScale: 1.0 property real fontScale: 1.0
property real dankBarFontScale: 1.0 property real dankBarFontScale: 1.0
property int textRenderType: SettingsData.TextRenderType.Native
property int textRenderQuality: SettingsData.TextRenderQuality.Default
property bool notepadUseMonospace: true property bool notepadUseMonospace: true
property string notepadFontFamily: "" property string notepadFontFamily: ""
@@ -242,6 +242,8 @@ var SPEC = {
monoFontFamily: { def: "Fira Code" }, monoFontFamily: { def: "Fira Code" },
fontWeight: { def: 400 }, fontWeight: { def: 400 },
fontScale: { def: 1.0 }, fontScale: { def: 1.0 },
textRenderType: { def: 1 },
textRenderQuality: { def: 0 },
notepadUseMonospace: { def: true }, notepadUseMonospace: { def: true },
notepadFontFamily: { def: "" }, notepadFontFamily: { def: "" },
@@ -448,6 +448,7 @@ Rectangle {
name: "sync" name: "sync"
size: 24 size: 24
color: Qt.rgba(Theme.surfaceText.r || 0.8, Theme.surfaceText.g || 0.8, Theme.surfaceText.b || 0.8, 0.4) color: Qt.rgba(Theme.surfaceText.r || 0.8, Theme.surfaceText.g || 0.8, Theme.surfaceText.b || 0.8, 0.4)
smoothTransform: BluetoothService.adapter?.discovering ?? false
RotationAnimator on rotation { RotationAnimator on rotation {
running: parent.visible running: parent.visible
@@ -177,6 +177,7 @@ Rectangle {
name: "sync" name: "sync"
size: 32 size: 32
color: Theme.primary color: Theme.primary
smoothTransform: NetworkService.wifiToggling
RotationAnimator on rotation { RotationAnimator on rotation {
running: NetworkService.wifiToggling running: NetworkService.wifiToggling
@@ -493,6 +494,7 @@ Rectangle {
name: "refresh" name: "refresh"
size: 48 size: 48
color: Qt.rgba(Theme.surfaceText.r || 0.8, Theme.surfaceText.g || 0.8, Theme.surfaceText.b || 0.8, 0.3) color: Qt.rgba(Theme.surfaceText.r || 0.8, Theme.surfaceText.g || 0.8, Theme.surfaceText.b || 0.8, 0.3)
smoothTransform: wifiScanningOverlay.visible
RotationAnimator on rotation { RotationAnimator on rotation {
running: wifiScanningOverlay.visible running: wifiScanningOverlay.visible
@@ -55,6 +55,7 @@ BasePill {
id: statusIcon id: statusIcon
anchors.centerIn: parent anchors.centerIn: parent
visible: root.isVerticalOrientation visible: root.isVerticalOrientation
smoothTransform: root.isChecking
name: { name: {
if (root.isChecking) if (root.isChecking)
return "refresh"; return "refresh";
@@ -109,6 +110,7 @@ BasePill {
DankIcon { DankIcon {
id: statusIconHorizontal id: statusIconHorizontal
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
smoothTransform: root.isChecking
name: { name: {
if (root.isChecking) if (root.isChecking)
return "refresh"; return "refresh";
@@ -146,6 +146,7 @@ Item {
color: Theme.withAlpha(Theme.surfaceText, 0.4) color: Theme.withAlpha(Theme.surfaceText, 0.4)
anchors.top: parent.top anchors.top: parent.top
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
smoothTransform: isRefreshing
property bool isRefreshing: false property bool isRefreshing: false
enabled: !isRefreshing enabled: !isRefreshing
@@ -884,6 +885,7 @@ Item {
color: Theme.withAlpha(Theme.surfaceText, 0.4) color: Theme.withAlpha(Theme.surfaceText, 0.4)
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
smoothTransform: isRefreshing
property bool isRefreshing: false property bool isRefreshing: false
enabled: !isRefreshing enabled: !isRefreshing
+1
View File
@@ -483,6 +483,7 @@ Item {
size: 40 size: 40
color: Theme.primary color: Theme.primary
anchors.centerIn: parent anchors.centerIn: parent
smoothTransform: loadingOverlay.visible
RotationAnimator { RotationAnimator {
target: spinningIcon target: spinningIcon
@@ -562,6 +562,7 @@ Item {
size: 20 size: 20
color: Theme.primary color: Theme.primary
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
smoothTransform: KeybindsService.loading
RotationAnimator on rotation { RotationAnimator on rotation {
from: 0 from: 0
@@ -375,6 +375,7 @@ FloatingWindow {
size: 48 size: 48
color: Theme.primary color: Theme.primary
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
smoothTransform: root.isLoading
RotationAnimator on rotation { RotationAnimator on rotation {
from: 0 from: 0
@@ -343,6 +343,7 @@ FloatingWindow {
size: 48 size: 48
color: Theme.primary color: Theme.primary
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
smoothTransform: root.isLoading
RotationAnimator on rotation { RotationAnimator on rotation {
from: 0 from: 0
@@ -671,6 +671,7 @@ Item {
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.4) color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.4)
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
smoothTransform: isRefreshing
property bool isRefreshing: false property bool isRefreshing: false
enabled: !isRefreshing enabled: !isRefreshing
@@ -329,6 +329,153 @@ Item {
} }
} }
SettingsCard {
tab: "typography"
tags: ["text", "render", "rendering", "quality", "anti-aliasing", "freetype", "distance", "field"]
title: I18n.tr("Text Rendering")
settingKey: "textRenderType"
iconName: "text_format"
Item {
width: parent.width
height: renderTypeGroup.implicitHeight
clip: true
DankButtonGroup {
id: renderTypeGroup
anchors.horizontalCenter: parent.horizontalCenter
buttonPadding: parent.width < 480 ? Theme.spacingS : Theme.spacingL
minButtonWidth: parent.width < 480 ? 64 : 96
textSize: parent.width < 480 ? Theme.fontSizeSmall : Theme.fontSizeMedium
model: ["Native", "Qt", "Curve"]
selectionMode: "single"
currentIndex: {
switch (SettingsData.textRenderType) {
case SettingsData.TextRenderType.Qt:
return 1;
case SettingsData.TextRenderType.Curve:
return 2;
default:
return 0;
}
}
onSelectionChanged: (index, selected) => {
if (!selected)
return;
switch (index) {
case 1:
SettingsData.set("textRenderType", SettingsData.TextRenderType.Qt);
break;
case 2:
SettingsData.set("textRenderType", SettingsData.TextRenderType.Curve);
break;
default:
SettingsData.set("textRenderType", SettingsData.TextRenderType.Native);
break;
}
}
Connections {
target: SettingsData
function onTextRenderTypeChanged() {
switch (SettingsData.textRenderType) {
case SettingsData.TextRenderType.Qt:
renderTypeGroup.currentIndex = 1;
break;
case SettingsData.TextRenderType.Curve:
renderTypeGroup.currentIndex = 2;
break;
default:
renderTypeGroup.currentIndex = 0;
break;
}
}
}
}
}
Rectangle {
width: parent.width
height: 1
color: Theme.outline
opacity: 0.15
}
Item {
width: parent.width
height: renderTypeDescription.implicitHeight + Theme.spacingS * 2
StyledText {
id: renderTypeDescription
x: Theme.spacingM
y: Theme.spacingS
width: parent.width - Theme.spacingM * 2
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
wrapMode: Text.WordWrap
text: {
switch (SettingsData.textRenderType) {
case SettingsData.TextRenderType.Qt:
return I18n.tr("Qt: distance-field renderer.");
case SettingsData.TextRenderType.Curve:
return I18n.tr("Curve: curve rasterizer.");
default:
return I18n.tr("Native: platform renderer (FreeType).");
}
}
}
}
Rectangle {
width: parent.width
height: 1
color: Theme.outline
opacity: 0.15
visible: SettingsData.textRenderType === SettingsData.TextRenderType.Qt
}
Item {
width: parent.width
height: visible ? qualityGroup.implicitHeight + qualityLabel.implicitHeight + Theme.spacingS : 0
visible: SettingsData.textRenderType === SettingsData.TextRenderType.Qt
clip: true
StyledText {
id: qualityLabel
x: Theme.spacingM
text: I18n.tr("Quality")
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
color: Theme.surfaceText
}
DankButtonGroup {
id: qualityGroup
anchors.top: qualityLabel.bottom
anchors.topMargin: Theme.spacingS
anchors.horizontalCenter: parent.horizontalCenter
buttonPadding: parent.width < 480 ? Theme.spacingXS : Theme.spacingS
minButtonWidth: parent.width < 480 ? 40 : 56
textSize: parent.width < 480 ? Theme.fontSizeSmall : Theme.fontSizeMedium
model: ["Default", "Low", "Normal", "High", "Very High"]
selectionMode: "single"
currentIndex: SettingsData.textRenderQuality
onSelectionChanged: (index, selected) => {
if (!selected)
return;
SettingsData.set("textRenderQuality", index);
}
Connections {
target: SettingsData
function onTextRenderQualityChanged() {
qualityGroup.currentIndex = SettingsData.textRenderQuality;
}
}
}
}
}
SettingsCard { SettingsCard {
tab: "typography" tab: "typography"
tags: ["animation", "speed", "motion", "duration"] tags: ["animation", "speed", "motion", "duration"]
+4 -2
View File
@@ -11,6 +11,7 @@ Item {
property real fill: filled ? 1.0 : 0.0 property real fill: filled ? 1.0 : 0.0
property int grade: Theme.isLightMode ? 0 : -25 property int grade: Theme.isLightMode ? 0 : -25
property int weight: filled ? 500 : 400 property int weight: filled ? 500 : 400
property bool smoothTransform: false
implicitWidth: Math.round(size) implicitWidth: Math.round(size)
implicitHeight: Math.round(size) implicitHeight: Math.round(size)
@@ -28,12 +29,13 @@ Item {
anchors.fill: parent anchors.fill: parent
font.family: materialSymbolsFont.name font.family: materialSymbolsFont.name
font.pixelSize: Theme.fontSizeMedium font.pixelSize: Math.round(Theme.fontSizeMedium)
font.weight: root.weight font.weight: root.weight
font.hintingPreference: Font.PreferNoHinting
color: Theme.surfaceText color: Theme.surfaceText
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
antialiasing: true renderType: root.smoothTransform ? Text.QtRendering : Text.NativeRendering
Behavior on color { Behavior on color {
enabled: Theme.currentAnimationSpeed !== SettingsData.AnimationSpeed.None enabled: Theme.currentAnimationSpeed !== SettingsData.AnimationSpeed.None
+28 -2
View File
@@ -3,7 +3,6 @@ import qs.Common
Text { Text {
property bool isMonospace: false property bool isMonospace: false
FontLoader { FontLoader {
id: interFont id: interFont
source: Qt.resolvedUrl("../assets/fonts/inter/InterVariable.ttf") source: Qt.resolvedUrl("../assets/fonts/inter/InterVariable.ttf")
@@ -24,6 +23,32 @@ Text {
return requestedFont; return requestedFont;
} }
readonly property int resolvedRenderType: {
switch (SettingsData.textRenderType) {
case SettingsData.TextRenderType.Qt:
return Text.QtRendering;
case SettingsData.TextRenderType.Curve:
return Text.CurveRendering;
default:
return Text.NativeRendering;
}
}
readonly property int resolvedRenderQuality: {
switch (SettingsData.textRenderQuality) {
case SettingsData.TextRenderQuality.Low:
return Text.LowRenderTypeQuality;
case SettingsData.TextRenderQuality.Normal:
return Text.NormalRenderTypeQuality;
case SettingsData.TextRenderQuality.High:
return Text.HighRenderTypeQuality;
case SettingsData.TextRenderQuality.VeryHigh:
return Text.VeryHighRenderTypeQuality;
default:
return Text.DefaultRenderTypeQuality;
}
}
readonly property var standardAnimation: { readonly property var standardAnimation: {
"duration": Appearance.anim.durations.normal, "duration": Appearance.anim.durations.normal,
"easing.type": Easing.BezierSpline, "easing.type": Easing.BezierSpline,
@@ -37,7 +62,8 @@ Text {
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
elide: Text.ElideRight elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
//renderType: Text.NativeRendering renderType: resolvedRenderType
renderTypeQuality: resolvedRenderQuality
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {