将 @font-face 添加到 CKEditor

发布于 2024-08-04 10:07:35 字数 241 浏览 2 评论 0原文

我想将字体添加到 CKEditor 字体组合框中。这本身就很容易。不过,我想添加的字体是与 @font-face CSS3 属性一起使用的自定义字体。 我设法做到了这一点,但编辑器本身不显示自定义字体。如果我只是采用 CKEditor 创建的 html 并将其显示在页面上的 div 中,则自定义字体会很好地显示。 我还想以某种方式将 @font-face 属性添加到 CKEditor 的文本区域,以便我的用户可以在键入时看到自定义字体。

这可能吗?

I would like to add a font to the CKEditor font combo box. This in itself is easy enough. However the font I would like to add is a custom font that I use with the @font-face CSS3 attribute.
I managed to do that but the editor itself does not show the custom font. If I just take the html created by CKEditor and show it in a div on the page, the custom font show nicely.
I would also like to somehow add the @font-face attribute to the text area of CKEditor, so my users can see the custom font as they type.

Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青巷忧颜 2024-08-11 10:07:35

将以下行添加到 ckeditor/config.js

config.contentsCss = 'fonts.css';
//the next line add the new font to the combobox in CKEditor
config.font_names = 'fontnametodisplay/yourfontname;' + config.font_names;

,其中 fonts.css 具有 @font-face 属性:

@font-face {  
    font-family: "yourfontname";  
    src: url( ../fonts/font.eot ); /* IE */  
    src: local("realfontname"), url("../fonts/font.TTF") format("truetype"); /*non-IE*/  
}

add the following line to ckeditor/config.js

config.contentsCss = 'fonts.css';
//the next line add the new font to the combobox in CKEditor
config.font_names = 'fontnametodisplay/yourfontname;' + config.font_names;

where fonts.css has the @font-face attribute:

@font-face {  
    font-family: "yourfontname";  
    src: url( ../fonts/font.eot ); /* IE */  
    src: local("realfontname"), url("../fonts/font.TTF") format("truetype"); /*non-IE*/  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文