-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable JSON structure when using fontc
- Loading branch information
1 parent
f0b9df0
commit 1eba766
Showing
3 changed files
with
54 additions
and
1 deletion.
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,43 @@ | ||
import os | ||
from tempfile import NamedTemporaryFile, TemporaryDirectory | ||
|
||
import yaml | ||
|
||
from gftools.builder.file import File | ||
from gftools.builder.operations import OperationBase | ||
|
||
|
||
class FontcAddSubset(OperationBase): | ||
description = "Add a subset from another font" | ||
rule = "gftools-add-ds-subsets $args -y $yaml -o $out $in" | ||
|
||
def validate(self): | ||
# Ensure there is a new name | ||
if not self.first_source.is_font_source: | ||
raise ValueError("%s is not a font source file" % self.first_source) | ||
if "subsets" not in self.original: | ||
raise ValueError("No subsets defined") | ||
|
||
def convert_dependencies(self, graph): | ||
self._target = TemporaryDirectory() # Stow object | ||
self._orig = NamedTemporaryFile(delete=False, mode="w") | ||
yaml.dump(self.original["subsets"], self._orig) | ||
self._orig.close() | ||
|
||
@property | ||
def targets(self): | ||
if "directory" in self.original: | ||
target = self.original["directory"] | ||
else: | ||
target = self._target.name | ||
dspath = os.path.join( | ||
target, self.first_source.basename.rsplit(".", 1)[0] + ".designspace" | ||
) | ||
return [File(dspath)] | ||
|
||
@property | ||
def variables(self): | ||
return { | ||
"yaml": self._orig.name, | ||
"args": self.original.get("args"), | ||
} |