So I was trying to make a simple text item with a custom text color and background color. But according to the documentation, I only found a method to set a text color (code below), but not the background color. Is there no functionality for setting the background color of a textitem yet?
var text = new PointText(new Point(200, 50));
text.fillColor = 'black';
text.content = 'This text is black. But cannot set background color?';
alternatively, are there any hacks that could help me get around this?
temporarily I found a solution using text item and rectangle item:
var text = new PointText({
point: new Point(40, 40),
content: "text color is white and background is black",
justification: "center",
fontFamily: 'Noto Sans',
fillColor: 'white'
});
var rect = new Path.Rectangle(text.bounds);
rect.fillColor = 'black';
rect.strokeColor = 'black';
text.insertAbove(rect);
But I really hope to figure out a way to just put the background color in without having to make another rectangle below textitem.
Came here looking for the same thing, also resorting to an extra rectangle placed behind the PointText item
Just stumbled across this:
http://paperjs.org/about/roadmap/
Specifically interesting is this point under the Planned section:
Typography using SVG fonts, with support for advanced typographic features such as type inside graphic shapes and along paths, with control over styles of sub-ranges of text.
So looks like it might be something in the works.
hey! just checked this issue again. I hope Paperjs will be contributed by many people to add the planned features..
Using the text.bounds, and then scaling the rect worked perfectly.
Most helpful comment
temporarily I found a solution using text item and rectangle item:
But I really hope to figure out a way to just put the background color in without having to make another rectangle below textitem.