Fix font and spaces

This commit is contained in:
Artur Adib 2011-11-08 16:05:11 -05:00
parent 9ebec03ddc
commit 686f275830

View File

@ -494,9 +494,7 @@ var CanvasGraphics = (function canvasGraphics() {
var fontHeight = text.geom.vScale * fontSize;
div.style.fontSize = fontHeight + 'px';
// TODO: family should be '= font.loadedName', but some fonts don't
// have spacing info (cf. fonts.js > Font > fields > htmx)
div.style.fontFamily = 'serif';
div.style.fontFamily = this.current.font.loadedName || 'serif';
div.style.left = text.geom.x + 'px';
div.style.top = (text.geom.y - fontHeight) + 'px';
div.innerHTML = text.str;
@ -560,8 +558,8 @@ var CanvasGraphics = (function canvasGraphics() {
current.x += charWidth;
text.str += unicodeToChar(glyph.unicode);
text.canvasWidth += charWidth;
text.length++;
text.canvasWidth += charWidth;
}
ctx.restore();
} else {
@ -582,9 +580,9 @@ var CanvasGraphics = (function canvasGraphics() {
ctx.fillText(char, width, 0);
width += charWidth;
text.str += char;
text.canvasWidth += charWidth;
text.str += char === ' ' ? ' ' : char;
text.length++;
text.canvasWidth += charWidth;
}
current.x += width;