1,准备要素
1)替换字体的js文件
js代码:
function com_stewartspeak_replacement() { /* Dynamic Heading Generator By Stewart Rosenberger http://www.stewartspeak.com/headings/ This script searches through a web page for specific or general elements and replaces them with dynamically generated images, in conjunction with a server-side script. */ replaceSelector("h1","dynatext/heading.php",true);//前两个参数需要修改 var testURL = "dynatext/loading.gif" ;//修改为对应的图片路径 var doNotPrintImages = false; var printerCSS = "replacement-print.css"; var hideFlicker = false; var hideFlickerCSS = "replacement-screen.css"; var hideFlickerTimeout = 100;//这里可以做相应的修改 /* --------------------------------------------------------------------------- For basic usage, you should not need to edit anything below this comment. If you need to further customize this script's abilities, make sure you're familiar with Javascript. And grab a soda or something. */ var items; var imageLoaded = false; var documentLoaded = false; function replaceSelector(selector,url,wordwrap) { if(typeof items == "undefined") items = new Array(); items[items.length] = {selector: selector, url: url, wordwrap: wordwrap}; } if(hideFlicker) { document.write('<link id="hide-flicker" rel="stylesheet" media="screen" href="' + hideFlickerCSS + '" />'); window.flickerCheck = function() { if(!imageLoaded) setStyleSheetState('hide-flicker',false); }; setTimeout('window.flickerCheck();',hideFlickerTimeout) } if(doNotPrintImages) document.write('<link id="print-text" rel="stylesheet" media="print" href="' + printerCSS + '" />'); var test = new Image(); test.onload = function() { imageLoaded = true; if(documentLoaded) replacement(); }; test.src = testURL + "" + (new Date()).getTime(); addLoadHandler(function(){ documentLoaded = true; if(imageLoaded) replacement(); }); function documentLoad() { documentLoaded = true; if(imageLoaded) replacement(); } function replacement() { for(var i=0;i<items.length;i++) { var elements = getElementsBySelector(items[i].selector); if(elements.length > 0) for(var j=0;j<elements.length;j++) { if(!elements[j]) continue ; var text = extractText(elements[j]); while(elements[j].hasChildNodes()) elements[j].removeChild(elements[j].firstChild); var tokens = items[i].wordwrap ""+escape(tokens[k]+' ')+"&selector="+escape(items[i].selector); var image = document.createElement("img"); image.className = "replacement"; image.alt = tokens[k] ; image.src = url; elements[j].appendChild(image); } if(doNotPrintImages) { var span = document.createElement("span"); span.style.display = 'none'; span.className = "print-text"; span.appendChild(document.createTextNode(text)); elements[j].appendChild(span); } } } if(hideFlicker) setStyleSheetState('hide-flicker',false); } function addLoadHandler(handler) { if(window.addEventListener) { window.addEventListener("load",handler,false); } else if(window.attachEvent) { window.attachEvent("onload",handler); } else if(window.onload) { var oldHandler = window.onload; window.onload = function piggyback() { oldHandler(); handler(); }; } else { window.onload = handler; } } function setStyleSheetState(id,enabled) { var sheet = document.getElementById(id); if(sheet) sheet.disabled = (!enabled); } function extractText(element) { if(typeof element == "string") return element; else if(typeof element == "undefined") return element; else if(element.innerText) return element.innerText; var text = ""; var kids = element.childNodes; for(var i=0;i<kids.length;i++) { if(kids[i].nodeType == 1) text += extractText(kids[i]); else if(kids[i].nodeType == 3) text += kids[i].nodeValue; } return text; } /* Finds elements on page that match a given CSS selector rule. Some complicated rules are not compatible. Based on Simon Willison's excellent "getElementsBySelector" function. Original code (with comments and description): http://simon.incutio.com/archive/2003/03/25/getElementsBySelector */ function getElementsBySelector(selector) { var tokens = selector.split(' '); var currentContext = new Array(document); for(var i=0;i<tokens.length;i++) { token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,''); if(token.indexOf('#') > -1) { var bits = token.split('#'); var tagName = bits[0]; var id = bits[1]; var element = document.getElementById(id); if(tagName && element.nodeName.toLowerCase() != tagName) return new Array(); currentContext = new Array(element); continue; } if(token.indexOf('.') > -1) { var bits = token.split('.'); var tagName = bits[0]; var className = bits[1]; if(!tagName) tagName = '*'; var found = new Array; var foundCount = 0; for(var h=0;h<currentContext.length;h++) { var elements; if(tagName == '*') elements = currentContext[h].all ""]*)""htmlcode"><"dip" (pixels dropped below baseline) of this font for this size. */ function get_dip($font,$size) { $test_chars = 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . '1234567890' . '!@#$%^&*()\'"\\/;.,`~<>[]{}-+_-=' ; $box = @ImageTTFBBox($size,0,$font,$test_chars) ; return $box[3] ; } /* attempt to create an image containing the error message given. if this works, the image is sent to the browser. if not, an error is logged, and passed back to the browser as a 500 code instead. */ function fatal_error($message) { // send an image if(function_exists('ImageCreate')) { $width = ImageFontWidth(5) * strlen($message) + 10 ; $height = ImageFontHeight(5) + 10 ; if($image = ImageCreate($width,$height)) { $background = ImageColorAllocate($image,255,255,255) ; $text_color = ImageColorAllocate($image,0,0,0) ; ImageString($image,5,5,5,$message,$text_color) ; header('Content-type: image/png') ; ImagePNG($image) ; ImageDestroy($image) ; exit ; } } // send 500 code header("HTTP/1.0 500 Internal Server Error") ; print($message) ; exit ; } /* decode an HTML hex-code into an array of R,G, and B values. accepts these formats: (case insensitive) #ffffff, ffffff, #fff, fff */ function hex_to_rgb($hex) { // remove '#' if(substr($hex,0,1) == '#') $hex = substr($hex,1) ; // expand short form ('fff') color if(strlen($hex) == 3) { $hex = substr($hex,0,1) . substr($hex,0,1) . substr($hex,1,1) . substr($hex,1,1) . substr($hex,2,1) . substr($hex,2,1) ; } if(strlen($hex) != 6) fatal_error('Error: Invalid color "'.$hex.'"') ; // convert $rgb['red'] = hexdec(substr($hex,0,2)) ; $rgb['green'] = hexdec(substr($hex,2,2)) ; $rgb['blue'] = hexdec(substr($hex,4,2)) ; return $rgb ; } /* convert embedded, javascript unicode characters into embedded HTML entities. (e.g. '%u2018' => '‘'). returns the converted string. */ function javascript_to_html($text) { $matches = null ; preg_match_all('/%u([0-9A-F]{4})/i',$text,$matches) ; if(!empty($matches)) for($i=0;$i<sizeof($matches[0]);$i++) $text = str_replace($matches[0][$i], '&#'.hexdec($matches[1][$i]).';',$text) ; return $text ; } "htmlcode">
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“使用PHP+JavaScript将HTML页面转换为图片的实例分享”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新动态
2024年11月16日
2024年11月16日
- 那英《如今》引进版[WAV+CUE][1G]
- 蔡幸娟.1991-真的让我爱你吗【飞碟】【WAV+CUE】
- 群星.2024-好团圆电视剧原声带【TME】【FLAC分轨】
- 陈思安.1990-国语钢琴酒吧5CD【欣代唱片】【WAV+CUE】
- 莫文蔚《莫后年代20周年世纪典藏》3CD[WAV+CUE][2G]
- 张惠妹《我要快乐》华纳[WAV+CUE][1G]
- 罗大佑1982《之乎者也》无法盗版的青春套装版 [WAV+CUE][1G]
- 曾庆瑜1989-款款柔情[日本东芝版][WAV+CUE]
- Scelsi-IntegraledesquatuorsacordesetTrioacordes-QuatuorMolinari(2024)[24bit-WAV]
- 房东的猫2017-房东的猫[科文音像][WAV+CUE]
- 杨乃文.2016-离心力(引进版)【亚神音乐】【WAV+CUE】
- 群星.2024-珠帘玉幕影视原声带【TME】【FLAC分轨】
- 芝麻龙眼.2008-光阴隧道民歌记录3CD【乡城】【WAV+CUE】
- 谭艳《再度重相逢HQII》头版限量[低速原抓WAV+CUE][549M]
- ABC唱片《蔡琴三十周年纪念版》6N纯银镀膜 [WAV+CUE][1.1G]