Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…FontExtension into dse2.0
  • Loading branch information
typemytype committed Sep 25, 2023
2 parents 40b5363 + eb1c935 commit 13e1e70
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions DesignspaceEditor2.roboFontExt/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ <h2 id="toc">Contents</h2>
<li><a href="#toc_9">Problems Tab</a></li>
<li><a href="#toc_10">Notes Tab</a></li>
<li><a href="#toc_11">Notifications</a></li>
<li><a href="#toc_12">Receiving and responding to notifications</a></li>
<li><a href="#toc_13">Scripting with the current designspace</a></li>
</ul>

<h2 id="toc_1">Designspace Editor Usage <a href="#toc"></a></h2>
Expand Down Expand Up @@ -867,6 +869,7 @@ <h2 id="toc_11">Notifications<a href="#toc">↑</a></h3>




<!--
ADD
https://github.com/LettError/designSpaceRoboFontExtension/blob/dse2.0/DesignspaceEditor2.roboFontExt/lib/main.py#L114-L134
Expand Down Expand Up @@ -896,5 +899,75 @@ <h2 id="toc_11">Notifications<a href="#toc">↑</a></h3>

</table>

<h3 id="toc_12">Receiving and responding to notifications<a href="#toc"></a></h3>

This is a demo of Subscriber receiving designspace notifications.

<code><pre>
from mojo.subscriber import Subscriber, registerRoboFontSubscriber

class DesignspaceEditorSubscriber(Subscriber):

debug = True

def designspaceEditorDidOpenDesignspace(self, info):
print("opened a designspace:", info["designspace"])

def designspaceEditorDidCloseDesignspace(self, info):
print("closed a designspace:", info["designspace"])

def designspaceEditorAxesDidAddAxis(self, info):
print("created a new axis:", info["axis"], "for", info["designspace"])

def designspaceEditorRulesDidChange(self, info):
print("rules did chagne for:", info["designspace"])

registerRoboFontSubscriber(DesignspaceEditorSubscriber)
</pre>
</code>

<ul>
<li>
<a href="https://robofont.com/documentation/topics/subscriber/?highlight=subscriber">
Additional Subscriber documentation at RoboFont.com
</a>
</li>
</ul>


<h2 id="toc_13">Scripting with the current designspace<a href="#toc"></a></h2>

With a document open in DesignspaceEditor you can call <code>CurrentDesignspace()</code>, similar to <code>CurrentFont()</code> and <code>CurrentGlyph()</code>. This returns the designspace wrapped in a <code>UFOOperator</code> object that can calculate single glyphs, kerning and font info.

<h3>Calculating a glyph</h3>
The example below calculates a single glyph at the default location. It returns a mathGlyph.

<code>
<pre>d = CurrentDesignspace()
d.loadFonts()
loc = d.newDefaultLocation()
g = d.makeOneGlyph("A", location=loc)
</pre>
</code>


<h3>Calculating kerning and info</h3>
The example below calculates a single kerning pair and an info object. <code>makeOneKerning</code> accepts a list of pairs to calculate. If no pairs are given, all pairs will be calculated.

<code>
<pre>d = CurrentDesignspace()
d.loadFonts()
loc = d.newDefaultLocation()

pairs = [('public.kern1.i', 'public.kern2.b')]
kern = d.makeOneKerning(loc, pairs)
print(kern.items())

info = d.makeOneInfo(loc)
print(info)
</pre>
</code>


</body>
</html>

0 comments on commit 13e1e70

Please sign in to comment.