Skip to content

Commit

Permalink
added correct kernings to letters in MCD file (default fonts only, no…
Browse files Browse the repository at this point in the history
…t for custom fonts)
  • Loading branch information
ArthurHeitmann committed Jun 25, 2023
1 parent e18b2cd commit 99789d5
Show file tree
Hide file tree
Showing 5 changed files with 4,963 additions and 24 deletions.
48 changes: 48 additions & 0 deletions lib/fileTypeUtils/ktb/ktbIO.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

import '../utils/ByteDataWrapper.dart';

class KtbEntry {
final String left;
final String right;
final int kerning;

const KtbEntry(this.left, this.right, this.kerning);

KtbEntry.read(ByteDataWrapper bytes)
: left = bytes.readString(2, encoding: StringEncoding.utf16),
right = bytes.readString(2, encoding: StringEncoding.utf16),
kerning = bytes.readInt16();

void write(ByteDataWrapper bytes) {
bytes.writeString(left, StringEncoding.utf16);
bytes.writeString(right, StringEncoding.utf16);
bytes.writeInt32(kerning);
}
}

class KtbFile {
final List<KtbEntry> entries;

const KtbFile(this.entries);

KtbFile.read(ByteDataWrapper bytes) : entries = <KtbEntry>[] {
var count = bytes.readInt16();
for (var i = 0; i < count; i++) {
entries.add(KtbEntry.read(bytes));
}
}

static Future<KtbFile> fromFile(String path) async {
var bytes = await ByteDataWrapper.fromFile(path);
return KtbFile.read(bytes);
}

void write(ByteDataWrapper bytes) {
bytes.writeInt16(entries.length);
for (var entry in entries) {
entry.write(bytes);
}
}
}


Loading

0 comments on commit 99789d5

Please sign in to comment.