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

Message ListMessage List     Post MessagePost Message

  CSS & Font
Posted by Sean Laks on May-11-2023 05:09
Hi Peter,

   I have a need to display certain fonts and colors that have been defined within our organization. The text to which the font and color will be applied are added via addtext method - say to display certain text within the chart area.

   Is there a way to refer to these in-house font families and colors within CD? Similar to using external CSS in plain HTML by providing the css path.

Thanks
Sean

  Re: CSS & Font
Posted by Peter Kwan on May-11-2023 15:09
Hi Sean,

ChartDirector cannot parse CSS. If you want to use CSS as a separate file, you would need to parse the CSS with your own code to obtain the font name. You can then use the font name in ChartDirector as long as Java can access that font.

Best Regards
Peter Kwan

  Re: CSS & Font
Posted by Sean L on May-11-2023 17:48
Hi Peter,

   Thx for the response. Slight mod to my original question on CSS.

   Is is possible to refer to a custom font family in CD (say addText method) that will be rendered correct in a png format which is the my final chart output? More like an inline css as opposed to external css.

  IN you response, you stated "as long as it is available to Java". What does entail?

Thx
Sean L

  Re: CSS & Font
Posted by Sean L on May-11-2023 18:36
I just came across a reference to "GraphicsEnvironment.getAvailableFontFamilyNames" in you font documentation. I presume this might answer my question.

  Re: CSS & Font
Posted by Peter Kwan on May-11-2023 20:02
Hi Sean L,

Fonts are managed by the OS. Different OS has different APIs for fonts. For example, the APIs on Windows and macOS and Linux are completely different.

For Java, the application only communicates with the Java VM. The Java VM should know how to access the fonts in the operating system.

ChartDirector can use all fonts that the Java VM can access. If your custom fonts are installed on the OS, all applications, including the Java VM, should be able to access them. For example, if you open MS Word, in the font list, you should see your custom fonts.

However, if the font is not installed on the OS (such as "web fonts" that are downloaded on the fly for a particular web page), Java would be unaware of the font and so ChartDirector is unable to use it.

The GraphicsEnvironment.getAvailableFontFamilyNames lists out all fonts that the Java VM is aware of and therefore usable in ChartDirector.

Best Regards
Peter Kwan

  Re: CSS & Font
Posted by Sean Laks on May-11-2023 22:43
Perfect. Thx for the explanation