break;
case "TrueType":
- // TrueType is disabled for the moment since the sanitizer prevent it
- // from loading because of an overdated cmap table
- return Fonts[aName] = {
- data: null,
- properties: {
- encoding: {},
- charset: null
- },
- loading: false,
- cache: Object.create(null)
- };
-
this.mimetype = "font/opentype";
var ttf = new TrueType(aFile);
this.font = ttf.data;
document.body.appendChild(canvas);
// Retrieve font charset
- var charset = Fonts[fontName].charset || [];
+ var charset = Fonts[fontName].properties.charset || [];
// if the charset is too small make it repeat a few times
var count = 30;
while (count-- && charset.length <= 30)
}
}
ctx.font = "bold italic 20px " + fontName + ", Symbol, Arial";
- var textWidth = ctx.measureText(testString);
+ var textWidth = ctx.measureText(testString).width;
if (debug)
ctx.fillText(testString, 20, 20);
window.clearInterval(interval);
Fonts[fontName].loading = false;
warn("Is " + fontName + " for charset: " + charset + " loaded?");
- } else if (textWidth != ctx.measureText(testString)) {
+ } else if (textWidth != ctx.measureText(testString).width) {
window.clearInterval(interval);
Fonts[fontName].loading = false;
}
// Generate the custom cmap of the font if needed
var encodingMap = {};
+ var charset = [];
if (fontDict.has("Encoding")) {
var encoding = xref.fetchIfRef(fontDict.get("Encoding"));
if (IsDict(encoding)) {
if (!encoding)
error("Unknown font encoding");
- var widths = xref.fetchIfRef(fontDict.get("Widths"));
var firstChar = xref.fetchIfRef(fontDict.get("FirstChar"));
+
+ var index = 0;
+ for (var j = 0; j < encoding.length; j++) {
+ encodingMap[firstChar + index++] = GlyphsUnicode[encoding[j]];
+ }
+
+ var widths = xref.fetchIfRef(fontDict.get("Widths"));
assertWellFormed(IsArray(widths) && IsInt(firstChar),
"invalid font Widths or FirstChar");
- var charset = [];
for (var j = 0; j < widths.length; j++) {
if (widths[j])
charset.push(encoding[j + firstChar]);
}
}
+ } else if (fontDict.has("ToUnicode")) {
+ TODO("ToUnicode stream translation not implemented");
}
var subType = fontDict.get("Subtype");