Fonts

Developers
2009-12-06
2013-04-26
  • Timothy Bourke
    Timothy Bourke
    2009-12-06

    The Fire UI is really working well in Mnemojojo.

    Some users have asked whether it would be possible to support custom fonts (for instance, trying to learn Chinese characters). From what I can work out, this is not supported in J2ME and the only solution is to use/write a custom engine.

    Have you encountered any similar issues with your user base?

    Thank you,

    Tim.

     

  • Anonymous
    2009-12-07

    Ya i am also looking for the same, shall we extend the fire core to support bitmap font, anyone pls guide to where to start so that i will do the same and post here.

     
  • Adding bitmap font support is something I want to do for a long time now but it always falls back due to other priorities…

    The basic idea would be to change the TextComponent, to support a bitmap font. Additionally there would be a need for a tool to export real fonts to the correct image format for use with fire.

    For that second thing we could use similar tools available from j2mepolish but i am not sure if the GPL license will allow the use outside of opensource projects.

     

  • Anonymous
    2009-12-07

    Thanks padeler

    Actually many free tools available for converting ttf / fnt font to bitmap font (i will search and send the best tool for this)

    meanwhile pls explain more that how to place the language content in html and render it

    pls help me where to start … any idea / flow in your mind :) ?

     
  • Timothy Bourke
    Timothy Bourke
    2009-12-07

    It would be great to have this feature. I'd be glad to help implement or test it.

    It would be good to provide a way to include a bitmap font inside an executable, i.e. the jar file, to avoid taxing the heap too much.

     
  • The only Component that prints text is the TextComponent. It is also used by the Browser for rendering HTML so, if we add support for bitmap fonts in the TextComponent it will work on any code that uses it to display text.

    The way i see it, there must be a CustomFont class implementing the usual methods that a j2me Font has (like fontHeight, stringWidth etc). 

    This CustomFont will be initialized with an image (png) as a parameter. That image will contain the characters of the Font and any other metrics required for it to work (i.e. character height).

    The CustomFont must also implement  a drawString(Graphics g, String str, int x,int y, int anchor)  method that will paint the string on the Graphics object.

    Finally there must be logic in the TextComponent class in order to work with the two different types of fonts, since the J2ME font is final and cannot be subclassed.

     
  • Abbas A
    Abbas A
    2010-01-07

    hi i have developed a browser type j2me application using Fire. Really Fire UI suits very well for my requirements..
    But  now i want to add custom font support for my application. So i'm started working on that ..
    Following Mr.padelers  idea..

    I need little more help to achieve this.. so if anybody started working on this mean share some ideas..Bec i'm very young in j2me development…

    Thanks..

     
  • Timothy Bourke
    Timothy Bourke
    2010-01-07

    It would be nice, if not too hard, to keep the character layout algorithms separate so as to make it easier to adapt the basic functionality for more challenging scripts (like Arabic with its right-to-left layout and context-dependent rules for positioning glyphs and accents).

     
  • Hello abbasvib,

    I will be happy to help you with the custom font support.

    I think the first thing needed is a tool to product font images and metrics in order to use them in the implementation. I believe such tools are available open source.

    Font metrics like characted width, height font file and so on should be added to the Theme file. The key-value pairs for the font can be loaded by the Theme implementation and then used by any component. For example a theme definition on the theme.properties could look like that:

    font.1.style: plain
    font.1.face: system
    font.1.size: tiny
    font.1.resource: file://font1.png
    font.1.characters.width: 5
    font.1.characters.height: 7
    font.1.orientation: left2right
    

    In the above the "font.1"  part groups the font properties.
    The style,face,size define the font name in the same way j2me defines fonts (in this case the font size is "tiny").
    The resource file is the image with the characters.

    The "font.1.characters" fields are metrics for the font. This part is tricky since there might need to be some kind of mapping for example "character 'a' is on coordinates (35,40) on the image with size (5,7)"

    I am not an expert on fonts so i can only guess on the font metrics required. I think a good tool that will produce a font image and metrics from a font file will also give the required metrics so we could continue that discussion from there.

    Let me know on your thoughts.

    best regards,

    pashalis