mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Takes ascent/descent in account in the text layer
This commit is contained in:
parent
4d01ff4079
commit
0131101275
5 changed files with 19 additions and 8 deletions
|
@ -919,10 +919,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
if (chunk !== '') {
|
||||
var bidiText = PDFJS.bidi(chunk, -1, font.vertical);
|
||||
var renderParams = textState.calcRenderParams();
|
||||
bidiText.x = renderParams.renderMatrix[4] - (textState.fontSize *
|
||||
renderParams.vScale * Math.sin(renderParams.angle));
|
||||
bidiText.y = renderParams.renderMatrix[5] + (textState.fontSize *
|
||||
renderParams.vScale * Math.cos(renderParams.angle));
|
||||
var fontHeight = textState.fontSize * renderParams.vScale;
|
||||
var fontAscent = font.ascent ? font.ascent * fontHeight :
|
||||
font.descent ? (1 + font.descent) * fontHeight : fontHeight;
|
||||
bidiText.x = renderParams.renderMatrix[4] - (fontAscent *
|
||||
Math.sin(renderParams.angle));
|
||||
bidiText.y = renderParams.renderMatrix[5] + (fontAscent *
|
||||
Math.cos(renderParams.angle));
|
||||
if (bidiText.dir == 'ttb') {
|
||||
bidiText.x += renderParams.vScale / 2;
|
||||
bidiText.y -= renderParams.vScale;
|
||||
|
|
|
@ -2183,6 +2183,8 @@ var Font = (function FontClosure() {
|
|||
this.wideChars = properties.wideChars;
|
||||
this.hasEncoding = properties.hasEncoding;
|
||||
this.cmap = properties.cmap;
|
||||
this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
|
||||
this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
|
||||
|
||||
this.fontMatrix = properties.fontMatrix;
|
||||
if (properties.type == 'Type3') {
|
||||
|
|
|
@ -954,6 +954,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
geometry.fontName = font.loadedName;
|
||||
geometry.fontFamily = font.fallbackName;
|
||||
geometry.fontSize = this.current.fontSize;
|
||||
geometry.ascent = font.ascent;
|
||||
geometry.descent = font.descent;
|
||||
return geometry;
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue