Custom font family dynamically ?

Post questions on how to use or achieve an effect in Inkscape.
amagick
Posts: 4
Joined: Sun Mar 01, 2015 6:00 pm

Custom font family dynamically ?

Postby amagick » Sun Mar 01, 2015 6:08 pm

Hi,

I want to import a font dynamically.

I tried like this but it does not work :

test.svg
<svg xmlns:svg="http://www.w3.org/2000/svg" version="1.2"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="800px" height="800px" viewBox="0 0 800 800">
<title>Text in a heart</title>


<defs>

<style type="text/css">
@font-face {
font-family: testfont;
src: url('testfont.ttf');
}
</style>


<path id="heartPath" fill="none" d="M367.386,236.209C303.31,86.667,121.172,121.558,119.973,295.124c0.664,95.325,86.73,130.957,144.918,169.065
c56.423,36.958,96.58,87.514,102.873,109.036c5.388-21.087,50.116-73.074,102.346-110.07
c57.109-40.452,145.582-73.744,144.917-169.067C613.821,120.092,428.516,92.631,367.386,236.209z"/>

</defs>

<use xlink:href="#heartPath"
fill="none" stroke="none"
fill-opacity="1" stroke-opacity="0" />

<flowRoot style="font-size:12px;text-align:justify;font-family:testfont;font-weight:normal;line-height:100%;">
<flowRegion>
<use xlink:href="#heartPath" />
</flowRegion>
<flowPara fill="red" fill-opacity="1" stroke-opacity="0">My custom text</flowPara>
</flowRoot>

</svg>


Code: Select all

inkscape -f test.svg -e test.png -y 1


or, it may be possible to set the default font from the command line?

Thank you

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Custom font family dynamically ?

Postby hulf2012 » Mon Mar 02, 2015 1:34 am

Hello,

- Are you puting the url in a correct way?. In your example, it's supposed taht your font is in the same directory that your svg file

- At the end., It may not be supported.

- It seems that there habe being changes in how inkscape handles extern fonts. Try to do a search in the forum to see if there are related topics.

amagick wrote:or, it may be possible to set the default font from the command line?

Thank you

- Have you read this?
http://tavmjong.free.fr/INKSCAPE/MANUAL ... dLine.html
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Custom font family dynamically ?

Postby ~suv » Mon Mar 02, 2015 1:51 am

hulf2012 wrote:- At the end., It may not be supported.

Not supported in inkscape (@font-face). Might work in browsers, or other SVG viewers.

amagick
Posts: 4
Joined: Sun Mar 01, 2015 6:00 pm

Re: Custom font family dynamically ?

Postby amagick » Mon Mar 02, 2015 6:29 pm

Is there another way to load a font file dynamically with Inkscape ?

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Custom font family dynamically ?

Postby ~suv » Mon Mar 02, 2015 9:17 pm

amagick wrote:Is there another way to load a font file dynamically with Inkscape ?

No. In current Inkscape, the only fonts available are those installed in the system at the time the current Inkscape session was launched.

Current Inkscape does not support
  • loading fonts (which are not regularly installed on the local system) from custom locations (e.g. project-related folders, or inkscape-specific shared resources folders),
  • reloading the list of fonts (which are installed regularly on the local system) during the current session (you need to quit and restart Inkscape after having installed new fonts to have them available in Inkscape),
  • using web fonts via '@font-face' CSS3 at-rule,
  • using SVG fonts defined in the current document as fonts for text objects in the same document.
Feature requests are filed for each of these aspects about font loading, but no one has been working on implementing any of them so far.

amagick
Posts: 4
Joined: Sun Mar 01, 2015 6:00 pm

Re: Custom font family dynamically ?

Postby amagick » Mon Mar 02, 2015 11:44 pm

Thank you for this very clear answer.

I'm looking for a way to generate PNG from SVG (from a script). This SVG contains a shape with text inside.

With Inkscape, everything works except that the font can not be customized dynamically.

Do you know a way (another program for example) that do this?

It is necessary that the program supports the tag "flowRoot" and "@ font-face" or a way to set the default font at the time of execution of the program.

Thank you


Return to “Help with using Inkscape”