Author Topic: Is it possible to format text on a surface?  (Read 591 times)

markc74

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Is it possible to format text on a surface?
« on: May 20, 2018, 03:37:36 PM »
I'm trying to create a group of objects that animate in and out of the screen in the same way, so I thought adding them to a surface would be the answer but I cant see a way to set font sizes within a surface. The only option I can find is to add text which defaults to a tiny font.

Is it possible?



markc74

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Re: Is it possible to format text on a surface?
« Reply #1 on: May 20, 2018, 03:48:34 PM »
After spending a good hour trying to work it out, 2 mins after posting I worked it out. Don't know if this is useful to anybody but here's how I did it!

local    foo = fe.add_surface(500,540);   
      foo.add_text("xxxxx",100,15,400,30).charsize=130;
      foo.add_text("222",100,200,400,30);
      foo.add_text("333",100,300,400,30);
      foo.add_text("444",100,520,400,30);

I really feel like an idiot!  :o

zpaolo11x

  • Sr. Member
  • ****
  • Posts: 201
    • View Profile
Re: Is it possible to format text on a surface?
« Reply #2 on: May 20, 2018, 11:50:16 PM »
After spending a good hour trying to work it out, 2 mins after posting I worked it out. Don't know if this is useful to anybody but here's how I did it!

Yes that's the right way. Did you notice that fonts on a surface have a slight border around them, when the surface is transparent?

markc74

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Re: Is it possible to format text on a surface?
« Reply #3 on: May 21, 2018, 06:28:25 AM »
Yes that's the right way. Did you notice that fonts on a surface have a slight border around them, when the surface is transparent?

Yes I did but I kinda like it looks. But now I cant seem to align the text in the surface though! Any ideas?

I've got this:

dd_artwork_options.add_text("Show Artwork",0, 0, 252, 66).charsize=40;

Which works great, albeit centres the text in the surface so tried this (and most variants I can think of!)

dd_artwork_options.add_text("Show Artwork",0, 0, 252, 66).charsize=40.align=Align.Left;
dd_artwork_options.add_text("Show Artwork",0, 0, 252, 66).charsize=40.align=Left;

But they don't work... Bah...

Am I missing something stupid? I've searched the site and couldn't see anything...

Many thanks for any help on this!

zpaolo11x

  • Sr. Member
  • ****
  • Posts: 201
    • View Profile
Re: Is it possible to format text on a surface?
« Reply #4 on: May 21, 2018, 07:21:06 AM »

dd_artwork_options.add_text("Show Artwork",0, 0, 252, 66).charsize=40.align=Align.Left;
dd_artwork_options.add_text("Show Artwork",0, 0, 252, 66).charsize=40.align=Left;

But they don't work...

Hmm I never pass parameters directly using the dot, try creating a new object for the text, something like

local options_text = dd_artwork_options.add_text("Show Artwork",0, 0, 252, 66)
options_text.charsize = 40
options_text.align=Align.Left

that should work

markc74

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Re: Is it possible to format text on a surface?
« Reply #5 on: May 21, 2018, 08:03:12 AM »
Thanks zpaolo11x,

That's soo close! How do I then add that object to a surface?

zpaolo11x

  • Sr. Member
  • ****
  • Posts: 201
    • View Profile
Re: Is it possible to format text on a surface?
« Reply #6 on: May 21, 2018, 08:05:24 AM »
That's soo close! How do I then add that object to a surface?

The object should be already added to the surface... look at the declaration:

local options_text = dd_artwork_options.add_text("Show Artwork",0, 0, 252, 66)

is adding the object to the dd_artwork_options surface (which I didn't declare in the code sinppet), while if it was like this:

local options_text = fe.add_text("Show Artwork",0, 0, 252, 66)

then the text object would be added to the main frontend.

markc74

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Re: Is it possible to format text on a surface?
« Reply #7 on: May 21, 2018, 08:56:06 AM »
Aaaaaah - now it clicks. ;D

Sorry I missed that the first time. Thank you very much for the explanation!

Best wishes,
Mark

Oomek

  • Sr. Member
  • ****
  • Posts: 214
    • View Profile
Re: Is it possible to format text on a surface?
« Reply #8 on: May 30, 2018, 03:44:53 AM »
That black fringing on a text drawn on a surface is caused by AM using alpha blend mode for surfaces. I’ve fixed it by setting premultiplied blend mode for surfaces in my commit that added blend modes to AM. You have to compile the current version from source or wait for the upcoming AM release.