Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何(以编程方式)将google字体添加到ckeditor_Javascript_Html_Ckeditor_Google Webfonts - Fatal编程技术网

Javascript 如何(以编程方式)将google字体添加到ckeditor

Javascript 如何(以编程方式)将google字体添加到ckeditor,javascript,html,ckeditor,google-webfonts,Javascript,Html,Ckeditor,Google Webfonts,我刚刚下载了CKEditor,它很棒。虽然我注意到它会使字体松弛。 因此,我认为能够将Google Web字体添加到CKEditor以增加其功能是一个好主意 我在网上搜索过,但我只能找到如何手动进入并在config.js文件中添加每种字体 有人能帮我以编程方式将所有Google Web字体添加到CKEditor并演示如何添加。您可以使用脚本语言使用开发者API拉入所有Google Web字体的列表,并自动生成CKEditor配置行 要使用API,您需要一个API密钥 要获取API密钥,请访问。在

我刚刚下载了CKEditor,它很棒。虽然我注意到它会使字体松弛。 因此,我认为能够将Google Web字体添加到CKEditor以增加其功能是一个好主意

我在网上搜索过,但我只能找到如何手动进入并在config.js文件中添加每种字体


有人能帮我以编程方式将所有Google Web字体添加到CKEditor并演示如何添加。

您可以使用脚本语言使用开发者API拉入所有Google Web字体的列表,并自动生成CKEditor配置行

要使用API,您需要一个API密钥

要获取API密钥,请访问。在服务窗格中,激活GoogleWebFonts开发者API;如果出现服务条款,请阅读并接受

接下来,转到API访问窗格。API键位于该窗格底部附近,标题为“简单API访问”的部分

拥有API密钥后,应用程序可以将查询参数key=yourAPIKey附加到所有请求URL

API密钥对于嵌入URL是安全的;它不需要任何编码


webfonts的端点是,它返回一个JSON响应,因此,例如,您可以在请求中使用jQuery来实现ajax,并迭代对象,构建配置行,然后复制并粘贴它。

好的,我找到了答案。我把它贴在这里,这样它可以帮助任何其他人谁寻找相同的。这就是:

myFonts = ['Aclonica', 'Allan', 'Allerta', 'Allerta Stencil', 'Amaranth', 'Angkor', 'Annie Use Your Telescope', 'Anonymous Pro', 'Anton', 'Architects Daughter', 'Arimo', 'Artifika', 'Arvo', 'Astloch', 'Bangers', 'Battambang', 'Bayon', 'Bentham', 'Bevan', 'Bigshot One', 'Bokor', 'Brawler', 'Buda', 'Cabin', 'Cabin Sketch', 'Calligraffitti', 'Candal', 'Cantarell', 'Cardo', 'Carter One', 'Caudex', 'Chenla', 'Cherry Cream Soda', 'Chewy', 'Coda', 'Coda Caption', 'Coming Soon', 'Content', 'Copse', 'Corben', 'Cousine', 'Covered By Your Grace', 'Crafty Girls', 'Crimson Text', 'Crushed', 'Cuprum', 'Damion', 'Dancing Script', 'Dangrek', 'Dawning of a New Day', 'Didact Gothic', 'Droid Sans', 'Droid Sans Mono', 'Droid Serif', 'EB Garamond', 'Expletus Sans', 'Fontdiner Swanky', 'Francois One', 'Freehand', 'GFS Didot', 'GFS Neohellenic', 'Geo', 'Goudy Bookletter 1911', 'Gruppo', 'Handlee', 'Hanuman', 'Holtwood One SC', 'Homemade Apple', 'IM Fell DW Pica', 'IM Fell DW Pica SC', 'IM Fell Double Pica', 'IM Fell Double Pica SC', 'IM Fell English', 'IM Fell English SC', 'IM Fell French Canon', 'IM Fell French Canon SC', 'IM Fell Great Primer', 'IM Fell Great Primer SC', 'Inconsolata', 'Indie Flower', 'Irish Grover', 'Josefin Sans', 'Josefin Slab', 'Judson', 'Jura', 'Just Another Hand', 'Just Me Again Down Here', 'Kenia', 'Khmer', 'Koulen', 'Kranky', 'Kreon', 'Kristi', 'Lato', 'League Script', 'Lekton', 'Limelight', 'Lobster', 'Lora', 'Luckiest Guy', 'Maiden Orange', 'Mako', 'Maven Pro', 'Meddon', 'MedievalSharp', 'Megrim', 'Merriweather', 'Metal', 'Metrophobic', 'Michroma', 'Miltonian', 'Miltonian Tattoo', 'Molengo', 'Monofett', 'Moul', 'Moulpali', 'Mountains of Christmas', 'Muli', 'Neucha', 'Neuton', 'News Cycle', 'Nobile', 'Nova Cut', 'Nova Flat', 'Nova Mono', 'Nova Oval', 'Nova Round', 'Nova Script', 'Nova Slim', 'Nova Square', 'Nunito', 'OFL Sorts Mill Goudy TT', 'Odor Mean Chey', 'Old Standard TT', 'Open Sans', 'Open Sans Condensed', 'Orbitron', 'Oswald', 'Over the Rainbow', 'PT Sans', 'PT Sans Caption', 'PT Sans Narrow', 'PT Serif', 'PT Serif Caption', 'Pacifico', 'Paytone One', 'Permanent Marker', 'Philosopher', 'Play', 'Playfair Display', 'Podkova', 'Preahvihear', 'Puritan', 'Quattrocento', 'Quattrocento Sans', 'Radley', 'Raleway', 'Reenie Beanie', 'Rock Salt', 'Rokkitt', 'Ruslan Display', 'Schoolbell', 'Shanti', 'Siemreap', 'Sigmar One', 'Six Caps', 'Slackey', 'Smythe', 'Sniglet', 'Special Elite', 'Sue Ellen Francisco', 'Sunshiney', 'Suwannaphum', 'Swanky and Moo Moo', 'Syncopate', 'Tangerine', 'Taprom', 'Tenor Sans', 'Terminal Dosis Light', 'The Girl Next Door', 'Tinos', 'Ubuntu', 'Ultra', 'UnifrakturCook', 'UnifrakturMaguntia', 'Unkempt', 'VT323', 'Vibur', 'Vollkorn', 'Waiting for the Sunrise', 'Wallpoet', 'Walter Turncoat', 'Wire One', 'Yanone Kaffeesatz'];

config.font_names = 'serif;sans serif;monospace;cursive;fantasy';

for(var i = 0; i<myFonts.length; i++){
            config.font_names = config.font_names+';'+myFonts[i];
            myFonts[i] = 'http://fonts.googleapis.com/css?family='+myFonts[i].replace(' ','+');
}

config.contentsCss = ['/ckeditor/contents.css'].concat(myFonts);
myFonts=['Aclonica','Allan','Allerta','Allerta Stencil','Amaranth','Angkor','Annie Use Your Telescope','Anonymous Pro','Anton','Architects Kirl','Armo','Artifika','Arvo','Astloch','Bangers','Maddambang','Bayon','Bentham','Bevan Bigshot One','Bokor','Brawler','Buda','Cabin','Cabines Sketch','s','Calligraffll、Cardo、Carter One、Caudex、Chenla、Cherry奶油苏打水、Chewy、Coda、Coda Caption、即将到来、Content、Copse、Corben、Cousine、蒙上您的恩典、狡猾的女孩、深红色文字、压碎的、Cuprum、Damion、舞蹈脚本、Dangrek、新的一天的黎明、Didact哥特式、Droid、Sans Droid Sans Mono、,“Droid Serif”、“EB Garamond”、“Expretus Sans”、“Fontdiner Swanky”、“Francois One”、“Freehand”、“GFS Didot”、“GFS Neohellenic”、“Geo”、“Goudy小册子1911”、“Gruppo”、“Handlee”、“Hanuman”、“Holtwood One SC”、“自制苹果”、“IM Fall DW Pica”、“IM Fall DW Pica SC”、“IM Fall Double Pica”、“IM Fall Double Pica SC”、“IM Fall English”、“IM Fall English”、“IM Fall Eng”《英语SC》,《我爱上了法国佳能》,《我爱上了法国佳能SC》,《我爱上了伟大的初级读物》,《Incolata》,《独立之花》,《爱尔兰格罗弗》,《约瑟芬·桑》,《约瑟芬史板》,《朱德森》,《朱拉》,《只是另一只手》,《我又来了》,《凯尼亚》,《高棉》,《库伦》,《克伦》,《克伦》,《克里斯蒂》,《拉托》,《联盟剧本》,《莱克顿》,‘聚光灯’、‘龙虾’、‘劳拉’、‘最幸运的家伙’、‘处女橙’、‘Mako’、‘Maven Pro’、‘Meddon’、‘MedievalSharp’、‘Megrim’、‘Merriweather’、‘Metal’、‘Metrophobic’、‘Michroma’、‘Miltonian’、‘Miltonian纹身’、‘Molengo’、‘Moul’、‘Moulpali’、‘圣诞山’、‘Muli’、‘Neucha’、‘Neuton’、‘新闻周刊’、‘Nobile’at、Nova Mono、Nova Oval、Nova Round、Nova Script、Nova Slim、Nova Square、Nunito、OFL Sorts Mill Goudy TT、气味代表Chey、旧标准TT、开放式SAN、开放式SAN、开放式SAN Condensed、Orbitron、Oswald、Over the Rainbow、PT Sans、PT Sans Caption、PT Sans Shorrow、PT Serif、PT Serif、PT Serif Caption、Pacifico、Paytone、P“永久标记”、“哲学家”、“游戏”、“游乐场展示”、“波德科娃”、“普雷维海尔”、“清教徒”、“四世纪”、“四世纪圣人”、“雷德利”、“雷威”、“瑞妮·比尼”、“岩盐”、“罗基特”、“罗斯兰展示”、“学钟”、“山蒂”、“西姆雷普”、“西格玛一号”、“六顶帽子”、“懒鬼”、“斯迈思”、“斯奈特莱特”、“特殊精英”、“苏·埃伦·弗朗西斯科”,‘阳光’、‘苏万纳蓬’、‘时髦与穆穆穆奥’、‘切分音’、‘橘子’、‘塔普罗姆’、‘男高音’、‘终端剂量光’、‘隔壁女孩’、‘蒂诺斯’、‘Ubuntu’、‘Ultra’、‘UnifrakturCook’、‘UnifrakturMaguntia’、‘蓬头垢面’、‘VT323’、‘Vibur’、‘Vollkorn’、‘等待日出’、‘Wallpother’、‘沃特Turncoat’、‘Wire One’、‘Yanone Kaffeesatz’;
config.font_names='serif;sans serif;monospace;草书;fantasy';

for(var i=0;我很感谢你的回复,但我才刚开始学习javascript。有没有可能帮我编写代码?嘿,当然,我写了拉它的代码,给我发封电子邮件daniel[at]buildhq.coThanks mate,我刚刚给你发了一封电子邮件。非常感谢你的帮助。干杯!它对我有用,但我收到一个错误,格式下拉列表中缺少其他字体。“拒绝从“”应用样式,因为它的MIME类型('text/html')不是受支持的样式表MIME类型,并且启用了严格的MIME检查。”