PIXI.Text letterSpacing
See original GitHub issueUsing the “letterSpacing”, PIXI.Text draws incorrectly
After viewing the source code and searching Google, I got to make it work correctly
I had to append the canvas in the document, otherwise it does not work. Any ideas on this?
canvas.style.letterSpacing = style.letterSpacing + 'px';
document.body.appendChild(canvas);
Text.prototype.drawLetterSpacing = function drawLetterSpacing(text, x, y) {
var isStroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var style = this._style;
// letterSpacing of 0 means normal
var letterSpacing = style.letterSpacing;
// if (letterSpacing === 0) {
if (isStroke) {
this.context.strokeText(text, x, y);
} else {
this.context.fillText(text, x, y);
}
// return;
// }
// var characters = String.prototype.split.call(text, '');
// var currentPosition = x;
// var index = 0;
// var current = '';
//
// while (index < text.length) {
// current = characters[index++];
// if (isStroke) {
// this.context.strokeText(current, currentPosition, y);
// } else {
// this.context.fillText(current, currentPosition, y);
// }
// currentPosition += this.context.measureText(current).width + letterSpacing;
// }
};
I would also like to do something like this
canvas.style.mozOsxFontSmoothing = 'grayscale';
canvas.style.webkitFontSmoothing = 'antialiased';
Issue Analytics
- State:
- Created 6 years ago
- Comments:22 (8 by maintainers)
Top Results From Across the Web
PIXI.Text letterSpacing · Issue #4635 · pixijs/pixijs - GitHub
Using the "letterSpacing", PIXI.Text draws incorrectly After viewing the source code and searching Google, I got to make it work correctly I ...
Read more >PIXI.TextStyle - PixiJS API Documentation
Documentation for PixiJS library. ... A TextStyle Object contains information to decorate a Text objects. ... letterSpacing, number, 0.
Read more >PIXI.TextStyle Editor - PixiJS
PixiJS TextStyle ; Font · Font Size. Font Style · Font Variant · Font Weight ; Stroke. Color. Thickness. Line Join · Miter...
Read more >Letterspacing with BitmapText - Pixi.js
Yea, but in my opionion letter spacing, in opposite to kerning, shouldn't be bound to glyph map, but rather to individual text field....
Read more >@pixi/text-html - npm
Better support for emojis and other HTML layout features, better compatibility with CSS line-height and letter-spacing. Disadvantages: Unlike PIXI.Text , ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s really worked https://jsfiddle.net/hg4pbsne/34/
@gizmooo It would be very helpful if you could make a PR for this problem, as It should help lots of users stop experiencing cutting off letters without workaround padding and improve general text look. It would be pleasant if you at least will share your solution.