My website allows user write short stories. I want they can free to format and style text, so I install NicEdit to do that. But NicEdit just has 9 default fonts; how to add more?
This is my editor. It use default code with full panel control.
My website allows user write short stories. I want they can free to format and style text, so I install NicEdit to do that. But NicEdit just has 9 default fonts; how to add more?
This is my editor. It use default code with full panel control.
很高兴,我已经成功添加了新闻字体 NicEdit。我在这里发布答案,希望它对每个人都有同样的问题有用。
1.下载字体文件,保存在某个文件夹中,我的方式是'css/font'
2.注册css文件:添加一个css文件“CustomFonts.css”有内容:(我用Fugaz One从谷歌字体下载)
@font-face {
font-family: "FugazOne";
src: url('font/FugazOne-Regular.ttf');
src: url('font/FugazOne-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
您可以更改字体文件的路径。
3.在添加nicEdit.js lib之前,以html形式链接css文件:
<link rel="stylesheet" type="text/css" href="css/customFont.css" />
<script type="text/javascript" src="js/nicEdit/nicEdit_dev.js"></script>
4.打开nicEdit.js,找到“nicEditorFontFamilySelect”这个词。您将在 nicEdit 中看到使用的字体列表,在 css 中通过 font-family register 添加新字体:
sel : {'arial' : 'Arial',..., 'FugazOne':'FugazOne'},
5.tada...完成!
P/s:当显示来自数据库的内容时,你必须确保网页已经加载customFont.css
。