Extract the subroutine bias computation into a helper function in src/core/font_renderer.js
This commit is contained in:
parent
40f531ee87
commit
6590cc32f2
@ -39,6 +39,17 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
return (data[offset] << 8) | data[offset + 1];
|
return (data[offset] << 8) | data[offset + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSubroutineBias(subrs) {
|
||||||
|
const numSubrs = subrs.length;
|
||||||
|
let bias = 32768;
|
||||||
|
if (numSubrs < 1240) {
|
||||||
|
bias = 107;
|
||||||
|
} else if (numSubrs < 33900) {
|
||||||
|
bias = 1131;
|
||||||
|
}
|
||||||
|
return bias;
|
||||||
|
}
|
||||||
|
|
||||||
function parseCmap(data, start, end) {
|
function parseCmap(data, start, end) {
|
||||||
var offset =
|
var offset =
|
||||||
getUshort(data, start + 2) === 1
|
getUshort(data, start + 2) === 1
|
||||||
@ -422,9 +433,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
subrs = fontDict.privateDict.subrsIndex.objects;
|
subrs = fontDict.privateDict.subrsIndex.objects;
|
||||||
}
|
}
|
||||||
if (subrs) {
|
if (subrs) {
|
||||||
let numSubrs = subrs.length;
|
|
||||||
// Add subroutine bias.
|
// Add subroutine bias.
|
||||||
n += numSubrs < 1240 ? 107 : numSubrs < 33900 ? 1131 : 32768;
|
n += getSubroutineBias(subrs);
|
||||||
subrCode = subrs[n];
|
subrCode = subrs[n];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -804,18 +814,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
this.cmap = cmap;
|
this.cmap = cmap;
|
||||||
this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
|
this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
|
||||||
|
|
||||||
this.gsubrsBias =
|
this.gsubrsBias = getSubroutineBias(this.gsubrs);
|
||||||
this.gsubrs.length < 1240
|
this.subrsBias = getSubroutineBias(this.subrs);
|
||||||
? 107
|
|
||||||
: this.gsubrs.length < 33900
|
|
||||||
? 1131
|
|
||||||
: 32768;
|
|
||||||
this.subrsBias =
|
|
||||||
this.subrs.length < 1240
|
|
||||||
? 107
|
|
||||||
: this.subrs.length < 33900
|
|
||||||
? 1131
|
|
||||||
: 32768;
|
|
||||||
|
|
||||||
this.isCFFCIDFont = cffInfo.isCFFCIDFont;
|
this.isCFFCIDFont = cffInfo.isCFFCIDFont;
|
||||||
this.fdSelect = cffInfo.fdSelect;
|
this.fdSelect = cffInfo.fdSelect;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user