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

Glyphs3 #923

Draft
wants to merge 192 commits into
base: main
Choose a base branch
from
Draft

Glyphs3 #923

wants to merge 192 commits into from

Conversation

schriftgestalt
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@belluzj belluzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schriftgestalt I had a scroll through, overall you're renaming some methods (I suppose to match Glyphs.app API?), you're adding the post_read mechanism to normalize input data, and you've changed the approach in a few places (axes and custom parameters) I suppose to fix bugs and match parameter names with Glyphs.app, right?

I have a question about the class hierarchy in classes.py: does their API now match Glyphs.app 3? And post_read normalizes the data to be the same as Glyphs.app 3? Or do they match both Glyphs.app 2 and 3? What would you do when you release Glyphs.app 4? Will you normalize in post_read to the data model of version 4?

Comment on lines +1351 to +1511
def __CustomParametersProxy_get_custom_values__(self, key):
parameters = []
for parameter in self:
if not parameter.active:
continue
if parameter.name == key:
parameters.append(parameter)
return parameters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't. Seem to be some intermediate state that is left over.

@@ -2440,7 +2737,7 @@ def applyTransform(self, transformationMatrix):
def draw(self, pen: AbstractPen) -> None:
"""Draws contour with the given pen."""
pointPen = PointToSegmentPen(pen)
self.drawPoints(pointPen)
frawPoints(pointPen)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@@ -2654,7 +2951,7 @@ def __init__(self, glyph="", offset=(0, 0), scale=(1, 1), transform=None):
else:
self.transform = transform

def clone(self):
def copy(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why rename every clone to copy? To match Glyphs.app API?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. In Glyphs/objectiveC, it is copy()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with this. I only called it clone because I had been doing too much Rust at the time. 🦀

@property
def weightValue(self):
return self._get_axis_value(0)
return self.internalAxesValues[0] if len(self.font.axes) > 0 else None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why test the length of one variable and index into another?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only produce a value if there are axis to back it up. Otherwise you get an IndexError in the getter.

@@ -3619,26 +4122,49 @@ class LayerComponentsProxy(LayerShapesProxy):


class GSLayer(GSBase):
def _serialize_attributes_to_plist(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't call this serialize, maybe just get_plist_attributes? Because this method doesn't write stuff to the writer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

Comment on lines +5189 to +5878
@property
def formatVersion(self):
raise "not implemented"

@formatVersion.setter
def formatVersion(self, value):
raise "not implemented"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted, same as the next 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I used those for debugging.

and glyph.export
and ".background" not in layer.name
):
self.bracket_layers.append(layer)
elif (
self.minimal
and layer.layerId not in master_layer_ids
and not layer._is_brace_layer()
and not layer.isBraceLayer()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this renamed to match a Glyphs.app API?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@@ -720,7 +734,7 @@ def _fake_designspace(self, ufos):
from .masters import to_glyphs_master_attributes
from .names import to_glyphs_family_names, to_glyphs_master_names
from .paths import to_glyphs_paths
from .sources import to_glyphs_sources
from .sources import _to_glyphs_source
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename function to not be private if it's the one you want to use from the sources module

@@ -18,10 +18,13 @@
import logging

from glyphsLib.util import bin_to_int_list, int_list_to_bin
from Foundation import NSArray
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't depend on mac-only stuff?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to get it to work from within Glyphs. This needs a better separation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schriftgestalt I just tried now to compile a project with this branch and this immediately crashed, so outside of a mac it's currently not possible to test this branch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it.

if note is not None:
ufo.info.note = note

delf(userData[UFO_NOTE_KEY])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

del

try:
return value.propertyListValueFormat_(3) # TODO: this is the plain Glyphs API. pythonize this
except:
from objc._pythonify import OC_PythonLong, OC_PythonFloat
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import also crashes on Windows/Linux

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we're not running CI tests on PRs, either.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hid that in a try:except:, too.

@belluzj
Copy link
Collaborator

belluzj commented Jul 15, 2024

@schriftgestalt do you intend to replace this PR with the new branch Glyphs3-merge?

@schriftgestalt
Copy link
Collaborator Author

Yes.

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

Successfully merging this pull request may close these issues.

3 participants