-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added correct kernings to letters in MCD file (default fonts only, no…
…t for custom fonts)
- Loading branch information
1 parent
e18b2cd
commit 99789d5
Showing
5 changed files
with
4,963 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.