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

Font weight and style resolving inconsistencies #868

Open
HerbertsVaadin opened this issue Sep 8, 2022 · 0 comments
Open

Font weight and style resolving inconsistencies #868

HerbertsVaadin opened this issue Sep 8, 2022 · 0 comments

Comments

@HerbertsVaadin
Copy link

HerbertsVaadin commented Sep 8, 2022

In com.openhtmltopdf.svgsupport.PDFTranscoder.OpenHtmlFontResolver
two getWeight methods resolve the font-weight:400 to different weight values.

private Float getWeight(Integer weight) {
    if (weight == null) {
        return null;
    }

    switch (weight.intValue()) {
    ...
    case 400:
        return TextAttribute.WEIGHT_REGULAR;
    ...
    }
}
Float getWeight(IdentValue weight) {
    if (weight == IdentValue.NORMAL) {
        return TextAttribute.WEIGHT_REGULAR;
    ...
    } else if (weight == IdentValue.FONT_WEIGHT_400) {
        return TextAttribute.WEIGHT_MEDIUM;
    } ...

}

WEIGHT_REGULAR=Float.valueOf(1.0f);
WEIGHT_MEDIUM=Float.valueOf(1.5f);

Similar problem for resolving styles.
Normal resolves to null here:

private Float getStyle(IdentValue fontStyle) {
	if (fontStyle == IdentValue.ITALIC ||
		fontStyle == IdentValue.OBLIQUE)
		return TextAttribute.POSTURE_OBLIQUE;
	
	return null;
}

Normal resolves to 0f here (which is the preffered value).

private Float getStyle(FontStyle style) {
    switch (style) {
    case ITALIC:
    case OBLIQUE:
        return TextAttribute.POSTURE_OBLIQUE;
    case NORMAL:
    default:
        return 0f;
    }
}

This causes the font not being interpreted correctly for drawing SVGs.

@HerbertsVaadin HerbertsVaadin changed the title Font weight resolving inconsistencies Font weight and style resolving inconsistencies Sep 8, 2022
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

1 participant