229 lines
7.7 KiB
Diff
229 lines
7.7 KiB
Diff
From 4b2322bf4d3076f50a1a966f0396980ba052b468 Mon Sep 17 00:00:00 2001
|
|
From: lichangze <lichangze@uniontech.com>
|
|
Date: Wed, 11 Jan 2023 11:22:13 +0800
|
|
Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=84=E9=81=BFfonts-gb-st-super?=
|
|
=?UTF-8?q?=E5=AD=97=E4=BD=93=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?=
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
由于fonts-gb-st-super字体的lang字段中没有zh-cn等中文字段,因此dde-daemon过滤掉了该字体.
|
|
增加不规范字体显示白名单,将该字体加入白名单中
|
|
|
|
Log: 规避fonts-gb-st-super字体不显示问题
|
|
Bug: https://pms.uniontech.com/bug-view-182839.html
|
|
Influence: 字体过滤条件
|
|
Change-Id: I0d24b3c587201e69d412a18777b14ccec19c561b
|
|
---
|
|
appearance/appearance.go | 5 +-
|
|
appearance/fonts/wrapper.go | 17 ++++-
|
|
appearance/manager.go | 65 +++++++++++++++++--
|
|
.../org.deepin.dde.daemon.appearance.json | 17 +++++
|
|
4 files changed, 94 insertions(+), 10 deletions(-)
|
|
create mode 100644 misc/dsg-configs/org.deepin.dde.daemon.appearance.json
|
|
|
|
diff --git a/appearance/appearance.go b/appearance/appearance.go
|
|
index 08f19b01..717211ee 100644
|
|
--- a/appearance/appearance.go
|
|
+++ b/appearance/appearance.go
|
|
@@ -10,10 +10,11 @@ import (
|
|
"time"
|
|
|
|
"github.com/godbus/dbus"
|
|
- "github.com/linuxdeepin/dde-daemon/appearance/background"
|
|
- "github.com/linuxdeepin/dde-daemon/loader"
|
|
"github.com/linuxdeepin/go-lib/dbusutil"
|
|
"github.com/linuxdeepin/go-lib/log"
|
|
+
|
|
+ "github.com/linuxdeepin/dde-daemon/appearance/background"
|
|
+ "github.com/linuxdeepin/dde-daemon/loader"
|
|
)
|
|
|
|
var (
|
|
diff --git a/appearance/fonts/wrapper.go b/appearance/fonts/wrapper.go
|
|
index 97fdf598..86ff3a92 100644
|
|
--- a/appearance/fonts/wrapper.go
|
|
+++ b/appearance/fonts/wrapper.go
|
|
@@ -15,6 +15,7 @@ import (
|
|
"os"
|
|
"regexp"
|
|
"strings"
|
|
+ "sync"
|
|
"unsafe"
|
|
|
|
"github.com/linuxdeepin/go-lib/strv"
|
|
@@ -33,6 +34,11 @@ var (
|
|
langReg = regexp.MustCompile("_")
|
|
)
|
|
|
|
+var (
|
|
+ _irregularFontWhiteList strv.Strv
|
|
+ _irregularFontWhiteListMu sync.Mutex
|
|
+)
|
|
+
|
|
var familyBlacklist = strv.Strv([]string{
|
|
// font family names of Deepin Open Symbol Fonts:
|
|
"Symbol",
|
|
@@ -149,15 +155,16 @@ func fcInfoToFamily(cInfo *C.FcInfo) *Family {
|
|
if familyBlacklist.Contains(family) {
|
|
return nil
|
|
}
|
|
-
|
|
// info.Deletable = isDeletable(info.File)
|
|
langs := strings.Split(C.GoString(cInfo.lang), defaultLangDelim)
|
|
+ _irregularFontWhiteListMu.Lock()
|
|
+ defer _irregularFontWhiteListMu.Unlock()
|
|
return &Family{
|
|
Id: family,
|
|
Name: getItemByIndex(indexOf(getCurLang(), familyLang), families),
|
|
Styles: strings.Split(C.GoString(cInfo.style), defaultNameDelim),
|
|
Monospace: isMonospace(family, C.GoString(cInfo.spacing)),
|
|
- Show: strv.Strv(langs).Contains(getCurLang()),
|
|
+ Show: _irregularFontWhiteList.Contains(family) || strv.Strv(langs).Contains(getCurLang()),
|
|
}
|
|
}
|
|
|
|
@@ -233,3 +240,9 @@ func getLangFromLocale(locale string) string {
|
|
}
|
|
return lang
|
|
}
|
|
+
|
|
+func SetIrregularFontWhiteList(whiteList strv.Strv) {
|
|
+ _irregularFontWhiteListMu.Lock()
|
|
+ _irregularFontWhiteList = whiteList
|
|
+ _irregularFontWhiteListMu.Unlock()
|
|
+}
|
|
diff --git a/appearance/manager.go b/appearance/manager.go
|
|
index beee00d2..20687456 100644
|
|
--- a/appearance/manager.go
|
|
+++ b/appearance/manager.go
|
|
@@ -24,18 +24,13 @@ import (
|
|
"github.com/fsnotify/fsnotify"
|
|
dbus "github.com/godbus/dbus"
|
|
"github.com/linuxdeepin/dde-api/theme_thumb"
|
|
- "github.com/linuxdeepin/dde-daemon/appearance/background"
|
|
- "github.com/linuxdeepin/dde-daemon/appearance/fonts"
|
|
- "github.com/linuxdeepin/dde-daemon/appearance/subthemes"
|
|
- "github.com/linuxdeepin/dde-daemon/common/dsync"
|
|
- ddbus "github.com/linuxdeepin/dde-daemon/dbus"
|
|
- "github.com/linuxdeepin/dde-daemon/session/common"
|
|
accounts "github.com/linuxdeepin/go-dbus-factory/com.deepin.daemon.accounts"
|
|
display "github.com/linuxdeepin/go-dbus-factory/com.deepin.daemon.display"
|
|
imageeffect "github.com/linuxdeepin/go-dbus-factory/com.deepin.daemon.imageeffect"
|
|
sessiontimedate "github.com/linuxdeepin/go-dbus-factory/com.deepin.daemon.timedate"
|
|
sessionmanager "github.com/linuxdeepin/go-dbus-factory/com.deepin.sessionmanager"
|
|
wm "github.com/linuxdeepin/go-dbus-factory/com.deepin.wm"
|
|
+ configManager "github.com/linuxdeepin/go-dbus-factory/org.desktopspec.ConfigManager"
|
|
login1 "github.com/linuxdeepin/go-dbus-factory/org.freedesktop.login1"
|
|
timedate "github.com/linuxdeepin/go-dbus-factory/org.freedesktop.timedate1"
|
|
gio "github.com/linuxdeepin/go-gir/gio-2.0"
|
|
@@ -48,6 +43,13 @@ import (
|
|
"github.com/linuxdeepin/go-lib/xdg/basedir"
|
|
x "github.com/linuxdeepin/go-x11-client"
|
|
"github.com/linuxdeepin/go-x11-client/ext/randr"
|
|
+
|
|
+ "github.com/linuxdeepin/dde-daemon/appearance/background"
|
|
+ "github.com/linuxdeepin/dde-daemon/appearance/fonts"
|
|
+ "github.com/linuxdeepin/dde-daemon/appearance/subthemes"
|
|
+ "github.com/linuxdeepin/dde-daemon/common/dsync"
|
|
+ ddbus "github.com/linuxdeepin/dde-daemon/dbus"
|
|
+ "github.com/linuxdeepin/dde-daemon/session/common"
|
|
)
|
|
|
|
//go:generate dbusutil-gen em -type Manager
|
|
@@ -103,6 +105,12 @@ const (
|
|
dbusInterface = dbusServiceName
|
|
)
|
|
|
|
+const (
|
|
+ dsettingsAppID = "org.deepin.dde.daemon"
|
|
+ dsettingsAppearanceName = "org.deepin.dde.daemon.appearance"
|
|
+ dsettingsIrregularFontWhiteListKey = "irregularFontWhiteList"
|
|
+)
|
|
+
|
|
var wsConfigFile = filepath.Join(basedir.GetUserConfigDir(), "deepin/dde-daemon/appearance/wallpaper-slideshow.json")
|
|
|
|
// Manager shows current themes and fonts settings, emit 'Changed' signal if modified
|
|
@@ -616,6 +624,9 @@ func (m *Manager) init() error {
|
|
logger.Warning("failed to set cursor theme:", err)
|
|
}
|
|
|
|
+ // Init IrregularFontWhiteList
|
|
+ m.initAppearanceDSettings()
|
|
+
|
|
// Init theme list
|
|
time.AfterFunc(time.Second*10, func() {
|
|
if !dutils.IsFileExist(fonts.DeepinFontConfig) {
|
|
@@ -1612,3 +1623,45 @@ func (m *Manager) iso6709Parsing(city, coordinates string) {
|
|
cdn.latitude = lat
|
|
m.coordinateMap[city] = &cdn
|
|
}
|
|
+
|
|
+func (m *Manager) initAppearanceDSettings() {
|
|
+ ds := configManager.NewConfigManager(m.sysSigLoop.Conn())
|
|
+
|
|
+ appearancePath, err := ds.AcquireManager(0, dsettingsAppID, dsettingsAppearanceName, "")
|
|
+ if err != nil {
|
|
+ logger.Warning(err)
|
|
+ return
|
|
+ }
|
|
+
|
|
+ dsAppearance, err := configManager.NewManager(m.sysSigLoop.Conn(), appearancePath)
|
|
+ if err != nil {
|
|
+ logger.Warning(err)
|
|
+ return
|
|
+ }
|
|
+
|
|
+ getIrregularFontWhiteListKey := func() {
|
|
+ v, err := dsAppearance.Value(0, dsettingsIrregularFontWhiteListKey)
|
|
+ if err != nil {
|
|
+ logger.Warning(err)
|
|
+ return
|
|
+ }
|
|
+ var irregularFontWhiteListKey strv.Strv
|
|
+ itemList := v.Value().([]dbus.Variant)
|
|
+ for _, i := range itemList {
|
|
+ irregularFontWhiteListKey = append(irregularFontWhiteListKey, i.Value().(string))
|
|
+ }
|
|
+ fonts.SetIrregularFontWhiteList(irregularFontWhiteListKey)
|
|
+ }
|
|
+
|
|
+ getIrregularFontWhiteListKey()
|
|
+
|
|
+ dsAppearance.InitSignalExt(m.sysSigLoop, true)
|
|
+ _, err = dsAppearance.ConnectValueChanged(func(key string) {
|
|
+ if key == dsettingsIrregularFontWhiteListKey {
|
|
+ getIrregularFontWhiteListKey()
|
|
+ }
|
|
+ })
|
|
+ if err != nil {
|
|
+ logger.Warning(err)
|
|
+ }
|
|
+}
|
|
diff --git a/misc/dsg-configs/org.deepin.dde.daemon.appearance.json b/misc/dsg-configs/org.deepin.dde.daemon.appearance.json
|
|
new file mode 100644
|
|
index 00000000..8fb7c853
|
|
--- /dev/null
|
|
+++ b/misc/dsg-configs/org.deepin.dde.daemon.appearance.json
|
|
@@ -0,0 +1,17 @@
|
|
+{
|
|
+ "magic": "dsg.config.meta",
|
|
+ "version": "1.0",
|
|
+ "contents": {
|
|
+ "irregularFontWhiteList": {
|
|
+ "value": ["GB_SS_GB18030_Extended"],
|
|
+ "serial": 0,
|
|
+ "flags": [],
|
|
+ "global": true,
|
|
+ "name": "IrregularFontWhiteList",
|
|
+ "name[zh_CN]": "不规范字体白名单",
|
|
+ "description": "不规范字体白名单,白名单中字体show字段为true",
|
|
+ "permissions": "read",
|
|
+ "visibility": "private"
|
|
+ }
|
|
+ }
|
|
+}
|
|
--
|
|
2.20.1
|
|
|