Looking for feedback/suggestions on my free bitmap font library (bit like TextCandy ...)

I downloaded this today to play with it, so I have whatever is currently on github.  I’m also using bmGlyph (can’t afford the other one right now) and I’m still seeing soft fonts.  I output my font at 128 point which should be plenty big. 

Do I have the latest that supports the @2x and @4x?  Should I be outputting “Corona 2.0” or some other output type?

Rob

The latest version supports Corona’s dynamic scaling. The suffixes used for the imagesheet and fnt files are taken from whatever is put in config.lua’s imageSuffix entry.

I’m on Mac and have tested only with fnt files generated by GlyphDesigner. I haven’t tried bmGlyph. I’ll give it a try to see if I find any issues with it…

When you publish, you should either use “Cocos2d/BMFont” or “Corona” format.

The “Corona 2.0” format outputs a lua control-file instead of fnt which doesn’t work.

I just tested bmGlyph and it works as expected. (Although the trial is severely limited to 50px Arial only). I couldn’t see much difference between the files generated by bmGlyph and GlyphDesigner, but the limit of the bmGlyph-trial prevented me from doing a proper test.

Dynamic imagesheet selection is controlled by using imageSuffix in config.lua. 

One thing to note is when you specify the fontSize in newBitmapText() it’s best specify the size in “base size” (the size without an image-suffix). Let’s say you have a font that you want to display at 50px base size and want to support @2x and @4x. You’ll publish 3 fonts (50px=base-size, 100px=@2x and 200px=@4x) and set up your imageSuffix entries in config.lua accordingly.

In your call to display.newBitmaptext() you should use fontsize=50. You can use a smaller value to downscale the font a bit, but too much downscaling doesn’t look good. Larger values can also be used, but will upscale and produce fuzzy text.

  1. Not sure what you mean here? So fontSize does not set the scale of the bitmap text, but just defines a how much of the font characters appear? (ex: if ‘A’ is 40x40, and you say 80, what happens…?)

  2. A method for hooking in would be best, yeah. 

  3. This just came up because you flat out say to run main.lua, but everything inside it is commented out. So to understand what you mean I’d have to open main.lua to know that I have to uncomment something and then I still don’t really have a good idea what any of those sub-scenes do without opening those up, too…Just an issue of initial usability, really…

  4. Well, it just feels like the animation method I have in mind (char-by-char reveal, no alpha stepping) could be simple enough to turn into a stock function. I’ll take a closer look at your code later, maybe I’ll see something else to do with it.

To your credit, I got the sample font running with the effect I had in mind in about an hour. So your code works great! I’ll try experimenting with removal and with a few new bmGlyph fonts soon, too.

The basic changes Ingemar made was to use the image suffix table in the config file rather than my method which was to physically search for their existence and pick the best. If there isn’t an imageSuffix entry then it will default to 1x.

Can you let me have the font/.fnt files etc. I have had this problem reported with bmGlyph by Richard9 but I haven’t been able to reproduce it, the only ‘low quality’ font output has been when the font graphic itself was low quality (e.g. small font) and was being scaled up, so it is pretty much doing exactly what it should , as you say 128 point should be fine at almost any zoom level.

I do have bmGlyph and glyphDesigner (both companies let me have a copy, which was very generous of them)

There is a status list at the bottom of the main font manager.lua file , at the time of writing the last entry is “Stopped crashing when no imageSuffix in config dated 5/7/14.” - this is the only change I made to Ingemar’s work, if you didn’t have imageSuffix in it failed. Bear in mind I’m in the UK so times are slightly out.

I have a weird issue.

I’ve noticed that sometimes multi-line text will have a very large bounding box (y-axis only).

Calling reformatText() on the string fixes the issue, but the issue doesn’t always happen.

I’ve attached a sample project that shows the issue.

Thanks - almost certainly a bug. I will sort it.

Great!

BTW.

It would be awesome to also have the kerning table included in the character-to-character calculations.

There are cases where the text looks a bit odd. For example “Total” looks a bit like “T otal” because of the lack of kerning.

The kerning info looks fairly simple in the fnt file: first=left-char-code second=right-char-code amount=adjustment-amount.

Would it require a bunch of work?

All I was saying about the @2x issue is that Corona silently uses best available, whereas font manager gives a warning. Should be easy enough to fix on my end.

Okay, I thought my new issue was solvable, but now I’m not so sure…

fontmanager.lua:54: bad argument #1 to 'lines' (FILE\* expected, got nil)

Usually this is just me getting tripped up over not setting the right fonts directory,  but I’ve made that change and it still can’t find the file. 

BitmapFont.fontDirectory = "assets/fonts" -- where font files are, fnt and png.

My basic structure is app/assets/fonts for the font, app/code/ for the font manager

EDIT: Yeah, it’s definitely crashing because it lacks the @2x asset. Simply copying the .fnt and .png and adding the @2x issue stop the crash. I will look into adding fallback code.

That should hopefully be fixed by Ingemar’s work - I used my own code, Ingermar’s scans the image suffix table in config.lua

Kerning shouldn’t be too difficult because it reformats, so the reformatting should, theoretically, just have to be adjusted to sort the kerning. I want to figure out the bug reported above first (this will be tomorrow morning probably). 

I don’t understand? The crash is strictly using the latest fontmanager.lua (a few minutes ago). Unless you mean the ingemar change you mention has yet to be integrated?

+1 on kerning, that would definitely help with the font I’m using. :slight_smile:

@richard

I added a new function called fm.BitmapFont:setFontDirectory() that you can use instead of modifying the module code. 

As for the crash you’re seeing. I think there might be a bug if there’s no imageSuffix in config.lua. 

Regarding the @2x warning. That’s on Android, right?

A font dir setter! Perfect! :slight_smile:

No, the @2x warning is on OSX simulator (iPhone 5). 

My config.lua has specific settings for @2x, @3x, @4x, but because I’m using GL_NEAREST I don’t always have assets for those resolutions. (It doesn’t make sense in many cases to carry a bunch more files if nearest neighbour scaling does the same job.)

My bad. That error message means it can’t find the .FNT file. I have added it to the issues to make it fail more gracefully and helpfully. 

You can figure out what it can’t find by adding print(self:getFontFile(fontName)) before line 54. I will update it so it gives a more helpful error message. 

I think it’s a side effect of Ingemar’s changes, the check was originally done when it was looking for font@2x.png font@4x.png and so on, so when it got the file name back it knew it existed.

I fixed the no imageSuffix entry bug which was crashing most of the demos which only had a very basic config.lua. The padding on characters that were images failed miserably as well. Not quite sure why but fixed it anyway :slight_smile:

Yeah  :( My change caused this to happen… sorry.

It doesn’t set either. It’s an absolute pixel height. So, if you define fontSize to be , say, 80, the font should fit perfectly in an 80 pixel high box and be properly vertically aligned. So if your A is 40x40 it will become 80x80 pixels because the aspect ratio of the character is maintained. It means ‘how tall in pixels do you want the string to be’. The library doesn’t actually care if A is 40x40 or 140x140, it will scale it to the size you want. Then you have the usual graphic tradeoff between pixellation and asset size.

It can look slightly odd because some faults have very low descenders and very high ascenders, I thought it was broken for a while, but putting the debug boxes on shows it is actually right. In multiline text it can look very spaced out, this was the reason for the setVerticalSpacing() method. 

You want to do something quite specific - whilst my system can do it (the alpha stepping is just commenting out one line in main_roll.lua) it’s not really designed for it. If you just want to do that it might be simpler to create some code to do exactly what you want. I suspect you don’t want any of the modifiers code for example. You could just hack out the first 300 or so (as far as “ModifierStore”) and possibly the Character Source/UTF-8 classes if you want this, and chuck the rest. This would give you a fairly robust single character bitmap font object without much unused code (you wouldn’t use BitmapCharacter:modify() probably).

Well I can work around for now by using fake @2x assets. :) 

Also found a pretty interesting Glyph Designer bug, for those who use it. Seems if you set an outer stroke, it always adds a +1 stroke. So outer stroke +2 is actually +1 stroke black, +2 stroke whatever colour you used. Center stroke doesn’t have this problem.

No problem, it is fixed (haven’t fixed the other one yet). It actually gives two warnings, the system call to get the directory gives a warning when the .FNT file is not found, and FM now gives out a similar warning.

Also found a pretty interesting Glyph Designer bug, for those who use it. Seems if you set an outer stroke, it always adds a +1 stroke. So outer stroke +2 is actually +1 stroke black, +2 stroke whatever colour you used. Center stroke doesn’t have this problem.

 
 
I haven’t seen that. I just tried by having a white font with a white 2px outer stroke. I see no black stroke included.
Weird.

GD version 1.9.2 (5666)