fix: 标题字体在部分操作系统上不生效

This commit is contained in:
wisonic-s 2023-09-06 21:45:19 +08:00
parent f77f1f6eb7
commit bf10112e79
13 changed files with 70 additions and 48 deletions

View File

@ -1466,6 +1466,7 @@ export default {
dimension_text_style: 'Name Style',
dimension_letter_space: 'Name Letter Space',
font_family: 'Font Family',
font_family_tip: 'The font will only take effect if it is installed on the operating system',
letter_space: 'Letter Space',
font_shadow: 'Font Shadow',
chart_area: 'Area',

View File

@ -1465,6 +1465,7 @@ export default {
dimension_text_style: '名稱樣式',
dimension_letter_space: '名稱字間距',
font_family: '字體',
font_family_tip: '只有操作系統上已安裝該字體才能生效',
letter_space: '字間距',
font_shadow: '字體陰影',
chart_area: '面積圖',

View File

@ -1464,6 +1464,7 @@ export default {
dimension_text_style: '名称样式',
dimension_letter_space: '名称字间距',
font_family: '字体',
font_family_tip: '只有操作系统上已安装该字体才能生效',
letter_space: '字间距',
font_shadow: '字体阴影',
chart_area: '面积图',

View File

@ -1146,6 +1146,13 @@ export const CHART_FONT_FAMILY = [
{ name: '楷体', value: 'KaiTi' }
]
export const CHART_CONT_FAMILY_MAP = {
'Microsoft YaHei': 'Microsoft YaHei',
'SimSun': 'SimSun, "Songti SC", STSong',
'SimHei': 'SimHei, Helvetica',
'KaiTi': 'KaiTi, "Kaiti SC", STKaiti'
}
export const CHART_FONT_LETTER_SPACE = [
{ name: '0px', value: '0' },
{ name: '1px', value: '1' },

View File

@ -55,7 +55,7 @@ import { baseRadarOptionAntV } from '@/views/chart/chart/radar/radar_antv'
import { baseWaterfallOptionAntV } from '@/views/chart/chart/waterfall/waterfall'
import { baseWordCloudOptionAntV } from '@/views/chart/chart/wordCloud/word_cloud'
import TitleRemark from '@/views/chart/view/TitleRemark'
import { DEFAULT_TITLE_STYLE } from '@/views/chart/chart/chart'
import { CHART_CONT_FAMILY_MAP, DEFAULT_TITLE_STYLE } from '@/views/chart/chart/chart'
import { baseMixOptionAntV } from '@/views/chart/chart/mix/mix_antv'
import ChartTitleUpdate from './ChartTitleUpdate.vue'
import { equalsAny } from '@/utils/StringUtils'
@ -429,7 +429,7 @@ export default {
this.title_class.fontStyle = customStyle.text.isItalic ? 'italic' : 'normal'
this.title_class.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
this.title_class.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.fontFamily = customStyle.text.fontFamily ? CHART_CONT_FAMILY_MAP[customStyle.text.fontFamily] : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : DEFAULT_TITLE_STYLE.letterSpace) + 'px'
this.title_class.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
}

View File

@ -97,7 +97,7 @@ import ViewTrackBar from '@/components/canvas/components/editor/ViewTrackBar'
import { getRemark, hexColorToRGBA } from '@/views/chart/chart/util'
import { baseTableInfo, baseTableNormal, baseTablePivot } from '@/views/chart/chart/table/table-info'
import TitleRemark from '@/views/chart/view/TitleRemark'
import { DEFAULT_TITLE_STYLE, NOT_SUPPORT_PAGE_DATASET } from '@/views/chart/chart/chart'
import { CHART_CONT_FAMILY_MAP, DEFAULT_TITLE_STYLE, NOT_SUPPORT_PAGE_DATASET } from '@/views/chart/chart/chart'
import ChartTitleUpdate from './ChartTitleUpdate.vue'
import { mapState } from 'vuex'
import DePagination from '@/components/deCustomCm/pagination.js'
@ -459,7 +459,7 @@ export default {
this.$refs.title.style.fontSize = customStyle.text.fontSize + 'px'
}
this.title_class.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.fontFamily = customStyle.text.fontFamily ? CHART_CONT_FAMILY_MAP[customStyle.text.fontFamily] : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : DEFAULT_TITLE_STYLE.letterSpace) + 'px'
this.title_class.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
//

View File

@ -50,6 +50,20 @@
:value="option.value"
/>
</el-select>
<el-tooltip
class="item"
effect="dark"
placement="bottom"
>
<div
slot="content"
v-html="$t('chart.font_family_tip')"
/>
<i
class="el-icon-info"
style="cursor: pointer;color: #606266;margin-left: 4px;"
/>
</el-tooltip>
</el-form-item>
<el-form-item
v-show="showProperty('fontSize')"

View File

@ -51,6 +51,20 @@
:value="option.value"
/>
</el-select>
<el-tooltip
class="item"
effect="dark"
placement="bottom"
>
<div
slot="content"
v-html="$t('chart.font_family_tip')"
/>
<i
class="el-icon-info"
style="cursor: pointer;color: #606266;margin-left: 4px;"
/>
</el-tooltip>
</el-form-item>
<el-form-item
v-show="showProperty('fontSize')"

View File

@ -49,7 +49,7 @@ import { getRemark, hexColorToRGBA } from '../../chart/util'
import eventBus from '@/components/canvas/utils/eventBus'
import { formatterItem, valueFormatter } from '@/views/chart/chart/formatter'
import TitleRemark from '@/views/chart/view/TitleRemark'
import { DEFAULT_SIZE, DEFAULT_TITLE_STYLE } from '@/views/chart/chart/chart'
import { CHART_CONT_FAMILY_MAP, DEFAULT_SIZE, DEFAULT_TITLE_STYLE } from '@/views/chart/chart/chart'
import ChartTitleUpdate from '../ChartTitleUpdate.vue'
export default {
@ -209,7 +209,7 @@ export default {
this.title_class.fontStyle = customStyle.text.isItalic ? 'italic' : 'normal'
this.title_class.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
this.title_class.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.fontFamily = customStyle.text.fontFamily ? CHART_CONT_FAMILY_MAP[customStyle.text.fontFamily] : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : DEFAULT_TITLE_STYLE.letterSpace) + 'px'
this.title_class.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
}

View File

@ -61,7 +61,7 @@ import { getRemark, hexColorToRGBA } from '../../chart/util'
import eventBus from '@/components/canvas/utils/eventBus'
import ViewTrackBar from '@/components/canvas/components/editor/ViewTrackBar'
import TitleRemark from '@/views/chart/view/TitleRemark'
import { DEFAULT_SIZE, DEFAULT_TITLE_STYLE } from '@/views/chart/chart/chart'
import { CHART_CONT_FAMILY_MAP, DEFAULT_SIZE, DEFAULT_TITLE_STYLE } from '@/views/chart/chart/chart'
import ChartTitleUpdate from '../ChartTitleUpdate.vue'
export default {
@ -236,7 +236,7 @@ export default {
this.title_class.fontStyle = customStyle.text.isItalic ? 'italic' : 'normal'
this.title_class.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
this.title_class.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.fontFamily = customStyle.text.fontFamily ? CHART_CONT_FAMILY_MAP[customStyle.text.fontFamily] : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : DEFAULT_TITLE_STYLE.letterSpace) + 'px'
this.title_class.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
}

View File

@ -140,6 +140,12 @@ export default {
},
linkageActiveParam: null,
linkageActiveHistory: false,
CHART_CONT_FAMILY_MAP: {
'Microsoft YaHei': 'Microsoft YaHei',
'SimSun': 'SimSun, "Songti SC", STSong',
'SimHei': 'SimHei, Helvetica',
'KaiTi': 'KaiTi, "Kaiti SC", STKaiti'
}
}
},
@ -248,7 +254,7 @@ export default {
this.titleClass.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
this.titleClass.fontSize = customStyle.text.isBolder ? 'bold' : 'normal'
this.titleClass.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : 'Microsoft YaHei'
this.titleClass.fontFamily = customStyle.text.fontFamily ? this.CHART_CONT_FAMILY_MAP[customStyle.text.fontFamily] : 'Microsoft YaHei'
this.titleClass.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : '0') + 'px'
this.titleClass.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
}
@ -257,23 +263,6 @@ export default {
this.borderRadius = (customStyle.background.borderRadius || 0) + 'px'
}
if (customStyle.text) {
this.title_show = customStyle.text.show
this.title_class.fontSize = customStyle.text.fontSize + 'px'
this.title_class.color = customStyle.text.color
this.title_class.textAlign = customStyle.text.hPosition
this.title_class.fontStyle = customStyle.text.isItalic ? 'italic' : 'normal'
this.title_class.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
this.title_class.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : DEFAULT_TITLE_STYLE.letterSpace) + 'px'
this.title_class.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
}
if (customStyle.background) {
this.title_class.background = hexColorToRGBA(customStyle.background.color, customStyle.background.alpha)
this.borderRadius = (customStyle.background.borderRadius || 0) + 'px'
}
}
this.initRemark()
},

View File

@ -133,6 +133,12 @@ export default {
},
linkageActiveParam: null,
linkageActiveHistory: false,
CHART_CONT_FAMILY_MAP: {
'Microsoft YaHei': 'Microsoft YaHei',
'SimSun': 'SimSun, "Songti SC", STSong',
'SimHei': 'SimHei, Helvetica',
'KaiTi': 'KaiTi, "Kaiti SC", STKaiti'
}
}
},
@ -240,7 +246,7 @@ export default {
this.titleClass.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
this.titleClass.fontSize = customStyle.text.isBolder ? 'bold' : 'normal'
this.titleClass.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : 'Microsoft YaHei'
this.titleClass.fontFamily = customStyle.text.fontFamily ? this.CHART_CONT_FAMILY_MAP[customStyle.text.fontFamily] : 'Microsoft YaHei'
this.titleClass.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : '0') + 'px'
this.titleClass.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
}
@ -249,23 +255,6 @@ export default {
this.borderRadius = (customStyle.background.borderRadius || 0) + 'px'
}
if (customStyle.text) {
this.title_show = customStyle.text.show
this.title_class.fontSize = customStyle.text.fontSize + 'px'
this.title_class.color = customStyle.text.color
this.title_class.textAlign = customStyle.text.hPosition
this.title_class.fontStyle = customStyle.text.isItalic ? 'italic' : 'normal'
this.title_class.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
this.title_class.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : DEFAULT_TITLE_STYLE.fontFamily
this.title_class.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : DEFAULT_TITLE_STYLE.letterSpace) + 'px'
this.title_class.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
}
if (customStyle.background) {
this.title_class.background = hexColorToRGBA(customStyle.background.color, customStyle.background.alpha)
this.borderRadius = (customStyle.background.borderRadius || 0) + 'px'
}
}
this.initRemark()
},

View File

@ -107,7 +107,13 @@
content: ''
},
buttonTextColor: null,
loading: true
loading: true,
CHART_CONT_FAMILY_MAP: {
'Microsoft YaHei': 'Microsoft YaHei',
'SimSun': 'SimSun, "Songti SC", STSong',
'SimHei': 'SimHei, Helvetica',
'KaiTi': 'KaiTi, "Kaiti SC", STKaiti'
}
}
},
@ -175,7 +181,7 @@
}
}
this.myChart.destroy()
this.pointLayer.layerPickService.layer.textureService.destroy()
this.pointLayer.layerPickService.layer.textureService.rendererService.destroy()
@ -200,7 +206,7 @@
if (this.textLayer) {
this.textLayer.configService.clean() // GlobalConfigService
}
if (this.pointLayer) {
for (const key in this.pointLayer) {
this.pointLayer[key] = null
@ -574,7 +580,7 @@
this.titleClass.fontStyle = customStyle.text.isItalic ? 'italic' : 'normal'
this.titleClass.fontWeight = customStyle.text.isBolder ? 'bold' : 'normal'
this.titleClass.fontFamily = customStyle.text.fontFamily ? customStyle.text.fontFamily : 'Microsoft YaHei'
this.titleClass.fontFamily = customStyle.text.fontFamily ? this.CHART_CONT_FAMILY_MAP[customStyle.text.fontFamily] : 'Microsoft YaHei'
this.titleClass.letterSpacing = (customStyle.text.letterSpace ? customStyle.text.letterSpace : '0') + 'px'
this.titleClass.textShadow = customStyle.text.fontShadow ? '2px 2px 4px' : 'none'
}