Skip to content

Using font family multiple times results in default font #977

Closed
@saschagehlich

Description

@saschagehlich

Issue or Feature

When registering multiple font files with the same font family, but different styles (like in examples/font.js), the default font is used instead of the given font files. When using different font family names for every font file, it works.

Right now, examples/font.js creates this image:

font2

As you can see, the Pfennig font is not used at all.

Changing the font definitions like this (and changing the font property on the rendering context accordingly):

Canvas.registerFont(fontFile('Pfennig.ttf'), {family: 'Pfennig'})
Canvas.registerFont(fontFile('PfennigBold.ttf'), {family: 'PfennigBold', weight: 'bold'})
Canvas.registerFont(fontFile('PfennigItalic.ttf'), {family: 'PfennigItalic', style: 'italic'})
Canvas.registerFont(fontFile('PfennigBoldItalic.ttf'), {family: 'PfennigBoldItalic', weight: 'bold', style: 'italic'})

This results in:

font

Your Environment

  • Version of node-canvas (e.g. 1.4.0): 2.0.0-alpha.3
  • Environment (e.g. node 4.2.0 on Mac OS X 10.8): node 7.9.0 on macOS 10.12.6

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