Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LibGDX FreeTypeFontGenerator

I've created LibGDX project with latest Gradle based setup application v1.1.0. When I created I didn't add FreeType extension on the project. Now I need it. How can I add it to already created project?

like image 931
KiKo Avatar asked Jun 12 '14 14:06

KiKo


People also ask

When should the freetypefontgenerator and freetypebitmapfontdata be disposed?

* FreeTypeFontGenerator must not be disposed until the font is no longer needed. The FreeTypeBitmapFontData must be * disposed (separately from the generator) when the font is no longer needed.

Is libGDX-FreeType compatible with HTML5?

gdx-freetype is not compatible with HTML5. However, you may use the gdx-freetype-gwt library by Intrigus to enable HTML5 functionality. Version 1.9.10.1 remains compatible with never versions of libGDX, including 1.10.0.

What is the default size of the font in the generator?

Default is 1024. /** Creates a new generator from the given font file. Uses {@link FileHandle#length ()} to determine the file size. If the file

Are there any new modules added to libGDX?

please note that since June 12 2014, there have been new modules added such as Ashley ( github.com/libgdx/ashley/wiki/How-to-use-Ashley ) .


2 Answers

From the libGDX's wiki

FreeTypeFont Gradle

Core Dependency:

  • compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

Desktop Dependency:

  • compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"

Android Dependency:

  • compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
  • natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
  • natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
  • natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"

iOS Dependency:

  • compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
  • natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"

Don't forget to refresh your dependencies ;)

like image 188
NiziL Avatar answered Oct 16 '22 13:10

NiziL


Here is a complete build.gradle with all the modules, you can see which one is FreeType related and just add it to your gradle configuration.

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.10+'
        classpath 'com.github.jtakakura:gradle-robovm-plugin:0.0.9'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = 'klaxon-game'
        gdxVersion = '1.1.0'
        roboVMVersion = '0.0.13'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

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.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.box2dlights:box2dlights:1.2"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
    }
}

project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "org.robovm:robovm-rt:${roboVMVersion}"
        compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
    }
}

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


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        compile "com.badlogicgames.box2dlights:box2dlights:1.2"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
    }
}

tasks.eclipse.doLast {
    delete ".project"
}
like image 33
EpicPandaForce Avatar answered Oct 16 '22 15:10

EpicPandaForce