Reference · The realistic Earth's pure parts
countryNameBoxfunction
About how wide and tall a country's name is, in pixels, without reading any layout: a Japanese character as wide as the text is tall, a capital about 0.7 of it, with the letters' spacing.
Import it
import { countryNameBox } from "@johnmorrisdotca/chikyu-earth/realistic";
Definition
function countryNameBox(text: string, size: number): { width: number; height: number; }
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The name. |
size | number | The text size in pixels. |
Returns
{ width: number; height: number; }
The width and height.
Examples
import { countryNameBox } from "@johnmorrisdotca/chikyu-earth/realistic";
console.log(countryNameBox("JAPAN", 12), countryNameBox("日本", 12));{ width: 50, height: 16 } { width: 30, height: 16 }What it prints (run when this page was built)