Author Topic: Multiple fonts in the same add_text  (Read 2581 times)

l3m35

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Multiple fonts in the same add_text
« on: March 19, 2020, 02:39:22 PM »
Maybe easy but I can't find out how.

Example: I'm using FontAwesome font to show icons and other for general text. But I need a string like "icon + game categories". So something like:

Code: [Select]
fe.add_text("icon [Category]", 0,0,flw,flh)
Any way to make "icon" use a font and [Category] use other? I tried to call the separately like this (this code was not tested, it's similar):

Code: [Select]
local a = "ï›°"
local b = "[Categories]"
a.font="fonta"
b.font ="fontb"
local c = fe.add_text(a +  b, 0,0,0,0)

It results in script error "trying to set 'string'".

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Multiple fonts in the same add_text
« Reply #1 on: March 19, 2020, 03:11:41 PM »
You need two different text objects. The font method belongs on a text object. You can get creative and see how large the text is. See my picknmix layout for an example. I have platform and filter accurately measured. The way described in official attract docs does not work.

https://gitlab.com/attractmode/attract/-/blob/master/config/layouts/picknmix/layout.nut

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Multiple fonts in the same add_text
« Reply #2 on: March 19, 2020, 03:16:01 PM »
Or you can customize your text font adding the icons, there's a lot of space in unicode font. I made a font that incorporates glyphs and system logos so I can write "Sysyem: GENESIS" with the genesis logo ;D

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Multiple fonts in the same add_text
« Reply #3 on: March 19, 2020, 04:14:11 PM »
@zpaolo which font tool are you using?

l3m35

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: Multiple fonts in the same add_text
« Reply #4 on: March 19, 2020, 04:24:51 PM »
Thank you all. So bad it's not simple like I was trying LOL

Anyway, I've made as keilmillerjr said: two objects and proper alignment. My worry was about position (in fact it's a clock so as numbers change maybe I would have a changing gap between icon and the first number), but now it's ok.

I could edit the font too, thanks for the idea. I use to edit fonts with Fontographer.

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Multiple fonts in the same add_text
« Reply #5 on: March 20, 2020, 01:11:49 AM »
@zpaolo which font tool are you using?

I design my glyphs and logos using inkscape or other vector software and export them in .svg format, then I use the online Icomoon app to convert svg to a font. At the end I use Fontsforge to copy/paste the glyphs inside the main font. You only have to experiment with the font parameters in icomoon to make them the right alignment with the standard font. Oh and the svg must have some "non visible" elements if you want all the logos to be the same size, otherwise icomoon will scale them to fit the font box
 

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Multiple fonts in the same add_text
« Reply #6 on: March 20, 2020, 01:13:42 AM »
Anyway, I've made as keilmillerjr said: two objects and proper alignment.

I find that with the msg_width property it's much simpler to align correctly fonts, I needed the logos in-line with text and I didn't want to re-position the elementrs every time, but it works great with msg_width