# How to make nifty gui textfield to use a larger font

Hi I have a text field on my screen but its tiny:

<panel height="13%" width="100%" childLayout="vertical">
<text id="label1" height="50%" font="Interface/Fonts/MinionPro.fnt" color="#f00f"
text="Hello World!" align="center" valign="center" />
</panel>
<panel height="10%" width="100%" backgroundColor="#55a5" childLayout="center">
<control name="textfield" text="Some text"/>
</panel>


the problem is I can not figure out how to change the font size on it. Please help me out here.

In jME/Nifty, each letter is basically a Quad with a Texture on it. Scaling font-textures usually looks horrible and I guess that's why Nifty doesn't provide an option for scaling (you can scale BitmapText in jME though).

Easiest way is to generate a new, bigger font. If you're using the jME SDK there's a built-in generator. Right click on a folder in the Projects Window and choose New -> Other -> GUI -> Font.

I recommend a padding of 2 for X and Y. Otherwise you might see random dots in the rendered text (these are parts of other letters that are overlapping the letter box in the texture).

Sometimes there's a huge gap between the letters. You can control that by using negative values for "letter spacing".

Nifty's Textfield-Control is a composition of panels and text elements. To use a bigger font you have to redefine its style. Grab the original nifty-textfield.xml from your nifty-style-black.jar or from here: https://github.com/nifty-gui/nifty-gui/blob/1.4/nifty-controls-style-black/src/main/resources/textfield/nifty-textfield.xml

Save it somewhere in your Assets/Interface folder and include it in your other XML like this:
(Make sure to include it after nifty-default-styles.xml)

<useStyles filename="Interface/textfield.xml" />


Now you have to adjust the style. Remove the base="base-font" attribute from the style with ID nifty-textfield#text and add font to the attributes-Tag. It should look like this:

<style id="nifty-textfield#text">
<attributes ... font="Interface/Fonts/YourFont-24.fnt" />
</style>


You probably also want to change the size of the Textfield to match the new font. Edit the other styles in this file as you need.

The Nifty Manual explains controls and styles in more detail:
• You could define multiple style sets - one for each resolution - all using the same names for the styles. Then check the resolution in java and add the appropriate style.xml with Nifty.addXml(). I think you could use the base="base-style" attribute so you only have to redefine the differences. Maybe this is useful to you: stackoverflow.com/questions/23265892/… – 1000ml Dec 23 '15 at 13:16