Menu

How to change the font?

2013-04-28
2015-02-09
  • Christian Wulf

    Christian Wulf - 2013-04-28

    For layouting the elements, CSSBox uses the Java serif font. However, I want it to use a physical font such as "Times New Roman". How can I achieve this?

     
  • Radek Burget

    Radek Burget - 2013-04-28

    Hi,
    you may use the canvas.getConfig().setDefaultFont() configuration function.

    However, this functionality is only available in the SVN trunk version. It will be available in the next CSSBox release (hopefuly in May). See the ImageRendered demo in trunk for an example (the setDefaultFonts() function)
    https://sourceforge.net/p/cssbox/code/HEAD/tree/trunk/src/org/fit/cssbox/demo/ImageRenderer.java

     
  • Nogge

    Nogge - 2013-04-29

    Interesting. But how can I get the font "Times New Roman" instance for a specific element after executing cssbox? It still returns the "Serif" font.

     
    • Nogge

      Nogge - 2013-04-29

      Ok, ok. I read your API and found the corresponding getter method. With java.awt.Font.decode you can receive the physical font indicated by the return value of getDefaultFont(). Thanks.

       

      Last edit: Nogge 2013-04-29
  • Ashish

    Ashish - 2015-02-09

    I was wondering Are you able to setDefaultFont(Str,Str) for BrowserConfig object? I tried but no effect on the generated svg .

    I tried with latest code from repository too(error using it). I would appreciate if you can suggest something to achieve functionality to add fonts that are available in your system(win / linux).

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.