mirror of
https://github.com/TextPlace/CoreTextPlace.git
synced 2025-04-30 12:41:10 +00:00
fix: dirty fix for char width
This commit is contained in:
parent
4dd8121ebb
commit
7923680e80
3 changed files with 9 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@textplace/core",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"exports": "./mod.ts",
|
||||
"imports": {
|
||||
"@deno/dnt": "jsr:@deno/dnt@^0.41.3",
|
||||
|
|
|
@ -10,5 +10,6 @@ export function getCharacterWidth(ch: string): number {
|
|||
);
|
||||
}
|
||||
|
||||
return unicodeWidth(ch);
|
||||
// TODO: Properly fix this.
|
||||
return Math.min(unicodeWidth(ch), 2);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,12 @@ Deno.test("getCharacterWidth CJK", () => {
|
|||
assertThrows(() => getCharacterWidth("ヨスガノ"));
|
||||
});
|
||||
|
||||
Deno.test("getCharacterWidth Emoji", () => {
|
||||
assertEquals(getCharacterWidth("👋"), 2);
|
||||
assertEquals(getCharacterWidth("🌲️"), 2);
|
||||
assertEquals(getCharacterWidth("👨👩👧👦"), 2);
|
||||
});
|
||||
|
||||
Deno.test("getCharacterWidth previously faulty cases", () => {
|
||||
assertEquals(getCharacterWidth("𤲶"), 2);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue