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];
|
||||
}
|
||||
|
||||
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) {
|
||||
var offset =
|
||||
getUshort(data, start + 2) === 1
|
||||
@ -422,9 +433,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
||||
subrs = fontDict.privateDict.subrsIndex.objects;
|
||||
}
|
||||
if (subrs) {
|
||||
let numSubrs = subrs.length;
|
||||
// Add subroutine bias.
|
||||
n += numSubrs < 1240 ? 107 : numSubrs < 33900 ? 1131 : 32768;
|
||||
n += getSubroutineBias(subrs);
|
||||
subrCode = subrs[n];
|
||||
}
|
||||
} else {
|
||||
@ -804,18 +814,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
||||
this.cmap = cmap;
|
||||
this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
|
||||
|
||||
this.gsubrsBias =
|
||||
this.gsubrs.length < 1240
|
||||
? 107
|
||||
: this.gsubrs.length < 33900
|
||||
? 1131
|
||||
: 32768;
|
||||
this.subrsBias =
|
||||
this.subrs.length < 1240
|
||||
? 107
|
||||
: this.subrs.length < 33900
|
||||
? 1131
|
||||
: 32768;
|
||||
this.gsubrsBias = getSubroutineBias(this.gsubrs);
|
||||
this.subrsBias = getSubroutineBias(this.subrs);
|
||||
|
||||
this.isCFFCIDFont = cffInfo.isCFFCIDFont;
|
||||
this.fdSelect = cffInfo.fdSelect;
|
||||
|
Loading…
Reference in New Issue
Block a user