Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
532 stars 140 forks source link

Font support #115

Closed PabloNeirotti closed 4 years ago

PabloNeirotti commented 9 years ago

Hi all! Hi Ancurio!

I've been following this project for over 6 months now. My game is finally on Steam (Early Access) yet I am still looking at the idea of using this as the "player" for my game. At least starting with Windows (since it's very Win32API dependent), because, oh my, that performance! This is using GPU, isn't it?

Anyways, with all my tests I got many things to work (minus audio, key presses, some drawing functions - since they rely on DLLs and would require further tweaking or discarding).

Now, for some reason the MKXP wasn't using my provided fonts (Helvetica Neue Condensed, provided in TTF format). Is this due to the extension? What I saw printed on screen instead of Helvetica Condensed was... some kind of Arial, but wasn't it. It looked thinner, reminded me of some Linux fonts.

Do you know anything about this? With time I would love to provide these enhancements to my users, and eventually expanding it to Mac + Linux support (as a Mac user myself! I need to play my game on a Virtual Machine).

Thank you! And thank you for your hard work. Let me know if I can help as a designer or Ruby programmer.

cremno commented 9 years ago

Now, for some reason the MKXP wasn't using my provided fonts (Helvetica Neue Condensed, provided in TTF format).

How exactly did you change the font and what is its file name?

What I saw printed on screen instead of Helvetica Condensed was... some kind of Arial, but wasn't it. It looked thinner, reminded me of some Linux fonts.

Liberation Sans (see assets/liberation.ttf) is used by default.

carstene1ns commented 9 years ago

Did you read https://github.com/Ancurio/mkxp#fonts and https://github.com/Ancurio/mkxp/blob/master/mkxp.conf.sample#L208 ?

PabloNeirotti commented 9 years ago

Hey there!

I did read the Readme.md. I did see there was a configuration file, although not sure how to use it. Is that for compiling my own Player? (I was using an existing binary).

I didn't change the fonts name or anything. While Helvetica Neue displays on the regular RPG Maker VX Ace player, it doesn't on MKXP (although instead of not displaying at all, it displays that Liberation Sans you mention — I KNEW IT WAS A LINUX-ISH FONT! I have an eye for fonts :D)

Thank you for the quick responses!

Ancurio commented 9 years ago

Hello,

if such a problem occurs, you should first try isolating it from the rest of your game. mkxp.conf is a configuration file that mkxp reads when it is run, and which influences the behavior of the engine at run time. You can use the customScript= entry to write a small font_name_bug.rb, and mkxp will run only that. This way you don't have to fiddle with your game scripts or create a useless dummy project.

To test what you're describing, this should be enough:

b = Bitmap.new(200, 100)
b.font.name = "Helvetica Neue Condensed"
b.draw_text(b.rect, "Hello World", 1)
s = Sprite.new
s.bitmap = b
loop { Graphics.update; Input.update }

Assuming this script is in your game folder, your mkxp.conf should containt:

customScript=font_name_bug.rb

Please report whether this fails to use your provided font.

(Edit: Added mkxp.conf example)

openmac commented 9 years ago

I just tried Ancurio's test script with HelveticaNeueCondensedBold.ttf that I extracted from the dfont file shipped with OS X, and changed this line:

b.font.name = "Helvetica Neue Condensed"

to:

b.font.name = "Helvetica Neue Condensed Bold"

It did not work, but I realized something, you have to write the font family name, not including the typeface, in my case the font family name is Helvetica Neue and the typeface is Condensed Bold so I had to use this line to make it work:

b.font.name = "Helvetica Neue"

I wonder if the font file you are using has the same naming method. You can make sure by opening the ttf file with Font Book on Mac: Image of Font Book

(BTW, make sure your ttf file is in a folder named "Fonts", it should be placed in the Resources folder inside your .app bundle on Mac and on Windows probably in the same path that your game files (Data & Graphics folders or game.rss3a) are on).

PabloNeirotti commented 9 years ago

Hey there! Thank you all for your responses.

I threw away the tweaks I made to make my game run on MKXP, so I can't test that right now :/ I will have to come back to it later.

However, in my game I name this font: Helvetica Neue LT Com 67 Medium Condensed

This is recognized by RPG Maker VX Ace's player. Would this need to be specified differently on MKXP for it to work? "Helvetica Neue" wouldn't be enough, as I need to specified I need the font variation.

Naturally the font is located at the Fonts folder.

Cheers!

cremno commented 9 years ago

Yeah, that is supported by RGSS (due to GDI) but not yet by mkxp, even though it already reads the style name.

PabloNeirotti commented 9 years ago

Hey Guys!

@Ancurio: I tried what you told me, now that I got back on trying to port my game to RKXP.

Tried both Helvetica Neue LT Com 67 Medium Condensed and Helvetica Neue Condensed without any luck. Running on Windows.

It is clearly running the test .rb — I see a black screen with a little white text that is clearly not Helvetica, nor condensed.

If I can't define the exact style I want... Is there any way to specify the exact filename of the font I want to use?

I just tried b.font.name = "HelveticaNeueLTCom-Bd.ttf", however, it didn't work either.

Thank you!

PabloNeirotti commented 9 years ago

Update: Using "Helvetica Neue LT Com"will actually work, but it picked the "Thin" variation as opposed to the "Medium" condensed version.

Is there any way to change the name of a font to bring it down to a level that RKXP can distinguish them, without the need of adding "Full Name" support? (I use Full Name on VX Ace to specify the font I want)

Ancurio commented 9 years ago

From the viewpoint of Freetype/SDL_ttf, a font has two strings identifying it, the "family" (Helvetica Neue LT Com) and "style" (Medium (Condensed)). Right now, mkxp only matches fonts by their family name. If multiple fonts of the same family are present, the one with "Regular" style is preferred, and if that's not present the preference is undefined.

Are you saying that you use multiple font files of the same family in your project?

Edit: s/Normal/Regular/ Edit2: Spelling

PabloNeirotti commented 9 years ago

Hey!

Indeed, I have Medium Condensed, Thin Condensed, etc...

But I found a workaround! https://github.com/behdad/fonttools/

This allows you to change the internal name of any Font. I've redone all of their names to something accessible. Now I am using exactly the font I want, in game :)

Pretty sweet, huh?