Skip to content

Tried to upgrade from 1.1.6 to 1.2.3, font sizes are broken. #561

Closed

Description

@dufia

Part of my code:

var openSansRegular = new Font('openSansRegular', 'data/fonts/Open_Sans/OpenSans-Regular.ttf');

function renderFooter (c, canvasHeight) {
  c.fillStyle = "#545454";
  c.font = "normal 11px openSansRegular";
  c.fillText('MMARocks.pl SINCE 2007  -  typermma.pl', 5, canvasHeight - 6);
  return false;
}

I then save it like this:

   var out = fs.createWriteStream(__dirname + '/../../data/bet-pictures/'+ filename);
    var stream = canvas.jpegStream({
        bufsize: 4096 // output buffer size in bytes, default: 4096
      , quality: 100 // JPEG quality (0-100) default: 75
      , progressive: false // true for progressive compression, default: false
    });

    stream.on('data', function(chunk){
      out.write(chunk);
      return false;
    });

Changing "11px" has literally no effect at all, size seems to default to 10px(or smth) at all times...

Also checked, its broken since 1.2.0.

Regards,
Konrad

Activity

  1. bmv437 commented on Jun 5, 2015

    @bmv437

    I've noticed this as well. It might be have something to do with the use of an external font.

    If you try c.font = "18px Arial"; font size will work. It looks like if it fails to parse any part of the font string (such as font-family), it discards the entire action of setting weight, size, and font-family.

    The fonts example located at:
    https://github.com/Automattic/node-canvas/blob/master/examples/font.js
    is broken.

    font.js example working in 1.1.6:
    Imgur font-1.1.6.png

    font.js example broken in 1.2.3:
    Imgur font-1.2.3.png

    I've tried on a mac and on an ubuntu linux machine with the same result

  2. caged commented on Jun 19, 2015

    @caged

    I'm getting a different behavior running font.js. I'm also getting odd behavior running text.js where the letters all overlap. It looks like cairo was updated in March, so I'm wondering if that has anything to do with the font issues.

    text

    font

    Edit: I'm on OSX 10.10.3 with all tests passing:

    > canvas@1.2.3 test /Users/justin/dev/them/node/node-canvas
    > make test
    
    canvas: 1.2.3
    cairo: 1.14.2
    
      ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
    
      36 passing (32ms)
    
  3. dunn commented on Jun 20, 2015

    @dunn

    I'm having the same problem with canvas 1.2.3, or a very similar one. With cairo 1.14.2, and node 0.12.4 (both installed with Homebrew) on 10.10.3, I get this for text.js:
    text

    and this for font.js:
    font

  4. LinusU commented on Jan 11, 2019

    @LinusU
    Collaborator

    The text backend has been reworked in 2.x, could you please try with that version and reopen if the issue persists, thanks ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions