Merge pull request #1417 from notmasteryet/issue-1395
Don't print missing symbols in the font
This commit is contained in:
commit
c7bd123bab
@ -756,24 +756,26 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var charWidth = glyph.width * fontSize * 0.001 +
|
var charWidth = glyph.width * fontSize * 0.001 +
|
||||||
Util.sign(current.fontMatrix[0]) * charSpacing;
|
Util.sign(current.fontMatrix[0]) * charSpacing;
|
||||||
|
|
||||||
var scaledX = x / fontSizeScale;
|
if (!glyph.disabled) {
|
||||||
switch (textRenderingMode) {
|
var scaledX = x / fontSizeScale;
|
||||||
default: // other unsupported rendering modes
|
switch (textRenderingMode) {
|
||||||
case TextRenderingMode.FILL:
|
default: // other unsupported rendering modes
|
||||||
case TextRenderingMode.FILL_ADD_TO_PATH:
|
case TextRenderingMode.FILL:
|
||||||
ctx.fillText(char, scaledX, 0);
|
case TextRenderingMode.FILL_ADD_TO_PATH:
|
||||||
break;
|
ctx.fillText(char, scaledX, 0);
|
||||||
case TextRenderingMode.STROKE:
|
break;
|
||||||
case TextRenderingMode.STROKE_ADD_TO_PATH:
|
case TextRenderingMode.STROKE:
|
||||||
ctx.strokeText(char, scaledX, 0);
|
case TextRenderingMode.STROKE_ADD_TO_PATH:
|
||||||
break;
|
ctx.strokeText(char, scaledX, 0);
|
||||||
case TextRenderingMode.FILL_STROKE:
|
break;
|
||||||
case TextRenderingMode.FILL_STROKE_ADD_TO_PATH:
|
case TextRenderingMode.FILL_STROKE:
|
||||||
ctx.fillText(char, scaledX, 0);
|
case TextRenderingMode.FILL_STROKE_ADD_TO_PATH:
|
||||||
ctx.strokeText(char, scaledX, 0);
|
ctx.fillText(char, scaledX, 0);
|
||||||
break;
|
ctx.strokeText(char, scaledX, 0);
|
||||||
case TextRenderingMode.INVISIBLE:
|
break;
|
||||||
break;
|
case TextRenderingMode.INVISIBLE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x += charWidth;
|
x += charWidth;
|
||||||
|
29
src/fonts.js
29
src/fonts.js
@ -1828,8 +1828,9 @@ var Font = (function FontClosure() {
|
|||||||
readGlyphNameMap(post, properties);
|
readGlyphNameMap(post, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the old CMAP table with a shiny new one
|
var glyphs, ids;
|
||||||
if (properties.type == 'CIDFontType2') {
|
if (properties.type == 'CIDFontType2') {
|
||||||
|
// Replace the old CMAP table with a shiny new one
|
||||||
// Type2 composite fonts map characters directly to glyphs so the cmap
|
// Type2 composite fonts map characters directly to glyphs so the cmap
|
||||||
// table must be replaced.
|
// table must be replaced.
|
||||||
// canvas fillText will reencode some characters even if the font has a
|
// canvas fillText will reencode some characters even if the font has a
|
||||||
@ -1861,7 +1862,9 @@ var Font = (function FontClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var glyphs = [], ids = [];
|
glyphs = [];
|
||||||
|
ids = [];
|
||||||
|
|
||||||
var usedUnicodes = [];
|
var usedUnicodes = [];
|
||||||
var unassignedUnicodeItems = [];
|
var unassignedUnicodeItems = [];
|
||||||
for (var i = 1; i < numGlyphs; i++) {
|
for (var i = 1; i < numGlyphs; i++) {
|
||||||
@ -1892,11 +1895,12 @@ var Font = (function FontClosure() {
|
|||||||
glyphs.push({ unicode: unicode, code: cid });
|
glyphs.push({ unicode: unicode, code: cid });
|
||||||
ids.push(i);
|
ids.push(i);
|
||||||
}
|
}
|
||||||
cmap.data = createCMapTable(glyphs, ids);
|
|
||||||
} else {
|
} else {
|
||||||
var cmapTable = readCMapTable(cmap, font);
|
var cmapTable = readCMapTable(cmap, font);
|
||||||
var glyphs = cmapTable.glyphs;
|
|
||||||
var ids = cmapTable.ids;
|
glyphs = cmapTable.glyphs;
|
||||||
|
ids = cmapTable.ids;
|
||||||
|
|
||||||
var hasShortCmap = !!cmapTable.hasShortCmap;
|
var hasShortCmap = !!cmapTable.hasShortCmap;
|
||||||
var toFontChar = this.toFontChar;
|
var toFontChar = this.toFontChar;
|
||||||
|
|
||||||
@ -2062,10 +2066,16 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
createGlyphNameMap(glyphs, ids, properties);
|
createGlyphNameMap(glyphs, ids, properties);
|
||||||
this.glyphNameMap = properties.glyphNameMap;
|
this.glyphNameMap = properties.glyphNameMap;
|
||||||
|
|
||||||
cmap.data = createCMapTable(glyphs, ids);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Converting glyphs and ids into font's cmap table
|
||||||
|
cmap.data = createCMapTable(glyphs, ids);
|
||||||
|
var unicodeIsEnabled = [];
|
||||||
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||||
|
unicodeIsEnabled[glyphs[i].unicode] = true;
|
||||||
|
}
|
||||||
|
this.unicodeIsEnabled = unicodeIsEnabled;
|
||||||
|
|
||||||
// Rewrite the 'post' table if needed
|
// Rewrite the 'post' table if needed
|
||||||
if (requiredTables.indexOf('post') != -1) {
|
if (requiredTables.indexOf('post') != -1) {
|
||||||
tables.push({
|
tables.push({
|
||||||
@ -2391,7 +2401,7 @@ var Font = (function FontClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
charToGlyph: function fonts_charToGlyph(charcode) {
|
charToGlyph: function fonts_charToGlyph(charcode) {
|
||||||
var fontCharCode, width, operatorList;
|
var fontCharCode, width, operatorList, disabled;
|
||||||
|
|
||||||
var width = this.widths[charcode];
|
var width = this.widths[charcode];
|
||||||
|
|
||||||
@ -2464,11 +2474,14 @@ var Font = (function FontClosure() {
|
|||||||
unicodeChars = String.fromCharCode(unicodeChars);
|
unicodeChars = String.fromCharCode(unicodeChars);
|
||||||
|
|
||||||
width = (isNum(width) ? width : this.defaultWidth) * this.widthMultiplier;
|
width = (isNum(width) ? width : this.defaultWidth) * this.widthMultiplier;
|
||||||
|
disabled = this.unicodeIsEnabled ?
|
||||||
|
!this.unicodeIsEnabled[fontCharCode] : false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fontChar: String.fromCharCode(fontCharCode),
|
fontChar: String.fromCharCode(fontCharCode),
|
||||||
unicode: unicodeChars,
|
unicode: unicodeChars,
|
||||||
width: width,
|
width: width,
|
||||||
|
disabled: disabled,
|
||||||
operatorList: operatorList
|
operatorList: operatorList
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user