How to get a normalized font size for a PDF using PDFBox - parsing

I am working on a project that parses pdf files and extracts text. I am using the TextPosition class to generate a data-structure containing the position and size of each character in the pdf file.
I am running into an issue where there is a custom defined Type 3 font inside the pdf with really large characters. Font that appears to be about font size 9 on the screen are actually set to a font size of 0.24. I attempted to try and use the fontDescriptor to try and get the cap height of the font and use that instead, but it is null. Also, there is another font on the page that has a large amount of white-space above and below it, making the Cap height unusable. Here is what the TextPosition class looks like for a random character on the page.
I was hoping that someone knew how to get the correct pt font size?
Thanks

Related

TCPDF MultiCell ignoring $fitcell parameter when using $ishtml=true

I have a pdf with an area for text to go. The text can sometimes be very long or quite short. TCPDF has a great feature in MultiCell called $fitcell, which adjusts the font size based on the containing cell.
However, this parameter gets ignored when I use $ishtml=true, and it doesn't change the font size, which then goes out of the cell when it gets too long.
I need it to be HTML (to change font colors and bold within the text), but also to be fitted by adjusting the size.
How can I accomplish this?
I have tried using writeHTMLcell, but it doesn't have a $fitcell param.

Multiple fonts on a single line of an eps file?

I'm trying to manipulate and modify a large number of eps files output by a web service. I have the code in python to interface with the server, and to edit the images to within about 99% of where I want them.
My issue deals with trying to display special characters. I've tried outputting the desired unicode character, Ψ, directly into the eps file, but this is displayed as different characters in both Preview for Mac and Adobe Illustrator. From some googling, it seems like eps doesn't accept unicode characters. Fair enough...
My current solution is to try to change the font in the eps files. This works when I want to display the Ψ as a single character. I just switch the font, and then switch back. As below:
/Symbol findfont 10.5 scalefont setfont
-9.1 36.1557 moveto (Y) show
/Helvetica-Bold findfont 10.5 scalefont setfont
Where I'm having a problem is when I want to display a title on each image. The title would include a mix of Helvetica-Light and Symbol fonts, I would want it to display as ABC1-Ψ123. I can't figure out how to switch the font of a single character within a larger block of text. Currently the eps files are written as shown:
/Helvetica-Light findfont 12 scalefont setfont
-43.093 304.224 moveto (ABC1-Y123) show
I'd appreciate any help.

How can I get a the default width of a specified font in Delphi?

I'm writing a DXF exporter/importer. The DXF MTEXT entity format supports width factor for a text block (how times it is wider than the default font width). The Windows LogFont record contains the lfWidth field (how many pixel will be the average font width if you select the logfont to create a hFont). How can I get the default width of the used font to calculate the scaling factor back and forth? Is there any WinAPI call?
OK. I have found It. The getTextMetrics fills up a TEXTMETRIC record. It has a tmAveCharWidth. The searched value.

Font in GVedit Editor

Is it possible to change the font size of the code in in GVedit Editor?
I do not mean the font of text in created graphs, but the font size of the source code.
Copy the text from webpage or word to GVEdit, the format will not change.
But I haven't find where to config it.

TextMorph default font size

I'm trying to have an empty TextMorph with a default font size of 12 points, where the original default is 9pts. If I bring up the halo and change the font size to 12pts, the empty TextMorph will still default to 9pts when text is entered into it. I can sort of get around this by putting a space in the TextMorph, then changing the font via the halo to be 12pts. However, this seems rather clunky, and as such was wondering if there might be another way to accomplish this?
thanks.

Resources