-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make only a couple of glyphs, take input from a string. * use glyphNames and decomposeComponents
- Loading branch information
Showing
3 changed files
with
19 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
#drawbot | ||
d = CurrentDesignspace() | ||
previewLoc = d.randomLocation() | ||
d.setPreviewLocation(previewLoc) | ||
print(dir(d)) | ||
if d is not None: | ||
previewLoc = d.randomLocation() | ||
d.setPreviewLocation(previewLoc) | ||
|
||
loc = dict(weight=800, width=800) | ||
r = d.makeOneGlyph("R", loc) | ||
loc = dict(weight=800, width=800) | ||
r = d.makeOneGlyph("R", loc) | ||
|
||
translate(100, 100) | ||
scale(0.8) | ||
drawGlyph(r) | ||
translate(100, 100) | ||
scale(0.8) | ||
drawGlyph(r) |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from fontTools.designspaceLib import InstanceDescriptor | ||
from mojo.UI import CurrentSpaceCenter, OpenSpaceCenter | ||
from mojo.UI import CurrentSpaceCenter, OpenSpaceCenter, splitText | ||
|
||
# Scripting with live designspaces | ||
# demo [email protected] 12.12.2023 | ||
|
||
proofText = "Designspace & UFOProcessor" | ||
|
||
# have a desigspace open in DSE2 | ||
ds = CurrentDesignspace() | ||
|
||
|
@@ -23,6 +25,8 @@ | |
# get the default font | ||
# note we ask for the default of a specific discrete location here | ||
defaultFont = ds.findDefaultFont(discreteLocation=discretePart) | ||
glyphNames = splitText(proofText, defaultFont.asFontParts().getCharacterMapping()) | ||
print("glyphNames", glyphNames) | ||
|
||
# make an "instance descriptor" object to specify what we want to see | ||
preview = InstanceDescriptor() | ||
|
@@ -32,7 +36,7 @@ | |
# now we're asking the designspace to make a font object with these specs | ||
# This makes the whole font. If you're just looking at a couple of characters | ||
# there are faster ways to do that. | ||
previewFont = ds.makeInstance(preview).asFontParts() | ||
previewFont = ds.makeInstance(preview, glyphNames=glyphNames, decomposeComponents=True).asFontParts() | ||
|
||
# finally, we give the resulting font to the space center. | ||
# have a spacecenter open | ||
|
@@ -41,7 +45,9 @@ | |
sp = OpenSpaceCenter(previewFont) | ||
|
||
sp.setFont(previewFont) | ||
sp.setRaw(f'HHOHOO \n {defaultFont.info.styleName}') | ||
spString = "/" + "/".join(glyphNames) | ||
print('spString', spString) | ||
sp.setRaw(spString) | ||
|
||
# optionally, open the font window | ||
#previewFont.openInterface() |