corona-textrender icon indicating copy to clipboard operation
corona-textrender copied to clipboard

Common fonts between devices

Open laurasweet8888 opened this issue 8 years ago • 12 comments

I spent the day to day trying to figure this all out. Almost got it working, but I need an easy way to use the system font, system fontbold etc... I tried changing texstyles.txt but it kept trying to use the avenir fonts no matter what I told it. Is there a way to get one code base working for all devices using this code?

laurasweet8888 avatar Feb 15 '17 23:02 laurasweet8888

Laura,

I just checked the example. When I change the the Title from "Avenir-Black" to "Baskerville"

	Title=Baskerville,24,32,0.5,0.5,0.5,,100%,,left,10,0,0,0,0

then reload in simulator, it works.

Note, changing the CSS in the sample HTML will do nothing at all.

I believe that f you do not specify a font for a style, it will default to the system font, OR keep the font of whatever contains the text.

Be sure you don't set "body", because that would set the font for everything inside.

To make a style without a font setting, just leave that part blank, like this: Title= ,24,32,0.5,0.5,0.5,,100%,,left,10,0,0,0,0

See if this helps.

Finally, while testing, be sure the caching is off, or you'll see the cached, optimized text instead of your changes.

-D

On Feb 15, 2017, at 3:01 PM, laurasweet8888 [email protected] wrote:

I spent the day to day trying to figure this all out. Almost got it working, but I need an easy way to use the system font, system fontbold etc... I tried changing texstyles.txt but it kept trying to use the avenir fonts no matter what I told it. Is there a way to get one code base working for all devices using this code?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mimetic/corona-textrender/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB184ajHp-N4W_bBva7Dzc_hRlxIoqsks5rc4OsgaJpZM4MCXOX.

...David I. Gross...

LinkedIn: http://www.linkedin.com/in/davidigross Photo Portfolio site: http://www.davidgrossphoto.com/ Inside-Outside: http://insideoutsideproject.com/ Mimetic Books: http://www.mimetic.com/ Mimetic Galleries: http://info.mimetic.com/

Email: [email protected] Mobile (direct) : +1 (408) 464-6182 (Pacific Time) Travel Tel: +1 (408) 827-8557 (GMT -8:00) Skype : davidgross

CONFIDENTIALITY NOTE: This e-mail and any attachments or previous e-mail messages attached to it are confidential and may be protected by legal privilege. If you are not the intended recipient, you are hereby notified that any disclosure, distribution, or copying of this message, or any attachment, is prohibited. If you have received this message in error, please notify the original sender immediately by returning it to the sender and delete this copy, along with any attachments, from your computer without reading or saving it in any manner. Thank you for your cooperation.

mimetic avatar Feb 16 '17 02:02 mimetic

Thanks for getting back so quickly. I really appreciate it. So I created a new textstyle without specifying any font and when I run it I get these errors.

In the end it just loads the base font for everything. So I don't get any bold or italic. The textrender example stays grey. maybe that is because of the caching. I will try to figure out where to turn that off.

textstyles5.txt

I also tried setting some base colors like this and it did nothing as well Heading = ,16,20,1,0,0,,100%,,left,0,0,0,0,0 Title=,24,32,1,0,0,,100%,,left,10,0,0,0,0 H1= ,24,26,221,0,0,,100%,,left,12,24,0,0,0

I am not sure if the colors are from 0 to 1 or 0 to 255 so I tried both.

my simple text test case looks like this: text = [[

TextRender Example

H1 title

Let's see what I does.

  • Item 1
  • BoldItem 2: One of the itallix? span and color
  • Item 3
]],

11:01:52.069 WARNING: Could not load font Avenir-Black. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Black. Using default font. 11:01:52.069 WARNING: fontmetrics doesn't have info about the font, 'Helvetica-Italic', using Baskerville settings. 11:01:52.069 WARNING: Could not load font Helvetica-Italic. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Oblique. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Roman. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Roman. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Roman. Using default font. 11:01:52.069 WARNING: fontmetrics doesn't have info about the font, 'Helvetica-Bold', using Baskerville settings. 11:01:52.069 WARNING: Could not load font Helvetica-Bold. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Black. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Roman. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Oblique. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Roman. Using default font. 11:01:52.069 WARNING: Could not load font Avenir-Roman. Using default font. 11:01:52.079 WARNING: Could not load font Avenir-Roman. Using default font.

laurasweet8888 avatar Feb 16 '17 16:02 laurasweet8888

OK, ignore that last response. Setting caching off fixed a lot of things. colors in the styles now work and it is using the default font. Which I guess is Helvetica. My Q is whether Helvetica will always be the default when I run it on different devices. It appears your code appends -Italic to the current font which for some reason isn't found. check out these new errors.

11:27:59.804 WARNING: fontmetrics doesn't have info about the font, 'Helvetica-Italic', using Baskerville settings. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: fontmetrics doesn't have info about the font, 'Helvetica-Bold', using Baskerville settings. 11:27:59.804 WARNING: Could not load font Helvetica-Bold. Using default font.

laurasweet8888 avatar Feb 16 '17 16:02 laurasweet8888

Yeah, caching is a drag when testing, but wow, it's fast when implemented.

My code has a table which tells each font what its italic and bold variations are, call "fontvariations.txt". Check to see what the correct font name is for the variations for Helvetica.

I'm surprised Helvetica is the default... Hah, found it!

  • line 1190 of textrender.lua sets the default to Helvetica, and has a little note saying "This will cause problems with Android". So, when you call the textrender, you can set the default font and variation, which should override that Helvetica setting. { font = "whateverfont", fontvariation = "italic", ...} and so on.

The font you want has to be installed for the app to find it. So, while iOS has Avenir, your Mac testing computer might not. Just FYI. I have Avenir in the app directory when testing.

I haven't testing anything on Android (pain in the ass).

Re the colors, I usually work with a DMC library installed so I can use 0-255 RGB colors. However, I think the code works fine with either RGB or those 0-1 colors; you just have to be consistent in your styles, etc.

Hope that helps. The code isn't perfect, but better than nothing! I haven't tweaked it in a while.

Above all it needs good documentation.

Best David

On Feb 16, 2017, at 8:30 AM, laurasweet8888 [email protected] wrote:

OK, ignore that last response. Setting caching off fixed a lot of things. colors in the styles now work and it is using the default font. Which I guess is Helvetica. My Q is whether Helvetica will always be the default when I run it on different devices. It appears your code appends -Italic to the current font which for some reason isn't found. check out these new errors.

11:27:59.804 WARNING: fontmetrics doesn't have info about the font, 'Helvetica-Italic', using Baskerville settings. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: Could not load font Helvetica-Italic. Using default font. 11:27:59.804 WARNING: fontmetrics doesn't have info about the font, 'Helvetica-Bold', using Baskerville settings. 11:27:59.804 WARNING: Could not load font Helvetica-Bold. Using default font.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mimetic/corona-textrender/issues/6#issuecomment-280381952, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB189jQvJmkqdbQ2i63qx3go_fE06roks5rdHmZgaJpZM4MCXOX.

...David I. Gross...

LinkedIn: http://www.linkedin.com/in/davidigross Photo Portfolio site: http://www.davidgrossphoto.com/ Inside-Outside: http://insideoutsideproject.com/ Mimetic Books: http://www.mimetic.com/ Mimetic Galleries: http://info.mimetic.com/

Email: [email protected] Mobile (direct) : +1 (408) 464-6182 (Pacific Time) Travel Tel: +1 (408) 827-8557 (GMT -8:00) Skype : davidgross

CONFIDENTIALITY NOTE: This e-mail and any attachments or previous e-mail messages attached to it are confidential and may be protected by legal privilege. If you are not the intended recipient, you are hereby notified that any disclosure, distribution, or copying of this message, or any attachment, is prohibited. If you have received this message in error, please notify the original sender immediately by returning it to the sender and delete this copy, along with any attachments, from your computer without reading or saving it in any manner. Thank you for your cooperation.

mimetic avatar Feb 16 '17 18:02 mimetic

Fonts are a royal pain in the ass, but thanks for helping. Sounds like, to use this, I will have to figure out which font is always available on each platform and create a textstylesMac.txt texstylesSim.txt, textstylesAndroid.txt, textstylesMS.txt and who knows what problems would happen on Steam, because Steam runs on all platforms. That is a lot if figuring. :(
Since it sounds like you have tested on Apple stuff, do you know what happens when a person has their language set to French or Italian?
This all makes me want to use simple pictures instead of words to describe what needs to be done.

laurasweet8888 avatar Feb 16 '17 22:02 laurasweet8888

You might be able to embed the fonts you need. That's what I do. Shouldn't that work?

No problems with other "left-to-right" languages (like French or Italian or Spanish). Arabic and Hebrew would be a problem — I'm not sure my code works with right-to-left languages.

-D

On Feb 16, 2017, at 2:26 PM, laurasweet8888 [email protected] wrote:

Fonts are a royal pain in the ass, but thanks for helping. Sounds like, to use this, I will have to figure out which font is always available on each platform and create a textstylesMac.txt texstylesSim.txt, textstylesAndroid.txt, textstylesMS.txt and who knows what problems would happen on Steam, because Steam runs on all platforms. That is a lot if figuring. :( Since it sounds like you have tested on Apple stuff, do you know what happens when a person has their language set to French or Italian? This all makes me want to use simple pictures instead of words to describe what needs to be done.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mimetic/corona-textrender/issues/6#issuecomment-280482605, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB184qczt-ZQG1TOC9_fMY2-ZtS5jrNks5rdM0PgaJpZM4MCXOX.

...David I. Gross...

LinkedIn: http://www.linkedin.com/in/davidigross Photo Portfolio site: http://www.davidgrossphoto.com/ Inside-Outside: http://insideoutsideproject.com/ Mimetic Books: http://www.mimetic.com/ Mimetic Galleries: http://info.mimetic.com/

Email: [email protected] Mobile (direct) : +1 (408) 464-6182 (Pacific Time) Travel Tel: +1 (408) 827-8557 (GMT -8:00) Skype : davidgross

CONFIDENTIALITY NOTE: This e-mail and any attachments or previous e-mail messages attached to it are confidential and may be protected by legal privilege. If you are not the intended recipient, you are hereby notified that any disclosure, distribution, or copying of this message, or any attachment, is prohibited. If you have received this message in error, please notify the original sender immediately by returning it to the sender and delete this copy, along with any attachments, from your computer without reading or saving it in any manner. Thank you for your cooperation.

mimetic avatar Feb 17 '17 00:02 mimetic

OK, here is the last thing I tried based on your comments: went to https://www.fontsquirrel.com/ and downloaded a free set of fonts. OpenSans.zip. This comes with 10 .tff files. I figure I only need 4 of them. regular, bold, italic, bold italic. I then copied those in to my main .lua app directory. Had to rename OpenSans-Regular.ttf to OpenSans.ttf. Had to create a copy of OpenSans.ttf called OpenSans-Normal.ttf. In the code before the call to textrender I set these params:
-- Not needed, but defaults font = "OpenSans", fontvariation = "Italic", fontvariation = "Bold", size = "12", lineHeight = "16", defaultStyle = "Normal",

I am not sure what defaultStyle = normal does. Ran in simulator and got fontmetrics errors. Which I expected because I have not created any fontmetrics data. Not sure how, is it necessary?

Everything runs but I don't see any bold or Italic text. I am able to change colors of things and see size differences between H1 and normal text. So I all seems to be working except for the bold and Italic not showing up.
image

I feel like am very close. :) Need to try the app on a real device and see what happens as well.

laurasweet8888 avatar Feb 20 '17 14:02 laurasweet8888

so on an Android Table it all looks good. So I just need to figure out why it doesn't show up correctly in the simulator. image

laurasweet8888 avatar Feb 20 '17 15:02 laurasweet8888

Right...the secret sauce is the metrics. I make the metrics using a website because my laptop doesn't seem to do it right. I don't recall if I posted the website code for it, if not, let me know I'll get it to you. Basically, I read the metrics using iMagick and generate a metrics file.

There's a new plugin some fellow has made that might allow me to read metrics from the files, but I haven't had time to figure it out.

The metrics files are not perfect, FYI. They do read the font metrics, but the quality of the positioning doesn't match InDesign, which was my goal. Close, but off...sometimes a word wraps.

Also, note that I wrap articles at ends of lines, i.e. I wrap a line ending in "a", as in "a fish." This is good typesetting but won't match some software.

Regarding bold/italic issues, that's why there's a variations file — you can't predict the file name, e.g. myfont-bold, because some "bold" variations are called "heavy" or "medium" and such. So, the variations file lets us map the auto generated name, e.g. "myfont-bold" ==> "myfont-heavy" or whatever the real font name is.

Let me know.

-D

Sent from my iPad

On Feb 20, 2017, at 7:40 AM, laurasweet8888 [email protected] wrote:

so on an Android Table it all looks good. So I just need to figure out why it doesn't show up correctly in the simulator.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

mimetic avatar Feb 20 '17 19:02 mimetic

Yeah font metrics are necessary to get good rendering, mostly line heights to be right. If you care about positioning.

I actually convert from InDesign files to publishing in my app, so it mattered for me. Probably not for simple stuff.

What are you creating?

Sent from my iPad

On Feb 20, 2017, at 7:40 AM, laurasweet8888 [email protected] wrote:

so on an Android Table it all looks good. So I just need to figure out why it doesn't show up correctly in the simulator.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

mimetic avatar Feb 20 '17 19:02 mimetic

I am creating a simple game with levels and thought I would have a panel which pops up and tells the user what to do next. I liked what you did so I could write in html instead of a bunch of text objects. I don't need anything 2 fancy. However, it would be nice if I could see my work in the simulator without having to load it on a device every time. Do you have it showing up correctly in the simulator?

laurasweet8888 avatar Feb 20 '17 22:02 laurasweet8888

Works perfectly in simulator for me. Is the issue that you don't have the font installed in your system?

Here's the font metrics generator: https://github.com/mimetic/corona-fontmetrics-generator https://github.com/mimetic/corona-fontmetrics-generator

-D

On Feb 20, 2017, at 2:35 PM, laurasweet8888 [email protected] wrote:

I am creating a simple game with levels and thought I would have a panel which pops up and tells the user what to do next. I liked what you did so I could write in html instead of a bunch of text objects. I don't need anything 2 fancy. However, it would be nice if I could see my work in the simulator without having to load it on a device every time. Do you have it showing up correctly in the simulator?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mimetic/corona-textrender/issues/6#issuecomment-281197767, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB182ZI1GNxBxSvn5YrDjcEzrxEwCQ0ks5rehUkgaJpZM4MCXOX.

...David I. Gross...

LinkedIn: http://www.linkedin.com/in/davidigross Photo Portfolio site: http://www.davidgrossphoto.com/ Inside-Outside: http://insideoutsideproject.com/ Mimetic Books: http://www.mimetic.com/ Mimetic Galleries: http://info.mimetic.com/

Email: [email protected] Mobile (direct) : +1 (408) 464-6182 (Pacific Time) Travel Tel: +1 (408) 827-8557 (GMT -8:00) Skype : davidgross

CONFIDENTIALITY NOTE: This e-mail and any attachments or previous e-mail messages attached to it are confidential and may be protected by legal privilege. If you are not the intended recipient, you are hereby notified that any disclosure, distribution, or copying of this message, or any attachment, is prohibited. If you have received this message in error, please notify the original sender immediately by returning it to the sender and delete this copy, along with any attachments, from your computer without reading or saving it in any manner. Thank you for your cooperation.

mimetic avatar Feb 20 '17 23:02 mimetic