Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fonts flipped upside down when embedded in the PDF #48

Open
fabioda opened this issue Jan 22, 2020 · 4 comments
Open

Fonts flipped upside down when embedded in the PDF #48

fabioda opened this issue Jan 22, 2020 · 4 comments

Comments

@fabioda
Copy link

fabioda commented Jan 22, 2020

When embedding fonts in the PDF, setting PDFGraphics2D.EMBED_FONTS to true, they get flipped upside down. After testing (I'm not competent in Java Graphics), I found the protected void writeString(String str, double x, double y) method in the PDFGraphics2D.java source in the freehep-graphicsio-pdf project to be the cause.
The line

// mirror the matrix
at.scale(1, -1);

seems to do the flipping, which works fine for non-ebedded fonts, but scales embedded fonts upside down.
I've modified that line that nows is:

// mirror the matrix
if (PDFFontIncluder.isStandardFont(getFont()))
at.scale(1, -1);

and from initial testing it seems to be working.
Has anybody experienced the issue, and has any clue as to how to effectively solve it correctly?

@murkle
Copy link

murkle commented Jan 23, 2020

I've not come across that one. It does remind me a bit about this fix (which has never made it into the official version IIRC) - worth trying!

http://dev.geogebra.org/trac/changeset/7436/trunk/geogebra/org/freehep/graphicsio/AbstractVectorGraphicsIO.java

@fabioda
Copy link
Author

fabioda commented Jan 23, 2020

Thank you for your suggestion. I already came across that patch when looking for solutions, and applied it, but unfortunately it didn't fix the issue.

@murkle
Copy link

murkle commented Jan 23, 2020

We use a fork of http://java.freehep.org/svn/repos/freehep/list/freehep/branches/vectorgraphics-emfplus/?revision=HEAD with a few patches applied. It's available here:

https://github.com/geogebra/geogebra/tree/master/desktop/src/main/java/org/freehep

and it works well for use so worth a try maybe?

Also worth adding in the ticket which exact font(s) you have the problem with - maybe there's something unusual about them

@fabioda
Copy link
Author

fabioda commented Jan 23, 2020

The issue has arisen first when using a "3 of 9 Barcode" font. The font is vertically symmetrical, so it was not easy to spot the problem, but it was printing in the wrong location (as it was flipped). I tried other TTFs, such as Consolas, and it also printed mirrored I've downloaded your fork, will give it a go and get back to you with feedback.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants