We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am a bit confused about the unit of measure generally used as input or output for the API. More concretely:
I want to get thewidth of a string, given a font and font size, in millimeters. I also want to express the font size itself in millimeters.
If I look into the source code of your FontUtils class, I see this method:
public static float getStringWidth(final PDFont font, final String text, final float fontSize) { try { return font.getStringWidth(text) / 1000 * fontSize; } catch (final IOException e) { // turn into runtime exception throw new IllegalStateException("Unable to determine text width", e); } }
I assume the unit of measure for fontSize is points, and what's returned is also the string width in points, but I am not sure.
So to create an equivalent millimeter-based method:
public static double getStringWidthMillimeters(String text, PDFont font, double fontSizeMM) throws IOException { double fontSizePts = fontSizeMM * POINTS_PER_MM; double widthPts = (font.getStringWidth(text) / 1000) * fontSizePts; double widthMM = widthPts / POINTS_PER_MM; return widthMM; }
This feels very fishy, because the multiplication and subsequent division by POINTS_PER_MM really cancel out:
return ((font.getStringWidth(text) / 1000) * (fontSizeMM * POINTS_PER_MM)) / POINTS_PER_MM;
Could you help me out here?
Regards,
Ayco
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am a bit confused about the unit of measure generally used as input or output for the API. More concretely:
I want to get thewidth of a string, given a font and font size, in millimeters. I also want to express the font size itself in millimeters.
If I look into the source code of your FontUtils class, I see this method:
I assume the unit of measure for fontSize is points, and what's returned is also the string width in points, but I am not sure.
So to create an equivalent millimeter-based method:
This feels very fishy, because the multiplication and subsequent division by POINTS_PER_MM really cancel out:
Could you help me out here?
Regards,
Ayco
The text was updated successfully, but these errors were encountered: