1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 17:18:07 +02:00

Add a basic support for TrueType (generate fonts with OS/2 table)

This commit is contained in:
Vivien Nicolas 2011-06-15 04:46:48 +02:00
parent bdf8577c48
commit 32118c5650
3 changed files with 246 additions and 9 deletions

18
pdf.js
View file

@ -52,7 +52,7 @@ var Stream = (function() {
this.bytes = new Uint8Array(arrayBuffer);
this.start = start || 0;
this.pos = this.start;
this.end = (start + length) || arrayBuffer.byteLength;
this.end = (start + length) || this.bytes.byteLength;
this.dict = dict;
}
@ -1411,11 +1411,13 @@ var Page = (function() {
var resources = xref.fetchIfRef(this.resources);
var fontsDict = new Dict();
// Get the fonts use on the page
// Get the fonts use on the page if any
var fontResources = resources.get("Font");
fontResources.forEach(function(fontKey, fontData) {
fontsDict.set(fontKey, xref.fetch(fontData))
});
if (IsDict(fontResources)) {
fontResources.forEach(function(fontKey, fontData) {
fontsDict.set(fontKey, xref.fetch(fontData))
});
}
// Get the fonts use on xobjects of the page if any
var xobjs = xref.fetchIfRef(resources.get("XObject"));
@ -1864,7 +1866,11 @@ var CanvasGraphics = (function() {
this.current.leading = leading;
},
setFont: function(fontRef, size) {
var font = this.res.get("Font").get(fontRef.name);
var font = this.res.get("Font");
if (!IsDict(font))
return;
font = font.get(fontRef.name);
font = this.xref.fetchIfRef(font);
if (!font)
return;