Added myself to the license (yay!)
Tweaked according to comments in pull request #482
This commit is contained in:
parent
870de2f7f3
commit
530d78e0f8
1
LICENSE
1
LICENSE
@ -8,6 +8,7 @@
|
|||||||
Justin D'Arcangelo <justindarc@gmail.com>
|
Justin D'Arcangelo <justindarc@gmail.com>
|
||||||
Yury Delendik
|
Yury Delendik
|
||||||
Kalervo Kujala
|
Kalervo Kujala
|
||||||
|
Adil Allawi <@ironymark>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
48
fonts.js
48
fonts.js
@ -670,7 +670,9 @@ var Font = (function Font() {
|
|||||||
format314);
|
format314);
|
||||||
};
|
};
|
||||||
|
|
||||||
function createOS2Table(properties) {
|
function createOS2Table(properties, override) {
|
||||||
|
var override = override || {};
|
||||||
|
|
||||||
var ulUnicodeRange1 = 0;
|
var ulUnicodeRange1 = 0;
|
||||||
var ulUnicodeRange2 = 0;
|
var ulUnicodeRange2 = 0;
|
||||||
var ulUnicodeRange3 = 0;
|
var ulUnicodeRange3 = 0;
|
||||||
@ -701,22 +703,19 @@ var Font = (function Font() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var openTypeUnitsPerEm = (typeof (properties.openTypeUnitsPerEm) == 'undefined') ? kPDFGlyphSpaceUnits : properties.openTypeUnitsPerEm;
|
var unitsPerEm = override.unitsPerEm || kPDFGlyphSpaceUnits;
|
||||||
var typoAscent = properties.ascent;
|
var typoAscent = override.ascent || properties.ascent;
|
||||||
var typoDescent = properties.descent;
|
var typoDescent = override.descent || properties.descent;
|
||||||
var winAscent = typoAscent;
|
var winAscent = override.yMax || typoAscent;
|
||||||
var winDescent = -typoDescent;
|
var winDescent = -override.yMin || -typoDescent;
|
||||||
|
|
||||||
// if the font already has ascent and descent information then use these values
|
// if there is a units per em value but no other override then scale the calculated ascent
|
||||||
if (typeof (properties.openTypeAscent) != 'undefined') {
|
if (unitsPerEm != kPDFGlyphSpaceUnits && 'undefined' == typeof(override.ascent)) {
|
||||||
typoAscent = properties.openTypeAscent;
|
|
||||||
typoDescent = properties.openTypeDescent;
|
|
||||||
winAscent = properties.openTypeYMax;
|
|
||||||
winDescent = -properties.openTypeYMin;
|
|
||||||
} else if (openTypeUnitsPerEm != kPDFGlyphSpaceUnits) {
|
|
||||||
// if the font units differ to the PDF glyph space units then scale up the values
|
// if the font units differ to the PDF glyph space units then scale up the values
|
||||||
typoAscent = Math.round(typoAscent * openTypeUnitsPerEm / kPDFGlyphSpaceUnits);
|
typoAscent = Math.round(typoAscent * unitsPerEm / kPDFGlyphSpaceUnits);
|
||||||
typoDescent = Math.round(typoDescent * openTypeUnitsPerEm / kPDFGlyphSpaceUnits);
|
typoDescent = Math.round(typoDescent * unitsPerEm / kPDFGlyphSpaceUnits);
|
||||||
|
winAscent = typoAscent;
|
||||||
|
winDescent = -typoDescent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '\x00\x03' + // version
|
return '\x00\x03' + // version
|
||||||
@ -1072,22 +1071,23 @@ var Font = (function Font() {
|
|||||||
virtualOffset: numTables * (4 * 4)
|
virtualOffset: numTables * (4 * 4)
|
||||||
};
|
};
|
||||||
|
|
||||||
//extract some more font properties from the OpenType head and hhea tables
|
|
||||||
properties.openTypeUnitsPerEm = int16([head.data[18], head.data[19]]);
|
|
||||||
properties.openTypeYMax = int16([head.data[42], head.data[43]]);
|
|
||||||
properties.openTypeYMin = int16([head.data[38], head.data[39]]) - 0x10000; //always negative
|
|
||||||
properties.openTypeAscent = int16([hhea.data[4], hhea.data[5]]);
|
|
||||||
properties.openTypeDescent = int16([hhea.data[6], hhea.data[7]]) - 0x10000; //always negative
|
|
||||||
|
|
||||||
|
|
||||||
// The new numbers of tables will be the last one plus the num
|
// The new numbers of tables will be the last one plus the num
|
||||||
// of missing tables
|
// of missing tables
|
||||||
createOpenTypeHeader(header.version, ttf, numTables);
|
createOpenTypeHeader(header.version, ttf, numTables);
|
||||||
|
|
||||||
if (requiredTables.indexOf('OS/2') != -1) {
|
if (requiredTables.indexOf('OS/2') != -1) {
|
||||||
|
//extract some more font properties from the OpenType head and hhea tables
|
||||||
|
var override = {
|
||||||
|
unitsPerEm: int16([head.data[18], head.data[19]]),
|
||||||
|
yMax: int16([head.data[42], head.data[43]]),
|
||||||
|
yMin: int16([head.data[38], head.data[39]]) - 0x10000, //always negative
|
||||||
|
ascent: int16([hhea.data[4], hhea.data[5]]),
|
||||||
|
descent: int16([hhea.data[6], hhea.data[7]]) - 0x10000 //always negative
|
||||||
|
}
|
||||||
|
|
||||||
tables.push({
|
tables.push({
|
||||||
tag: 'OS/2',
|
tag: 'OS/2',
|
||||||
data: stringToArray(createOS2Table(properties))
|
data: stringToArray(createOS2Table(properties, override))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user