Skip to content

Commit e6a7b3d

Browse files
committed
Add dark theme to font previews and fix #2055
1 parent 222f6c7 commit e6a7b3d

2 files changed

Lines changed: 46 additions & 14 deletions

File tree

‎QuickLook.Plugin/QuickLook.Plugin.FontViewer/Resources/font2html.html‎

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Transfonter demo</title>
6+
<script>
7+
(function () {
8+
var d = window.matchMedia('(prefers-color-scheme: dark)').matches;
9+
document.documentElement.dataset.theme = d ? 'dark' : 'light';
10+
})();
11+
</script>
612
<style>
713
@font-face {
814
--font-family;
@@ -60,13 +66,47 @@
6066
border-collapse: collapse;
6167
border-spacing: 0;
6268
}
69+
/* Theme tokens — same pattern as iconfont (QuickLook.WebPlugins) */
70+
:root {
71+
color-scheme: light dark;
72+
--bg: #f1f1f1;
73+
--surface: #ffffff;
74+
--text: #000000;
75+
--text-muted: #999999;
76+
--heading-bg: #444444;
77+
--heading-text: #ffffff;
78+
}
79+
80+
:root[data-theme="dark"] {
81+
--bg: #1a1a1e;
82+
--surface: #252529;
83+
--text: #e8e8ed;
84+
--text-muted: #9898a6;
85+
--heading-bg: #2a2a30;
86+
--heading-text: #e8e8ed;
87+
}
88+
89+
@media (prefers-color-scheme: dark) {
90+
:root:not([data-theme="light"]) {
91+
--bg: #1a1a1e;
92+
--surface: #252529;
93+
--text: #e8e8ed;
94+
--text-muted: #9898a6;
95+
--heading-bg: #2a2a30;
96+
--heading-text: #e8e8ed;
97+
}
98+
}
99+
100+
:root[data-theme="light"] { color-scheme: light; }
101+
:root[data-theme="dark"] { color-scheme: dark; }
102+
63103
/* common styles */
64104
body {
65-
background: #f1f1f1;
66-
color: #000;
105+
background: var(--bg);
106+
color: var(--text);
67107
}
68108
.page {
69-
background: #fff;
109+
background: var(--surface);
70110
width: 100%;
71111
height: 100%;
72112
margin: 0 auto;
@@ -79,9 +119,9 @@
79119
}
80120
h1 {
81121
position: relative;
82-
background: #444;
122+
background: var(--heading-bg);
83123
font-size: 32px;
84-
color: #fff;
124+
color: var(--heading-text);
85125
padding: 10px 20px;
86126
margin: 0 0 10px 0;
87127
}
@@ -129,7 +169,7 @@
129169
font-size: 10px;
130170
font-weight: normal;
131171
font-style: normal;
132-
color: #999;
172+
color: var(--text-muted);
133173
padding-right: 6px;
134174
}
135175
/* fonts demo styles */

‎QuickLook.Plugin/QuickLook.Plugin.FontViewer/WebfontPanel.cs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ static WebfontPanel()
4242
InitializeResources();
4343
}
4444

45-
public WebfontPanel()
46-
{
47-
if (OSThemeHelper.AppsUseDarkTheme())
48-
{
49-
_webView.CreationProperties.AdditionalBrowserArguments = "--enable-features=WebContentsForceDark";
50-
}
51-
}
52-
5345
protected static void InitializeResources()
5446
{
5547
if (_resources.Any()) return;

0 commit comments

Comments
 (0)