kateliev / TypeRig

Proxy API and Font Development Toolkit for FontLab
https://kateliev.github.io/TypeRig/
BSD 3-Clause "New" or "Revised" License
48 stars 3 forks source link

pGlyph > Layer Mark Issue #60

Closed alex-phil closed 2 years ago

alex-phil commented 2 years ago

Vassil, please take a look at this line:

https://github.com/kateliev/TypeRig/blob/74a486c80116105116711004f64018ff6d3b3116/Lib/typerig/proxy/fl/objects/glyph.py#L171

I think it must be replaced by

self.layer(layer).mark = mark_color

to make the code work. Try to set a layer-specific flag with the method, and you will get an error. Thank you for looking into this.

kateliev commented 2 years ago

@alex-phil Yes you are totally right! Fixed! Thank you Alex!

alex-phil commented 2 years ago

Vassil, I just wanted to make sure whether this was intended. With the current setup of the function, setMark() will set layer-specific flags only. Since you removed the if-else structure from the function code, setting glyph-specific flags now seems to require iterating over all layers of a glyph and applying setMark() to each of them. Which might raise issues with backwards compatibility of existing scripts that use setMark().

def setMark(self, mark_color, layer=None):
  if layer is None:
    self.fl.mark = self.mark = mark_color
  else:
    self.layer(layer).mark = mark_color
kateliev commented 2 years ago

Good question @alex-phil! Will investigate... i have some strange feeling that the global flGlyph.mark was actually not working ...

alex-phil commented 2 years ago

I just checked, @kateliev. We can use

from typerig.proxy.fl.objects.glyph import *
pGlyph().mark = 100

to set the glyph-specific flag for the current glyph to 100. So the global flGlyph.mark seems to be working.

kateliev commented 2 years ago

@alex-phil fixed! Thank you!