百度编辑器Ueditor增加字体的修改方法
ueditor本身自带11种字体
使用过程中这11种字体往往不能满足我们的需求,现在我要添加“仿宋”和“仿宋gb2312”两种字体
过程如下:
1、找到文件 ueditor/lang/zh-cn/zh-cn.js ,找到其中的fontfamily节点,添加“仿宋”和“仿宋gb2312”
'fontfamily':{ 'songti': '宋体', 'simsun': '仿宋', 'fangsong_gb2312': '仿宋_gb2312', 'kaiti':'楷体', 'heiti':'黑体', 'lishu':'隶书', 'yahei':'微软雅黑', 'andalemono':'andale mono', 'arial': 'arial', 'arialblack':'arial black', 'comicsansms':'comic sans ms', 'impact':'impact', 'timesnewroman':'times new roman' },
2、找到文件ueditor\ueditor.config.js文件(网上也看到一说是ueditor\editor_config.js文件,可能版本问题),找到其中被注释掉的fontfamily节点,去掉该节点的注释,添加“仿宋”和“仿宋gb2312”
//fontfamily //字体设置 label留空支持多语言自动切换,若配置,则以配置值为准 ,'fontfamily':[ { label: '', name: 'songti', val: '宋体,simsun' }, { label: '', name: 'simsun', val: '仿宋,simsun' }, { label:'',name:'fangsong_gb2312',val:'仿宋_gb2312 ,fangsong_gb2312'}, { label:'',name:'kaiti',val:'楷体,楷体_gb2312, simkai'}, { label:'',name:'yahei',val:'微软雅黑,microsoft yahei'}, { label:'',name:'heiti',val:'黑体, simhei'}, { label:'',name:'lishu',val:'隶书, simli'}, { label:'',name:'andalemono',val:'andale mono'}, { label:'',name:'arial',val:'arial, helvetica,sans-serif'}, { label:'',name:'arialblack',val:'arial black,avant garde'}, { label:'',name:'comicsansms',val:'comic sans ms'}, { label:'',name:'impact',val:'impact,chicago'}, { label:'',name:'timesnewroman',val:'times new roman'} ] //fontsize //字号 //,'fontsize':[10, 11, 12, 14, 16, 18, 20, 24, 36]
添加好的效果图:
可以看到,仿宋和仿宋gb2312被成功添加上去了
最后,附上部分中文字体的英文名,方便添加字体
华文细黑:stheiti light [stxihei]
华文黑体:stheiti
华文楷体:stkaiti
华文宋体:stsong
华文仿宋:stfangsong
俪黑 pro:lihei pro medium
俪宋 pro:lisong pro light
标楷体:biaukai
苹果俪中黑:apple ligothic medium
苹果俪细宋:apple lisung light
新细明体:pmingliu
细明体:mingliu
标楷体:dfkai-sb
黑体:simhei
宋体:simsun
新宋体:nsimsun
仿宋:fangsong
楷体:kaiti
仿宋_gb2312:fangsong_gb2312
楷体_gb2312:kaiti_gb2312
微软正黑体:microsoft jhenghei
微软雅黑体:microsoft yahei
隶书:lisu
幼圆:youyuan
华文细黑:stxihei
华文楷体:stkaiti
华文宋体:stsong
华文中宋:stzhongsong
华文仿宋:stfangsong
方正舒体:fzshuti
方正姚体:fzyaoti
华文彩云:stcaiyun
华文琥珀:sthupo
华文隶书:stliti
华文行楷:stxingkai
华文新魏:stxinwei