Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fontRenderingContext is not good for vector drawing #32

Closed
lpaatero opened this issue Nov 17, 2021 · 2 comments
Closed

fontRenderingContext is not good for vector drawing #32

lpaatero opened this issue Nov 17, 2021 · 2 comments

Comments

@lpaatero
Copy link

lpaatero commented Nov 17, 2021

In RC1 fontRenderingContext does not seem to have proper hints for vector drawing. implementation leads to side-effects for example when fonts are drawn in vertically compressed way. Unfortunately I cannot produce simple test-case right now.

Current code uses Graphics2G from bitmap:

calcGfx.addRenderingHints(renderingHints);
fontRenderContext = calcGfx.getFontRenderContext();

The renderingHints seems to be empty by default, but at least VALUE_FRACTIONALMETRICS_ON should be specified. Also the bitmap resolution is not reflecting any rasterization resolution being done later in process.

But as vector image is being created, code like

AffineTransform vectorFontScaling = new AffineTransform();
vectorFontScaling.setToScale( 100.0, 100.0);
fontRenderContext = new FontRenderContext( vectorFontScaling, true, true );

would give more predictable results (tested to remove the problems). This would basically tell to ignore anything relating to the rasterization in font handling.

If fonts are being rasterized (are they in PdfBox?), then fontRenderContext should be based on correct resolution of bitmap in order to produce good results.

@lpaatero lpaatero changed the title Poor fontRenderingContext is not good for vector drawing Nov 17, 2021
@rototor
Copy link
Owner

rototor commented Nov 17, 2021

Sorry, I don't fully understand your problem. What version of PDFBox-Graphics2D are you using?

You should only use the PDFBox 2.0 based version 0.33, as the PDFBox 3.0 is not yet stable (and has still many new bugs).

Nothing is rasterized, fonts are usually generated as vectors. Only if you register a font file it will embed the font.

What PDF viewer are you using? Can you attach a sample PDF which is wrong?

@rototor
Copy link
Owner

rototor commented Dec 19, 2021

I've just released version 0.34. It now sets rendering hint RenderingHints.KEY_FRACTIONALMETRICS to RenderingHints.VALUE_FRACTIONALMETRICS_ON by default.

Is this what you meant?

@rototor rototor closed this as completed Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants