- From: Glenn Adams <gadams@xfsi.com>
- Date: Sun, 3 Oct 2010 18:01:48 +0800
- To: SVG Working Group WG <public-svg-wg@w3.org>
- Message-ID: <AANLkTimNeZysNNsDcX1j28YEV9PrA=kagge055LFZj5K@mail.gmail.com>
I recently formulated a meager proposal to improve the HTML5 2D Canvas
interface with respect to glyph drawing and metrics. See the following.
Perhaps something similar to this can be considered for SVG usage as well.
- context.fillGlyph(glyph,x,y)
- glyph is an integer denoting glyph index, from 0 to N-1, where N
is number of glyphs in current font (same applies below)
- x,y - position at which origin of glyph is to be placed (based on
current transform)
- context.strokeGlyph(glyph,x,y)
- metrics = context.measureGlyph(glyph,vertical)
- vertical is a boolean, where true means that metrics should be
returned for use with vertical text layout, and false means
that metrics
should be returned for use with horizontal text layout; note that the
definition of glyph origin may change with respect to vertical vs
horizontal;
- metrics returned is GlyphMetrics object, with all values therein
determined in accordance with current font, font size, and
transformation
matrix
- metrics.bearingX
- bearingX is real number expressing x distance from glyph origin
to left-most boundary of bounding box
- metrics.bearingY
- bearingY is real number expressing y distance from glyph origin
to top-most boundary of bounding box
- metrics.width
- width is real number expressing width of glyph bounding box (not
glyph X advancement)
- metrics.height
- height is real number expressing height of glyph bounding box
(not glyph Y advancement)
- metrics.advanceX
- advanceX is real number expressing nominal distance to advance
the x coordinate of the current point after rendering glyph,
where positive
means left, and negative means right in the user coordinate space;
- metrics.advanceY
- advanceY is real number expressing nominal distance to advance
the y coordinate of the current point after rendering glyph,
where positive
means down, and negative means up in the user coordinate space
Regards,
Glenn Adams
On Sun, Oct 3, 2010 at 2:45 PM, SVG Working Group Issue Tracker <
sysbot+tracker@w3.org <sysbot%2Btracker@w3.org>> wrote:
>
> ISSUE-2379 (font metrics): Consider adding advanced font metrics interface
> [SVG 2]
>
> http://www.w3.org/Graphics/SVG/WG/track/issues/2379
>
> Raised by: Doug Schepers
> On product: SVG 2
>
> It is often useful to get various aspects of a font as it will appear on
> screen, including the em-width, x-height, baseline, string length, etc.
> Right now, these aren't exposed to script, but it would be nice to have a
> font metric interface. Maybe consider this for generalization to CSS/HTML
> as well?
>
>
>
>
Received on Sunday, 3 October 2010 10:09:48 UTC