-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the builder into smaller files
- Loading branch information
Showing
27 changed files
with
1,395 additions
and
1,066 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2015 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import (print_function, division, absolute_import, | ||
unicode_literals) | ||
|
||
|
||
def to_ufo_blue_values(_context, ufo, master): | ||
"""Set postscript blue values from Glyphs alignment zones.""" | ||
|
||
alignment_zones = master.alignmentZones | ||
blue_values = [] | ||
other_blues = [] | ||
for zone in sorted(alignment_zones): | ||
pos = zone.position | ||
size = zone.size | ||
val_list = blue_values if pos == 0 or size >= 0 else other_blues | ||
val_list.extend(sorted((pos, pos + size))) | ||
|
||
ufo.info.postscriptBlueValues = blue_values | ||
ufo.info.postscriptOtherBlues = other_blues | ||
|
||
|
||
def to_glyphs_blue_values(context, ufo, master): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2015 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import (print_function, division, absolute_import, | ||
unicode_literals) | ||
|
||
UFO_FORMAT = '%Y/%m/%d %H:%M:%S' | ||
|
||
|
||
def to_ufo_time(datetime_obj): | ||
"""Format a datetime object as specified for UFOs.""" | ||
return datetime_obj.strftime(UFO_FORMAT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2015 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import (print_function, division, absolute_import, | ||
unicode_literals) | ||
|
||
|
||
def draw_components(pen, components): | ||
"""Draw .glyphs components onto a pen, adding them to the parent glyph.""" | ||
|
||
for component in components: | ||
pen.addComponent(component.name, | ||
component.transform) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright 2015 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import (print_function, division, absolute_import, | ||
unicode_literals) | ||
|
||
from collections import OrderedDict | ||
|
||
|
||
class GlyphsToUFOContext(object): | ||
"""Builder context for Glyphs to UFO + designspace.""" | ||
|
||
def __init__(self, font, defcon): | ||
"""Create a context for the Glyphs to UFO + designspace builder. | ||
Keyword arguments: | ||
font -- The GSFont object to transform into UFOs | ||
defcon -- The defcon module to use to build UFO objects (you can pass | ||
a custom module that has the same classes as the official | ||
defcon to get instances of your own classes) | ||
""" | ||
self.font = font | ||
self.defcon = defcon | ||
|
||
self.ufos = OrderedDict() | ||
""" | ||
The set of UFOs (= defcon.Font objects) that will be built, | ||
indexed by master ID, the same order as masters in the source GSFont. | ||
""" | ||
|
||
self.designspace = None | ||
"""The MutatorMath Designspace object that will be built.""" | ||
|
||
|
||
class UFOToGlyphsContext(object): | ||
"""Builder context for UFO + designspace to Glyphs.""" | ||
|
||
def __init__(self, ufos, designspace, classes): | ||
"""Create a context for the UFO + designspace to Glyphs builder. | ||
Keyword arguments: | ||
ufos -- The list of UFOs to combine into a GSFont | ||
designspace -- A MutatorMath Designspace to use for the GSFont | ||
classes -- The glyphsLib.classes module to use to build glyphsLib | ||
classes (you can pass a custom module with the same classes | ||
as the official glyphsLib.classes to get instances of your | ||
own classes) | ||
""" | ||
self.ufos = ufos | ||
self.designspace = designspace | ||
self.classes = classes | ||
|
||
self.font = None | ||
"""The GSFont that will be built.""" |
Oops, something went wrong.