init project
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.imyeyu.font.icon.ttf;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/// TrueType 大端字节缓冲区
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-07-13 16:26
|
||||
final class FontBuffer {
|
||||
|
||||
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
void u8(int value) {
|
||||
out.write(value & 0xFF);
|
||||
}
|
||||
|
||||
void i16(int value) {
|
||||
u16(value);
|
||||
}
|
||||
|
||||
void u16(int value) {
|
||||
out.write((value >>> 8) & 0xFF);
|
||||
out.write(value & 0xFF);
|
||||
}
|
||||
|
||||
void u32(long value) {
|
||||
out.write((int) ((value >>> 24) & 0xFF));
|
||||
out.write((int) ((value >>> 16) & 0xFF));
|
||||
out.write((int) ((value >>> 8) & 0xFF));
|
||||
out.write((int) (value & 0xFF));
|
||||
}
|
||||
|
||||
void u64(long value) {
|
||||
u32(value >>> 32);
|
||||
u32(value);
|
||||
}
|
||||
|
||||
void tag(String tag) {
|
||||
byte[] bytes = tag.getBytes(StandardCharsets.US_ASCII);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
u8(i < bytes.length ? bytes[i] : 32);
|
||||
}
|
||||
}
|
||||
|
||||
void bytes(byte[] bytes) {
|
||||
out.writeBytes(bytes);
|
||||
}
|
||||
|
||||
void pad4() {
|
||||
while (out.size() % 4 != 0) {
|
||||
u8(0);
|
||||
}
|
||||
}
|
||||
|
||||
int length() {
|
||||
return out.size();
|
||||
}
|
||||
|
||||
byte[] bytes() {
|
||||
return out.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user