Re: make font metrics visible to user

I think most people would prefer a method to offer more useful vertical positioning options than just baseline.  The metrics are just a means to this end.

When automating with Adobe Illustrator I’ve built a function that can verticallyAlign() by any of several useful vertical positioning points.  I find ‘visual vertical centerline’ to be the most useful to vertically align text to the side of objects like logos or bar chart bars.  While not a metric itself, it is derived from the metrics.

For Illustrator development, I have to enable the function with a table of metrics manually extracted with FontLab Studio.  If the method itself could pull those font metrics I would happily never look upon a font metric again.

I’m not a js expert, so if anyone is interested in building a js version of verticallyAlign() I’m more than happy to share my metrics diagrams or Skype some knowledge transfer.  But perhaps it’s premature if the API for accessing font metrics is not all there yet.

Dave



From: Paul LeBeau <paul.lebeau@gmail.com>
Date: Tuesday, April 25, 2017 at 7:10 AM
To: Ulrich-Matthias Schäfer <ulima.ums@gmail.com>
Cc: Francis Hemsher <fhemsher@gmail.com>, www-svg <www-svg@w3.org>
Subject: Re: make font metrics visible to user
Resent-From: <www-svg@w3.org>
Resent-Date: Tuesday, April 25, 2017 at 7:11 AM

Actually, there is already an API in the browser for accessing font metrics: CanvasRenderingContext2D.measureText() which returns a TextMetrics object containing all the values you'd want.

https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics


The bad news is that it isn't properly supported yet. The only value that the browsers currently return is width.

If it was better supported, you could use that for better metrics. For example: https://jsfiddle.net/f8nfyvp4/2/


Paul

On 25 April 2017 at 22:20, Ulrich-Matthias Schäfer <ulima.ums@gmail.com<mailto:ulima.ums@gmail.com>> wrote:
Yes. Having a tightest box of certain text or glyph is a useful feature, too.
Somewhat like: text.getTightestBox()
For my case I would like to have a function `text.getFontMetrics()` which tells me the exact metrics of the font of this text element (maybe including bboxes and glyphs) taking all font properties into account.

2017-04-25 12:14 GMT+02:00 Francis Hemsher <fhemsher@gmail.com<mailto:fhemsher@gmail.com>>:
Just to add something to your suggestions...
Also, what would be just dandy, is to have the actual bounding box dimensions for the unicode svg drawing of each font character. Otherwise it is tedious to accurately place font icons, and other individual characters.
Francis

On Sat, Apr 22, 2017 at 8:21 AM, Ulrich-Matthias Schäfer <ulima.ums@gmail.com<mailto:ulima.ums@gmail.com>> wrote:
Hey everyone,
I am one of the maintainers of the svg.js library and one thing we stumpled over was svg text which is really hard to tame. The text is positioned relative to the baseline which makes sense in one case but is bad in others. We tried to position text based on the upper left edge and currently we use browsers bounding box implementation to achieve that. However - this differs around browsers and I was looking for a more stable way to do that.
One possibility which came into my mind was to add a method to get the metrics of the font which is used. Most importingly the values of unitsPerEm and the baseline position. That alone would allow us to move the text in a consistent manner.
Is there any effort I dont know of to put something like this into the specs?

Thanks for reading! Cheers,
Fuzzy




MFS Email system made the following annotation
---------------------------------------------------------------------------------------------------------------------------------------
This email communication and any attachments may contain proprietary, confidential, or privileged information. If you are not the intended recipient, you are hereby notified that you have received this email in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited. The sender does not waive confidentiality or any privilege by mistransmission. If you have received this email in error, please notify the sender immediately, delete this email, and destroy all copies and any attachments.

Received on Wednesday, 26 April 2017 12:59:07 UTC