HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Loading Custom Fonts  (Read 2035 times)

Amanda_Brooks

  • General Accounts
  • *
  • Posts: 514
    • View Profile
    • Heroes and Villains
Loading Custom Fonts
« on: Sep 03, 13, 07:51:27 PM »

We've been trying for a while now to get a custom font loaded from the repository, but we've not had any luck with it yet - it's in .ttf format, so we're pretty sure that's not what's causing the problems.

This is the code we're currently using:

Quote
method HE_FirstChance( ) as Boolean
  SubstituteFont( DEFAULTTEXT, "Tahoma" )      // specify a FontFace that exists in your font file
  return false
.

Any suggestions or advice?
Logged
"Heroes and Villains" - www.heroes-and-villains.com
Facebook: https://www.facebook.com/HeroesAndVillainsMMORPG
Twitter: @Plan_Z_Studios

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Loading Custom Fonts
« Reply #1 on: Sep 03, 13, 10:16:05 PM »

Search for  "SubstituteFont" in the forums, its covered quite a bit already.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Amanda_Brooks

  • General Accounts
  • *
  • Posts: 514
    • View Profile
    • Heroes and Villains
Re: Loading Custom Fonts
« Reply #2 on: Sep 03, 13, 10:38:22 PM »

We've already look at that thread and others, and we've copied the advice in them, but without any success - what we're really looking for is any other project that has successfully loaded a custom font to just paste the code they used here, so that we and other projects who are having issues with it can see how it'as meant to be done properly.
Logged
"Heroes and Villains" - www.heroes-and-villains.com
Facebook: https://www.facebook.com/HeroesAndVillainsMMORPG
Twitter: @Plan_Z_Studios

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Loading Custom Fonts
« Reply #3 on: Sep 03, 13, 10:41:32 PM »

Have you tried just making a test gui element and using the properties panel to test your font works without involving any scripting / code?

Might help narrow down things.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Amanda_Brooks

  • General Accounts
  • *
  • Posts: 514
    • View Profile
    • Heroes and Villains
Re: Loading Custom Fonts
« Reply #4 on: Sep 03, 13, 11:16:35 PM »

There are 8 display fonts available in the GUI creation of a label, without scripting each of those can be used, though we are looking to set our choice of font in, not use one of the defaults.
Logged
"Heroes and Villains" - www.heroes-and-villains.com
Facebook: https://www.facebook.com/HeroesAndVillainsMMORPG
Twitter: @Plan_Z_Studios

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Loading Custom Fonts
« Reply #5 on: Sep 04, 13, 04:55:22 AM »

Is your font in the root of your repository?  If not, you are missing the path.  If so, consider these points:
  • the ttf file name itself must be referenced; the extension is optional for installed fonts, but necessary for repository fonts
  • if you want to reference a font in the root of your repo, it still needs the forward-slash, i.e. "/myfont.ttf"
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Chromehound

  • General Accounts
  • *
  • Posts: 151
    • View Profile
Re: Loading Custom Fonts
« Reply #6 on: Sep 04, 13, 11:03:50 AM »

just type in your font name in the properties panel for the label - look for the fontface box and put it in there.  As Scott says above "/myfont.ttf"  include the .ttf unless it's a default windows font.

I put mine in a GUI/fonts folder so in my properties window, it'd be /GUI/fonts/customfont.ttf
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Loading Custom Fonts
« Reply #7 on: Sep 04, 13, 12:02:54 PM »

no coding is needed for custom fonts to work, they changed that a while back, just have to key in the correct file path into the properties window. How that is done depends on where the font is.

See above for examples.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Loading Custom Fonts
« Reply #8 on: Sep 04, 13, 01:22:33 PM »

You still need SubstituteFont() to change the font that gets used for the standard names like DEFAULTTEXT.  Its a good idea to do so for the GAMETEXT value.  Then if you use GAMETEXT throughout and decide to change that font, you only need to do it at the one SubstituteFont() call instead of needing to change it everywhere it was used.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Loading Custom Fonts
« Reply #9 on: Sep 04, 13, 02:09:44 PM »

True, on that aspect. Was just pointing out that it's best to test a font with just substituting it on a gui / test gui element, then you know everything is correct, for the substitute font command.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Amanda_Brooks

  • General Accounts
  • *
  • Posts: 514
    • View Profile
    • Heroes and Villains
Re: Loading Custom Fonts
« Reply #10 on: Sep 04, 13, 02:39:37 PM »

Ok, we fixed this in a weird way, sort of by accident - wee deleted our custom .ttf font and replaced it with a custom .otf font, which worked perfectly - but our concern now is that because the HE wiki says that fonts have to be .ttf, we're wondering if the fact we managed to get an .otf working is just down to some kind of glitch that could be fixed in the future.
Logged
"Heroes and Villains" - www.heroes-and-villains.com
Facebook: https://www.facebook.com/HeroesAndVillainsMMORPG
Twitter: @Plan_Z_Studios

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Loading Custom Fonts
« Reply #11 on: Sep 04, 13, 02:42:31 PM »

did you guys have that oft loaded on your windows machines locally?
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Amanda_Brooks

  • General Accounts
  • *
  • Posts: 514
    • View Profile
    • Heroes and Villains
Re: Loading Custom Fonts
« Reply #12 on: Sep 04, 13, 06:12:32 PM »

No, just downloaded and stored in a zip file.
Logged
"Heroes and Villains" - www.heroes-and-villains.com
Facebook: https://www.facebook.com/HeroesAndVillainsMMORPG
Twitter: @Plan_Z_Studios