Skip to content

Commit

Permalink
15.1.01.1
Browse files Browse the repository at this point in the history
Validate the data so that we fixed the corrupted data and decreased the file size
  • Loading branch information
squid233 committed Sep 16, 2023
1 parent 482dcdd commit ef64968
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Dfile.encoding=UTF-8
projGroupId=io.github.over-run
projArtifactId=unifont
projName=unifont
projVersion=15.1.01
projVersion=15.1.01.1
projDesc=Java Unifont binding
projVcs=Over-Run/unifont
projBranch=0.x
Expand Down
Binary file modified src/main/resources/assets/_overrun/fonts/unifont.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/_overrun/fonts/unifont_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/_overrun/fonts/unifont_plane1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions src/test/java/DataValidator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* MIT License
*
* Copyright (c) 2023 Overrun Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*/

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
* A data validator that validates the images.
*
* @author squid233
* @since 15.1.01.1
*/
public class DataValidator {
private static void validate(String path) throws IOException {
final BufferedImage image = ImageIO.read(new File(path));
final int width = image.getWidth();
final int height = image.getHeight();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
final int argb = image.getRGB(x, y);
if (argb != 0xffffffff && argb != 0xff000000) {
throw new IllegalStateException(path.substring(path.lastIndexOf('/') + 1) + ": " + "Invalid data 0x" + Integer.toHexString(argb) + " at x: " + x + ", y: " + y);
}
}
}
}

public static void main(String[] args) throws IOException {
validate("src/main/resources/assets/_overrun/fonts/unifont.png");
validate("src/main/resources/assets/_overrun/fonts/unifont_jp.png");
validate("src/main/resources/assets/_overrun/fonts/unifont_plane1.png");
}
}

0 comments on commit ef64968

Please sign in to comment.