Excellent, I’ll close that then.
No problem. Yes it can (this is what Richard 9 wants). If you look at the main.lua file which is a placeholder for others comment out all except require(“main_roll”) and run it, it rolls out some text - this particular interpretation also allows ‘events’ in the text, in this case the speed changes (and it print ‘shake’ to the console). The file is some support classes (one does the roll out, one does the events/animation and one puts the whole thing together, then there is a sample class and showing how it works.
It’s a cheat though ; it is an ‘animation’ which progressively reveals the text. The whole text is always there, it’s just the bits that haven’t been revealed yet have an alpha of zero 
can you explain how the animation work? dos it animate the bits of text one by one, or is it something else? Because i worry about the performance of the device, as sometimes animations can be quite heavy in Corona. But hell, I’ll even try this asap. this really intrigues me 
At heart all if it is a display group with a collection of bitmaps, which are by default arranged in a line or multiple lines, you can left, centre and right justify them. This is their ‘normal’ state and to the system that is what they are. So if you animate them the anchor points don’t move (as opposed to if you use transition.to on it)
The animation is driven by the concept of modifiers. For each displayed character you can change specific features - position offset, scale and rotation, alpha pretty much to anything you like. The ‘modifier’ receives a table saying which character, word, line etc. it is on and the modifiers work out what to do. So if you want your third word to be twice as big your modifier would have something like.
if info.wordIndex == 3 then modifier.xScale = 2, modifier.yScale = 2 end
Something like the wobble modifier just sticks a few small random numbers in the modifier.
Animation is basically a time adjusted modifier. There are two values used for this, an elapsed time since the string was created, and a ‘position’ function which is a percentage of width when static, but when modified this moves along.
If you don’t animate the text but just shape it, the modifier is applied once and then nothing else happens, so there are no performance issues other than the time Corona takes to render the font bitmaps.
If you animate it, then at a given rate (you can change this) the bitmaps are continually re-modified, so you can then use the time features to make it move. This obviously has resource implications, because everything is repositioned and recalculated. If it was (say) used in an arcade game for the score it would be fine static - to the system it’s just more bitmap images - but animated might slow things down to much especially on low end Android hardware.
In general though it’s fine. I’ve got an ultra cheapie 7" tablet - the worst I could find - and it seems to cope fine.
So the roll out modifier is something like:
if info.elapsedTime/1000 \> info.index then modifier.alpha = 1 else modifier.alpha = 0 end
So every one second, the elapsed time reveals one more character (index is the character number it is enquiring about) after 1 second, index 1 is shown, after 2 seconds 1 and 2, after 3 seconds 1,2, and 3 etc. Modifiers can be functions (simpler) or classes (useful where you have state - e.g. the main_roll.lua file has a speed state).
You don’t have to use modifiers, you can just write things like:
b = display.newBitmapString("Hello world",160,240,"retroFont",42):setModifier("curve"):animate()
and it will create the string, and curve it and animate that curve. The built in named effects are just a few modifiers I’ve written, most of them are a couple of lines of code.
Note, this chaining approach is a shorthand for:
b = display.newBitmapString("Hello world",160,240,"retroFont",42) b:setModifier("curve") b:animate()
There is one down side, which I haven’t come up with an answer to yet. You can treat it exactly as a display.newGroup() object - it is one - except for the following problem:
If you animate a font, it adds an enterFrame listener so it can animate. This creates an external reference to the bitmap object, and I haven’t figured out how to autoRemove this listener.
You can remove the bitmap string just with bitmap:removeSelf() and it tidies up after itself, you can turn the animation off with bitmap:stop() and same thing happens, but Composer/Storyboard’s garbage collection doesn’t seem to have a finaliser.
So if you do purge an animated string this way, it will still be there (non visible) because of the enterFrame reference.
If you turn the animation off in the exit phase of the Scene managers, or remove the string, it works fine. If you don’t animate it it works fine, it’s just like any other graphic.
which means, even though i removed the text, the enter frame listener is still there, and probably (and will, in my opinion) cause something unexpected under Corona hood.
does removing the object clean entirely all listeners attached to it? As I understand, you also need to kill the listeners, and I don’t have any idea how to remove an enterFrame listener.
Quite splendid though. i’ll follow the progress updates. I’ll give feedback as soon as I able to use it. the library one is to use right, now the demo one?
It appears not. You don’t need to remove this listener though, just stop the animation with the :stop() method or remove the bitmap with :removeSelf().
The font-demo is usually slightly out of date ; the best one to use is the font-manager which has an assortment of simple demos that can be changed by editing the main.lua file.
okay, I’ll give feedback as soon as I try it! 
…you’re absolutely right. bmGlyph is not passing on the padding. Bah!
Well, I give in. I’ll switch to Glyph Designer tomorrow morning and report in based on what I find.
…I posted and yet it’s not there?
Anyway, you’re right. Glyph designer worked, though there is some suspicious x-spacing. I wish there was a way to edit that in the Glyph Designer…
The bigger problem with Glyph Designer is working from large assets. Ideally you want your “core” asset to be the small one, because 2x, 3x, 4x can be multiples. If your big asset is core, then you need to make sure the entire rest of your project does the same. It may not seem like a big deal now but with @3x gaining in importance (it seems likely it will be the new iPhone resolution) assets will look sloppy at a res that can’t be evenly divided.
paulscottrobson, the library works great so far. I have an RPG-style text window printing out characters like a champ.
There’s only one thing I can’t puzzle out - most likely because I just don’t have a good handle on your speed calculation method: how do I create a pause command? i.e.: {pause} being wait 2000ms before the next character printout?
I could just make a {pause} event that sets an absurdly low text speed, but the problem with that is that I have to set it before the character, not after. So, "lorem ipsum.{pause}"is intended but the workaround would need “lorem ipsum{pause}.”
EDIT: I’m specifically looking to jury-rig the Rollout code. 
Hi, the RolloutModifier class has a faux time, which isn’t actually real time, it ‘pretends’ to be, but actually it is adjusted by the speed, so what needs to happen is this needs to be able to be stopped altogether, so to speak. I will try and add this tomorrow.
Ugh, so for some reason my project didn’t have a config.lua. That being said,
a ) The font is still highly blurry with one present
b ) @2x and @4x assets don’t seem to legible at all, as if they’re using either completely busted export details or perhaps the details of the 1x sheet.
Glyph Designer looks perfect though. Hmm.
Sorry, haven’t forgotten about this, I’ve been out all day, pretty much literally, I will try and amend this tomorrow.
No worries; the great thing about game development is there are about 10 other major tasks at any given time. 
I should upload a new version of addLineBreaks() - extended it to support font manager. 
I do wonder if it is mostly to do with BmGlyph and its settings. In *theory* they should do the same thing, and produce the same output, pretty much. All the library is doing, pretty much, is treating them as a sprite sheet and creating and animating those sprites. That bit is actually relatively straightforward.
Unless BmGlyph have wired it up in a really weird fashion it shouldn’t make any difference on 2x 4x and (1x) other than obvious things like the resolution and sheet size. From what I can see, what it does is create three fonts with the three different names.
Having used both of them Glyph Designer is more expensive, but it is a much better program in the way it is built.
Hi, I’ve added code to the rollout modifier and the main_roll demo now has a {pause4} command which is easy to clone/modify if you want a variety of pauses.
The bmGlyph author sent me a working project and output files. It does appear to work well, at least, using his assets and the bmf.lua font controller he built. He says he sent you a message a few days ago and hasn’t heard back? (From talking with him he’s clearly motivated to make sure his stuff is working cross-library. And with fontmanager, it’s not; I’m reliably getting a hazy 1x and broken 2x/4x with everything bmGlyph outputs.)
You need not be confused by the multi-file output, by the way; display.newSprite uses the information given from the 1x asset, and them multiplies it as necessary if 2x or 4x assets are needed according to config.lua. The @2x/@4x fnt files are not used unless you choose to sub them in through code.
Anyway, I think Glyph Designer has a strong, consistent presentation but it just is missing some very important features right now that bmGlyph has:
- Substitute image for glyph
- Custom x-spacing per glyph (I have to edit the Glyph Designer .fnt file manually to do this…)
- A build wizard for automatic 1x/2x/4x/etc output.
- .lua instead of .fnt support if you want to roll that way
That being said, something is fishy with the numbers. I’ve dropped a sample export (1x,2x,4x textures + .fnt file) into dropbox if you want to give it a quick look. If the problem is on his end, I have to think there’s something wrong with the glyph coordinates, but I’m just not experienced enough with the format to see any tell-tale problems.
Hi. Can you forward my email address to him (paul@robsons.org.uk). I don’t recall having an email from him but I might have deleted it accidentally. I will try to contact them direct.
I have made some progress, I have got the FM using the correct sprite sheet - because I wasn’t setting sheetContentWidth and sheetContentHeight it always picked up the 1x display.
But there is another problem.
The .fnt file (your dropbox one) only has one layout of fonts.
However, if you look at newTest.png and newTest@2x.png, they are different layouts - different characters in different positions - it isn’t just a ‘scaled up’ version of newTest.png (which is, I think, how it’s supposed to work).
So there must either be some way of generating alternate .fnt file - otherwise I have no idea where the characters are - or alternatively some way of getting bmGlyph to use the same layout for every png file, just scaled to suit.
Thanks to Stephane at bmGlyph I now have more idea :)
The problem with bmGlyph is that as I suggested there is only one .fnt file - there should be three pairs, of .fnt files, usually called font.fnt font@2x.fnt and font@4x.fnt.
The way FM now works is it picks up a file appropriate for the scale. There is a calculation in the retina code tutorial which works out what the ‘preferred scale’ is - this returns a value between 1,2,3 and 4. 1 is a 320x480 iPhone, 4 a Retina iPad (2048x1536 ?)
What it does is to look for these backwards - so for a retina iPad it will start @4x (at font@4x.fnt) and work its way down until it finds a .fnt/.png file that exist. For a basic iPhone it will go straight to the 1 x scale file (e.g. font.fnt). So it pretty much picks the best available. You can override this, if you put font@4x in the font name it will use the 4x font irrespective of what else is there.
You still have the basic issue though that a 1x font has to look okay on the device it is running on. If bmGlyph or Glyph Designer produces a rather smallish font which is quite pixellated it’s going to stay looking pixellated. It is a trade off with texture memory.
The other change is that I have extended UTF-8 decoding so it uses up to the six byte character maximum, if anyone should want this.
Padding is still in the pipeline.
Works great so far, thanks paulscottrobson. Will be working with this closely soon to shake it out a bit, but seems solid!