Add FontShape.getRule which returns the name for the ctx object

This commit is contained in:
Julian Viereck 2011-09-13 07:59:24 -07:00
parent 86681a8d25
commit 966cbc2112
2 changed files with 16 additions and 10 deletions

View File

@ -441,6 +441,17 @@ var FontShape = (function FontShape() {
for (var name in obj) { for (var name in obj) {
this[name] = obj[name]; this[name] = obj[name];
} }
var name = this.loadedName;
var bold = this.black ? (this.bold ? 'bolder' : 'bold') :
(this.bold ? 'bold' : 'normal');
var italic = this.italic ? 'italic' : 'normal';
var serif = this.serif ? 'serif' : 'sans-serif';
var typeface = '"' + name + '", ' + serif;
this.$name1 = italic + ' ' + bold + ' ';
this.$name2 = 'px ' + typeface;
}; };
function int16(bytes) { function int16(bytes) {
@ -448,6 +459,10 @@ var FontShape = (function FontShape() {
}; };
constructor.prototype = { constructor.prototype = {
getRule: function fonts_getRule(size) {
return this.$name1 + size + this.$name2;
},
charsToUnicode: function fonts_chars2Unicode(chars) { charsToUnicode: function fonts_chars2Unicode(chars) {
var charsCache = this.charsCache; var charsCache = this.charsCache;
var str; var str;

11
pdf.js
View File

@ -4824,8 +4824,6 @@ function ScratchCanvas(width, height) {
} }
var CanvasGraphics = (function() { var CanvasGraphics = (function() {
var kScalePrecision = 50;
var kRasterizerMin = 14;
var kExecutionTime = 50; var kExecutionTime = 50;
var kExecutionTimeCheck = 500; var kExecutionTimeCheck = 500;
@ -5127,14 +5125,7 @@ var CanvasGraphics = (function() {
if (this.ctx.$setFont) { if (this.ctx.$setFont) {
this.ctx.$setFont(name, size); this.ctx.$setFont(name, size);
} else { } else {
var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') : this.ctx.font = fontObj.getRule(size);
(fontObj.bold ? 'bold' : 'normal');
var italic = fontObj.italic ? 'italic' : 'normal';
var serif = fontObj.serif ? 'serif' : 'sans-serif';
var typeface = '"' + name + '", ' + serif;
var rule = italic + ' ' + bold + ' ' + size + 'px ' + typeface;
this.ctx.font = rule;
} }
}, },
setTextRenderingMode: function(mode) { setTextRenderingMode: function(mode) {