Skip to content

Commit c5f5c29

Browse files
committed
fix: 修正不同dpi下字体大小问题
1 parent 485280c commit c5f5c29

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

ppttimer.ahk

+8-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DllCall("SetThreadDpiAwarenessContext", "ptr", -4, "ptr")
88
global pt_IniFile := A_ScriptDir "\ppttimer.ini"
99
global lastProfile, profiles := [], MonitorCount, lastMonitor, manualModeSupressDetection, showOnAllMonitors, isPptTimerOn
1010
global startKey, stopKey, resetKey, pauseKey, quitKey, moveKey, allMonitorKey
11-
global opacity, fontface, fontweight, fontsize, textColor, AheadColor, timeoutColor, backgroundColor, bannerWidth, bannerHeight, bannerPosition, bannerMargin, stopResetsTimer, pt_Duration, pt_Ahead, pt_PlayFinishSound, pt_FinishSoundFile, pt_PlayWarningSound, pt_WarningSoundFile, sendOnTimeout
11+
global opacity, fontface, fontweight, fontsize, indicator_fontsize := 12, textColor, AheadColor, timeoutColor, backgroundColor, bannerWidth, bannerHeight, bannerPosition, bannerMargin, stopResetsTimer, pt_Duration, pt_Ahead, pt_PlayFinishSound, pt_FinishSoundFile, pt_PlayWarningSound, pt_WarningSoundFile, sendOnTimeout
1212
global currentIndicator := ""
1313

1414
global Guis := []
@@ -247,19 +247,16 @@ refreshUI() {
247247
dpi_scale := GetDpiForMonitor(EnumMonitors()[A_index]) / 96
248248

249249
if (!dpi_scale) {
250-
dpi_scale := 1
251-
fontsize_scaled := fontsize * 1.5
252-
indicator_fontsize := 9 * 1.5
253-
} else {
254-
fontsize_scaled := fontsize * dpi_scale
255-
indicator_fontsize := 9
250+
dpi_scale := A_ScreenDPI / 96
256251
}
257252

253+
fontsize_scaled := fontsize * dpi_scale
254+
indicator_fontsize_scaled := indicator_fontsize * dpi_scale
255+
258256
bannerWidth_scaled := bannerWidth * dpi_scale
259257
bannerHeight_scaled := bannerHeight * dpi_scale
260258
bannerMargin_scaled := bannerMargin * dpi_scale
261259
indicator_y_scaled := 2.5 * dpi_scale
262-
indicator_fontsize_scaled := indicator_fontsize * dpi_scale
263260
indicator_width_scaled := 40
264261

265262
MonitorWidth := MonitorRight - MonitorLeft
@@ -281,8 +278,6 @@ refreshUI() {
281278
xposition := MonitorRight - bannerWidth_scaled - bannerMargin_scaled
282279
yposition := MonitorTop + bannerMargin_scaled
283280
}
284-
; msgbox, % bannerWidth_scaled ", " bannerHeight_scaled
285-
; msgbox, % (MonitorRight - bannerWidth_scaled) ", " xposition ", " yposition
286281
hCountDown := Guis[A_index]
287282
hText := Texts[A_index]
288283
hIndicatorText := Indicators[A_index]
@@ -489,6 +484,8 @@ loadProfile(idx) {
489484
pt_Duration := validNumberOrDefault(pt_Duration, 1200)
490485
pt_Ahead := validNumberOrDefault(pt_Ahead, 120)
491486

487+
fontsize := fontsize * 96 / A_ScreenDPI
488+
492489
refreshUI()
493490
if (isPptTimerOn) {
494491
updateCountDownText()
@@ -508,7 +505,7 @@ loadProfile(idx) {
508505
loadDefaultProfile(){
509506
InIRead, fontface, %pt_IniFile%, Main, fontface, Microsoft Yahei
510507
InIRead, fontweight, %pt_IniFile%, Main, fontweight, bold
511-
InIRead, fontsize, %pt_IniFile%, Main, fontsize, 24
508+
InIRead, fontsize, %pt_IniFile%, Main, fontsize, 36
512509
InIRead, textColor, %pt_IniFile%, Main, textcolor, 000000
513510

514511
InIRead, AheadColor, %pt_IniFile%, Main, aheadColor, 9D1000

ppttimer.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ margin=0
2828
;字体样式
2929
fontface=Microsoft Yahei
3030
fontweight=bold
31-
fontsize=24
31+
fontsize=36
3232
textcolor=000000
3333

3434
;提前提醒时的字体颜色

0 commit comments

Comments
 (0)