ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  SVG and font names
Posted by Claudio Weber Abramo on Feb-18-2013 22:32
Hi:

When outputting SVG charts, the text bits are formatted thus:

<tspan style='font:21px Font Token Name;' x='290' y='54'>The text to be rendered</tspan>

For some OTF fonts, the correct font is not fetched, being replaced by the next fallback font.

I've found out that the problem is solved by surrounding the font's token name with quotes, thus:

<tspan style='font:21px "Font Token Name";' x='290' y='54'>The text to be rendered</tspan>

So, is there a way to force ChartDirector (php v. 5.0) to place quotes around font token names?

Thanks.

  Re: SVG and font names
Posted by Peter Kwan on Feb-19-2013 02:55
Hi Claudio,

Unluckily, ChartDirector currently is hard coded to output the font name without quotes and cannot be configured. I am worried with the current version of ChartDirector, the only method is to post-process the SVG output to add the quotes.

Regards
Peter Kwan

  Re: SVG and font names
Posted by Claudio Weber Abramo on Feb-19-2013 03:14
Hi, Peter, thank you.

Well, let's string-replace then.

It is a curious behaviour, since it only affects some fonts. It must be some buggy thing in the fonts themselves that prevent them to be rendered in browsers when called from SVG.

I tested Firefox, Chrome, Safari -- buggy SVGs, by the way -- and IE and none of them accepted the font without the quotes.

(The problem is not manifested when the fonts are declared in CSS styles).

On the other hand, the fonts (they are the exact same fonts, btw) work fine in other applications.

Well, thanks.

  Re: SVG and font names
Posted by Peter Kwan on Feb-19-2013 22:57
Hi Claudio,

Actually, we have checked the CSS standard on font names, and we think the font name issued may be a ChartDirector bug.

As according to the standard, if the font name is not quoted, all the words in the font names should be valid "identifiers". An identifier must begin with A-Z or a-z and must not contain certain reserve characters.

For example, the name "Times New Roman" (unquoted) is OK (as "Times", "New", and "Roman" are all valid identifiers), while the name "MyFont 2013" (unquoted) is not OK, as "2013" is not a valid identifier. If a font name includes non-identifiers, it should be quoted.

We will probably fix this issue in the next update of ChartDirector.

Regards
Peter Kwan

  Re: SVG and font names
Posted by Claudio Weber Abramo on Feb-19-2013 23:18
Ha!

Nothing like going to the source.

The fonts that aren't working all have a number (the weight) asociated to them.

Best regards,

Claudio

  Re: SVG and font names
Posted by Claudio Weber Abramo on Feb-20-2013 18:10
Dear Peter:

A suggestion for the next ChartDir version:

When outputting bitmap charts, CD needs that the declared fonts' files are present at the server because it needs their metrics to actually draw them.

However, when producing vector outputs, the only reason why the fonts must be installed in the server is to allow CD to pick up their names. CD doesn't do anything with their metrics because the actual rendering happens at the client side.

So, instead of requiring that font files (myspecialfont.otf) are declared, CD could be made to (also) accept font names (My Special Font).

Regards,

Claudio

  Re: SVG and font names
Posted by Peter Kwan on Feb-20-2013 23:31
Hi Claudio,

Actually, ChartDirector does need the font metrics. It is because ChartDirector performs layout. For example, it needs to know the size of the text to center align the text, to draw a box around the text, to "pack the plot aera" (see XYChart.packPlotArea), to layout the legend box, etc..

What ChartDirector does not need are the "glyphs" (the shapes of the characters). In general, the software the produces the SVG output needs to know the font metrics, which the software that "renders" the SVG (the client) needs to know the glyphs.

Some old font systems use two separate files for the font metrics and the glyphs (such as the pfm and pfb files in Adobe Type 1 fonts). But many modern fonts nowadays use a format that combines them into one file.

Regards
Peter Kwan

  Re: SVG and font names
Posted by Claudio Weber Abramo on Feb-20-2013 23:55
Oops, rightly so. I haven't considered text-alignment positioning.