
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@borgar/textbox
Advanced tools
Textbox is a simple library to layout multiline text for display on SVG or Canvas. It can fairly decently line-break and render rich text given some boundaries. It understands simple text, and a small subset of HTML and LaTeX syntaxes. The original purpose of this software is to aid labeling charts.
Take a look at Textbox example and demos if you are curious what this library can do.
... if it doesn't fit designated area.- but not before).If you don't want to download and build Textbox yourself, the library is also provided as an NPM package:
$ npm install @borgar/textbox
For any use, you will need to start by defining a new Textbox instance. You may pass a configuration object as a parameter:
const box = new Textbox({
font: '12px/14px sans-serif',
width: Infinity,
height: Infinity,
align: 'left',
valign: 'top',
x: 0,
overflow: 'ellipsis',
parser: 'text',
createElement: Textbox.createElement
});
Shown here are the defaults, but any or all of the above parameters can be provided. The Textbox instance will provide methods by the same name, along with line-breaking and rendering methods:
const box = new Textbox()
.font('16px/19px sans-serif')
.align('center')
.parser('html')
.createElement(React.createElement);
Full API documentation can be found in docs/API.md.
In SVG links do not automatically get color or pointer cursor. You will need to add your own styles to these.
svg text a {
fill: blue;
text-decoration: underline;
cursor: pointer;
}
Multi-word links in SVG text are not necessarily a single entity/element like they are in HTML. If the text in a link is line-broken, then hovering one segment will not cause segment in the next line over to trigger hover styles.
Text justification does not work consistently in all browsers as they have buggy support for the word-spacing property. Google Chrome seems to work fine, Safari works for plain text but incorrectly for formatted text. Firefox is fairly random. Test your output in different browsers before you publish.
Subscript and superscript are bugged in Firefox because they have never implemented the baseline-shift property. The bug report is 20 years old currently, so aaaaaany day now.
FAQs
A utility to render formatted multi-line rich text.
The npm package @borgar/textbox receives a total of 1,277 weekly downloads. As such, @borgar/textbox popularity was classified as popular.
We found that @borgar/textbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.