diff --git a/src/assets/cour.ttf b/src/assets/cour.ttf deleted file mode 100644 index 46a0712..0000000 Binary files a/src/assets/cour.ttf and /dev/null differ diff --git a/src/assets/simhei.ttf b/src/assets/simhei.ttf deleted file mode 100644 index 5bd4687..0000000 Binary files a/src/assets/simhei.ttf and /dev/null differ diff --git a/src/assets/simkai.ttf b/src/assets/simkai.ttf deleted file mode 100644 index d7c3b90..0000000 Binary files a/src/assets/simkai.ttf and /dev/null differ diff --git a/src/assets/simsun.ttf b/src/assets/simsun.ttf deleted file mode 100644 index e0115ab..0000000 Binary files a/src/assets/simsun.ttf and /dev/null differ diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue index c67797a..fc8a8ba 100644 --- a/src/components/HelloWorld.vue +++ b/src/components/HelloWorld.vue @@ -17,7 +17,7 @@ import JsZip from 'jszip' import {Jbig2Image} from '../utils/jbig2' import {pipeline} from "../utils/pipeline" -import {getExtensionByPath, replaceFirstSlash, converterDpi, convertPathAbbreviatedDatatoPoint, calPathPoint, calTextPoint} from "../utils/ofd_util" +import {getFontFamily, getExtensionByPath, replaceFirstSlash, converterDpi, convertPathAbbreviatedDatatoPoint, calPathPoint, calTextPoint} from "../utils/ofd_util" let parser = require('fast-xml-parser'); import ASN1 from '@lapo/asn1js'; import Base64 from '@lapo/asn1js/base64'; @@ -221,7 +221,7 @@ export default { } text.setAttribute('fill', defaultStrokeColor); text.setAttribute('fill', defaultFillColor); - text.setAttribute('style', `font-size:${size}px;font-family: ${this.fontResObj[font]};`) + text.setAttribute('style', `font-size:${size}px;font-family: ${getFontFamily(this.fontResObj[font])};`) svg.appendChild(text); } @@ -689,12 +689,16 @@ export default { font-weight: 500; font-size: 1rem; color: white; - font-family: "楷体"; + font-family: "Kai, KaiTi"; } .mycanvas { border: 1px solid rgb(199, 198, 198); } +.hidden{ + display: none !important; +} + diff --git a/src/main.js b/src/main.js index 7b5527e..f506a47 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,5 @@ import Vue from 'vue' import App from './App.vue' -import './styles/index.css' Vue.config.productionTip = false new Vue({ diff --git a/src/styles/index.css b/src/styles/index.css index d68995c..139597f 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -1,28 +1,2 @@ -@font-face { - font-family: "Courier New"; - src: url("../assets/cour.ttf"); -} -@font-face { - font-family: "黑体"; - src: url("../assets/simhei.ttf"); -} -@font-face { - font-family: "楷体"; - src: url("../assets/simkai.ttf"); -} - -@font-face { - font-family: "KaiTi"; - src: url("../assets/simkai.ttf"); -} - -@font-face { - font-family: "宋体"; - src: url("../assets/simsun.ttf"); -} - -.hidden{ - display: none !important; -} diff --git a/src/utils/ofd_util.js b/src/utils/ofd_util.js index 94e738f..e8fb124 100644 --- a/src/utils/ofd_util.js +++ b/src/utils/ofd_util.js @@ -194,4 +194,18 @@ export const decodeHtml = function(s){ }); }; +let FONT_FAMILY = { + '楷体': '楷体, KaiTi, Kai', + 'KaiTi': '楷体, KaiTi, Kai', + 'Kai': '楷体, KaiTi, Kai', + '宋体': 'SimSun, Songti SC', +}; + +export const getFontFamily = function (font) { + if (FONT_FAMILY[font]) { + font = FONT_FAMILY[font]; + } + return font; +} +