Reference · The realistic Earth's pure parts
nameWidthfunction
About how wide a name is, in pixels, without reading any layout: a Japanese character is as wide as the text is tall, any other about 0.58 of it.
Import it
import { nameWidth } from "@johnmorrisdotca/chikyu-earth/realistic";
Definition
function nameWidth(text: string, size: number): number
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The name. |
size | number | The text size in pixels. |
Returns
number
The width, in pixels.
Examples
import { nameWidth } from "@johnmorrisdotca/chikyu-earth/realistic";
console.log(nameWidth("Tokyo", 12), nameWidth("東京", 12));39 28What it prints (run when this page was built)