0

So, I am making a Game called Fall Down 4 and currently I am just using the built in font (the font that it usually comes with). Now, I want the Title to look more attractive and Good and to do that, i actually downloaded different fonts from Google. I Then created a assests folder and in that folder i copied the font that i installed in my computer (I looked at the different forums on stack overflow). Now my question is how Do i Change the default font to this new downloaded font. Like I just Don't know where to go to change the font of the Text.

I have seen many people ask this question on this fourm but what i want is different FONTS, a FONT that is not BUILT IN, i wannt to USE the FONT I DOWNLOADED and That is what I need help With.

So Please tell me step by step on how to change the font of the text to the font That I have installed in my computer.

The Code:

public class FallDown4TitleScreen extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fall_down_title_screen);

    Typeface myTypeFace = Typeface.createFromAsset(getAssets(), "Spac3 tech free promo.ttf");

    final Button playbutton = (Button) findViewById(R.id.Playbutton);
    final Button custButton = (Button) findViewById(R.id.custButton);
    final Button settingButton = (Button) findViewById(R.id.settingButton);
    final TextView textView = (TextView) findViewById(R.id.textView);

    textView.setTypeface(myTypeFace);

    playbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            custButton.setVisibility(View.INVISIBLE);
            settingButton.setVisibility(View.INVISIBLE);
            textView.setVisibility(View.VISIBLE);
            playbutton.setVisibility(View.INVISIBLE);
        }
    });
}

}

Jainam Patel
  • 41
  • 2
  • 3
  • 12
  • Possible duplicate of [How to change fontFamily of TextView in Android](http://stackoverflow.com/questions/12128331/how-to-change-fontfamily-of-textview-in-android) – ekchang May 07 '16 at 16:58

1 Answers1

0

If you are looking to set a custom TrueType font from your asset folder to some textviews or similar views, you could simply do like:

textview.setTypeface(Typeface.createFromFile(getAssets(),"fonts/yourfont.ttf"));

take a look at this discussion if you are looking to change the default font in your app:

Is it possible to set a custom font for entire of application?

However, mobile games generally use bitmap fonts, and draw that on canvas. Hope that helped!!

Community
  • 1
  • 1
  • Waitt... I just want to make sure... To Create a a Folder inside the assets folder.. I did the Follwoing: New > Folder > assets Folder. and in that I pasted the fonts. Is that RIte? – Jainam Patel May 07 '16 at 17:57
  • yes! you are good to go that way. File > New > folder > assets Folder, then you can see asset folder under main, you could even use sub-folders for different type of assets. like a fonts folder and place that font there. – Harshal Sharma May 07 '16 at 18:15
  • but now it's working but when I run the Entire text should be the same font. I can only see " All Own" when its suppose to be "Fall Down 4". Please help why that does that. I have updated the code to see what i am doing. – Jainam Patel May 07 '16 at 20:22
  • i don't get you, but what i can tell you is make your font name without spaces, and must check your xmls for sizes. – Harshal Sharma May 10 '16 at 13:52