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

Message ListMessage List     Post MessagePost Message

  Text Anti-aliasing
Posted by Andreas on Jul-24-2014 05:36
Attachments:
I'm using the PHP version of CD on an Ubuntu 12.04 server.

Everything is working excellent, except that small fonts are not being anti-aliased. I tried
forcing this with $c->setAntiAlias(1,1) but that didn't help either.

I'm replacing Google Image Charts with CD, and need to get as close to the original Google
charts as possible.

Here is an example. The one with smooth fonts is from Google, and the one with non-anti-
aliased fonts is from CD.

Big fonts are anti-aliased OK. Just the small ones aren't.

Any work-arounds?

Thanks,
-Andreas
chart.png
makeChart.png

  Re: Text Anti-aliasing
Posted by Peter Kwan on Jul-25-2014 01:05
Hi Andreas,

Is it possible the font does not even exists in your machine, so it cannot be anti-aliased?

For example, suppose your chart is using the Arial font. Have you installed the Arial font
(which is a Microsoft font) on Linux in the fonts subdirectory under the directory that
contains the ChartDirector shared object "libchartdir.so". Usually, the ChartDirector
shared objects are copied to the PHP extension directory, so the fonts should be copied
to a "fonts" subdirectory under the PHP extension directory.

Because the Arial font is a Microsoft copyrighted font, it is unlikely your Linux distribution
will include this font. However, you can download this font and install in your Linux legally
subject to Microsoft licensing condition. See:

http://sourceforge.net/project/showfiles.php?group_id=34153&release_id=105355
http://www.microsoft.com/typography/faq/faq8.htm

http://www.advsofteng.com/doc/cdphp.htm#fontspec.htm

If your code is using a font that does not exist, ChartDirector will substitution it with
another font in order to display the text. The substituted font can be a bitmap font and
may not support anti-alias at all. To support anti-alias, it is suggested you use true type
fonts by downloading them to the "fonts" subdirectory mentioned above.

For the Google charts, they are likely to be rendered on the browser side, not on the
server side. The browser machine is likely to be a machine with a GUI and with commonly
used fonts, and so the text on the pie chart can be displayed normally. But for
ChartDirector, the text is rendered on the server side, so the server needs to have the
font instead of the browser.

Hope this can help.

Regards
Peter Kwan

  Re: Text Anti-aliasing
Posted by Andreas on Jul-25-2014 01:51
Hi Peter,

Google Image Charts are created server-side as well.

I checked our server, and no MS fonts were installed. I installed the fonts accepting the
EULA, and restart Apache, but Arial 8pt is still not anti-aliased.

Any other ideas?

Thanks,
-Andreas

  Re: Text Anti-aliasing
Posted by Peter Kwan on Jul-25-2014 19:51
Hi Andreas,

Would you mind to verify the followings?

(a) The Arial font "arial.ttf" is copied to the "fonts" subdirectory under the directory that
contains the active "libchartdir.so". In PHP, usually ChartDirector is installed by copying all
the ChartDirector shared object to the PHP extension directory, so the active
"libchartdir.so" should be in the PHP extension directory.

(b) The fonts subdirectory, as well as the "arial.ttf" file inside it, is readable by the
anonymous user (readable by "everyone").

(c) Restart the Apache after adding a new font (because the old fonts could have been
cached, and we need to clear the cache).

(d) Make sure in your code, the arial font is specified using the font file name "arial.ttf".

If the above still does not solve the problem, please try the cdinfo.php script in the sample
code subdirectory "ChartDirector/phpdemo/cdinfo.php". This script will perform a font
loading test for the "arial.ttf" font, and will list out where it is trying to search for the font
and whether it is successful or not. Please kindly let me know what is the result.

Regards
Peter Kwan

  Re: Text Anti-aliasing
Posted by Andreas on Jul-25-2014 23:39
Thanks Peter.
Just copying arial.ttf to the PHP extension_dir fixed the problem.
Cheers,
-Andreas