# How can I add extensions to libGDX?

I had a problem with my Font in a game I am developing in libGDX. After some googling I was instructed to use the following code:

private void createFonts() {
FileHandle fontFile = Gdx.files.internal("data/Roboto-Bold.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 12;
textFont = generator.generateFont(parameter);
parameter.size = 24;
titleFont = generator.generateFont(parameter);
generator.dispose();
}


The problem is there is no FreeTypeFontGenerator class in any of the libGDX libraries I am using. I found that it was an extension. LINK

I can't seem to find clear instruction on how to import these extensions so that I may use them in my game.

I am using Android Studio for development.

A lot of great Libgdx extensions have been added to the maven repository such as freetype, tools and many other great libraries. This means you can add extensions in a blink of an eye, at least if you used the gradle LibGDX setup.

In your case you want to add freetype, look it up in the link above and select the version you need. Now select the tab Gradle and copy that link.

Open up the build.gradle at the root of your project. This file takes care of building the project for you. You just have to add this line in the modules you want to use it. I show you a example of my desktop module in the build.gradle file.

project(":desktop") {
apply plugin: "java"

dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile 'com.underwaterapps.overlap2druntime:overlap2d-runtime-libgdx-my:0.1.0'

Now all you need is to sync the project with the gradle files. In Android Studio I would go Tools > Android > Sync Project with Gradle Files. If you do not use Android Studio and cannot find this just search google how to sync with gradle for your IDE.
For example, you can see from this Gradle/Maven repository search that there are both gdx-freetype and gdx-freetype-platform JARs.
To add them to Gradle, you just need to add the dependency name and version under the dependencies section.