我使用的是django-text-ckeditor和djangocms。我有完全相同的問題。請注意步驟並逐步完成。
- 使用
Ctrl + Shift + T
開放式終端。
- 轉到項目目錄,如果使用virtualenv,則激活您的virtualenv。
- 型
python manage.py shell
- 然後鍵入
from django.conf import settings
- 然後鍵入
settings.CKEDITOR_SETTINGS
看到默認的Django文本CKEditor的設置。此設置與此類似: CKEDITOR_SETTINGS = { 'allowedContent': True, 'autoParagraph': False, 'baseHref': '/media/', 'enterMode': 'CKEDITOR.ENTER_BR', 'extraAllowedContent': 'style;*;*{*}', 'filebrowserImageBrowseUrl': '/filebrowser/', 'language': '{{ language }}', 'removePlugins': 'stylesheetparser,about,showblocks,language,form,flash,iframe', 'skin': 'moonocolor', 'toolbar': 'toolbar_Basic', }
- 現在您可以在您的
settings.py
中定義CKEDITOR_SETTINGS
並覆蓋它。
- 現在你需要
font_names
鍵添加到CKEDITOR_SETTINGS
類似這樣: CKEDITOR_SETTINGS = { ..., ..., 'font_names': 'IRANSans; Yekan; Bnasim; Bkoodak;, ..., }
如果你自定義的字體名稱初始化這個7步驟,字體組合。我懇請你正確地做到這一點。
注意,如果你有在statics
和主題這些字體由@font-face
在你的CSS定義,你可以在CKEditor的使用字體。 例如,這是它定義我farsifonts.css
,我的字體:
@font-face {
font-family: 'Droid Arabic Naskh';
font-style: normal;
font-weight: 400;
src: url('../fonts/DriodArabicNaskh/Regular/DroidNaskh-Regular.eot');
src: url('../fonts/DriodArabicNaskh/Regular/DroidNaskh-Regular.eot?#iefix') format('embedded-opentype'),
url('../fonts/DriodArabicNaskh/Regular/DroidNaskh-Regular.woff2') format('woff2'),
url('../fonts/DriodArabicNaskh/Regular/DroidNaskh-Regular.woff') format('woff'),
url('../fonts/DriodArabi.loginColumnscNaskh/Regular/DroidNaskh-Regular.ttf') format('truetype');
}
@font-face {
font-family: 'Droid Arabic Naskh';
font-style: normal;
font-weight: 700;
src: url('../fonts/DriodArabicNaskh/Bold/DroidNaskh-Bold.eot');
src: url('../fonts/DriodArabicNaskh/Bold/DroidNaskh-Bold.eot?#iefix') format('embedded-opentype'),
url('../fonts/DriodArabicNaskh/Bold/DroidNaskh-Bold.woff2') format('woff2'),
url('../fonts/DriodArabicNaskh/Bold/DroidNaskh-Bold.woff') format('woff'),
url('../fonts/DriodArabicNaskh/Bold/DroidNaskh-Bold.ttf') format('truetype');
}
@font-face {
font-family: 'Droid Arabic Kufi';
font-style: normal;
font-weight: 400;
src: url('../fonts/DroidArabicKufi/Regular/DroidKufi-Regular.eot');
src: url('../fonts/DroidArabicKufi/Regular/DroidKufi-Regular.eot?#iefix') format('embedded-opentype'),
url('../fonts/DroidArabicKufi/Regular/DroidKufi-Regular.woff2') format('woff2'),
url('../fonts/DroidArabicKufi/Regular/DroidKufi-Regular.woff') format('woff'),
url('../fonts/DroidArabicKufi/Regular/DroidKufi-Regular.ttf') format('truetype');
}
@font-face {
font-family: 'Droid Arabic Kufi';
font-style: normal;
font-weight: 700;
src: url('../fonts/DroidArabicKufi/Bold/DroidKufi-Bold.eot');
src: url('../fonts/DroidArabicKufi/Bold/DroidKufi-Bold.eot?#iefix') format('embedded-opentype'),
url('../fonts/DroidArabicKufi/Bold/DroidKufi-Bold.woff2') format('woff2'),
url('../fonts/DroidArabicKufi/Bold/DroidKufi-Bold.woff') format('woff'),
url('../fonts/DroidArabicKufi/Bold/DroidKufi-Bold.ttf') format('truetype');
}
@font-face {
font-family: 'Bnasim';
src: url('../fonts/BBCNasim/BBCNasim.eot');
src: url('../fonts/BBCNasim/BBCNasim.eot?#iefix') format('embedded-opentype');
src: local('☺'), url('../fonts/BBCNasim/BBCNasim.woff') format('woff'),
url('../fonts/BBCNasim/BBCNasim.ttf') format('truetype'),
url('../fonts/BBCNasim/BBCNasim.svg#BBCNasim') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Bkoodak';
src: url('../fonts/BKoodak/BKoodak.eot');
src: url('../fonts/BKoodak/BKoodak.eot?#iefix') format('embedded-opentype');
src: local('☺'), url('../fonts/BKoodak/BKoodak.woff') format('woff'),
url('../fonts/BKoodak/BKoodak.ttf') format('truetype'),
url('../fonts/BKoodak/BKoodak.svg#BKoodak') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Bnazanin';
src: url('../fonts/BNazanin/BNazanin.eot');
src: url('../fonts/BNazanin/BNazanin.eot?#iefix') format('embedded-opentype');
src: local('☺'), url('../fonts/BNazanin/BNazanin.woff') format('woff'),
url('../fonts/BNazanin/BNazanin.ttf') format('truetype'),
url('../fonts/BNazanin/BNazanin.svg#BNazanin') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'yekan';
src: url('../fonts/WeblogmaYekan.eot?#') format('eot'), /* IE6â€「8 */
url('../fonts/WeblogmaYekan.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/WeblogmaYekan.ttf') format('truetype'); /* Saf3â€」5, Chrome4+, FF3.5, Opera 10+ */
}
@font-face {
font-family: IRANSans;
font-style: normal;
font-weight: bold;
src: url('../fonts/iransans/eot/IRANSansWeb_Bold.eot');
src: url('../fonts/iransans/eot/IRANSansWeb_Bold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/iransans/woff2/IRANSansWeb_Bold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/iransans/woff/IRANSansWeb_Bold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/iransans/ttf/IRANSansWeb_Bold.ttf') format('truetype');
}
@font-face {
font-family: IRANSans;
font-style: normal;
font-weight: 500;
src: url('../fonts/iransans/eot/IRANSansWeb_Medium.eot');
src: url('../fonts/iransans/eot/IRANSansWeb_Medium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/iransans/woff2/IRANSansWeb_Medium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/iransans/woff/IRANSansWeb_Medium.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/iransans/ttf/IRANSansWeb_Medium.ttf') format('truetype');
}
@font-face {
font-family: IRANSans;
font-style: normal;
font-weight: 300;
src: url('../fonts/iransans/eot/IRANSansWeb_Light.eot');
src: url('../fonts/iransans/eot/IRANSansWeb_Light.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/iransans/woff2/IRANSansWeb_Light.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/iransans/woff/IRANSansWeb_Light.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/iransans/ttf/IRANSansWeb_Light.ttf') format('truetype');
}
@font-face {
font-family: IRANSans;
font-style: normal;
font-weight: 200;
src: url('../fonts/iransans/eot/IRANSansWeb_UltraLight.eot');
src: url('../fonts/iransans/eot/IRANSansWeb_UltraLight.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/iransans/woff2/IRANSansWeb_UltraLight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/iransans/woff/IRANSansWeb_UltraLight.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/iransans/ttf/IRANSansWeb_UltraLight.ttf') format('truetype');
}
@font-face {
font-family: IRANSans;
font-style: normal;
font-weight: normal;
src: url('../fonts/iransans/eot/IRANSansWeb.eot');
src: url('../fonts/iransans/eot/IRANSansWeb.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/iransans/woff2/IRANSansWeb.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/iransans/woff/IRANSansWeb.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/iransans/ttf/IRANSansWeb.ttf') format('truetype');
}
@font-face {
font-family: VazirCode;
font-style: normal;
font-weight: normal;
src: url('../fonts/vazir-code/Vazir-Code.eot');
src: url('../fonts/vazir-code/Vazir-Code.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/vazir-code/Vazir-Code.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/vazir-code/Vazir-Code.ttf') format('truetype');
}
注:你的字體沒有送達。也許你有這個列表中的一個問題:
被成功地加載的字體,即如果你在瀏覽器的開發者工具查看網絡請求的字體文件呢? – sjm
那麼你沒有正確的目錄路徑呢? – sjm