如何获取系统字体?
1.首先在需要获取系统字体的网页<body>后加入以下代码:
<DIV style="LEFT: 0px; POSITION: absolute; TOP: 0px"> <OBJECT ID="dlgHelper" CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" WIDTH="0px" HEIGHT="0px"> </OBJECT> <script src="FontFacesMenu.js" language="javascript" type="text/javascript"></script> </DIV> |
2.将以下内容保存为:FontFacesMenu.js文件。
// FontFacesMenu.js var fontsArray = new Array(); var fontsIsAdded = false; function fontFacesMenuEnter(fontFacesDropdownList, dlgHelperId) { if((fontsIsAdded == false )||(fontsArray=='''')) { fontsArray = getSystemFonts(dlgHelperId); fontsIsAdded = true; for (var s=1; s < fontsArray.length; s++) { newOption = document.createElement("option"); newOption.value = fontsArray[s]; newOption.text = fontsArray[s]; fontFacesDropdownList.add(newOption); } } } function getSystemFonts(dlgHelperId) |
系统字体:
<SELECT ID="blessingWords_FontFamily_DL" name="blessingWords_FontFamily_DL" onChange="//SetFontFace(this[this.selectedIndex].innerText,this[this.selectedIndex].value);this.selectedIndex=0;" style="width:140px;" onmouseenter="fontFacesMenuEnter(this, ''dlgHelper'');//updateFontList();"> <OPTION VALUE=""><- 设置字体 -></OPTION> </SELECT> |
4.如何将我的系统字体保存为文件?(对于端开发略有小用)
(1)如果你的服务器的字体配置与你现有电脑字体配置一样的话,使用script脚本,然后COPY至写字板或记事本,再保存。
接着上面步骤继续往下做:
(续)步骤一:将以下代码放在<Body>区内:
<textarea name="FontList" id="FontList" cols="35" rows="20" id="FontList" style="position:absolute; left:0px; top:0px; z-index:10000"></textarea> |
步骤二:
<Script> // "blessingWords_FontFamily_DL" 需要改成你自己获取系统字体下拉菜单的名字(如果你已经改过的话) var dropDownListName = "blessingWords_FontFamily_DL"; function updateFontList() { var list=""; var blessingWords_FontFamily_DL = document.all[dropDownListName]; for(i=0; i <blessingWords_FontFamily_DL.options.length; i++) { list += ''<OPTION VALUE="'' + blessingWords_FontFamily_DL.options[i].text + ''">''+ blessingWords_FontFamily_DL.options[i].text + ''</OPTION>\r\n''; } document.all("FontList").value = list; } </Script> |
步骤三:将上面第3条中最后的"//updat