最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add fonts into NicEdit? - Stack Overflow

programmeradmin2浏览0评论

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.

Share Improve this question edited Sep 14, 2014 at 10:46 Davuz asked May 22, 2013 at 2:40 DavuzDavuz 5,29613 gold badges43 silver badges62 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Very happy, I've added news fonts NicEdit successful. I post answer here, hope it userful for everyone has the same problem.

1.Download font file, save in some folder, in my way is 'css/font'

2.Register in css file: add a css file "CustomFonts.css" has content: (I use Fugaz One download from Google Font)

@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;
}

You may change path to font file.

3.Link css file in html form, before add nicEdit.js lib:

<link rel="stylesheet" type="text/css" href="css/customFont.css" />
<script type="text/javascript" src="js/nicEdit/nicEdit_dev.js"></script>

4.Open nicEdit.js and find word "nicEditorFontFamilySelect". You will see a fonts list use in nicEdit, add new font here by font-family register in css:

sel : {'arial' : 'Arial',..., 'FugazOne':'FugazOne'},

5.tada... DONE!

P/s: when show content from database, you must sure webpage had load customFont.css.

发布评论

评论列表(0)

  1. 暂无评论