Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeTypeFontGenerator with user-supplied PixmapPacker improvements #2993

Closed
wants to merge 18 commits into from

Conversation

RobRendell
Copy link

As discussed in #2980, I've made some changes to the PixmapPacker so that it can provide an array of TextureRegions based on its pages, and FreeTypeFontGenerator so it uses this method if the user provides their own packer as a FreeTypeFontParameter.

I've updated the PixmapPackerTest to both generate and update the TextureAtlas, to use different-sized pixmaps (and not just the same one with three different names despite creating three of them :), and to show the resulting texture atlas (change pages by hitting 0-9).

FreeTypePackTest now uses the new method. I've also created a new FreeTypeAtlasTest which uses the less efficient (but more convenient) method of just generating the fonts directly. I ran the tests before and after my changes on my laptop, and the times reported by those tests are comparable (but Nathan said that the performance difference would be worse on mobile).

Before my change, FreeTypePackTest
943 ms, 596 ms, 604 ms, 676 ms

After my change, FreeTypePackTest
608 ms, 666 ms, 640 ms

After my change, new FreeTypeAtlasTest
643 ms, 646 ms, 623 ms

try {
c.close();
} catch (Exception ignored) {
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like formatting only. You should check your IDE settings to avoid these kind of automated changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this shows up in this PR, I made the change here in 4f8b073. My personal rule for braces is to use braces if the statement spans multiple lines, for clarity about when the code is executed. I wouldn't normally go around making these kinds of changes, but I had just refactored StreamUtil a bit in
49a7c11 and shortly after the commit I noticed closeQuietly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I guess it shows up in the diff because this PR can't be auto merged. @RobRendell can you merge the latest libgdx into your PR branch?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is now done. Merged, rebased and force-pushed to my forked branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, can be auto merged now once everything settles.

@NathanSweet
Copy link
Member

I think that's it for my review. I think it looks good and we should merge after those changes or discussion.

xoppa and others added 12 commits April 10, 2015 10:13
…libgdx-issue2980

Conflicts:
	CHANGES
	extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java
	gdx/src/com/badlogic/gdx/graphics/g2d/PixmapPacker.java
	tests/gdx-tests/src/com/badlogic/gdx/tests/PixmapPackerTest.java
	tests/gdx-tests/src/com/badlogic/gdx/tests/extensions/FreeTypeAtlasTest.java
	tests/gdx-tests/src/com/badlogic/gdx/tests/extensions/FreeTypePackTest.java
@RobRendell
Copy link
Author

I've made some further changes, some of which are in line with your suggestions :)

  • PixmapPacker can pack Pixmaps "anonymously", through a new PixmapPacker.pack(Pixmap) method. FreeTypeFontGenerator uses this feature, and no longer constructs names for its glyphs.
  • PixmapPacker can pack direct to the texture (if the texture exists), via PixmapPacker.packDirectToTexture(String, Pixmap) and PixmapPacker.packDirectToTexture(Pixmap). This will update the texture directly if it exists and doesn't have other changes pending. FreeTypeFontGenerator uses this feature too, instead of updating the texture itself.
  • PixmapPacker.updateTextureAtlas takes a boolean parameter which directs it whether to refresh textures or not.

How does it all look to you?

@RobRendell
Copy link
Author

Hum, I seem to have messed up the pull/rebase/merge across my branches... Xoppa's last commit seems to be showing up as a diff in my pull request now. Peculiar.

@NathanSweet
Copy link
Member

Not sure what's going on with the diff. Maybe you can squash your commits?

@RobRendell
Copy link
Author

I'm in the process of making a fresh branch off master and cherry-picking my changes over, and I was going to create a fresh pull request off that branch. Does that work for you?

@NathanSweet
Copy link
Member

Sure. I don't pretend to understand silly Git. :p

@RobRendell
Copy link
Author

Ok, fresh pull request created. I don't know if I can cancel this one, but I'll see what I can do.

@RobRendell
Copy link
Author

Ah, that would be the "Close and comment" button.

@RobRendell RobRendell closed this Apr 10, 2015
NathanSweet added a commit that referenced this pull request Apr 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants