diff --git a/css/style.css b/css/style.css index c957ceb..121d0b9 100644 --- a/css/style.css +++ b/css/style.css @@ -390,7 +390,7 @@ html, body { padding: 0; font-size: 16px; color: #000; - font-family: "Microsoft YaHei", "微软雅黑", sans-serif; + font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; background: transparent; outline: 2px solid transparent; border-radius: 4px; diff --git a/index.html b/index.html index c3c23af..a8c1d23 100644 --- a/index.html +++ b/index.html @@ -31,10 +31,11 @@
diff --git a/js/script.js b/js/script.js index 0a25178..0729ec0 100644 --- a/js/script.js +++ b/js/script.js @@ -1199,13 +1199,22 @@ // 更新颜色选择器 colorPicker.value = rgbToHex(color); - // 更新字体选择器 + // 更新字体选择器 - 匹配字体栈中的主要字体 + let matched = false; for (let option of fontPicker.options) { - if (option.value === fontFamily || fontFamily.includes(option.value)) { + const optionFonts = option.value.toLowerCase().split(',').map(f => f.trim()); + const currentFonts = fontFamily.toLowerCase().split(',').map(f => f.trim()); + // 检查是否有主要字体匹配 + if (optionFonts.some(of => currentFonts.includes(of))) { fontPicker.value = option.value; + matched = true; break; } } + // 如果没有匹配,默认选择第一个(系统默认) + if (!matched && fontPicker.options.length > 0) { + fontPicker.value = fontPicker.options[0].value; + } // 更新字号选择器 const fontSizeValueEl = fontSizePicker.querySelector('.roller-value'); @@ -1730,7 +1739,7 @@ fontPicker.addEventListener('change', () => { const targetInput = editingInput || selectedInput; if (!targetInput) return; - targetInput.style.fontFamily = fontPicker.value + ', sans-serif'; + targetInput.style.fontFamily = fontPicker.value; }); // 字号选择器 - 密码锁式滚轮