display.newText() lineheight and letterspacing

You could probably approximate it - for each character create a display object for it , measure its width then delete it (only need to do this once) and then use this to convert your space split string into a string with newlines at the appropriate points.

Well this seems like only way, but for some font like Chinese, breaking it will be a very challenging work, as corona dont treat each chinese character as a string character.

And not sure how is the rendering cost, because I am rendering a whole long list of paragraph that is about few thousand characters.

Lua and Corona probably aren’t ideal for Chinese and similar fonts. I think you end up doing your own encoding a lot of the time - my BitmapFont library has options to change the encoding to UTF-8 so the non ASCII characters can be used but I don’t think it is very well supported. In terms of the rendering cost, Bitmap font libraries will almost all be 1-1 character -> Corona image, so using the stock text is best at that sort of level. I would think the actual rendering would be fairly efficient, because it’s probably just directly calling an Android/iOS function or two which does that. You’d probably just have to experiment with that - if you are thinking of running on a phone hardware scrounge an old discarded Android phone off someone who has upgraded and see how that copes with it. I also tend to have a really cheap (£40 ish) android tablet as well for this sort of testing, stuff can work fine in the simulator but the cheap hardware can’t manage it (though in my experience you have to really flog it !)

Lineheight is currently really bad in newText.  I’m surprised there aren’t more posts about this.

The standard lineheight corona is using seems far to high and the inability to change it is Boooooooo. :frowning:

I know we are dependent on the operating system’s font rendering and on Android, it could vary from maker to maker.

Rob

Well, maybe.  

I’ve been out of the  Corona loops for a little while… I’m going back and updating apps I had last touched in 2012.

Back then, I was using the crawlspace lib’s “newParagraph” function to handle multiline formatting.  It included line height and alignment well better than the current “newText” does.

It seems really “odd” that a 3rd party lib 2 years ago was able to do it better than the current built in system.  Give a try on a multi-line with something like AmericanTypewriter at size 18.  It’s not even close to useful without the ability to change the line height.

Of course,  I do partially blame myself for not looking to see if there was just an updated crawlspace lib before re-writing a whole bunch of code to work with the new newText.  Still can’t help be a bit disappointed that after all this time, writing text with Corona is so painful.

Well ok, I feel a little better that it has NOT been updated. :wink:

https://github.com/AdamBuchweitz/CrawlSpaceLib

But check the newParagraph setup there.  I suppose I could just got back re-wrap a wrapless (no-width) newText call … But seriously, at this age in Corona, it seems we shouldn’t have to do that just to get lineheight control. :wink:

I can ask the Engineers to look into this, but they are going to want a bug report.  The bug report needs to have any assets needed to run it, and a config.lua and build.settings in a .zip file.

Rob

… Sure –  Or anyone could save the trouble of that just drop this at the top of any ole main.lua they have sitting around real quick for an example – or see the screenshot attached (see bottom of post) – or try just actually using the language for a purpose other than a game.  ;-)

local options = { text = "This is a long line of text that shows how much line height is used. On small screens, space is a premium commodity and this is a waste.", width = display.contentWidth\*.85, font="AmericanTypewriter-Bold", fontSize = 20, align = "center" } local tmpText = display.newText (options) tmpText.x = display.contentWidth/2; tmpText.y = display.contentHeight/2 - 100; local options = { text = "Meanwhile, the line height on this font is not so bad... but given screenspace, there is STILL room that a developer might want to salvage.", width = display.contentWidth\*.85, font=native.systemFont, fontSize = 24, align = "center" } local tmpText = display.newText (options) tmpText.x = display.contentWidth/2; tmpText.y = display.contentHeight/2 + 120; if (1==1) then return true end;

Also, note that when you go to add code to a post here in the forum, Lua is oddly not an options in the menu.  Granted, that’s not needed – but given that this is a Lua oriented forum. :wink:

… And then here’s a quick real-world example of where the space is causing problems in our “Character Prompts” app…

This is just one example on one screen of one app.  But you can see that we don’t need that kind of line spacing for any of these fields.  They would be much better off scrunched together a little.   It looks very cluttered because trait and hobby, in particular are spread so much.   Favorite saying also takes up much more room than it needs to via the newText() line height.

Character Prompts is currently in the store using the “old way” and crawlspace…

https://itunes.apple.com/us/app/character-prompts/id493346374

If you want Engineering to look at this, there has to be a trackable entry in the bug database.  Engineering does not use Forums as means to allocate and track their work. 

That said, I don’t see that much of an issue above.  Fonts, in particular once you get away from the main font foundries and heavily tested fonts and into free fonts, you will find that there are tons of “metric” problems with them.  These metric issues manifest themselves in things like the characters sitting too high in their box, being too short for the space asked for etc.

I don’t know what we can do since we hand the font to the OS and get an image back and there’s not much in between.  I don’t know if we can specify a line height or not when we ask the OS to render the text, but that is the most likely scenario.  We can’t analyze every font.

Rob

I wouldn’t expect Corona to analyze every font.

I’d just like the ability to set the line height myself if I don’t like the default.

It’s really one of those basic stylization things that most designers have an interest in tweaking.

I also posted a screenshot above from our real world app that it does cause a problem with.  I will have to use a different font or use/update the newParagraph function from the crawlspace lib.  My point still being that line height control is a basic thing that folks shouldn’t have to write wrappers for in 2014. :wink:

Hello

and yes, lineHeight and letterSpacing is badly needed!

I haven’t read all posts here, but as I produced some fonts myself, I would like to add:

lineHeight might not be a big thing to achieve. Every font delivers its geometry which is read and used by the script. display.newText() seems to read the basic fontHeight of a font, using this as a parameter for lineHeight. This is why the lines in rendered texts are so narrow, it is like lineHeight 1.0 in other applications. It’s not best readable.

It would be a great if the Corona Engineering could at least add this feature: with units of em = multiples of the fontSize or in Corona pixel. 

If the Engineering need some more detail information about font techniques, please let me know, maybe I can help.

I just declined a feature request on this since it had been nearly two years with a total of two votes on it. Feel free to create a new feedback item for it, though it would be a better use of your votes to vote on some of the other display.newText() based feature requests.

http://feedback.coronalabs.com

Rob

Hi Rob,

there are aome different feature requests about text and aligning / line height / spacing / manipulating. I searched for “text” as a keyword.

The sum of all votes is 380.

Maybe there is a chance to combine these feature requests as they address mostly the same topic, with a little different details.

164 votes:

more control and choices for text objects

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3575422-more-control-and-choices-for-text-objects

120 votes for:

display.newText() advanced options / justification

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/4784694-display-newtext-advanced-options-justification

51 votes for:

Stroke to text

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3575018-stroke-to-text

45 votes for:

Manipulate text size, style, font, and color like HTML

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/6265139-manipulate-text-size-style-font-and-color-like

Kind regards from Berlin,

Simon

Yes, we can combine those into a mega request. It’s a lot of votes. But text is a complex thing that can pull our engineers down a rabbit hole that will. I suspect that Perk will have some ideas on what things we should work on next, but we’ve not had time to have those conversations yet. 

Rob

Hi Rob, 

this is good news for all who love good typography in apps :slight_smile:

Many Corona developers would be very happy!

My suggestion would be:

  1. line height and letter spacing

  2. manipulation of single or several strings inside of a text: in size, position, color and even font style, making text like “CO2” possible

  3. other text manipulation like stroke or outlined letters

If the default line height is left at 1.0, there might be no change to existing apps.

Simon

Personally I don’t think its either “good” or “news”. It’s purely administrative information. I can combine the various requests into one. I haven’t yet, because I need to make sure all of the various  items are represented in the mega-request. Also I’m concerned the bigger the task, the harder it will to get the request done.

Please do not read my previous comment as any commitment to any progress on it.

Rob

Adjusting line height and character spacing is a critical feature!

My manager has asked me to suggest a 2D platform for mobile development; and I am having to pass on Corona because it won’t be able to deliver even the minimum basic requirements that the design team expects. I am personally a huge fan of Corona, but with modern app development the in-ability to do even the most basic text formatting is crippling.

Please fix this!!!

1 Like