Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Looking for feedback/suggestions on my free bitmap font library (bit like TextCandy ...)
Started by paulscottrobson May 08 2014 01:11 PM

* * * * * 1 votes
125 replies to this topic
[TOPIC CONTROLS]
« Page 4 of 6 2 3 4 5 6
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#76

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,925 posts
  • Enterprise

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



[TOPIC: post.html]
#77

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

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...



[TOPIC: post.html]
#78

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

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.



[TOPIC: post.html]
#79

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

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.



[TOPIC: post.html]
#80

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

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.

 

Attached File  fmtest.zip   359.21KB   90 downloads



[TOPIC: post.html]
#81

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

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



[TOPIC: post.html]
#82

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

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?



[TOPIC: post.html]
#83

richard9

[GLOBAL: userInfoPane.html]
richard9
  • Corona Geek

  • 1,118 posts
  • Enterprise

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.



[TOPIC: post.html]
#84

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

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



[TOPIC: post.html]
#85

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

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). 



[TOPIC: post.html]
#86

richard9

[GLOBAL: userInfoPane.html]
richard9
  • Corona Geek

  • 1,118 posts
  • Enterprise

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. :)



[TOPIC: post.html]
#87

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

@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?



[TOPIC: post.html]
#88

richard9

[GLOBAL: userInfoPane.html]
richard9
  • Corona Geek

  • 1,118 posts
  • Enterprise

A font dir setter! Perfect! :)

 

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.)



[TOPIC: post.html]
#89

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

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 :)



[TOPIC: post.html]
#90

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

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



[TOPIC: post.html]
#91

richard9

[GLOBAL: userInfoPane.html]
richard9
  • Corona Geek

  • 1,118 posts
  • Enterprise

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.



[TOPIC: post.html]
#92

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

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.



[TOPIC: post.html]
#93

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

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)



[TOPIC: post.html]
#94

richard9

[GLOBAL: userInfoPane.html]
richard9
  • Corona Geek

  • 1,118 posts
  • Enterprise

 
 
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)

 

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...



[TOPIC: post.html]
#95

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

A font dir setter! Perfect! :)

 

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.)

 

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



[TOPIC: post.html]
#96

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

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 ?



[TOPIC: post.html]
#97

richard9

[GLOBAL: userInfoPane.html]
richard9
  • Corona Geek

  • 1,118 posts
  • Enterprise

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

 

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. :) This is why typically the way developers check for missing high res assets is to simply load the app and look for pixelation. :)



[TOPIC: post.html]
#98

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

@richard

 

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

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...



[TOPIC: post.html]
#99

paulscottrobson

[GLOBAL: userInfoPane.html]
paulscottrobson
  • Contributor

  • 456 posts
  • Corona SDK

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 ?



[TOPIC: post.html]
#100

richard9

[GLOBAL: userInfoPane.html]
richard9
  • Corona Geek

  • 1,118 posts
  • Enterprise

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 ?

 

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)




[topic_controls]
« Page 4 of 6 2 3 4 5 6
 
[/topic_controls]