v0.9.4: reduced allocations when text is being matches to a font
This commit is contained in:
parent
92f190d04c
commit
d47c8d1fac
|
@ -42,6 +42,7 @@ import com.watabou.noosa.Game;
|
|||
import com.watabou.utils.PlatformSupport;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AndroidPlatformSupport extends PlatformSupport {
|
||||
|
@ -264,17 +265,17 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||
packer = new PixmapPacker(pageSize, pageSize, Pixmap.Format.RGBA8888, 1, false);
|
||||
}
|
||||
|
||||
private static Pattern KRMatcher = Pattern.compile("\\p{InHangul_Syllables}");
|
||||
private static Pattern SCMatcher = Pattern.compile("\\p{InCJK_Unified_Ideographs}|\\p{InCJK_Symbols_and_Punctuation}|\\p{InHalfwidth_and_Fullwidth_Forms}");
|
||||
private static Pattern JPMatcher = Pattern.compile("\\p{InHiragana}|\\p{InKatakana}");
|
||||
private static Matcher KRMatcher = Pattern.compile("\\p{InHangul_Syllables}").matcher("");
|
||||
private static Matcher SCMatcher = Pattern.compile("\\p{InCJK_Unified_Ideographs}|\\p{InCJK_Symbols_and_Punctuation}|\\p{InHalfwidth_and_Fullwidth_Forms}").matcher("");
|
||||
private static Matcher JPMatcher = Pattern.compile("\\p{InHiragana}|\\p{InKatakana}").matcher("");
|
||||
|
||||
@Override
|
||||
protected FreeTypeFontGenerator getGeneratorForString( String input ){
|
||||
if (KRMatcher.matcher(input).find()){
|
||||
if (KRMatcher.reset(input).find()){
|
||||
return KRFontGenerator;
|
||||
} else if (SCMatcher.matcher(input).find()){
|
||||
} else if (SCMatcher.reset(input).find()){
|
||||
return SCFontGenerator;
|
||||
} else if (JPMatcher.matcher(input).find()){
|
||||
} else if (JPMatcher.reset(input).find()){
|
||||
return JPFontGenerator;
|
||||
} else {
|
||||
return basicFontGenerator;
|
||||
|
|
|
@ -23,8 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.desktop;
|
|||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
|
@ -32,9 +30,8 @@ import com.watabou.noosa.Game;
|
|||
import com.watabou.utils.PlatformSupport;
|
||||
import com.watabou.utils.Point;
|
||||
|
||||
import org.lwjgl.util.tinyfd.TinyFileDialogs;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DesktopPlatformSupport extends PlatformSupport {
|
||||
|
@ -98,13 +95,13 @@ public class DesktopPlatformSupport extends PlatformSupport {
|
|||
packer = new PixmapPacker(pageSize, pageSize, Pixmap.Format.RGBA8888, 1, false);
|
||||
}
|
||||
|
||||
private static Pattern asianMatcher = Pattern.compile("\\p{InHangul_Syllables}|" +
|
||||
private static Matcher asianMatcher = Pattern.compile("\\p{InHangul_Syllables}|" +
|
||||
"\\p{InCJK_Unified_Ideographs}|\\p{InCJK_Symbols_and_Punctuation}|\\p{InHalfwidth_and_Fullwidth_Forms}|" +
|
||||
"\\p{InHiragana}|\\p{InKatakana}");
|
||||
"\\p{InHiragana}|\\p{InKatakana}").matcher("");
|
||||
|
||||
@Override
|
||||
protected FreeTypeFontGenerator getGeneratorForString( String input ){
|
||||
if (asianMatcher.matcher(input).find()){
|
||||
if (asianMatcher.reset(input).find()){
|
||||
return asianFontGenerator;
|
||||
} else {
|
||||
return basicFontGenerator;
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.robovm.apple.systemconfiguration.SCNetworkReachabilityFlags;
|
|||
import org.robovm.apple.uikit.UIApplication;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class IOSPlatformSupport extends PlatformSupport {
|
||||
|
@ -97,13 +98,13 @@ public class IOSPlatformSupport extends PlatformSupport {
|
|||
packer = new PixmapPacker(pageSize, pageSize, Pixmap.Format.RGBA8888, 1, false);
|
||||
}
|
||||
|
||||
private static Pattern asianMatcher = Pattern.compile("\\p{InHangul_Syllables}|" +
|
||||
private static final Matcher asianMatcher = Pattern.compile("\\p{InHangul_Syllables}|" +
|
||||
"\\p{InCJK_Unified_Ideographs}|\\p{InCJK_Symbols_and_Punctuation}|\\p{InHalfwidth_and_Fullwidth_Forms}|" +
|
||||
"\\p{InHiragana}|\\p{InKatakana}");
|
||||
"\\p{InHiragana}|\\p{InKatakana}").matcher("");
|
||||
|
||||
@Override
|
||||
protected FreeTypeFontGenerator getGeneratorForString( String input ){
|
||||
if (asianMatcher.matcher(input).find()){
|
||||
if (asianMatcher.reset(input).find()){
|
||||
return asianFontGenerator;
|
||||
} else {
|
||||
return basicFontGenerator;
|
||||
|
|
Loading…
Reference in New Issue
Block a user