Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Text options?
Started by hasen6 Apr 10 2018 05:10 AM

18 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

hasen6

[GLOBAL: userInfoPane.html]
hasen6
  • Contributor

  • 151 posts
  • Corona SDK

I've been reading a bit about display.newText and I'm getting a bit worried I have to admit. Are they any features other than size and colour?? I mean anything at all would be great, like character spacing, stroke, scaling on the x or y axis etc. There must be something we can do other than just standard fonts...especially for game making.

 

Here's hoping I'm wrong about this. I saw some people asking for these features about four years ok so I'm hoping some of them have been aded by now.

 

I really need just something simple like a stroke on my text because it can't be seen very well where it is if it's all just one colour. It's dynamically changing text so I can't use an image.



[TOPIC: post.html]
#2

schizoid2k

[GLOBAL: userInfoPane.html]
schizoid2k
  • Contributor

  • 570 posts
  • Corona SDK

I agree... I think text support is somewhat lacking, and would love to see improvements in that area.

 

Long ago, there was a product called Text Candy, and I use(d) that for years.  It's no longer supported by the vendor (although it still works), but I would love to see Corona purchase/upgrade that product or develop their own version of this.

 

There's a product on another platform that allows incredible text functionality using TTF fonts (without the need to create bitmaped fonts). I am not sure how feasible that would be on the Corona platform (although Text Candy had some limited TTF support, so maybe it is possible).  If that could be developed, it would absolutely incredible.

 

Here's hoping.

 

--john



[TOPIC: post.html]
#3

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,280 posts
  • Corona SDK

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.



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,605 posts
  • Corona SDK

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


Edited by roaminggamer, 10 April 2018 - 09:00 AM.


[TOPIC: post.html]
#5

hasen6

[GLOBAL: userInfoPane.html]
hasen6
  • Contributor

  • 151 posts
  • Corona SDK

@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

 

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.

 

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.

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!



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,399 posts
  • Enterprise

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



[TOPIC: post.html]
#7

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,605 posts
  • Corona SDK

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 )


Edited by roaminggamer, 10 April 2018 - 09:23 AM.


[TOPIC: post.html]
#8

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,605 posts
  • Corona SDK

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

 

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



[TOPIC: post.html]
#9

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 2,120 posts
  • Corona SDK

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



[TOPIC: post.html]
#10

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,605 posts
  • Corona SDK

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

 

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



[TOPIC: post.html]
#11

hasen6

[GLOBAL: userInfoPane.html]
hasen6
  • Contributor

  • 151 posts
  • Corona SDK

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.



[TOPIC: post.html]
#12

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,280 posts
  • Corona SDK

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.



[TOPIC: post.html]
#13

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,868 posts
  • Corona SDK

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.



[TOPIC: post.html]
#14

hasen6

[GLOBAL: userInfoPane.html]
hasen6
  • Contributor

  • 151 posts
  • Corona SDK

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



[TOPIC: post.html]
#15

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,868 posts
  • Corona SDK

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!



[TOPIC: post.html]
#16

hasen6

[GLOBAL: userInfoPane.html]
hasen6
  • Contributor

  • 151 posts
  • Corona SDK

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.



[TOPIC: post.html]
#17

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,280 posts
  • Corona SDK

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.



[TOPIC: post.html]
#18

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 824 posts
  • Corona SDK

@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.  :(

 

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.



[TOPIC: post.html]
#19

hasen6

[GLOBAL: userInfoPane.html]
hasen6
  • Contributor

  • 151 posts
  • Corona SDK

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.

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.




[topic_controls]
[/topic_controls]