-
Notifications
You must be signed in to change notification settings - Fork 9
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
Bounding box for text #2
Comments
Greetings
On Fri, Apr 21, 2017 at 3:04 PM, Daniel Ecer ***@***.***> wrote:
Is it possible to get the bounding box for text / characters (for the
original / embedded font).
The SVG includes the position of the characters but not the bounding box.
There is an *svgx:width* which appears to be using a different unit (and
no height, although there is the *font-size*).
The actual BoundingBox will depend on the precise characters and glyphs you
are using - e.g. bold might push the height up a few fractions of a pixel.
At present the height of the bounding box is heuristically calculated from
the font-size by a simple multiplier.
The width is a parameter reported by PDFBox and is given by the
document/font. It's the guideline for whether to include spaces between
characters - the average x-distance to the origin of the next character as
determined by the font setter. In principle it could vary with kerning but
in practice is a single integer for each character. To get the
intercharacter spacing = svgx:width / 1000. * font-size
(the svgx is because SVG has no attribute for character width).
It seems to work most of the time. If svgx:width is not reported (e.g. in
diagrams we have to guess in some way).
… —
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAsxSzvLtqXTkCOZ-5SEvt9ZKnl2QCMUks5ryLdggaJpZM4NEWHY>
.
--
Peter Murray-Rust
Reader Emeritus University of Cambridge +44-1223-763069
and
ContentMine Ltd
|
Thank you for the response Peter. Okay, I thought the exact bounding box of the glyph might be available when it is 'rendered'. I will for now estimate it as you suggested. |
On Fri, Apr 21, 2017 at 5:06 PM, Daniel Ecer ***@***.***> wrote:
Thank you for the response Peter.
Okay, I thought the exact bounding box of the glyph might be available
when it is 'rendered'.
All PDF documents must contain the glyph information in some form.
Sometimes it is one of the 14 Allowed fonts which every PDF must honour.
Sometimes it gets Fonts from the host, but it also has a font library and
one can retrieve the font. This can be either a bitmap (non-scalable) , or
a path (scalable) in SVG.
I will for now estimate it as you suggested.
If you are doing very precise kerning you will need the glyphs. I spent
some years working with M$ on chemistry and maths and they have very
intricate systems. But if you just want to see whether one word overlaps
another then the font-height will probably be fine.
… —
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAsxS49DeR_Cwx6442Leik-_W7hHcHM7ks5ryNPpgaJpZM4NEWHY>
.
--
Peter Murray-Rust
Reader Emeritus University of Cambridge +44-1223-763069
and
ContentMine Ltd
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to get the bounding box for text / characters (for the original / embedded font).
The SVG includes the position of the characters but not the bounding box.
There is an svgx:width which appears to be using a different unit (and no height, although there is the font-size).
The text was updated successfully, but these errors were encountered: