Requires

Provides

Fonts for ART, implements code from [Cufón](http://cufon.shoqolate.com/)

Authors:
[Simo Kinnunen](http://twitter.com/sorccu), [Valerio Proietti](http://mad4milk.net/)
  1. 12
  2. 13
  3. 14
  4. 15
  5. 16
  6. 17
  7. 18
  8. 19
  9. 20
  10. 21
  11. 22
  12. 23
  13. 24
  14. 25
  15. 26
  16. 27
  17. 28
  18. 29
  19. 30
  20. 31
  21. 32
  22. 33
  23. 34
  24. 35
  25. 36
  26. 37
  27. 38
  28. 39
  29. 40
  30. 41
  31. 42
  32. 43
  33. 44
  34. 45
  35. 46
  36. 47
  37. 48
  38. 49
  39. 50
  40. 51
  41. 52
  42. 53
  43. 54
  44. 55
  45. 56
  46. 57
  47. 58
  48. 59
  49. 60
  50. 61
  51. 62
  52. 63
  53. 64
  54. 65
  55. 66
  56. 67
  57. 68
  58. 69
  59. 70
  60. 71
  61. 72
  62. 73
  63. 74
  64. 75
  65. 76
  66. 77
  67. 78
  68. 79
  69. 80
  70. 81
  71. 82
  72. 83
  73. 84
  74. 85
  75. 86
  76. 87
  77. 88
  78. 89
  79. 90
(function(){ var fonts = {}; ART.registerFont = function(font){ var face = font.face, family = face['font-family'], weight = (face['font-weight'] > 400 ? 'bold' : 'normal'), style = (face['font-stretch'] == 'oblique' ? 'italic' : 'normal'); fonts[weight + style + name] = font; return this; }; var VMLToSVG = function(path, s, x, y){ var end = ''; var regexp = /([mrvxe])([^a-z]*)/g, match; while ((match = regexp.exec(path))){ var c = match[2].split(','); switch (match[1]){ case 'v': end += 'c ' + (s * c[0]) + ',' + (s * c[1]) + ',' + (s * c[2]) + ',' + (s * c[3]) + ',' + (s * c[4]) + ',' + (s * c[5]); break; case 'r': end += 'l ' + (s * c[0]) + ',' + (s * c[1]); break; case 'm': end += 'M ' + (x + (s * c[0])) + ',' + (y + (s * c[1])); break; case 'x': end += 'z'; break; } } return end; }; var parseFontString = function(font){ var regexp = /^\s*((?:(?:normal|bold|italic)\s+)*)(?:(\d+(?:\.\d+)?)[ptexm\%]*(?:\s*\/.*?)?\s+)?\s*\"?([^\"]*)/i, match = regexp.exec(font); return { fontFamily: match[3], fontSize: match[2], fontStyle: (/italic/.exec(match[1]) || ''), fontWeight: (/bold/.exec(match[1]) || '') }; }; ART.Font = new Class({ Extends: ART.Shape, initialize: function(text, font){ this.parent(); if (text != null && font != null) this.draw(text, font); }, draw: function(text, font){ if (typeof font == 'string') font = parseFontString(font); var family = font.fontFamily || font['font-family'], weight = font.fontWeight || font['font-weight'] || 'normal', style = font.fontStyle || font['font-style'] || 'normal', size = parseFloat(font.fontSize || font['font-size'] || font.size); font = font.glyphs ? font : fonts[weight + style + name]; if (!font) throw new Error('The specified font has not been found.'); size = size / font.face['units-per-em']; var width = 0, height = size * font.face.ascent, path = ''; for (var i = 0, l = text.length; i < l; ++i){ var glyph = font.glyphs[text.charAt(i)] || font.glyphs[' ']; var w = size * (glyph.w || font.w); if (glyph.d) path += VMLToSVG('m' + glyph.d + 'x', size, width, height); width += w; } height -= size * font.face.descent; return this.parent(path, width, height); } }); })();