本文整理汇总了Python中mojo.roboFont.CurrentFont.naked方法的典型用法代码示例。如果您正苦于以下问题:Python CurrentFont.naked方法的具体用法?Python CurrentFont.naked怎么用?Python CurrentFont.naked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mojo.roboFont.CurrentFont
的用法示例。
在下文中一共展示了CurrentFont.naked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GenerateImageFont
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import naked [as 别名]
class GenerateImageFont(object):
def __init__(self):
self.font = CurrentFont()
if self.font is None:
return
doc = self.font.document()
if doc is None:
return
self.window = doc.getMainWindow()
vanilla.dialogs.getFolder(parentWindow=self.window, resultCallback=self.generate)
def generate(self, saveDir):
if not saveDir:
return
saveDir = saveDir[0]
f = self.font.naked()
glyphs = [g for g in f if not g.template]
progress = ProgressWindow("Generating .png's", tickCount=len(glyphs), parentWindow=self.window)
gridSize = int(getExtensionDefault(GRID_DEFAULTS_KEY, 50))
for g in glyphs:
if g.unicode is not None:
fileName = "%04X" %g.unicode
else:
fileName = glyphNameToFileName(g.name, f)
path = os.path.join(saveDir, "%s.png" %fileName)
image = g.getRepresentation("com.typemytype.pixelImageFactory", gridSize=gridSize)
data = image.TIFFRepresentation()
imageRep = NSBitmapImageRep.imageRepWithData_(data)
pngData = imageRep.representationUsingType_properties_(NSPNGFileType, None)
pngData.writeToFile_atomically_(path, False)
progress.update()
progress.close()
示例2: AdjustAnchors
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import naked [as 别名]
class AdjustAnchors(BaseWindowController):
def __init__(self):
self.font = CurrentFont()
self.glyph = CurrentGlyph()
self.upm = self.font.info.unitsPerEm
self.glyphPreviewCacheDict = {} # key: glyph name -- value: list containing assembled glyphs
self.anchorsOnMarksDict = {} # key: anchor name -- value: list of mark glyph names
self.anchorsOnBasesDict = {} # key: anchor name -- value: list of base glyph names
self.marksDict = {} # key: mark glyph name -- value: anchor name (NOTE: It's expected that each mark glyph only has one type of anchor)
self.fillAnchorsAndMarksDicts()
self.glyphNamesList = [] # list of glyph names that will be displayed in the UI list
self.selectedGlyphNamesList = [] # list of glyph names selected in the UI list
self.extraGlyphsList = [] # list of the glyph objects that should be inserted before and after the accented glyphs
self.Blue, self.Alpha = 1, 0.6
self.font.naked().addObserver(self, "fontWasModified", "Font.Changed")
addObserver(self, "_fontWillClose", "fontWillClose")
addObserver(self, "_currentFontChanged", "fontResignCurrent")
addObserver(self, "_currentGlyphChanged", "currentGlyphChanged")
addObserver(self, "_drawFill", "draw")
addObserver(self, "_drawFill", "drawInactive")
addObserver(self, "_previewFill", "drawPreview")
addObserver(self, "_drawGlyphs", "draw") # observer for the draw event
addObserver(self, "_drawGlyphs", "drawInactive") # draw the glyphs when the glyph window is not in focus
addObserver(self, "_drawGlyphs", "drawPreview")
integerNumFormatter = NSNumberFormatter.alloc().init()
integerNumFormatter.setAllowsFloats_(False)
integerNumFormatter.setGeneratesDecimalNumbers_(False)
intPosMinZeroNumFormatter = NSNumberFormatter.alloc().init()
intPosMinZeroNumFormatter.setAllowsFloats_(False)
intPosMinZeroNumFormatter.setGeneratesDecimalNumbers_(False)
intPosMinZeroNumFormatter.setMinimum_(NSNumber.numberWithInt_(0))
intPosMinOneNumFormatter = NSNumberFormatter.alloc().init()
intPosMinOneNumFormatter.setAllowsFloats_(False)
intPosMinOneNumFormatter.setGeneratesDecimalNumbers_(False)
intPosMinOneNumFormatter.setMinimum_(NSNumber.numberWithInt_(1))
self.textSize = getExtensionDefault("%s.%s" % (extensionKey, "textSize"))
if not self.textSize:
self.textSize = 150
self.lineHeight = getExtensionDefault("%s.%s" % (extensionKey, "lineHeight"))
if not self.lineHeight:
self.lineHeight = 200
self.extraSidebearings = getExtensionDefault("%s.%s" % (extensionKey, "extraSidebearings"))
if not self.extraSidebearings:
self.extraSidebearings = [0, 0]
self.extraGlyphs = getExtensionDefault("%s.%s" % (extensionKey, "extraGlyphs"))
if not self.extraGlyphs:
self.extraGlyphs = ''
posSize = getExtensionDefault("%s.%s" % (extensionKey, "posSize"))
if not posSize:
posSize = (100, 100, 1200, 400)
self.calibrateMode = getExtensionDefault("%s.%s" % (extensionKey, "calibrateMode"))
if not self.calibrateMode:
self.calibrateMode = False
calibrateModeStrings = getExtensionDefault("%s.%s" % (extensionKey, "calibrateModeStrings"))
if not calibrateModeStrings:
calibrateModeStrings = {
'group1.baseInput': 'dotlessi o s',
'group1.markInput': 'dieresis circumflex macron breve caron',
'group2.baseInput': 'I O S',
'group2.markInput': 'dieresis.cap circumflex.cap macron.cap breve.cap caron.cap',
'group3.baseInput': 'I.sc O.sc S.sc',
'group3.markInput': 'dieresis circumflex macron breve caron',
'group4.baseInput': '',
'group4.markInput': '',
}
# -- Window --
self.w = FloatingWindow(posSize, extensionName, minSize=(500, 400))
self.w.fontList = List((10, 10, 190, -41), self.glyphNamesList, selectionCallback=self.listSelectionCallback)
if roboFontVersion < '1.7':
self.w.fontList.getNSTableView().sizeToFit() # use the full width of the column
self.w.fontList.show(not self.calibrateMode)
self.w.lineView = MultiLineView((210, 10, -10, -41),
pointSize = self.textSize,
lineHeight = self.lineHeight,
displayOptions={"Beam" : False, "displayMode" : "Multi Line"}
)
# -- Calibration Mode --
baseLabel = "Bases"
markLabel = "Marks"
width, height = 190, 140
self.cm = Group((0, 0, 0, 0))
# ---
self.cm.group1 = Group((5, height*0, width, height-10))
self.cm.group1.baseLabel = TextBox((0, 0, width, 20), baseLabel)
self.cm.group1.baseInput = EditText((0, 21, width, 22), calibrateModeStrings['group1.baseInput'], callback=self.updateCalibrateMode, continuous=False)
#.........这里部分代码省略.........