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

Hmm. Same version of GD. If I set a black (78%) 2px outer stroke I get 1px black, then 2px 78% black. The difference is only noticeable in Photoshop; GD’s preview only shows the 2px. If I set to grey (100%), then I just get 3px of grey (on a 2px setting)

I’m wondering if this could be caused by changing the font size (ctrl+) though…

Okay, so when I check the imageSuffix() it also needs to check the file actually physically exists ? I will add that as an issue.

Have fixed this by checking the file exists, the problem with this is it is belting out warnings because I use system.pathForFile() - I can’t find a system.doesFileExist() method, is there one ?

It works fine, it just belts out.

WARNING: Cannot create path for resource file 'fonts/demofont@2x.fnt'. File does not exist

for unavailable resolutions. Any ideas ?

I think so. In Corona itself basically all of the multires supporting functions will use @2x/etc if there and supported by config, but silently use the original asset if not. (I suppose they might also use best available, but I haven’t tested that). For developers this is helpful because there are all sorts of reasons why you might not have multiple versions of the same asset:

  1. Nearest neighbor scaling means it would just be the same thing

  2. You’re loading images from the internet

  3. You don’t have another density of that resolution at the moment (for example, coding on the fly)

  4. You’re using a new scale (ex: the likely @3x coming this fall) and haven’t done all the exports yet

It’s just too problematic to expect every resolution to be present on every build. :slight_smile: This is why typically the way developers check for missing high res assets is to simply load the app and look for pixelation. :slight_smile:

@richard

Yeah, I can confirm that the stroke-width is +1 in GD. Setting it to 0 produces a 1px stroke :slight_smile:

However the color is solid. Maybe there are some other settings in GD that I haven’t set to get the behavior you’re seeing…

The resolutions is still fixed, basically as I suggested it just checks to see if the .fnt file is there, and picks the best. Minor downside is that it is belting out the warnings, which is Corona. Can’t find a silent way to check for the existence of a resource ?

There’s no call for if a file exists. I believe you just have to attempt the load in an if statement to ensure that you handle loading alternatives.

There is a safe, silent way to do it using LFS (Lua File System) but you’d have to check it against iOS (device!) and Android (device!) to ensure it works since they both have different ways of handling the ResourceDirectory. I would think it should work because neither .png or .fnt is on the protected list (for example, you can’t use LFS to look for lua files) but I do remember having quite the time trying to autoload assets across sim and two device platforms. (I think my specific problem was that I was trying to load TexturePacker Lua files corresponding to .png files though. With .png and .fnt only it might have worked)

I’ll look into it. The warnings are annoying ; it works fine, I think, but I don’t really like superfluous warnings. 

This is the thread where I detailed how I was using lfs. It’s pretty code light, but does have the extra require. The difference is that this one is trying to load everything from a directory and not a specific file.

I ended up abandoning the approach because I wanted to auto-require imageSheet .lua files generated by TexturePackerPro, and sadly lua is that special case that really can’t be handled in this manner. Irregular files are just assets (i.e.: .fnt) so they should be fine. The Corona SDK documentation mentions that you can’t read .png files from the resource directory in Android, so that might be a show stopper though. (the detail is a bit unclear; does that mean LFS can’t find it, or just system.*?)

Wow, I ask a question and wake up the next morning and this thread exploded…

Good news, not using Corona 2.0 seems to have solved my blurry issues.

Thanks,

Rob

Yeah, that’s what I thought I asked before. If it’s absolute pixel height then I would assume (for ease of use) that you could fall back on “A” to set font size. Sure, it might not always look perfect, but it’s better than an assert. 

Now then, I bought bmGlyph and tried building a basic font from an existing .TTF. It’s showing up extremely blurry despite there being @2x and @4x assets, as if only the 1x asset is being used. I’m not entirely sure why, yet, but I am noticing some problems. Note that this is with both custom TTF and OSX standard TTF; I seem to have the same problem across every font I’ve tried.

1. You need to pass on padding data from the .fnt file to graphics.newImageSheet (.border). (Needed to fix OpenGL bleed artifacts)

I’m not entirely sure but I think in bmGlyph padding would be a combination of Bounding Box and Padding, as padding doesn’t seem to apply along the extreme edges of the texture. (The .fnt file carries both padding and spacing on the first line; not sure which is which…)

  1. I’m noticing two specific problems: heavy blur (again, looks like only 1x assets in use) and the y offset is off on everything, giving a jumpy look where the text dips up and down. 

Specific bmGlyph output options:

  • @4x: scale 100%

  • @2x: scale 50%

  • sd: scale 25%

  • power of 2 texture

  • 0 bounding, 0 padding

  • Auto x/y offsets is on, although it doesn’t seem to change things either way

This generates the -, @2x, @4x assets.

a. If I turn on “Align to Grid”, the glyphs are all enormously spaced out, which makes me wonder what happens to the offsets when one does this.

b. Although the publishing wizard makes it easy to setup the 3 resolution outputs, choosing a project type doesn’t seem to make a difference for the purposes of font manager. cocos2d+bmfont or corona presets both give the same output files.

Looking at your provided demo fonts:

  1. They all work, and look sharp (no 1x blurriness)

  2. Substantial naming differences between the texture and .fnt files, which is not wrong, but a bit weird…

  3. I can’t be entirely sure but there looks to be (some) similar y-offset problems with the demo fonts. For example, on demofont the interior lowercase all seem to be lifted.

(Why bmGlyph? Unlike Glyph Designer, (a) it has specific support for mobile packages, including Corona, in mind, and (b) it’s available for cheap through the App Store.)

The “Ingemar bug”, that is the display box showing the bounds of the text and the whole text string being initially shown wrongly has been closed. 

The “Richard9 bug” (not detecting when @2x is used in config.lua but isn’t actually present) is fixed, but it is chucking out warnings, hope to fix this tomorrow.

Thanks everyone.

Hi. I’ve got Glyph Designer and the demo version of bmglyph so I have been experimenting.

With respect to padding, I’ve yet to find anything that is anything other than 0,0,0,0. I’m not quite sure what you mean ?

BmGlyph - I tried your settings and yes, it does look terrible. The output from bmglyph (the small fonts) is awful though :frowning:  Viewing it in a image viewer it does look all blurry. If you have a font that looks okay on the .png but doesn’t work can you send it to me ?

I can only do it on 50 pt size mind. I found that simply calling the font bmgfont@4x or whatever worked fine, even when it was scaled down. 

I don’t quite see how bmGlyph is going to work - it generates three different font file bmgfont.fnt bmgfont@2x.fnt and bmgfont@4x.fnt so there isn’t likely to be much in the way of auto detection.

You were right about the alignment. I think it’s right now - I made a font from straight Arial and it looks like it is matching  up as it does in LibreOffice, at various scales, so I think it’s right - it’s certainly a lot closer than it was. 

The font image name is part of the .fnt file, so it doesn’t matter what it is as long as its consistent.

Padding

Padding applies a border around every glyph. So a padding of two adds a 2px transparent gap around A, B, C, etc. This can be important sometimes because there are situations (especially if Corona is not using GL_NEAREST) where the sprites will bleed and the edge of one glyph ends up on another.

You can set the padding directly in bmGlyph. The only thing I’m not sure about is that it’s a single value (not 4) so not sure exactly what the .fnt translation of that number means, except perhaps -2,-2,2,2

bmglyph files

I don’t think you need to worry about the @2x/@4x .fnt files. TexturePacker does the same thing with .lua. AFAIK corona only needs the base file to calculate the differences, since internally what graphics.* does is use all numbers from 1x to calculate 4x.

Just checked my project, and the 1x file was also awful in my case. But I re-ran the publish and now it looks alright in the PNG file. Not great, but not super hazy. And I have another test that seems to look alright at all three. You can grab them here, temporarily. (They’re both the same font, one has no stroke)  Still can’t get anything but 1x haze in the simulator, though.

Having experimented with LFS this AM, it seems to work fine on iDevices and the simulator, but not on Android ; seems to be the problem about the zipped directory.  My simple test program to read it using system.pathForFile(nil,system.resourceDirectory) seems to have crashed my Android tablet :frowning:

As such I’m tempted to leave it as it is, using system.pathForFile as a file exists test, and just live with the warning messages.

@paulscottrobson

Good news! It looks like the warnings are only printed in the Corona Simulator. When I test on device (iOS and Android) I don’t see any warnings in the device Console/logcat.

PS.

I think that CoronaLabs have changed the behavior of pathForFile() at some point in time, because I can’t remember that it checked for a file’s existence before. It *is* documented that a warning will be displayed though. (But it doesn’t on a device… which is a good thing)

Ah, right. I wasn’t quite sure what these things actually meant :slight_smile: I’ll fix that today, that isn’t particularly difficult. 

I think the problem with bmGlyph is it just produces smaller font files than GlyphDesigner does by default - I’m not sure there’s anything wrong with the code (except the bleeding issue you mention above) other than it’s trying to scale things up too much. If I run in 320 x 480 and pick iPad Retina that means a scale-up of 4x before you even do anything else. 

This https://coronalabs.com/blog/2012/03/22/developing-for-ipad-retina-display/ should work though I haven’t tried it.

Have you ever managed to actually generate a padded font ? There’s a padding and bounding box option on bmGlyph but it doesn’t affect the padding setting irrespective of what it is set to.  The Glyph Designer one does seem to work though.

sorry for bumping out of discussion, but does this library able to do than just animated moving text? like for example, a typewriting effect dialog that appears in RPGs? would love to try this when I have the time though :slight_smile: