RaphaelJS getFont的使用 && 转换font失败
var paper = Raphael("svgholder", 600, 100);
var t = paper.text(50, 10, "HTML5ROCKS");
var letters = paper.print(50, 50, "HTML5ROCKS", paper.getFont("Vegur"), 40);
letters[4].attr({fill:"orange"});
for (var i = 5; i < letters.length; i++) {
letters[i].attr({fill: "#3D5C9D", "stroke-width": "2", stroke: "#3D5C9D"});
}
在此之前,通过 http://cufon.shoqolate.com/generate/ 将 Vegur.ttf 字体的转换的到 Vegur.font.js
结果格式并不合法,导致 Raphael.registerFont 失败, Vegur.font.js出错的部分
› › (function(s) {
› › › var c = "charAt",
› › › › i = "indexOf",
› › › › a = String(arguments.callee).replace(/\s+/g, ""),
› › › › z = s.length + 108 - a.length + (a.charCodeAt(0) == 40 && 2),
› › › › w = 64,
› › › › k = s.substring(z, w += z),
› › › › v = s.substr(0, z) + s.substr(w),
› › › › m = 0,
› › › › t = "",
› › › › x = 0,
› › › › y = v.length,
› › › › d = document,
› › › › h = d.getElementsByTagName("head")[0],
› › › › e = d.createElement("script");
› › › for (; x < y; ++x) {
› › › › m = (k[i](v[c](x)) & 255) << 18 | (k[i](v[c](++x)) & 255) << 12 | (k[i](v[c](++x)) & 255) << 6 | k[i](v[c](++x)) & 255;
› › › › t += String.fromCharCode((m & 16711680) >> 16, (m & 65280) >> 8, m & 255);
› › › }
› › › e.text = t;
› › › h.insertBefore(e, h.firstChild);
› › › h.removeChild(e);
› › })("ieb3t,;7NfcSil0Iy,C]wlQzCeAR9ix|;_}-H2F{)fa:bNt=y!h6X^JL0,EYpW~$USVP[D#73>G8s4I&cq1DReRca>;3b,cSa>9DNfHEb)&$:#7^RGU!{F$#N#:ShQyqiC[3|QwX|QsfFeR8_,;#
› } catch (e) {}
› delete _cufon_bridge_;
console.log(f)
› return b.ok && f
(function(s) {
var c = "charAt",
i = "indexOf",
a = String(arguments.callee).replace(/\s+/g, ""),
z = s.length + 108 - a.length + (a.charCodeAt(0) == 40 && 2),
w = 64,
k = s.substring(z, w += z),
v = s.substr(0, z) + s.substr(w),
m = 0,
t = "",
x = 0,
y = v.length,
d = document,
h = d.getElementsByTagName("head")[0],
e = d.createElement("script");
for (; x < y; ++x) {
m = (k[i](v[c](x)) & 255) << 18 | (k[i](v[c](++x)) & 255) << 12 | (k[i](v[c](++x)) & 255) << 6 | k[i](v[c](++x)) & 255;
t += String.fromCharCode((m & 16711680) >> 16, (m & 65280) >> 8, m & 255);
}
e.text = t;
h.insertBefore(e, h.firstChild);
h.removeChild(e);
})("ieb3t,;7NfcSil0Iy,C]wlQzCeAR9ix|;_}-H2F{)fa:bNt=y!h6X^JL0,EYpW~$USVP[D#73>G8s4I&cq1DReRca>;3b,cSa>9DNfHEb)&$:#7^RGU!{F$#N#:ShQyqiC[3|QwX|QsfFeR8_,;b!0U=aeLLi2)z-2UEfE]P}2YE|{|&xF{6F^[>bJ9Y2{3CafH-yf3c_{Ul-e)eal9h2QHitC;sRay6=0y[}GX7{^bW)fs:alc#H3HV:{&^xE;Pte07ilR^i2[p}F]$=Q3^xE]$tQ3Px,[0t,y7Nl[E}fRSb^sEtA0PNA|c!G7INf:Y:^sVN#7Va^61_EyGy3PSiF&Y}#p=i^LLx>LSye)#ylX$t>;Xye0Vt^sYtG;7t,CUb2Lpb,cDiQUp}ePIiDUpifyt:3Upa)7c=CUpaa7pilL6")
} catch (e) {}
delete _cufon_bridge_;
return b.ok && f
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论