View Full Version : Controlling Font Size in CyCivicsScreen


Aussie_Lurker
Oct 30, 2006, 08:25 AM
Hi guys. Well my Civics Mod continues apace. However, I have run into a problem. In order to fit all the civics categories into the screen, I am going to need to reduce the width of each of the Help Tabs. Unfortunately this is going to lead to text overruns at the current font size.
Now I have found references to "<Font>" in CyCivics.py, but nothing I do actually seems to change to size of the font. Can anyone suggest where I might be going wrong?

Aussie_Lurker.

Déja
Oct 30, 2006, 10:43 AM
I'm at work, so I can't check, but perhaps you'll need to look at the GameFonts file or references to it that determine the glyph size. I don't think that civ uses a TrueType or similar scalable font.

ArbitraryGuy
Nov 02, 2006, 01:15 AM
EDIT: Never mind, doesn't answer question posed.

ArbitraryGuy
Nov 02, 2006, 01:52 AM
Got it.

In CvCivicsScreen.py (vanilla), line 268

screen.addMultilineText(szHelpAreaID, szHelpText,...blah, blah, blah

add to the text, a fontsize string... chaning it to

screen.addMultilineText(szHelpAreaID, u"<font=X>" + szHelpText,...blah, blah, blah

where, X is the font size, 2 or 1 is smaller than the standard (which I think is 3).

Hope this helps :goodjob:

Aussie_Lurker
Nov 02, 2006, 06:52 AM
Hi there AG, thanks for your help. Python is definitely NOT my strong suit ;). To show you what I was after, though, have a look at this picture:

http://forums.civfanatics.com/uploads/33710/CivicsScreen7.JPG

You see how the writing up the top is going off the square? I was wondering if there is any way that I can change the font for this part of the civics screen?

Again, anyhelp is appreciated.

Aussie_Lurker.

TAfirehawk
Nov 02, 2006, 10:26 AM
Not sure how easily it can be adapted to any other mod, but in ViSa mrgenie made the Civic Screen horizontally scrollable to allow for unlimited Civic Categories.

I didn't do any of the code, but you can check out the screen shots in our thread linked in my sig. And of course our source code is available for anybody to use as well.

ArbitraryGuy
Nov 02, 2006, 12:35 PM
Aussie_Lurker,

What I posted above will change the font size in the descriptions of civic effects box (the multiline text in the bottom panels... which python calls the "HelpText"), which I think you will have to do anyway with such narrow columns. I thought that's what you were asking for (sorry for misunderstanding your question).

If you want the civics names in the top panels to be smaller, add a fontsize string to the following:

Ln. 164 in vanilla (in Warlords it should be similar... its in the drawAllButtons class in CvCivicsScreen.py)

change:
screen.setText(self.getCivicsTextName(j), "", gc.getCivicInfo(j).getDescription(), ... blah, blah, blah

to (adding in a string for fontsize, the "" marks must be included):
screen.setText(self.getCivicsTextName(j), "", u"<font=X>" + gc.getCivicInfo(j).getDescription(), ... blah, blah, blah

Where X is your font size. You'll get the following as pictured below (where I used u"<font=1>"). Note, you will still have to change button size (so that they're smaller too) and changing the text margin helps to make it look better (all defined in the top section of CvCivicsScreen.py).

Hope this helps... :goodjob:

ArbitraryGuy
Nov 02, 2006, 12:45 PM
Note: To change the other font text sizes, you'll have to locate those texts and insert a fontsize string there, as well. Why don't you PM me (or post here) your CvCivicsSreen.py (the version that you are using) and I'll put in font size variables for you to easily control all the font sizes at the top of the file? That'd be the easiest solution, and it would make it easier for you to play around with until you get the result you want.