# core/graphic/textstringtexturecache (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/core/graphic/textstringtexturecache/

Measures text without a Graphic. (same as measureTextMetrics, same name as measure_text_without_graphic in the Rust version. null if there is no document)

Example: Measure text width without Graphic

```js
import { measureTextWithoutGraphic } from "./build/vanilla.js";

const textMetrics = measureTextWithoutGraphic("bold 16px sans-serif", "Hello");
if (textMetrics !== null) {
	console.log(textMetrics.width);
}
```

## Functions and constants

- `measureTextWithoutGraphic(fontString, text)` (method, since 0.4.0): Measures text without a Graphic. (same as measureTextMetrics, same name as measure_text_without_graphic in the Rust version. null if there is no document)
  - `fontString` string: CSS font string. (e.g. "bold 16px sans-serif")
  - `text` string: Text to measure.
  - returns TextMetrics | null: Text metrics. (shared by the cache so do not modify, null if there is no document)
