Skip to content

Commit

Permalink
Merge pull request #4736 from Snuffleupagus/glyph-accent-buildPath
Browse files Browse the repository at this point in the history
Build paths for glyph accents when drawing text as curves
  • Loading branch information
yurydelendik committed May 14, 2014
2 parents 179f423 + b907e15 commit 048c6d9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var isAddToPathSet = !!(state.textRenderingMode &
TextRenderingMode.ADD_TO_PATH_FLAG);
if (font.data && (isAddToPathSet || PDFJS.disableFontFace)) {
for (var i = 0; i < glyphs.length; i++) {
if (glyphs[i] === null) {
continue;
}
var fontChar = glyphs[i].fontChar;
var buildPath = function (fontChar) {
if (!font.renderer.hasBuiltPath(fontChar)) {
var path = font.renderer.getPathJs(fontChar);
this.handler.send('commonobj', [
Expand All @@ -303,6 +299,21 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
path
]);
}
}.bind(this);

for (var i = 0, ii = glyphs.length; i < ii; i++) {
var glyph = glyphs[i];
if (glyph === null) {
continue;
}
buildPath(glyph.fontChar);

// If the glyph has an accent we need to build a path for its
// fontChar too, otherwise CanvasGraphics_paintChar will fail.
var accent = glyph.accent;
if (accent && accent.fontChar) {
buildPath(accent.fontChar);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
},

paintChar: function (character, x, y) {
paintChar: function CanvasGraphics_paintChar(character, x, y) {
var ctx = this.ctx;
var current = this.current;
var font = current.font;
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
!type4psfunc.pdf
!issue1350.pdf
!S2.pdf
!glyph_accent.pdf
!personwithdog.pdf
!helloworld-bad.pdf
!zerowidthline.pdf
Expand Down
Binary file added test/pdfs/glyph_accent.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@
"rounds": 1,
"type": "eq"
},
{ "id": "glyph_accent",
"file": "pdfs/glyph_accent.pdf",
"md5": "1526e4edaa3ec439ebf156d0a0b385aa",
"link": false,
"rounds": 1,
"type": "eq",
"about": "Glyph accent drawn as curves."
},
{ "id": "simpletype3font",
"file": "pdfs/simpletype3font.pdf",
"md5": "b374c7543920840c61999e9e86939f99",
Expand Down

0 comments on commit 048c6d9

Please sign in to comment.