SVG font imported in fontforge wrong centering

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

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?
Thanks!

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.

The error REPLICATION:
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
svg-font-dialog.cpp
inside the function
SvgFontsDialog::set_glyph_description_from_selected_path
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));
    pathv*=m;
    //then we offset it
    pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x));

Best Regards

MDP (m.d.p) wrote :

Is it possible that the matrix transformation needs to become
1,0,0,-1,0,-2*path_height
, 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 :

Oops
1,0,0,-1,0,-path_height
so
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