×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Regular Contributor
    Join Date
    Jun 2009
    Location
    Tel-Aviv Israel
    Posts
    410

    Suggestions for the best implementation of fonts for j2me

    Hey guys, this past week I was busy trying to design the best implementation of fonts for J2ME, now I had an idea and I went with it, but I got to find out it was limited, not programmingly speaking but more of the font been nice kind of limited, when I force the fonts to fit a specific size(Mono space), in some cases the fonts looks like sheet, and I tried everything, they just don't look nice enough for me. now, I would like to design a font system which is Images based but with a different size (width, and perhaps height) for each font, I've done something relatively close to that but found out that it is tricky and very time consuming, so I was thinking to ask you guys, if anyone has an idea, please do share I would love to read what you think about the subject.
    Thanks,
    Adam Zehavi.

  2. #2
    Regular Contributor
    Join Date
    Jun 2009
    Location
    Tel-Aviv Israel
    Posts
    410

    Re: Suggestions for the best implementation of fonts for j2me

    well one of my thoughts was to provide two files for the font object, the one to be the image, and the other the ASCII value of the font with its rectangle in the image, and to hold all the information(ASCII and Image) in the font object...

    what do you think?
    Thanks,
    Adam Zehavi.

  3. #3
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Suggestions for the best implementation of fonts for j2me

    well afaik all third parties libraries nd apps in vague uses their custom fonts based on images nd also there is no other way rather than standard way of MIDP implementation and this images based font.

    Yes of course displaying image based text is tricky process moreover if you want to make text size dynamically big nd small you have to resize the images dynamically which is very CPU intensive process nd if since these fonts can only be placed in low level GUI so these have to invalidated every sec which make the condition even worse if one is resizing the text on the fly.

    However the second approach to store images for diff. size of fonts but that will make the size of jar big enough for most of low end devices but is most used nd widely accepted approach
    Regards,
    Saurabh

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Suggestions for the best implementation of fonts for j2me

    You can look at this implemenatation - http://developers.sun.com/mobility/m...termemulator3/

    FN Wiki link - http://wiki.forum.nokia.com/index.ph...nts_in_Java_ME


    thanks,
    ~Amitabh

  5. #5
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    53

    Re: Suggestions for the best implementation of fonts for j2me

    With J2ME Polish or similar does anyone know if it is possible to build different jars which ringfence a selection of bitmap fonts with point sizes
    appropriate to the screen dimensions of the target phone ?

    How do commercial J2ME games developers handle fonts in their midlets ?
    I can't see how they could bundle bitmap font assets for *all* possible target handsets without swelling the jar file beyond what is acceptible

    --Ian

  6. #6
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Suggestions for the best implementation of fonts for j2me

    I dont know exactly about j2me polish but commercial games make different build for different screen sizes nd also they incorporate image based text in support of my point extract any jar file of any commercial game, in files you obtained you will find an image file containing images of character that are used in that particular games
    Regards,
    Saurabh

  7. #7
    Regular Contributor
    Join Date
    Jun 2009
    Location
    Tel-Aviv Israel
    Posts
    410

    Re: Suggestions for the best implementation of fonts for j2me

    Thanks for all your responses. My main idea was to make a few general fonts, just like every device support a few basic fonts (which are looking different on each device, and therefor does not provide a visual consistency of the same application on different devices, which may cause unexpected/undesired results) and a few fonts modifiers, like a color wrapper for the fonts, or any other thing I might think of in the future...

    (of course these actions would require me to design a transparent mutable image object)

    does any one have any other suggestion to add, to make, I ask because I really want to design a very strong font system for J2ME, so I may use in any of my applications.
    Thanks,
    Adam Zehavi.

  8. #8
    Regular Contributor
    Join Date
    Jun 2009
    Location
    Tel-Aviv Israel
    Posts
    410

    Re: Suggestions for the best implementation of fonts for j2me

    Quote Originally Posted by im2amit View Post
    You can look at this implemenatation - http://developers.sun.com/mobility/m...termemulator3/

    FN Wiki link - http://wiki.forum.nokia.com/index.ph...nts_in_Java_ME


    thanks,
    ~Amitabh
    nice implementation, but I had something a bit more complicated in mind, I would like to choose my own font color, and font style would be an effect that changes the image of the font as it is stored in the Image[] of the font images, plus I don't really see the need for baseline, but it can't harm to have one defined.
    for example I would want my font to be Yellow, with a Green wrapper (terrible combination I know :-)) I would like this font to hold images of the final design and then to use it in my application, so the only real CPU consumption would be only at the creation of the fonts, and the runtime cost would be practically the same as in the example you gave.
    Thanks,
    Adam Zehavi.

  9. #9
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Suggestions for the best implementation of fonts for j2me

    I store fonts in three parts:

    1. the PNG data for the image
    2. the list of characters in the image (in order) as a UTF-8 string
    3. an array of bytes for the character widths (for proportionally spaced fonts)

    Oh, and some extra info for the font height, width of a space, character spacing, line spacing, and so on.

    Then I bundle all of this into one ".font" file.

    The image is just the image of the font, so different style = different image. All the characters are in one image, using a clipping to paint the appropriate character (I posted a simplified version of the code on the forum somewhere...).

    Graham.

  10. #10
    Regular Contributor
    Join Date
    Jun 2009
    Location
    Tel-Aviv Israel
    Posts
    410

    Re: Suggestions for the best implementation of fonts for j2me

    would clip and paint be faster then painting each font as an image by itself?
    Thanks,
    Adam Zehavi.

  11. #11
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Suggestions for the best implementation of fonts for j2me

    Oh... if you want to change the colour of the font dynamically... you can do that by editing the palette in the PNG data. That's simplest for single colour fonts (since you'll only have two palette entries, and the first one will be transparent). You need to re-calculate the CRC for the palette chunk, but the algorithm is in the PNG spec.

  12. #12
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Suggestions for the best implementation of fonts for j2me

    Quote Originally Posted by TacB0sS View Post
    would clip and paint be faster then painting each font as an image by itself?
    No, it will be slightly slower. But it will consume maybe as little as half the memory. It will also impact a lot less on the JAR size.

  13. #13
    Regular Contributor
    Join Date
    Jun 2009
    Location
    Tel-Aviv Israel
    Posts
    410

    Re: Suggestions for the best implementation of fonts for j2me

    yes thats the idea, but I was thinking to change the bytes of the image, to replaced the black ones with a different color, more over I would like to add effects to the fonts, which would be different "FontTamplate" object, that would add itself to the right image, so for example if I have font6x8, and a wrapper for these fonts font6x8Wrapper, I could have any font color that I would want with any wrapper color that I might choose...

    and I could to this with many things like a bold effect, or an italic effect... with an object that manipulates the bytes of the image to do my bid...
    Thanks,
    Adam Zehavi.

  14. #14
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Suggestions for the best implementation of fonts for j2me

    Changing the colours is easy, provided you know what order they appear in the palette (and provided it's a palette-mode PNG). You can manipulate the pixel data too, but that's a different story. For bold, you can do like the code on the Sun site, and just draw each character twice. You could follow their example for italic too...

  15. #15
    Regular Contributor
    Join Date
    Jun 2009
    Location
    Tel-Aviv Israel
    Posts
    410

    Re: Suggestions for the best implementation of fonts for j2me

    Quote Originally Posted by grahamhughes View Post
    No, it will be slightly slower. But it will consume maybe as little as half the memory. It will also impact a lot less on the JAR size.
    Very funny man, did you really think I would save each in a different file? one file for all the fonts as I posted a while back, and another for the data, and the fonts are set once at the creation of the object,

    for example you would like to have a font6x8, so you go to "MyFonts" and say:

    Font font= MyFonts.font6x8.copy(); // creates a copy of the fonts images.

    font.setColor(Color.Red); ==> {
    change the bytes of each image from black to red, and save the current color value for future changes.
    }

    font.addEffect(new BoldEffect()) ==>{
    boldEffect would create a new transparent mutable image(that I would have to design using changing the byte array) and would draw the same fonts image twice with one pixel offset to the right, to give a bold effect.
    }

    font.addEffect(new WrapperEffect(MyFonts.font6x8Wrapper.copy().setColor(SomeOtherColor)) ==> {
    this would create a new transparent mutable image and would draw both the font and the wrapper images on that new image... and then I get a new look every time ...
    }

    after designing the font dynamically I only need to paint it on the canvas...

    what do you think?
    Thanks,
    Adam Zehavi.

Similar Threads

  1. Installing Multiple Types of Fonts on a Symbian S60 Device
    By ahmadn in forum General Development Questions
    Replies: 1
    Last Post: 2009-04-22, 18:25
  2. Fonts in SVG-T implementation
    By nummisalo in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2006-03-19, 14:35
  3. 9500 worst Communicator ever. Suggestions to improve it.
    By creacom000 in forum General Development Questions
    Replies: 4
    Last Post: 2005-07-21, 11:16
  4. Downloading fonts to Nokia device
    By grao in forum Symbian
    Replies: 0
    Last Post: 2005-01-19, 16:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×