This repository has been archived by the owner on Oct 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 164005a
Showing
792 changed files
with
73,032 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# robofab manual | ||
# Anchor object | ||
# usage examples | ||
|
||
f = CurrentFont() | ||
|
||
for g in f: | ||
if len(g.anchors) > 0: | ||
print g, g.anchors |
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,9 @@ | ||
# robofab manual | ||
# Anchor object | ||
# attribute examples | ||
|
||
g = CurrentGlyph() | ||
|
||
if len(g.anchors) > 0: | ||
for a in g.anchors: | ||
print a.position |
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,10 @@ | ||
# the easiest way to get to a component | ||
# is to get one from a glyph | ||
|
||
from robofab.world import CurrentFont | ||
|
||
f = CurrentFont() | ||
g = f['adieresis'] | ||
|
||
for c in g.components: | ||
print c |
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,12 @@ | ||
# robofab manual | ||
# Component object | ||
# attribute examples | ||
|
||
print f['adieresis'].components[0].baseGlyph | ||
print f['adieresis'].components[1].baseGlyph | ||
|
||
# move the component in the base glyph | ||
f['adieresis'].components[1].offset = (100,100) | ||
|
||
# scale the component in the base glyph | ||
f['adieresis'].components[0].scale = (.5, .25) |
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,9 @@ | ||
# robofab manual | ||
# Contour object | ||
# usage examples | ||
|
||
# take a glyph (one with outlines obviously) | ||
c = CurrentGlyph() | ||
|
||
# get to contours by index: | ||
print c[0] |
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,17 @@ | ||
# robofab manual | ||
# Font object | ||
# Usage examples | ||
|
||
# start using the current font | ||
from robofab.world import CurrentFont | ||
f = CurrentFont() | ||
|
||
# get a clean, empty new font object, | ||
# appropriate for the current environment | ||
f = robofab.world.RFont() | ||
|
||
# get an open dialog and start a new font | ||
f = OpenFont() | ||
|
||
# open the font at path | ||
f = OpenFont(path) |
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,8 @@ | ||
# robofab manual | ||
# Font object | ||
# Iterate through the font object to get to the glyphs. | ||
|
||
f = CurrentFont() | ||
|
||
for glyph in f: | ||
print glyph.name |
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,8 @@ | ||
# cache the kerning object for speed | ||
|
||
from robofab.world import CurrentFont | ||
|
||
f = CurrentFont() | ||
|
||
cachedKerning = f.kerning | ||
# continue to use cachedKerning, not f.kerning. |
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,17 @@ | ||
# robofab manual | ||
# Font object | ||
# attribute examples | ||
# Most useful attributes of RFont | ||
# are actually stored in RFont.info | ||
|
||
f = CurrentFont() | ||
print f.info.unitsPerEm | ||
|
||
# kerning data is available in the kerning object: | ||
print f.kerning | ||
|
||
# len() gives you the "length" of the font, i.e. the number of glyphs | ||
print "glyphs in this font:", len(f) | ||
|
||
# treat a font object as a dictionary to get to the glyphs | ||
print f["A"] |
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,12 @@ | ||
# robofab manual | ||
# Font object | ||
# method examples | ||
|
||
from robofab.world import CurrentFont | ||
f = CurrentFont() | ||
|
||
# the keys() method returns a list of glyphnames: | ||
print f.keys() | ||
|
||
# find unicodes for each glyph by using the postscript name: | ||
f.autoUnicodes() |
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,12 @@ | ||
# robofab manual | ||
# Font object | ||
# method examples, available in FontLab | ||
|
||
from robofab.world import CurrentFont | ||
f = CurrentFont() | ||
|
||
# the keys() method returns a list of glyphnames: | ||
print f.selection | ||
|
||
# generate font binaries | ||
f.generate('otfcff') |
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,22 @@ | ||
# robofab manual | ||
# Glyph object | ||
# Usage examples | ||
|
||
# start using the current font | ||
from robofab.world import CurrentGlyph | ||
g = CurrentGlyph() | ||
|
||
# suppose you've done the right imports | ||
# different ways of creating glyphs | ||
# a new empty glyph object | ||
g = robofab.world.RGlyph() | ||
|
||
# a new empty fontlab glyph object | ||
g = robofab.objects.objectsFL.RGlyph() | ||
|
||
# a new empty robofab glyph object | ||
g = robofab.objects.objectsRF.RGlyph() | ||
|
||
# the easiest way to get a new glyph | ||
# is to ask a font to make you one: | ||
g = aFontObject[glyphName] |
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,28 @@ | ||
# robofab manual | ||
# Glyph object | ||
# attribute examples | ||
|
||
from robofab.world import CurrentFont, CurrentGlyph | ||
f = CurrentFont() | ||
|
||
# create a glyph object by asking the font | ||
g = f["Adieresis"] | ||
|
||
# alternatively, create a glyph object for the current glyph | ||
g = CurrentGlyph() | ||
|
||
# get the width | ||
print g.width | ||
|
||
# get the name | ||
print g.name | ||
|
||
# a list of unicode values for this glyph. Can be more than 1! | ||
print g.unicodes | ||
|
||
# set the width | ||
g.width = 1000 | ||
print g.width | ||
|
||
# get the number of contours in a glyph by getting its length | ||
print len(g) |
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,12 @@ | ||
# robofab manual | ||
# Glyph object | ||
# method examples | ||
|
||
# get a glyph object from a font | ||
f = CurrentFont() | ||
g = f["A"] | ||
print g | ||
|
||
# move the glyph 10 units to the right, and 200 units up: | ||
g = f["a"] | ||
g.move((10, 200)) |
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,21 @@ | ||
# robofab manual | ||
# Glyph object | ||
# method examples | ||
|
||
# In FontLab the baseglyph of a component can't be changed easily. | ||
# This assumes that there will only be | ||
# one component that needs to be remapped. | ||
|
||
def remapComponent(glyph, oldBaseGlyph, newBaseGlyph): | ||
foundComponent = None | ||
for component in glyph.components: | ||
if component.baseGlyph = oldBaseGlyph: | ||
foundComponent = component | ||
break | ||
if foundComponent is None: | ||
return | ||
offset = foundComponent.offset | ||
scale = foundComponent.scale | ||
glyph.removeComponent(component) | ||
glyph.appendComponent(newBaseGlyph, offset=offset, scale=scale) | ||
|
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,21 @@ | ||
# robofab manual | ||
# Info object | ||
# usage examples | ||
|
||
from robofab.world import CurrentFont | ||
|
||
f = CurrentFont() | ||
print f.info.postscriptFullName | ||
print f.info.openTypeNameDesigner | ||
|
||
f.info.openTypeNameDesigner = "Jan van Krimpen" | ||
print f.info.openTypeNameDesigner | ||
print f.info.openTypeOS2VendorID | ||
print f.info.unitsPerEm | ||
print f.info.xHeight | ||
print f.info.openTypeNameLicenseURL | ||
|
||
# but you can set the values as well | ||
f.info.postscriptUniqueID = 4309359 | ||
f.info.openTypeNameDesigner = "Eric Gill" | ||
|
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,11 @@ | ||
# robofab manual | ||
# Kerning object | ||
# usage examples | ||
|
||
f = CurrentFont() | ||
print f.kerning | ||
|
||
# getting a value from the kerning dictionary | ||
print f.kerning[('V', 'A')] | ||
print f.kerning[('T', 'X')] | ||
print f.kerning.keys() |
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,9 @@ | ||
# robofab manual | ||
# Lib object | ||
# attribute examples | ||
|
||
# RFont objects have a lib: | ||
print aFont.lib | ||
|
||
# content of the lib of a font exported from RoboFog | ||
print f.lib.keys() |
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,13 @@ | ||
# robofab manual | ||
# Point object | ||
# usage examples | ||
|
||
contour = CurrentGlyph()[0] | ||
print contour.points[0] | ||
|
||
from random import randint | ||
for p in contour.points: | ||
p.x += randint(-10,10) | ||
p.y += randint(-10,10) | ||
|
||
contour.update() |
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,10 @@ | ||
# robofab manual | ||
# Segment object | ||
# usage examples | ||
|
||
f = OpenFont() | ||
|
||
for g in f: | ||
for contour in g: | ||
for segment in contour: | ||
print segment |
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,16 @@ | ||
# robofab manual | ||
# Segment object | ||
# attribute examples | ||
|
||
f = OpenFont() | ||
|
||
for g in f: | ||
for contour in g: | ||
for segment in contour: | ||
print len(segment) | ||
print segment.type | ||
print segment.smooth | ||
print segment.points | ||
print segment.onCurve | ||
print segment.offCurve | ||
print segment.selected |
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,10 @@ | ||
# robofab manual | ||
# Segment object | ||
# method examples | ||
|
||
f = OpenFont() | ||
|
||
for g in f: | ||
for contour in g: | ||
for segment in contour: | ||
segment.move((50, 25)) |
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,7 @@ | ||
# robofab manual | ||
# bPoint object | ||
# Usage examples | ||
|
||
g = CurrentGlyph() | ||
for aPt in g[0].bPoints: | ||
print aPt |
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,8 @@ | ||
# robofab manual | ||
# bPoint object | ||
# Attribute examples | ||
|
||
g = CurrentGlyph() | ||
|
||
for aPt in g[0].bPoints: | ||
print aPt.bcpIn, aPt.bcpOut, aPt.anchor |
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,12 @@ | ||
# robofab manual | ||
# Buildingaccents howto | ||
# usage examples | ||
|
||
from robofab.world import CurrentFont | ||
|
||
f = CurrentFont() | ||
f.newGlyph("aacute") | ||
f["aacute"].appendComponent("a") | ||
f["aacute"].appendComponent("acute", (200, 0)) | ||
f["aacute"].width = f["a"].width | ||
f.update() |
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,32 @@ | ||
# robofab manual | ||
# Buildingaccents howto | ||
# AccentBuilder examples | ||
|
||
from robofab.world import CurrentFont | ||
from robofab.accentBuilder import AccentTools, buildRelatedAccentList | ||
|
||
font = CurrentFont() | ||
|
||
# a list of accented glyphs that you want to build | ||
myList = ['Aacute', 'aacute'] | ||
|
||
# search for glyphs related to glyphs in myList and add them to myList | ||
myList = buildRelatedAccentList(font, myList)+myList | ||
|
||
# start the class | ||
at = AccentTools(font, myList) | ||
|
||
# clear away any anchors that exist (this is optional) | ||
at.clearAnchors() | ||
|
||
# add necessary anchors if you want to | ||
at.buildAnchors(ucXOffset=20, ucYOffset=40, lcXOffset=15, lcYOffset=30) | ||
|
||
# print a report of any errors that occured | ||
at.printAnchorErrors() | ||
|
||
# build the accented glyphs if you want to | ||
at.buildAccents() | ||
|
||
# print a report of any errors that occured | ||
at.printAccentErrors() |
Oops, something went wrong.