SVG font imported in fontforge wrong centering

Bug #694517 reported by florin on 2010-12-26
This bug affects 2 people
Affects Status Importance Assigned to Milestone

Bug Description

Using the default template fontforge_glyph making a svg font glyph then export to .svg and import in fontforge, in Inkscape the glyph looks centered in the template but in fontforge it is imported centered wrrong. If the glyph it is exported from fontforge after centering it to the guildes in fontforge and import it like .svg in Inkscape I get the offcentering i get from inkscape to fontforge.

I dunno if it an Inkscape bug or fontforge bug. I`m not a programmer.

jazzynico (jazzynico) wrote :

Could you please provide a test file that demonstrate this issue so that we can investigate?

florin (grigoreflorin1985) wrote :
florin (grigoreflorin1985) wrote :

Note the difference in position from the base template from Inkscape and the difference from export from fontforge after I corrected the the position of the glyph.

jazzynico (jazzynico) on 2010-12-27
summary: - SVG font imported in fontforge wrrong centering
+ SVG font imported in fontforge wrong centering
MDP (m.d.p) wrote :

I would redifine the DESCRIPTION:
- A curve is converted to a SVG font glyph with a wrong y coordinate for the start point.

1) create a 800x800 square in a 800x800 page and 'get curves from selection', the description of polygon "d" of the square is 'm 0,0 800,0 0,800 -800,0 z', of the glyph is 'm 0,1024 800,0 0,-800 -800,0 z'. Note the y of the first, reference point from 0 becomes 1024.
2) create a 400x400 square centered in a 800x800 page and 'get curves from selection', polygon: m 200,200 400,0 0,400 -400,0 z
glyph: m 200,824 400,0 0,-400 -400,0 z . The y of the first point, 200 -> 824
3) a path for a 600x200 rectangle described as 'm 100,367 600,0 0,200 -600,0 z' but with a 'transform: translate(0,133)' in its parent node, obtained by draggin the thing around, will be converted as 'm 100,657 600,0 0,-200 -600,0 z'. While 367+657 is correctly 1024, as expected (still wrong of course), the translation (133px) is not computed - thus the obtained glyph will not be positioned like the one which is seen.

On fontforge, the first gliph will actually be drawn from point (0,1024), the second from (200,824), the third from (100,657).

Where would I TRACK it:
Inside file
inside the function
the path is flipped vertically then it is offset, only for what x is concerned.
I presume also the y needs to be interpolated.
Following is the original code:

    Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d"));
    //This matrix flips the glyph vertically
    Geom::Matrix m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0));
    //then we offset it

Best Regards

MDP (m.d.p) wrote :

Is it possible that the matrix transformation needs to become
, so the code something like
Geom::Matrix m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord( path_height ));
(I currently do not know how to get the path height)

MDP (m.d.p) wrote :

Geom::Matrix m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord( -path_height ));

jazzynico (jazzynico) on 2012-06-23
tags: added: importing
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers