Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base version fix? #3

Open
maxbbender opened this issue Sep 13, 2016 · 0 comments
Open

Base version fix? #3

maxbbender opened this issue Sep 13, 2016 · 0 comments

Comments

@maxbbender
Copy link

maxbbender commented Sep 13, 2016

This is taken from source/os/canvastext.ts

The total var seems to be the length of the string in terms of width. But... it never gets changed anywhere after initiating. Then at the bottom it just returns 0.

public static draw(ctx, font, size, x, y, str) {

        var total = 0;

        var len = str.length;

        var mag = size / 25.0;

        ctx.save();

        ctx.lineCap = "round";

        ctx.lineWidth = 2.0 * mag;

        ctx.strokeStyle = "black";

        for (var i = 0; i < len; i++) {
            var c = CanvasTextFunctions.letter(str.charAt(i));
            if (!c) {
                continue;
            }
            ctx.beginPath();
            var penUp = true;
            var needStroke = 0;
            for (var j = 0; j < c.points.length; j++) {
                var a = c.points[j];
                if (a[0] === -1 && a[1] === -1) {
                    penUp = true;
                    continue;
                }
                if (penUp) {
                    ctx.moveTo( x + a[0]*mag, y - a[1]*mag);
                    penUp = false;
                } else {
                    ctx.lineTo( x + a[0]*mag, y - a[1]*mag);
                }
            }
            ctx.stroke();
            x += c.width*mag;
        }
        ctx.restore();
        return total;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant