我已經簽出此主題:Google Fonts and TinyMCE,事實上以前甚至已成功將新字體添加到用戶的TinyMCE字體選項。將新字體添加到TinyMCE字體選項
但我不確定這裏出了什麼問題,爲什麼我不能再這樣做了。我正在嘗試添加一個新字體,Samman
,我剛剛從MyFonts.com獲得。
在我的TinyMCE的初始化,包括我這樣的:
content_css : "css/fonts.css,css/userdesigntool.css,http://fonts.googleapis.com/css?family=Paytone+One,http://fonts.googleapis.com/css?family=Aclonica",
css/fonts.css
就是我所描述的新字體。在這個文件中,我只是保存在我的fonts/css
文件夾我的服務器上的新字體列出如下:
@font-face {
font-family: 'sammanregular';
src: url('fonts/samman/samman-webfont.eot');
src: url('fonts/samman/samman-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/samman/samman-webfont.woff') format('woff'),
url('fonts/samman/samman-webfont.ttf') format('truetype'),
url('fonts/samman/samman-webfont.svg#sammanregular') format('svg');
font-weight: normal;
font-style: normal;
}
我得到了這些產生過字體,松鼠(因爲我已經成功地與其他字體之前完成),以及我仔細檢查過,以確保文件實際上處於預期的路徑上,並且它們是。
在TinyMCE的初始化theme_advanced_fonts
進入,我有這樣的:
theme_advanced_fonts : tm_fonts,
// some more stuff below
凡tm_fonts
是我的javascript這樣描述一個變量:
var tm_fonts = "Andale Mono=andale mono,times;"+
"Arial=arial,helvetica,sans-serif;"+
"Arial Black=arial black,avant garde;"+
"Book Antiqua=book_antiquaregular,palatino;"+
"Corda Light=CordaLight,sans-serif;"+
"Courier New=courier_newregular,courier;"+
"Flexo Caps=FlexoCapsDEMORegular;"+
"Lucida Console=lucida_consoleregular,courier;"+
"Georgia=georgia,palatino;"+
"Helvetica=helvetica;"+
"Impact=impactregular,chicago;"+
"Museo Slab=MuseoSlab500Regular,sans-serif;"+
"Museo Sans=MuseoSans500Regular,sans-serif;"+
"Oblik Bold=OblikBoldRegular;"+
"Sofia Pro Light=SofiaProLightRegular;"+
"Symbol=webfontregular;"+
"Tahoma=tahoma,arial,helvetica,sans-serif;"+
"Terminal=terminal,monaco;"+
"Tikal Sans Medium=TikalSansMediumMedium;"+
"Times New Roman=times new roman,times;"+
"Trebuchet MS=trebuchet ms,geneva;"+
"Verdana=verdana,geneva;"+
"Webdings=webdings;"+
"Wingdings=wingdings,zapf dingbats"+
"Aclonica=Aclonica, sans-serif;"+
"Michroma=Michroma;"+
"Paytone One=Paytone One, sans-serif;"+
"Andalus=andalusregular, sans-serif;"+
"Arabic Style=b_arabic_styleregular, sans-serif;"+
"Andalus=andalusregular, sans-serif;"+
"KACST_1=kacstoneregular, sans-serif;"+
"Mothanna=mothannaregular, sans-serif;"+
"Nastaliq=irannastaliqregular, sans-serif;"+
"Samman=sammanregular;";
現在發生的事情是,Samman
做在用戶可以在TinyMCE中選擇的字體列表中顯示出來,但是當我選擇這種字體時文本沒有任何反應,文本保持在它正在使用的任何現有字體上。
當我使用瀏覽器的調試器時,果然我可以看到TinyMCE的iframe確實包含提及Samman的css/fonts.css
文件。但是當我改變TinyMCE中的字體時,我可以在調試器中看到span
風格的font-family
這個文本沒有改變。如果我選擇另一種字體,則span
樣式會更改,但如果我選擇Samman
,則不會發生任何情況。
因爲我添加了字體,所以也許我只是忘記了一些東西而已經有一段時間了?但我似乎無法弄清楚。
你剛剛救了我的命,謝謝! (: –
如果你碰巧使用TinyMCE 4.x將theme_advanced_fonts更改爲'font_formats'按照http://www.tinymce.com/wiki.php/Configuration:font_formats –