Text options?

I ask this question out of complete ignorance, but what would be the advantage of that over the Bitmap fonts that GlyphDesigner produces out of basically any type of font.

@hasen6,

I’m not sure why you’re worried.   Typically text objects in game engines are pretty basic.  Sure, some support fancy text, but not all. 

Corona text objects are very basic.  The things you mention are more of what you’d find in an art program or a word processor.

Things you can do:

  • set fill color (color of text)
  • set x and y scale
  • set position, anchor, … i.e. all standard display object stuff

To get italic, bold, etc.  You simply use an italic or bold font.  You would have to include these anyways even if the text objects supported faces.  Face support comes from having multiple variants of a font on your machine (either in separate files or in a single unified file),  i.e. the are not typically programmatic (art programs do tweak fonts a bit).  

If you need more, I strongly second @agramonte.  Use bitmapped fonts. 

This is the pro way to handle text and IMHO gives superior performance and visuals over any built-in text in any engine. 

Why?  Because you have total control, which is what I think you’re looking for.

Are you a PC or Mac user?  @agramonte has suggested a tool already if you’re a Mac user.  If you’re PC 71 Squared has a tool and there are others too. 

I’m sure if you hunt you can also find a free Web based tool.

So you can set scale across the x or y position? So I can scale the font taller if I want or wider? That’s good, there was me thinking all it had was position and colour. Position’s not really worth mentioning, without that it wouldn’t even be an engine anyone could use lol.

Oh right I didn’t know about that. I didn’t want anything special, just basic stuff like stroke, character spacing or scaling across one axis but it seems you’re saying that scaling can be done. I need support for Chinese fonts so don’t want to do anything fancy, I just want to use the system fonts since custom Chinese fonts tend to be bigger than your average game is!

The display.newText() will probably never be much more than straight font presentation. This is where bitmap fonts come into play. You can do way more fancy things with them than you can straight text.  We hope to have some more rich text type options in the future, but that would be more HTML styling. To do more, you would want to use bitmap fonts.

There are multiple libraries out there that can be found.  Ponywolf includes a bitmap font with his templates he did for Corona:

https://github.com/ponywolf/ponyfont

Devilsquid did a step-by-step guide: https://devilsquid.com/bitmap-fonts-a-step-by-step-guide/

He links to another bitmap library that I actually use in my games.

Rob

One thing you can’t do with Corona text is mix font variations in a single text render.

i.e. This would be four text objects in Corona.  You’d have to align them to eachother to give the impression of 

This is bold , while this is a italic, this is black, this is red.  

   (1)                (2)                 (3)            (4)

My #1 suggestion is, decide what you want to do and test it early (before you make your game) in a standalone demo.  Get it working, then work on the game.

This suggestion applies to all critical dependencies.  Identify them first, test and verify them, then, and only then make game.

I know this is hard to do, but you should try or you may be sorely disappointed if something critical is not supported by whatever engine/SDK you use.

For English, I’ve written * some HTML interpreters but they only work so-so:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/10/mltext_mod.zip

( Some of the code is borrowed from elsewhere.)

mltext.jpg

local mlText = require "mltext.mltext" local myMLString = '\<font size="22" color="ForestGreen"\>This is a test of\</font\>\<br\>\<br\>' .. 'MLText by \<a href = "www.roaminggamer.com"\>Roaming Gamer, LLC.\</a\>\<br\>\<br\>' .. '\<font face = "Arial" size="26" color="red"\>This is some red size 26 Arial!\</font\>\<br\>\<br\>' .. 'And an image of a \<a href = "www.roaminggamer.com"\>\<img src="joker.png" alt="A Joker" height="40" width="40" yOffset = "-12"\>Joker!\</a\>' local group = display.newGroup() -- Base settings for text without \<font\> statements. local params = { font = "Consolas", fontSize = 24, fontColor = { 255, 255, 128 }, spaceWidth = 14, lineHeight = 22, linkColor1 = {0,0,255}, linkColor2 = {255,0,255}, } local tmp = mlText.newMLText( group, myMLString, 10, 60, params )

Note: There is another ongoing discussion about text objects here you may find useful:

https://forums.coronalabs.com/topic/72346-outlining-text/

RichText support would be an easy win.

Cool font support would allow individual characters to be animated and transitioned.  Would be awesome if we could access characters as objects and apply transitions and filters individually.

Exposing the rendered font as a displayobject would also be an easy win as we could then do lots more “cool stuff” to it.

Maybe a cool font plugin idea right there?

Note: bitmap fonts are useless for multi-lingual apps

@sgs - Yes, you have a point.  Multi-ligual games + bitmap fonts == “pain and/or bloat” choose one or both for extra pleasure. :slight_smile:

Also, rich text would be sweet.  May someone smarter than me hear you and write that plugin.

Ok thanks for the replies, I guess I was right to be worried then. No problem, I can do a drop shadow effect by duplicating the text object I guess.

You can do drop shadow with a bitmap font in :30 seconds with one of the multiple tools in this thread. Even with multiple languages support the impact would be minor.

Agreed, it’s worth the effort to learn how bitmap fonts work. Once you’ve chosen your library (i.e. ponyfont, font manager) and got the process down in BM Glyph, it doesn’t add much time and the effect will be much better. A bit of work now will stand you in good stead for this and future projects.

It’s no different than any other game engine, indeed in Unity you pretty much have to go down this route with TextMeshPro as the built in text is awfully fuzzy.

I assumed bitmap fonts wasn’t gonna work with Chinese?

Hmm, well I’ve got them working with a variety of foreign characters (Greek, Russian, Vietnamese etc.), haven’t tried Chinese though.

Worth giving BM glyph a go - it’s free!

All those languages have alphabets. You can only really compare Chinese with Japanese in that respect. Chinese is made up of thousands of characters so custom fonts are typically anything from 8mb to 50 mb. I’m guessing bitmap fonts like I assumed would be no use with Chinese.

There are plenty of bitmap fonts for Mandarin out there. I don’t know your app but it is very unlikely you’ll need all 50,000 symbols for your app. Most people only know about 5K to 6K. And a typical app with labels like “Player one”, “Good Job”, “Play again” and “Help” you’ll probably do fine with a few hundred symbols. For input Android or iOS provides the keyboard. For large portions of text, you probably don’t want it highly stylized or animated so you can use a regular font.

@schizoid2k I’m curious what said product is.

@hasen6  I’ll mention this again for completeness. It still needs better docs, a better sample, and probably some thorough testing in all those *Array bits (my idea in exposing these was to make text meshes). I intended to do this quite early but got sidetracked.  :frowning:

If it looks at all useful, give it a try and let me know of any issues. (I think iOS at least might need a rebuild.)

EDIT : An example video of the plugin I mentioned, which I’m lately updating, is shown here. (I’ve finally been attending to the docs too.) I might see if I can rename it to  truetype  as well, so the link above might not be long for this world.

I made apps in the past using another engine with custom Chinese fonts and I tried removing characters to reduce the font size but it’s pretty tough. That’s why I normally use system fonts for Chinese. If all is needed is stuff like “Player one”, “Good Job”, “Play again” and “Help” then it’d probably be simpler and about the same size to go with image based text wouldn’t it?

It’s the text that needs to change dynamically that can cause more of an issue.

Anyway it’s pretty hard to edit fonts as far I know and you have to have a list of the most common characters. Even then, 5k-6k is still gonna make a font much, much bigger than a regular alphabet based font. And that’s just for ONE font.