Jelajahi Sumber

文字字号16号 以及16号以下 ,拼音字号是文字字号的 75%。

文字字号16号以上 , 拼音字号是文字字号的  60%。
得到小数后,4舍5入取整
zq 1 bulan lalu
induk
melakukan
9e04128e2e
1 mengubah file dengan 19 tambahan dan 0 penghapusan
  1. 19 0
      src/components/PinyinText.vue

+ 19 - 0
src/components/PinyinText.vue

@@ -849,6 +849,25 @@ export default {
         this.isAllSetting = false;
       }
 
+      let _fontSize = styles['font-size'] ? styles['font-size'] : null;
+      if (!_fontSize) _fontSize = block.styleObj && block.styleObj.fontSize ? block.styleObj.fontSize : null;
+      if (!_fontSize && this.bodyStyles.fontSize) _fontSize = this.bodyStyles.fontSize;
+
+      if (_fontSize) {
+        // 取出字号里面的数字,做计算处理之后,自动加上原来的单位
+        const fontSizeMatch = _fontSize.match(/^([\d.]+)(\D*)$/);
+        if (fontSizeMatch) {
+          const fontSizeValue = parseFloat(fontSizeMatch[1]);
+          const fontSizeUnit = fontSizeMatch[2] || 'px';
+
+          // 根据字号大小确定比例:16号及以下75%,16号以上60%
+          const ratio = fontSizeValue <= 16 ? 0.75 : 0.6;
+          const calculatedSize = Math.round(fontSizeValue * ratio);
+
+          // 保留原始单位
+          styles['font-size'] = `${calculatedSize}${fontSizeUnit}`;
+        }
+      }
       // 明确重置不应该继承的样式
       styles['text-decoration'] = 'none';
       styles['font-style'] = 'normal';