Jump to content

Stroke outside of text, not inside


Growler
 Share

Recommended Posts

How do I stroke the outside of a font? font.drawStroke seems to stroke the inside of the font.

Something like this: http://jsfiddle.net/vNWn6/ (as shown in this issue here: https://github.com/melonjs/melonJS/issues/299)

Your example, here https://melonjs.github.io/melonJS/examples/font_test/, doesn't seem to show clearly how to do this.

@obiot

My code:

game.ClickableEntity = me.Entity.extend({
	init: function(x, y, settings) {
        ...

        this.color = 'black';
        this.font = new me.Font('Verdana', 14, this.color);
        this.font.bold();
        this.font.strokeStyle.parseCSS('white');
        this.font.lineWidth = 1;
    draw: function(renderer) {
        this.font.draw(renderer, this.text, (this.width/2)-10, (this.height/2)-10);
        this.font.drawStroke(renderer, this.text, (this.width/2)-10, (this.height/2)-10);
    },

How mine currently looks in game:
 

Screen Shot 2019-12-15 at 7.32.08 PM.png

Edited by Growler
Link to comment
Share on other sites

  • 3 weeks later...

Hi, actually the current implementation is correct in the sense that it complies with the html5 font API, where font.drawStroke() strokes the outline of the letters while font.draw() fills the inside of the letters. As you can see on the below example, the outline stroke is actually the "edge" of the letter and not outside of it :

image.png.c0ab5fcee315930dd134ec09cde5023e.png

 

looks like you have an issue due to a "too low res" ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...