Fixes to character size calculations.

This commit is contained in:
2017-10-11 16:44:42 +02:00
parent 6dfc248b9a
commit 6b8bbc367f
2 changed files with 5 additions and 2 deletions

View File

@@ -87,7 +87,9 @@ namespace VAR.PdfTools
char actualChar = firstChar; char actualChar = firstChar;
foreach (IPdfElement elem in widths.Values) foreach (IPdfElement elem in widths.Values)
{ {
_widths.Add(actualChar, PdfElementUtils.GetReal(elem, 500) / glyphSpaceToTextSpace); double width = PdfElementUtils.GetReal(elem, 500);
if (width < 0.0001f && width > -0.0001f) { width = 500; }
_widths.Add(actualChar, width / glyphSpaceToTextSpace);
actualChar++; actualChar++;
} }
// FIMXE: Calculate real height // FIMXE: Calculate real height

View File

@@ -125,7 +125,8 @@ namespace VAR.PdfTools
textElem.Matrix = _textMatrixCurrent.Multiply(_graphicsMatrix); textElem.Matrix = _textMatrixCurrent.Multiply(_graphicsMatrix);
textElem.RawText = _sbText.ToString(); textElem.RawText = _sbText.ToString();
textElem.VisibleText = PdfString_ToUnicode(textElem.RawText, _font); textElem.VisibleText = PdfString_ToUnicode(textElem.RawText, _font);
textElem.VisibleWidth = _textWidth * textElem.Matrix.Matrix[0, 0]; PdfCharElement lastChar = _listCharacters[_listCharacters.Count - 1];
textElem.VisibleWidth = (lastChar.Displacement + lastChar.Width) * textElem.Matrix.Matrix[0, 0];
textElem.VisibleHeight = (_font.Height * _fontSize) * textElem.Matrix.Matrix[1, 1]; textElem.VisibleHeight = (_font.Height * _fontSize) * textElem.Matrix.Matrix[1, 1];
textElem.Characters = new List<PdfCharElement>(); textElem.Characters = new List<PdfCharElement>();
foreach (PdfCharElement c in _listCharacters) foreach (PdfCharElement c in _listCharacters)