def push_ratio(self, height=False, bbox=False): modifiers = QtGui.QApplication.keyboardModifiers( ) # Listen to Shift - reverses the ratio if bbox: if modifiers == QtCore.Qt.AltModifier: target = QtGui.QInputDialog.getDouble(self, 'Ratio Calculator', 'Set Target Ratio:', 100, 0, 500, 2) for row in range(self.tab_masters.rowCount): layerName = self.tab_masters.item(row, 0).text() if height: ratio_height = ratfrac( self.ratio_target[layerName].height(), self.ratio_source[layerName].height(), 100) if modifiers == QtCore.Qt.ShiftModifier: ratio_height = 2 * 100. - ratio_height # Reverse ratio elif modifiers == QtCore.Qt.AltModifier: ratio_height = 100 + target - ratio_height # Reverse ratio self.tab_masters.cellWidget(row, 10).setValue(ratio_height) else: ratio_width = ratfrac(self.ratio_target[layerName].width(), self.ratio_source[layerName].width(), 100) if modifiers == QtCore.Qt.ShiftModifier: ratio_width = 2 * 100. - ratio_width # Reverse ratio elif modifiers == QtCore.Qt.AltModifier: ratio_width = 100 + target - ratio_width # Reverse ratio self.tab_masters.cellWidget(row, 9).setValue(ratio_width) else: ratio = QtGui.QInputDialog.getDouble(self, 'Ratio', 'Enter Ratio:', 100, -500, 500, 2) for row in range(self.tab_masters.rowCount): self.tab_masters.cellWidget(row, [9, 10][height]).setValue(ratio) print 'Done:\t| Delta Machine | Pushed Ratio data per master.'
def update(self): from typerig.brain import linspread, geospread, ratfrac minAxisStem, maxAxisStem = min(self.masters.values()), max( self.masters.values()) minAxisPos, maxAxisPos = min(self.masters.keys()), max( self.masters.keys()) self.stems = [ int(round(item)) for item in list( geospread(self.masters[minAxisPos], self.masters[maxAxisPos], self.steps)) ] self.data = { int( ratfrac(stem - minAxisPos, maxAxisStem - minAxisPos, max(self.masters.keys()))): stem for stem in self.stems } self.instances = sorted(self.data.keys())
def update(self): from math import sqrt from typerig.brain import linspread, geospread, ratfrac self.wt_stems = [ int(round(item)) for item in geospread(self.wt0, self.wt1, self.wt_steps) ] self.wt_instances = [ int(ratfrac(item - self.wt0, self.wt1 - self.wt0, 1000)) for item in self.wt_stems ] self.wd_instances = [] if self.wd_steps >= 2: from itertools import product self.wd_instances = [ int(item) for item in list(linspread(0, 1000, self.wd_steps)) ] self.instances = list(product(self.wt_instances, self.wd_instances)) else: self.instances = self.wt_instances
# Typeface: Bolyar Sans # Date: 11.12.2018 #---------------------------------- # - Dependancies import fontlab as fl6 from typerig.proxy import pFont, pGlyph from typerig.brain import ratfrac # - Init ------------------------------------------------ font = pFont() font_metrics = font.fontMetrics() glyph = pGlyph() layers = ['100', '900'] # - Process -------------------------------------------- for glyph in font.selected_pGlyphs(): for layer in layers: scale = ratfrac(font_metrics.getCapsHeight(layer), glyph.getBounds(layer).height(), 1) glyph.layer(layer).transform = glyph.layer(layer).transform.scale( scale, scale) glyph.update() print 'DONE:\t Glyph: %s; Scale: %s' % (glyph.name, scale) # - Finish -------------------------------------------- font.update() print 'DONE.'