Esempio n. 1
0
    i = i + 1

# k = 0
# for instance in font.instances:
#     if instance.isItalic == 1:
#         delInstances.append(k)
#         k = k - 1
#     k = k + 1

for masterIndex in delMasters:
    del font.masters[masterIndex]

# for instanceIndex in delInstances:
#     del font.instances[instanceIndex]

for parameter in font.customParameters:
    if parameter.name == "Axes":
        j = 0
        for axis in parameter.value:
            if axis["Tag"] != "wght":
                delAxes.append(j)
                j = j - 1
            j = j + 1

        for axisIndex in delAxes:
            parameter.value.pop(axisIndex)

print "Built Space Mono Roman source"

font.save(filename)
Esempio n. 2
0
sub dollar.rvrn by dollar.tf.rvrn; # for rvrn""")]

for instance in font.instances:
    deavtivateThisInstance = True
    for customParam in instance.customParameters:
        if customParam.name == "Save as TrueType" and customParam.value == 1:
            deavtivateThisInstance = False
    if deavtivateThisInstance == True:
        instance.active = 0

if "Italic" in file:
    glyphsToActivateExport = italicBracketGlyphs
    appendFeatureCode = italicFeaCode
else:
    glyphsToActivateExport = uprightBracketGlyphs
    appendFeatureCode = uprightFeaCode

for eachGlyph in glyphsToActivateExport:
    font.glyphs[eachGlyph].export = 1

for feaCode in appendFeatureCode:
    for f in font.features:
        if f.name == feaCode[0]:
            f.code += "\n" + feaCode[1]
            f.automatic = False
            # print f.code

newFileName = file.replace(".glyphs", "-build.glyphs")

font.save(newFileName)
Esempio n. 3
0
	Set metrics in all masters of a Glyphs source to easily adjust metrics with 
	a minimum of clicking and typing. Update values, then run once.

	USAGE:

	You must have glyphsLib installed, for instance via `pip install glyphsLib`.

	Then, run this via the terminal, adding the path to a Glyphs source:

	python3 sources/scripts/set-metrics.py sources/LibreCaslonText.glyphs
"""

from glyphsLib import GSFont
import sys

filepath = sys.argv[1]

font = GSFont(filepath)

for master in font.masters:
	master.customParameters["hheaAscender"] = 1940
	master.customParameters["hheaDescender"] = -520
	master.customParameters["hheaLineGap"] = 0
	master.customParameters["typoAscender"] = 1940
	master.customParameters["typoDescender"] = -520
	master.customParameters["typoLineGap"] = 0
	master.customParameters["winAscent"] = 1696
	master.customParameters["winDescent"] = 531

font.save(filepath)
# Remove Rename Glyphs custom parameter
for instance in font.instances:
	for customParam in instance.customParameters:
		if customParam.name == "Rename Glyphs":
			del customParam

# Find brace glyphs
listOfBraceGlyphs = []
for eachGlyph in font.glyphs:
	for eachLayer in eachGlyph.layers:
		if re.match('.*\d\}$', eachLayer.name):
			listOfBraceGlyphs += [eachGlyph.name]

print "\tBrace glyphs found: ", listOfBraceGlyphs
listOfBraceGlyphs += ["space", ".notdef"]

listOfGlyphsNotToExport = [g.name for g in font.glyphs if g.name not in listOfBraceGlyphs]

for eachGlyph in listOfGlyphsNotToExport:
	font.glyphs[eachGlyph].export = 0

# for eachGlyph in listOfBraceGlyphs:
# 	try:
# 		font.glyphs[eachGlyph].export = 1
# 	except:
# 		pass

newFileName = file.replace(".glyphs", "-onlyBraceGlyphs.glyphs")

font.save(newFileName)
Esempio n. 5
0
import sys
from glyphsLib import GSFont


def settransformedcomponents(f):

    glyphs = []

    # Collect glyphs
    for glyph in f.glyphs:
        for layer in glyph.layers:
            for i, component in enumerate(layer.components):
                if component.transform[0] != 1 or component.transform[3] != 1:
                    if [glyph, len(layer.components), i] not in glyphs:
                        glyphs.append([glyph, len(layer.components), i])

    # Adjust transform
    for glyph, component_count, i in glyphs:
        for layer in glyph.layers:
            if component_count == len(layer.components):
                if layer.components[i].transform[0] == 1:
                    layer.components[i].transform[0] = 0.999
                if layer.components[i].transform[3] == 1:
                    layer.components[i].transform[3] = 0.999


if __name__ == "__main__":
    font = GSFont(sys.argv[-1])
    settransformedcomponents(font)
    font.save(sys.argv[-1])