Board index FlightGear Development Canvas

Strange thing with font mapper

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Strange thing with font mapper

Postby Soitanen » Fri Mar 25, 2016 7:44 pm

I have strange thing with font mapper.

My old svg file work good, but I have mistake in positions, so I need to move entire layer. After layer reposition all fonts are dropped from Liberation Sans to something bold.
I tried to investigate the problem and have no luck with it. On this screen zero on the left side is wrong font. Other zeroes are right.

Image

Here is XML code for wrong zero:
Code: Select all
font-size:52.00250165px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:end;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#ffffff;fill-opacity:1;stroke:none;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans, Normal';writing-mode:lr;

And this is code for normal zero:
Code: Select all
font-size:52.00214767px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:end;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Liberation Sans;-inkscape-font-specification:Liberation Sans


Here is my font-mapper code:
Code: Select all
      var font_mapper = func(family, weight)
      {
         if( family == "Liberation Sans" and weight == "normal" )
            return "LiberationFonts/LiberationSans-Regular.ttf";
      };


Also it seems, that old SVG file was saved with inkscape:version="0.48.4 r9939", and new file is saved with inkscape:version="0.91 r".

Where is the error?
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: Strange thing with font mapper

Postby gooneybird » Fri Mar 25, 2016 8:31 pm

There's a bug in Inkscape 0.91 that causes problems with certain fonts and some files created in earlier versions.

I have installed the portable version of .48 for anything that does not work in .91.
If the text does not need to be a font it can be converted to paths in .48 and saved as an svg, it will then display as intended when imported into .91.
My Github repository (mostly AI stuff) https://github.com/gooneybird47
User avatar
gooneybird
 
Posts: 3046
Joined: Sat May 31, 2008 2:57 pm

Re: Strange thing with font mapper

Postby Gijs » Sat Mar 26, 2016 12:30 am

Inkscape nowadays removes the apostrophes from font names, like 'Liberation Sans'. Not sure if that's by intention or a bug, but you can run a simple replace all on your svg file to re-add the apostrophes once you're done editing in Inkscape.
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9544
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Strange thing with font mapper

Postby Soitanen » Sat Mar 26, 2016 7:19 am

I changed font-mapper string. New version of Inkscape adds apostrophes, old doesn't. So I make:
Code: Select all
if( family == "'Liberation Sans'" and weight == "normal" )

(added apostrophes in font family) and it works with old variant and new variant too.
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: Strange thing with font mapper

Postby Gijs » Sat Mar 26, 2016 9:49 am

Ah yeah sorry, I mixed old and new :oops:
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9544
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Strange thing with font mapper

Postby Soitanen » Mon Mar 28, 2016 10:47 am

He-he!

Adventures continue!

I edited some things in PFD, re-saved SVG and get inverted circles!
Image

So, only use of old Inkscape version can help?
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: Strange thing with font mapper

Postby Hooray » Mon Mar 28, 2016 12:09 pm

Actually, there's a tiny Nasal module named svg.nas (see $FG_ROOT/Nasal/Canvas) that will read those SVG/XML files and convert them into Canvas nodes (OpenVG/ShivaVG paths) - in other words, depending on the nature of the differences in the output, it should be possible to patch up the svg parser to also support the new format.

To make changes to that module, you need to understand how parsing works and how a stack works (the data structure).
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Strange thing with font mapper

Postby Soitanen » Mon Mar 28, 2016 12:44 pm

I don't know about stack, but I changed lines 282 and 284:
old:
Code: Select all
            var cmd_vg = args[i + 4] ? Path.VG_LCCWARC_TO : Path.VG_LCWARC_TO;
          else
            var cmd_vg = args[i + 4] ? Path.VG_SCCWARC_TO : Path.VG_SCWARC_TO;


new:
Code: Select all
            var cmd_vg = args[i + 4] ? Path.VG_LCWARC_TO : Path.VG_LCCWARC_TO;
          else
            var cmd_vg = args[i + 4] ? Path.VG_SCWARC_TO : Path.VG_SCCWARC_TO;


Just tested it in my 737-800 with custom PFD and which uses common ND (old versioned SVG), and I see nothing broken.

Could someone look it a little bit closer?
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: Strange thing with font mapper

Postby Johan G » Mon Mar 28, 2016 3:28 pm

I think it is highly unlikely that the SVG format have changed in regard to the graphical elements, even though a new version of Inkscape may have a slightly different file format otherwise. :|
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Strange thing with font mapper

Postby Hooray » Mon Mar 28, 2016 3:35 pm

SVG is a W3C standard - thus, the most likely issue/reason is that our svg.nas parser only supports a really really tiny subset of that standard, while Inkscape supports much more of it, and probably still is in the process of adding SVG features that not even Inkscape supports currently.

If you can post the differences (or even the inkscape changelog), we can probably extend/modify the svg.nas module accordingly.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Strange thing with font mapper

Postby Soitanen » Mon Mar 28, 2016 3:40 pm

Ok, here is diff of .svg file in case of broken circle.
First string - old version, that worked good,
Last string - modified automatically by new Inkscape, which caused inverted circles to be appeared.
Code: Select all
-         d="m 544.12039,747.87402 c 0,5.07683 -4.11558,9.19241 -9.19241,9.19241 -5.07683,0 -9.19241,-4.11558 -9.19241,-9.19241 0,-5.07682 4.11558,-9.19241 9.19241,-9.19241 5.07683,0 9.19241,4.11559 9.19241,9.19241 z"
+         d="m 544.12039,747.87402 a 9.1924105,9.1924105 0 0 1 -9.19241,9.19241 9.1924105,9.1924105 0 0 1 -9.19241,-9.19241 9.1924105,9.1924105 0 0 1 9.19241,-9.19241 9.1924105,9.1924105 0 0 1 9.19241,9.19241 z"
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: Strange thing with font mapper

Postby gooneybird » Mon Mar 28, 2016 4:45 pm

My Github repository (mostly AI stuff) https://github.com/gooneybird47
User avatar
gooneybird
 
Posts: 3046
Joined: Sat May 31, 2008 2:57 pm

Re: Strange thing with font mapper

Postby Soitanen » Mon Mar 28, 2016 4:50 pm

gooneybird wrote in Mon Mar 28, 2016 4:45 pm:Have you tried it saving as "Plain SVG"?

Tried now. The same inverted circles.
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: Strange thing with font mapper

Postby nathanjent » Wed Jun 22, 2016 2:04 pm

Soitanen wrote in Mon Mar 28, 2016 3:40 pm:Ok, here is diff of .svg file in case of broken circle.
First string - old version, that worked good,
Last string - modified automatically by new Inkscape, which caused inverted circles to be appeared.
Code: Select all
-         d="m 544.12039,747.87402 c 0,5.07683 -4.11558,9.19241 -9.19241,9.19241 -5.07683,0 -9.19241,-4.11558 -9.19241,-9.19241 0,-5.07682 4.11558,-9.19241 9.19241,-9.19241 5.07683,0 9.19241,4.11559 9.19241,9.19241 z"
+         d="m 544.12039,747.87402 a 9.1924105,9.1924105 0 0 1 -9.19241,9.19241 9.1924105,9.1924105 0 0 1 -9.19241,-9.19241 9.1924105,9.1924105 0 0 1 9.19241,-9.19241 9.1924105,9.1924105 0 0 1 9.19241,9.19241 z"


I just solved this issue and wanted to post in case anyone else came across it.
The path command c (curveto) seems to be a better choice than the a (elliptical arc) command when using SVG in FlightGear. There is likely a difference in implementation with Inkscape.
To fix the circle path switch to the edit path (F2) tool and select all of the circle's nodes and hit the "make selected nodes smooth" or "make selected nodes symmetric" buttons to convert the path to use the c command instead.
nathanjent
 
Posts: 1
Joined: Wed Jun 22, 2016 1:50 pm

Re: Strange thing with font mapper

Postby Soitanen » Thu Jun 30, 2016 11:35 am

nathanjent wrote in Wed Jun 22, 2016 2:04 pm:I just solved this issue and wanted to post in case anyone else came across it.
The path command c (curveto) seems to be a better choice than the a (elliptical arc) command when using SVG in FlightGear. There is likely a difference in implementation with Inkscape.
To fix the circle path switch to the edit path (F2) tool and select all of the circle's nodes and hit the "make selected nodes smooth" or "make selected nodes symmetric" buttons to convert the path to use the c command instead.

Thanks! But your method didn't work for me, but I used "Convert selected object's stroke to path" and it works.
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 7:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17


Return to Canvas

Who is online

Users browsing this forum: No registered users and 4 guests