我想add new font
在tinymce editor
其中显示font dropdown
并应用于编辑器文本。
我尝试在高级主题皮肤文件夹的字体文件夹中添加 ttf 字体,并为@font-face添加editor_template.js
和添加 css 。contect.css
我在字体下拉列表中获得了字体名称。但是当我应用于任何文本时,对该文本没有任何字体效果。
什么是我找不到的实际问题。希望这是路径问题或其他...
I solved the issue,
Check all the possible issues below and fix them to add a font in TinyMCE editor.
Create fonts folder : tinymce/themes/advanced/
- if not exists.
"tinymce/themes/advanced/fonts/aphrodite_pro.ttf.
Add font in editor_template.js & editor_template_src.js
include in "theme_advanced_fonts"
Ex: theme_advanced_fonts: "Aphrodite Pro=aphrodite pro"
,
Maintain "theme_advanced_fonts"
font name sequence in above both js files.
Most important part: "Aphrodite Pro"
name is defined by us where "aphrodite pro"
is the name of the font.
Note this might not work in TinyMCE version 4 or higher. Check new documentation: https://www.tinymce.com/docs/configure/content-formatting/#font_formats
使用谷歌字体我刚刚使用两行(在 TinyMCE 初始化中)解决了这个问题:
content_css: ['https://fonts.googleapis.com/css?family=Gugi'],
font_formats: 'Arial Black=arial black,avant garde;Gugi=Gugi, cursive;Times New Roman=times new roman,times;',
新字体名为 Gugi,将出现在 arial black 和 times new roman 之间
您需要根据需要设置theme_advanced_fonts配置参数。如果您需要将字体添加到编辑器 iframe 头contect.css
中,@font-face
这是正确的方法。
我已经通过安装 Papyrus 字体研究了这个解决方案,它运行良好(在任何 css 文件中都没有任何 @font-face),但是在 Mac(运行 Lion)上使用多个浏览器进行研究时,我发现虽然它在 Safari 和Firefox,Papyrus 选项不会显示在 Chrome 的文本编辑器字体下拉列表中。我看到其他人在相关领域遇到了一些 Chrome 问题,所以我不确定这是否可以在 Chrome 中修复。
我在两个 .js 文件中添加了 Papyrus=Papyrus,以相同的相对位置顺序,并添加了所描述的字体文件夹,以及字体文件 Papyrus.TTF(如图所示的大写和小写)。
在 Safari 和 Firefox 中,这会导致 Papyrus 出现在下拉列表中,Papyrus 字体出现在编辑器文本和网站页面上,完全符合要求。
但不是在 Chrome 中,因为无法选择字体。