aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Zechner <contact@badlogicgames.com>2016-05-11 10:55:36 +0200
committerMario Zechner <contact@badlogicgames.com>2016-05-11 10:55:36 +0200
commit0edda60f5bca60b71326f37a6d5fcd964c462841 (patch)
tree5a561a03f7cb0fc0d78eff6f22260855add8a67d
parentda27e2dae56be0a159e82231e5c3a5b83b099063 (diff)
parentad8b71b5888039062aebd35d648a8523622d33d4 (diff)
downloadlibgdx-0edda60f5bca60b71326f37a6d5fcd964c462841.tar.gz
Merge pull request #3927 from JFixby/Free-type-font-generator-texture-bleeding-#3521-fix-tier.3.1
remove texture artifacts for FreeTypeFontGenerator
-rwxr-xr-xCHANGES1
-rwxr-xr-xextensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java6
-rwxr-xr-xgdx/src/com/badlogic/gdx/graphics/g2d/PixmapPacker.java19
3 files changed, 26 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 31bdaba00..5d5241b6b 100755
--- a/CHANGES
+++ b/CHANGES
@@ -25,6 +25,7 @@
- Added TextureArray wrapper see https://github.com/libgdx/libgdx/pull/3807
- Fixed bug in AndroidGL20.cpp which cast a pointer to a 32-bit int. Crash on 64-bit ARM, but only for a specific code path and address...
- Fixed multiple controllers registering on same index with LWJGL3, see https://github.com/libgdx/libgdx/issues/3774
+- Fixed the FreeTypeFontGenerator texture bleeding, see https://github.com/libgdx/libgdx/issues/3521
[1.9.1]
- API Change: Override GwtApplication#createApplicationListener() to create your ApplicationListener
diff --git a/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java b/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java
index 9820092fd..555eb04e5 100755
--- a/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java
+++ b/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java
@@ -369,6 +369,12 @@ public class FreeTypeFontGenerator implements Disposable {
}
ownsAtlas = true;
packer = new PixmapPacker(size, size, Format.RGBA8888, 1, false, packStrategy);
+ packer.setTransparentColor(parameter.color);
+ packer.getTransparentColor().a = 0;
+ if (parameter.borderWidth > 0) {
+ packer.setTransparentColor(parameter.borderColor);
+ packer.getTransparentColor().a = 0;
+ }
}
if (incremental) data.glyphs = new Array(charactersLength + 32);
diff --git a/gdx/src/com/badlogic/gdx/graphics/g2d/PixmapPacker.java b/gdx/src/com/badlogic/gdx/graphics/g2d/PixmapPacker.java
index 50cc22f92..dcba57b4c 100755
--- a/gdx/src/com/badlogic/gdx/graphics/g2d/PixmapPacker.java
+++ b/gdx/src/com/badlogic/gdx/graphics/g2d/PixmapPacker.java
@@ -101,6 +101,7 @@ public class PixmapPacker implements Disposable {
Format pageFormat;
int padding;
boolean duplicateBorder;
+ Color transparentColor = new Color(0f, 0f, 0f, 0f);
final Array<Page> pages = new Array();
PackStrategy packStrategy;
@@ -346,8 +347,12 @@ public class PixmapPacker implements Disposable {
final Array<String> addedRects = new Array();
boolean dirty;
+ /** Creates a new page filled with the color provided by the {@link PixmapPacker#getTransparentColor()} */
public Page (PixmapPacker packer) {
image = new Pixmap(packer.pageWidth, packer.pageHeight, packer.pageFormat);
+ final Color transparentColor = packer.getTransparentColor();
+ this.image.setColor(transparentColor);
+ this.image.fill();
}
public Pixmap getPixmap () {
@@ -573,6 +578,7 @@ public class PixmapPacker implements Disposable {
public SkylinePage (PixmapPacker packer) {
super(packer);
+
}
static class Row {
@@ -580,4 +586,17 @@ public class PixmapPacker implements Disposable {
}
}
}
+
+ /** @see PixmapPacker#setTransparentColor(Color color) */
+ public Color getTransparentColor () {
+ return this.transparentColor;
+ }
+
+ /** Sets the default <code>color</code> of the whole {@link PixmapPacker.Page} when a new one created. Helps to avoid texture
+ * bleeding or to highlight the page for debugging.
+ * @see Page#Page(PixmapPacker packer) */
+ public void setTransparentColor (Color color) {
+ this.transparentColor.set(color);
+ }
+
}