Re: Text ascent, descent and x-height

On Sat, 08 Nov 2014 00:05:00 +0100, Jurriën Stutterheim  
<j.stutterheim@cs.ru.nl> wrote:

> Hi all,
>
> For my research I'm currently working on a high-level, compositional  
> image API in the purely functional programming language Clean. We are  
> using SVG as back-end, i.e., we are generating SVG from this high-level  
> image description.
>
> In order to successfully generate images containing text, we need access  
> to font metrics. Currently, SVGTextContentElement already defines  
> getComputedTextLength, amongst others. However, to accurately position  
> text in an image, we also need access to a font's ascent, descent and  
> x-height. While this information is already present in the form of an  
> attribute on the font-face element, I would like to be able to access  
> this information for any given text, even if I haven't manually defined  
> the font in a font-face element.

Note that SVG fonts have been removed from SVG2.

> In particular, I would like to see the following additions to  
> SVGTextContentElement:
>
> interface SVGTextContentElement : SVGElement, SVGTests, SVGLangSpace,  
> SVGExternalResourcesRequired, SVGStylable {
>
>   (snip)
>
>   float getComputedTextAscentHeight();
>   float getComputedTextDecentHeight();
>   float getComputedTextXHeight();
> };
>
> Would this be possible?

Yes, it's technically possible.

> What are the technical hurdles for such an API?

Font-switching or font fallbacks may affect the result, for example.

> Also, what is the formal procedure for proposing such API changes?

Typically, the first step would be to present your use-cases and  
requirements.

Access to more font metrics has been requested before, see
https://www.w3.org/Graphics/SVG/WG/wiki/SVG2_Requirements_Mailing_List_Feedback#Consider_adding_advanced_font_metrics_interface  
(ISSUE-2379).

Cheers
-- 
Erik Dahlstrom, Web Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group

Received on Tuesday, 11 November 2014 09:10:27 UTC