Skip to content

Commit

Permalink
chore: update gradle version to 8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
闫茂源 committed May 23, 2024
1 parent bb64b96 commit 73f3689
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 184 deletions.
14 changes: 1 addition & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'jme3-freetype-font.java-application-conventions'
//id 'com.github.johnrengelman.shadow' version '7.1.1'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

ext.imguiVersion = '1.86.11'
Expand Down Expand Up @@ -48,16 +48,4 @@ application {
mainClass = 'io.github.jmecn.font.editor.Main'

applicationDefaultJvmArgs = ["-XstartOnFirstThread"]

applicationDistribution.from('../preset') {
into ('preset')
}
applicationDistribution.from('../font') {
into ('font')
include "NotoSerifSC-Regular.otf"
include "NotoSansSC-Regular.ttf"
include "unifont-15.1.05.otf"
include "FreeSerif.ttf"
include "OFL.txt"
}
}
9 changes: 8 additions & 1 deletion app/src/main/java/io/github/jmecn/font/editor/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jme3.app.SimpleApplication;
import com.jme3.app.StatsAppState;
import com.jme3.app.state.AppState;
import com.jme3.asset.AssetInfo;
import com.jme3.asset.AssetKey;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
Expand Down Expand Up @@ -35,6 +36,7 @@
import io.github.jmecn.font.packer.Page;
import io.github.jmecn.font.packer.strategy.GuillotineStrategy;
import io.github.jmecn.font.packer.strategy.SkylineStrategy;
import io.github.jmecn.font.utils.FileUtils;
import org.lwjgl.PointerBuffer;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.tinyfd.*;
Expand Down Expand Up @@ -254,7 +256,12 @@ private void initImGui() {
imFontConfig.setMergeMode(true); // Merge Default, Cyrillic, Japanese ranges and manual specific chars

final short[] glyphRanges = rangesBuilder.buildRanges();
ImFont imFont = io.getFonts().addFontFromFileTTF("font/NotoSerifSC-Regular.otf", 16, imFontConfig, glyphRanges);

// read all bytes
AssetInfo assetInfo = assetManager.locateAsset(new AssetKey<>("font/NotoSerifSC-Regular.otf"));
byte[] data = FileUtils.readAllBytes(assetInfo.openStream());

ImFont imFont = io.getFonts().addFontFromMemoryTTF(data, 16, imFontConfig, glyphRanges);
io.getFonts().build(); // Build custom font
io.setFontDefault(imFont); // Set custom font to default

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
id 'jme3-freetype-font.java-common-conventions'

// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 1 addition & 2 deletions lib/src/main/java/io/github/jmecn/font/CommonChars.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public enum CommonChars {
/*y*/"压押鸦鸭呀丫芽牙蚜崖衙涯雅哑亚讶焉咽阉烟淹盐严研蜒岩延言颜阎闫炎沿奄掩眼衍演艳堰燕厌砚雁唁彦焰宴谚验殃央鸯秧杨扬佯疡羊洋阳氧仰痒养样漾邀腰妖瑶摇尧遥窑谣姚咬舀药要耀椰噎耶爷野冶也页掖业叶曳腋夜液一壹医揖铱依伊衣颐夷遗移仪胰疑沂宜姨彝椅蚁倚已乙矣以艺抑易邑屹亿役臆逸肄疫亦裔意毅忆义益溢诣议谊译异翼翌绎茵荫因殷音阴姻吟银淫寅饮尹引隐印英樱婴鹰应缨莹萤营荧蝇迎赢盈影颖硬映哟拥佣臃痈庸雍踊蛹咏泳涌永恿勇用幽优悠忧尤由邮铀犹油游酉有友右佑釉诱又幼迂淤于盂榆虞愚舆余俞逾鱼愉渝渔隅予娱雨与屿禹宇语羽玉域芋郁吁遇喻峪御愈欲狱育誉浴寓裕预豫驭鸳渊冤元垣袁原援辕园员圆猿源缘远苑愿怨院曰约越跃钥岳粤月悦阅耘云郧匀陨允运蕴酝晕韵孕" +
/*w*/"挖哇蛙洼娃瓦袜歪外豌弯湾玩顽丸烷完碗挽晚皖惋宛婉万腕汪王亡枉网往旺望忘妄威巍微危韦违桅围唯惟为潍维苇萎委伟伪尾纬未蔚味畏胃喂魏位渭谓尉慰卫瘟温蚊文闻纹吻稳紊问嗡翁瓮挝蜗涡窝我斡卧握沃巫呜钨乌污诬屋无芜梧吾吴毋武五捂午舞伍侮坞戊雾晤物勿务悟误" +
"、,;。!?·.:…——“”‘’『』「」()《》〈〉〔〕【】"
),
;
);
private final String chars;
CommonChars(String chars) {
this.chars = chars;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public class BitmapFontDelegate {
throw new FtRuntimeException("Failed to init BitmapTextDelegate", e);
}
}

/**
* This is delegate method for BitmapFont::getPage(int index)
*
* @param obj the BitmapFont instance
* @param args page index
* @return the material of this page
*/
public static Material getPage(@This Object obj, @AllArguments Object ... args) {
BitmapFont font = (BitmapFont) obj;
int index = (int) args[0];
Expand All @@ -41,6 +49,11 @@ public static Material getPage(@This Object obj, @AllArguments Object ... args)
}
}

/**
* This is delegate method for BitmapFont::getPageSize()
* @param obj the BitmapFont instance
* @return the pageSize
*/
public static int getPageSize(@This Object obj) {
BitmapFont font = (BitmapFont) obj;
if (font.getCharSet() instanceof FtBitmapCharacterSet) {
Expand Down
18 changes: 2 additions & 16 deletions lib/src/main/java/io/github/jmecn/font/freetype/FtLibrary.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.jmecn.font.freetype;

import io.github.jmecn.font.exception.FtRuntimeException;
import io.github.jmecn.font.utils.FileUtils;
import org.lwjgl.PointerBuffer;
import org.lwjgl.system.MemoryStack;
import org.slf4j.Logger;
Expand All @@ -26,7 +26,6 @@ public class FtLibrary implements AutoCloseable {
public static final int MIN_SPREAD = 2;
public static final int DEFAULT_SPREAD = 8;
public static final int MAX_SPREAD = 32;
public static final int SDF_UNIT_ONE = 256;

private long address;
private final String version;
Expand Down Expand Up @@ -120,20 +119,7 @@ public FtFace newFace(InputStream inputStream) {
}

public FtFace newFace(InputStream inputStream, long faceIndex) {
// Read all data
ByteArrayOutputStream bos = new ByteArrayOutputStream(65536);
BufferedInputStream bis = new BufferedInputStream(inputStream);
byte[] buffer = new byte[4096];
int len;
try {
while ((len = bis.read(buffer)) != -1) {
bos.write(buffer, 0, len);
}
} catch (IOException e) {
throw new FtRuntimeException("Read font data failed", e);
}

byte[] data = bos.toByteArray();
byte[] data = FileUtils.readAllBytes(inputStream);
if (data.length == 0) {
throw new IllegalArgumentException("input stream is empty");
}
Expand Down

This file was deleted.

34 changes: 34 additions & 0 deletions lib/src/main/java/io/github/jmecn/font/utils/FileUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.github.jmecn.font.utils;

import io.github.jmecn.font.exception.FtRuntimeException;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
* desc:
*
* @author yanmaoyuan
*/
public final class FileUtils {
private FileUtils() {
}

public static byte[] readAllBytes(InputStream inputStream) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(65536);
BufferedInputStream bis = new BufferedInputStream(inputStream);
byte[] buffer = new byte[4096];
int len;
try {
while ((len = bis.read(buffer)) != -1) {
bos.write(buffer, 0, len);
}
} catch (IOException e) {
throw new FtRuntimeException("Read font data failed", e);
}

return bos.toByteArray();
}
}

This file was deleted.

9 changes: 0 additions & 9 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.1.1/userguide/multi_project_builds.html
*/

rootProject.name = 'jme3-freetype-font'
include('lib')
project(':lib').name = 'jme3-freetype-font'
Expand Down

0 comments on commit 73f3689

Please sign in to comment.