opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.46k stars 476 forks source link

How to change the color of glyph item in glyph inspector example #421

Closed marioloncarek closed 4 years ago

marioloncarek commented 4 years ago

Hello and thanks for this great plugin. Im struggling to change the color or fill of the color of the loaded OTF font. So not in the glyph-display but in the list of the font glyphs.

Current Behavior

cant change the default black color of the glyphs in list

Steps to Reproduce (for bugs)

  1. fork the example of glyph inspector

Context

Having only the black color in the list makes the glyphs invisible since my background is dark.

Your Environment

fizfaz commented 4 years ago

The glyph is drawn here:

https://github.com/opentypejs/opentype.js/blob/342fac9e81a34ef08b69c5f08a0ec71727e0b832/glyph-inspector.html#L294

one way to change the color is to get the path of the glyph, and change the color here:


    var path = glyph.getPath(x0, fontBaseline, fontSize);
    path.fill = '#ff0000';    // <-- change the color here
    path.draw(ctx);

//    glyph.draw(ctx, x0, fontBaseline, fontSize);
}`

image