Skip to content

Commit 9d533dd

Browse files
committed
Forgot to commit new glyph.js
1 parent a67b76e commit 9d533dd

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

www/font_info.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<link rel="stylesheet" href="css/blitzer/jquery-ui-1.8.14.custom.css" />
1313
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
1414
<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
15-
<script type="text/javascript" src="js/glyph.js?v=3"></script>
15+
<script type="text/javascript" src="js/glyph.js?v=4"></script>
1616
<script type="text/javascript">
1717
$(function() {
1818
$("#tabs").tabs({

www/js/glyph.js

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
var Glyph = {
2+
glyphs: [],
23
ratio: null,
34
head: null,
45
os2: null,
5-
hmtx: null,
6-
7-
midValue: function (a, b){
8-
return a + (b - a)/2;
9-
},
6+
hmtx: null,
7+
width: null,
8+
height: null,
9+
scale: 1.0,
1010

1111
splitPath: function(path) {
1212
return path.match(/([a-z])|(-?\d+(?:\.\d+)?)/ig);
@@ -60,7 +60,6 @@ var Glyph = {
6060
return;
6161
}
6262

63-
6463
var contour, path, transform;
6564

6665
for (var ci = 0, cl = contours.length; ci < cl; ci++) {
@@ -88,14 +87,16 @@ var Glyph = {
8887
var element = canvas[0];
8988
var ctx = element.getContext("2d");
9089
var ratio = Glyph.ratio;
91-
Glyph.width = element.width;
92-
Glyph.height = element.height;
93-
94-
ctx.lineWidth = ratio;
90+
var width = Glyph.width * Glyph.scale;
91+
var height = Glyph.height * Glyph.scale;
92+
ctx.clearRect(0, 0, width, height);
93+
94+
ctx.lineWidth = ratio / Glyph.scale;
9595

9696
// Invert axis
97-
ctx.translate(0, Glyph.height);
97+
ctx.translate(0, height);
9898
ctx.scale(1/ratio, -(1/ratio));
99+
ctx.scale(Glyph.scale, Glyph.scale);
99100

100101
ctx.translate(0, -Glyph.head.yMin);
101102

@@ -114,7 +115,7 @@ var Glyph = {
114115
var s = ratio*3;
115116

116117
ctx.strokeStyle = "rgba(0,0,0,0.5)";
117-
ctx.lineWidth = ratio * 1.5;
118+
ctx.lineWidth = (ratio * 1.5) / Glyph.scale;
118119

119120
// origin
120121
ctx.beginPath();
@@ -151,5 +152,24 @@ var Glyph = {
151152
//ctx.globalCompositeOperation = "xor";
152153

153154
Glyph.drawSVGContours(ctx, shape.SVGContours);
155+
},
156+
drawAll: function(){
157+
$.each(Glyph.glyphs, function(i, g){
158+
Glyph.draw($('#glyph-'+g[0]), g[1], g[0]);
159+
});
160+
},
161+
resize: function(value){
162+
Glyph.scale = value / 100;
163+
164+
$.each(document.getElementsByTagName('canvas'), function(i, canvas){
165+
canvas.height = Glyph.height * Glyph.scale;
166+
canvas.width = Glyph.width * Glyph.scale;
167+
});
168+
169+
Glyph.drawAll();
154170
}
155-
};
171+
};
172+
173+
$(function(){
174+
Glyph.drawAll();
175+
});

0 commit comments

Comments
 (0)