def draw(self, page, x, y): fillColor = self.style.get('fill') if fillColor is not None: setFillColor(fillColor) setStrokColor(None) stroke(0.8) strokeWidth(0.5) fill(None) rect(x, y, self.w, self.h) if len(self.dimensions) == 1: raise ValueError('Not supporting 1 axis now') if len(self.dimensions) > 2: raise ValueError('Not supporting >2 axis now') axisNames = sorted(self.dimensions.keys()) axisX = axisNames[0] sizeX = self.dimensions[axisX] axisY = axisNames[1] sizeY = self.dimensions[axisY] stepX = self.w / (sizeX + 1) stepY = self.h / (sizeY + 1) """Add more parametric layout behavior here.""" RANGE = 1000 for indexX in range(sizeX + 1): for indexY in range(sizeY + 1): ox = 30 oy = 25 px = ox + x + indexX * stepX py = oy + y + indexY * stepY self.location[axisX] = indexX * RANGE / sizeX self.location[axisY] = indexY * RANGE / sizeY glyphPathScale = self.fontSize / self.font.info.unitsPerEm drawGlyphPath(self.font.ttFont, self.glyphNames[0], px, py, self.location, s=glyphPathScale, fillColor=(0, 0, 0)) fs = FormattedString('%s %d\n%s %d' % (axisX, indexX * RANGE / sizeX, axisY, indexY * RANGE / sizeY), fontSize=6, fill=0) w, h = fs.size() page.text( fs, px - stepX / 4, py - 16) # Bit of hack, we need the width of the glyph here. fs = FormattedString('Other axes: %s' % self.location, fontSize=6, fill=0) w, h = fs.size() page.text(fs, x, y - 16)
def draw(self, page, x, y): if self.drawBefore is not None: # Call if defined self.drawBefore(self, p, view) fillColor = self.style.get('fill') if fillColor is not None: setFillColor(fillColor) setStrokColor(None) #stroke(0.8) #strokeWidth(0.5) #fill(None) #rect(x, y, self.w, self.h) stroke(None) stepX = self.w / (self.sizeX + 1) stepY = self.h / (self.sizeY + 1) """Add more parametric layout behavior here.""" for indexX in range(self.sizeX + 1): for indexY in range(self.sizeY + 1): ox = 30 oy = 25 px = ox + x + indexX * stepX py = oy + y + indexY * stepY if self.locations is not None: location = choice(self.locations) else: location = self.getRandomLocation() glyphPathScale = self.fontSize / self.font.info.unitsPerEm fillColor = self.style.get('textFill') or (0, 0, 0) drawGlyphPath(self.font.ttFont, self.glyphNames[0], px, py, location, s=glyphPathScale, fillColor=fillColor) if self.recipeAxes: recipe = self.location2Recipe(location) fs = FormattedString(recipe, fontSize=4, fill=0) w, h = fs.size() page.text( fs, px - stepX / 4, py - 24 ) # Bit of hack, we need the width of the glyph here. if len(self.recipeAxes) > 3: recipe = self.location2Recipe(location, 3, 6) fs = FormattedString(recipe, fontSize=4, fill=0) w, h = fs.size() page.text( fs, point(px - stepX / 4 + 30, py - 24) ) # Bit of hack, we need the width of the glyph here. if self.drawAfter is not None: # Call if defined self.drawAfter(self, p, view)
def getMarker(markerId, arg=None): u"""Answer a formatted string with markerId that can be used as non-display marker. This way the Composer can find the position of markers in text boxes, after FS-slicing has been done. Note there is always a very small "white-space" added to the string, so there is a potential difference in width that matters. For that reason markers should not be changed after slicing (which would theoretically alter the flow of the FormattedString in an box) and the markerId and amount/length of args should be kept as small as possible. Note that there is a potential problem of slicing through the argument string at the end of a textBox. That is another reason to keep the length of the arguments short. And not to use any spaces, etc. inside the markerId. Possible slicing through line-endings is not a problem, as the raw string ignores them.""" marker = MARKER_PATTERN % (markerId, arg or '') return FormattedString(marker, fill=None, stroke=None, fontSize=0.0000000000001)
def drawPageNameInfo(self, page, origin): u"""Draw additional document information, color markers, page number, date, version, etc. outside the page frame, if drawing crop marks.""" if self.showPageNameInfo: bleed = self.css('bleed') cms = self.css('viewCropMarkSize') - bleed fontSize = self.css('viewPageNameFontSize') dt = datetime.datetime.now() d = dt.strftime("%A, %d. %B %Y %I:%M%p") s = 'Page %s | %s | %s' % (page.parent.getPageNumber(page), d, page.parent.title or 'Untitled') if page.name: s += ' | ' + page.name fs = FormattedString(s, font=self.css('viewPageNameFont'), fill=0, fontSize=fontSize) text(fs, (self.pl + bleed, self.pb + page.h + cms - fontSize * 2)) # Draw on top of page.
def draw(self, page, x, y): u"""Draw the circle info-graphic, showing most info about the variation font as can be interpreted from the file.""" fill(0.9) stroke(None) mx = x + self.w / 2 my = y + self.h / 2 # Gray circle that defines the area of oval(x, y, self.w, self.h) # Draw axis spikes first, so we can cover them by the circle markers. axes = self.font.axes fontSize = self.style.get('fontSize', self.DEFAULT_FONT_SIZE) # Draw name of the font fill(0) text( FormattedString(self.font.info.familyName, font=self.style['labelFont'], fontSize=self.style['axisNameFontSize']), (x - fontSize / 2, y + self.h + fontSize / 2)) # Draw spokes fill(None) stroke(0) strokeWidth(1) newPath() for axisName, angle in self.angles.items(): markerX, markerY = self._angle2XY(angle, self.w / 2) moveTo((mx, my)) lineTo((mx + markerX, my + markerY)) drawPath() # Draw default glyph marker in middle. glyphName = self.glyphNames[0] defaultLocation = {} self._drawGlyphMarker(mx, my, glyphName, fontSize, defaultLocation, strokeW=3) # Draw DeltaLocation circles. for axisName, (minValue, defaultValue, maxValue) in axes.items(): angle = self.angles[axisName] # Outside maxValue location = {axisName: maxValue} markerX, markerY = self._angle2XY(angle, self.w / 2) self._drawGlyphMarker(mx + markerX, my + markerY, glyphName, fontSize / 2, location) # Interpolated DeltaLocation circles. location = { axisName: minValue + (maxValue - minValue) * INTERPOLATION } markerX, markerY = self._angle2XY(angle, self.w / 4) self._drawGlyphMarker(mx + markerX * INTERPOLATION * 2, my + markerY * INTERPOLATION * 2, glyphName, fontSize / 2, location) # Draw axis names and DeltaLocation values if self.showAxisNames: for axisName, (minValue, defaultValue, maxValue) in axes.items(): angle = self.angles[axisName] location = {axisName: maxValue} valueFontSize = self.style.get('valueFontSize', 12) axisNameFontSize = self.style.get('axisNameFontSize', 12) markerX, markerY = self._angle2XY(angle, self.w / 2) fs = FormattedString(makeAxisName(axisName), font=self.style.get( 'labelFont', 'Verdana'), fontSize=axisNameFontSize, fill=self.style.get('axisNameColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect(mx + markerX - tw / 2 - 4, my + markerY - axisNameFontSize / 2 - th * 1.5 - 4, tw + 8, th) text(fs, (mx + markerX - tw / 2, my + markerY - axisNameFontSize / 2 - th * 1.5)) # DeltaLocation master value if maxValue < 10: sMaxValue = '%0.2f' % maxValue else: sMaxValue = ` int(round(maxValue)) ` fs = FormattedString(sMaxValue, font=self.style.get( 'labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect(mx + markerX - tw / 2 - 4, my + markerY + valueFontSize / 2 + th * 1.5 - 4, tw + 8, th) text(fs, (mx + markerX - tw / 2, my + markerY + valueFontSize / 2 + th * 1.5)) # DeltaLocation value interpolationValue = minValue + (maxValue - minValue) * INTERPOLATION if interpolationValue < 10: sValue = '%0.2f' % interpolationValue else: sValue = ` int(round(interpolationValue)) ` fs = FormattedString(sValue, font=self.style.get( 'labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect( mx + markerX * INTERPOLATION - tw / 2 - 4, my + markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5 - 4, tw + 8, th) text(fs, (mx + markerX * INTERPOLATION - tw / 2, my + markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5)) # DeltaLocation value if minValue < 10: sValue = '%0.2f' % minValue else: sValue = ` int(round(minValue)) ` fs = FormattedString(sValue, font=self.style.get( 'labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) minM = 0.2 rect(mx + markerX * minM - tw / 2 - 4, my + markerY * minM + th * 0.5 - 4, tw + 8, th) text(fs, (mx + markerX * minM - tw / 2, my + markerY * minM + th * 0.5))
def draw(self, page, x, y): u"""Draw the circle info-graphic, showing most info about the variation font as can be interpreted from the file.""" fill(0.9) stroke(None) mx = x + self.w / 2 my = y + self.h / 2 # Gray circle that defines the area of oval(x, y, self.w, self.h) # Draw axis spikes first, so we can cover them by the circle markers. axes = self.font.axes markerSize = self.style.get('fontSize', self.DEFAULT_FONT_SIZE) # Calculate sorted relative angle pairs. xAngles = {} # X-ref, key is angle, value is list of axisName for axisName in axes: angle = globals()[axisName] if not angle in xAngles: # Ignore overlapping xAngles[angle] = axisName #print xAngles sortedAngles = sorted(xAngles) anglePairs = [] a1 = None for a2 in sortedAngles: if a1 is not None: if abs(a2 - a1) < CONNECT: # Max angle to connect anglePairs.append((a1, a2)) a1 = a2 # Draw name of the font fill(0) text( FormattedString(self.font.info.familyName, font=self.style['labelFont'], fontSize=self.style['titleFontSize']), (x - markerSize / 2, y + self.h + markerSize / 4)) # Draw spokes fill(None) stroke(0.7) strokeWidth(1) # Gray on full circle newPath() for axisName, angle in self.angles.items(): markerX, markerY = self._angle2XY(angle, self.w / 2) moveTo((mx - markerX, my - markerY)) lineTo((mx + markerX, my + markerY)) drawPath() # Black on range of axis. stroke(0) newPath() for axisName, angle in self.angles.items(): minValue, defaultValue, maxValue = axes[axisName] markerX, markerY = self._angle2XY(angle, self.w / 2) if minValue < defaultValue: moveTo((mx, my)) lineTo((mx - markerX, my - markerY)) if defaultValue < maxValue: moveTo((mx, my)) lineTo((mx + markerX, my + markerY)) drawPath() # Pair combinations if anglePairs: newPath() for a1, a2 in anglePairs: markerX1, markerY1 = self._angle2XY(a1, self.w / 2) markerX2, markerY2 = self._angle2XY(a2, self.w / 2) moveTo((mx + markerX1, my + markerY1)) lineTo((mx + markerX2, my + markerY2)) moveTo((mx + markerX1 * INTERPOLATION, my + markerY1 * INTERPOLATION)) lineTo((mx + markerX2 * INTERPOLATION, my + markerY2 * INTERPOLATION)) stroke(0, 0, 1) fill(None) drawPath() # Draw default glyph marker in middle. glyphName = self.glyphNames[0] defaultLocation = {} self._drawGlyphMarker(mx, my, glyphName, markerSize, defaultLocation) # http://stackoverflow.com/questions/1734745/how-to-create-circle-with-bézier-curves # Draw DeltaLocation circles. for axisName, (minValue, defaultValue, maxValue) in axes.items(): angle = self.angles[axisName] if defaultValue < maxValue: # Outside maxValue location = {axisName: maxValue} markerX, markerY = self._angle2XY(angle, self.w / 2) self._drawGlyphMarker(mx + markerX, my + markerY, glyphName, markerSize, location) # Interpolated DeltaLocation circles. location = { axisName: defaultValue + (maxValue - defaultValue) * INTERPOLATION } markerX, markerY = self._angle2XY(angle, self.w / 4) self._drawGlyphMarker(mx + markerX * INTERPOLATION * 2, my + markerY * INTERPOLATION * 2, glyphName, markerSize, location) if minValue < defaultValue: # Outside minValue. location = {axisName: minValue} markerX, markerY = self._angle2XY(angle, self.w / 2) self._drawGlyphMarker(mx - markerX, my - markerY, glyphName, markerSize, location) # Interpolated DeltaLocation circles. location = { axisName: minValue + (defaultValue - minValue) * INTERPOLATION } markerX, markerY = self._angle2XY(angle, self.w / 4) self._drawGlyphMarker(mx - markerX * 2 * INTERPOLATION, my - markerY * 2 * INTERPOLATION, glyphName, markerSize, location) # If there are any pairs, draw the interpolation between them #if anglePairs: # for a1, a2 in anglePairs: # axis1 = # Draw axis names and DeltaLocation values if self.showAxisNames: for axisName, (minValue, defaultValue, maxValue) in axes.items(): if minValue < defaultValue: angle = self.angles[axisName] valueFontSize = self.style.get('valueFontSize', 12) axisNameFontSize = self.style.get('axisNameFontSize', 12) markerX, markerY = self._angle2XY(angle, self.w / 2) fs = FormattedString( makeAxisName(axisName), font=self.style.get('labelFont', 'Verdana'), fontSize=axisNameFontSize, fill=self.style.get('axisNameColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect(mx - markerX - tw / 2 - 4, my - markerY - axisNameFontSize / 2 - th * 1.5 - 4, tw + 8, th) text(fs, (mx - markerX - tw / 2, my - markerY - axisNameFontSize / 2 - th * 1.5)) # DeltaLocation master value if 0 < minValue < 10: sMinValue = '%0.2f' % minValue else: sMinValue = ` int(round(minValue)) ` fs = FormattedString( sMinValue, font=self.style.get('labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect(mx - markerX - tw / 2 - 4, my - markerY + valueFontSize / 2 + th * 1.5 - 4, tw + 8, th) text(fs, (mx - markerX - tw / 2, my - markerY + valueFontSize / 2 + th * 1.5)) # DeltaLocation value interpolationValue = minValue + (defaultValue - minValue) * INTERPOLATION if 0 < interpolationValue < 10: sValue = '%0.2f' % interpolationValue else: sValue = ` int(round(interpolationValue)) ` fs = FormattedString( sValue, font=self.style.get('labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect( mx - markerX * INTERPOLATION - tw / 2 - 4, my - markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5 - 4, tw + 8, th) text(fs, (mx - markerX * INTERPOLATION - tw / 2, my - markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5)) # DeltaLocation value if 0 < defaultValue < 10: sValue = '%0.2f' % defaultValue else: sValue = ` int(round(defaultValue)) ` fs = FormattedString( sValue, font=self.style.get('labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) minM = 0.15 rect(mx - markerX * minM - tw / 2 - 4, my - markerY * minM - 8, tw + 8, th) text(fs, (mx - markerX * minM - tw / 2, my - markerY * minM - 4)) if defaultValue < maxValue: angle = self.angles[axisName] valueFontSize = self.style.get('valueFontSize', 12) axisNameFontSize = self.style.get('axisNameFontSize', 12) markerX, markerY = self._angle2XY(angle, self.w / 2) fs = FormattedString( makeAxisName(axisName), font=self.style.get('labelFont', 'Verdana'), fontSize=axisNameFontSize, fill=self.style.get('axisNameColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect(mx + markerX - tw / 2 - 4, my + markerY - axisNameFontSize / 2 - th * 1.5 - 4, tw + 8, th) text(fs, (mx + markerX - tw / 2, my + markerY - axisNameFontSize / 2 - th * 1.5)) # DeltaLocation master value if 0 < maxValue < 10: sMaxValue = '%0.2f' % maxValue else: sMaxValue = ` int(round(maxValue)) ` fs = FormattedString( sMaxValue, font=self.style.get('labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect(mx + markerX - tw / 2 - 4, my + markerY + valueFontSize / 2 + th * 1.5 - 4, tw + 8, th) text(fs, (mx + markerX - tw / 2, my + markerY + valueFontSize / 2 + th * 1.5)) # DeltaLocation value interpolationValue = defaultValue + ( maxValue - defaultValue) * INTERPOLATION if 0 < interpolationValue < 10: sValue = '%0.2f' % interpolationValue else: sValue = ` int(round(interpolationValue)) ` fs = FormattedString( sValue, font=self.style.get('labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) rect( mx + markerX * INTERPOLATION - tw / 2 - 4, my + markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5 - 4, tw + 8, th) text(fs, (mx + markerX * INTERPOLATION - tw / 2, my + markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5)) # DeltaLocation value if defaultValue < 10: sValue = '%0.2f' % defaultValue else: sValue = ` int(round(defaultValue)) ` fs = FormattedString( sValue, font=self.style.get('labelFont', 'Verdana'), fontSize=valueFontSize, fill=self.style.get('axisValueColor', 0)) tw, th = textSize(fs) fill(0.7, 0.7, 0.7, 0.6) stroke(None) minM = 0.15 rect(mx + markerX * minM - tw / 2 - 4, my + markerY * minM - 8, tw + 8, th) text(fs, (mx + markerX * minM - tw / 2, my + markerY * minM - 4))
def newFS(t, e=None, style=None, w=None, h=None, fontSize=None, styleName=None, tagName=None): u"""Answer a *FormattedString* instance from valid attributes in *style*. Set all values after testing their existence, so they can inherit from previous style formats. If target width *w* or height *h* is defined, then *fontSize* is scaled to make the string fit *w* or *h*.""" hyphenation(css('hyphenation', e, style)) # TODO: Should be text attribute, not global fs = FormattedString('') sFont = css('font', e, style) if sFont is not None: fs.font(sFont) # Forced fontSize, then this overwrites the style['fontSize'] if it is there. # TODO: add calculation of rFontSize (relative float based on root-fontSize) here too. sFontSize = fontSize or css( 'fontSize', e, style) or 16 # May be scaled to fit w or h if target is defined. sLeading = css('leading', e, style) rLeading = css('rLeading', e, style) if sLeading or (rLeading and sFontSize): lineHeight = (sLeading or 0) + (rLeading or 0) * (sFontSize or 0) if lineHeight: fs.lineHeight(lineHeight) if sFontSize is not None: fs.fontSize( sFontSize) # For some reason fontSize must be set after leading. sFallbackFont = css('fallbackFont', e, style) if sFallbackFont is not None: fs.fallbackFont(sFallbackFont) sFill = css('textFill', e, style) if sFill is not NO_COLOR: # Test on this flag, None is valid value setFillColor(sFill, fs) sCmykFill = css('cmykFill', e, style, NO_COLOR) if sCmykFill is not NO_COLOR: setFillColor(sCmykFill, fs, cmyk=True) sStroke = css('textStroke', e, style, NO_COLOR) sStrokeWidth = css('textStrokeWidth', e, style) if sStroke is not NO_COLOR and strokeWidth is not None: setStrokeColor(sStroke, sStrokeWidth, fs) sCmykStroke = css('cmykStroke', e, style, NO_COLOR) if sCmykStroke is not NO_COLOR: setStrokeColor(sCmykStroke, sStrokeWidth, fs, cmyk=True) sAlign = css( 'xTextAlign', e, style) # Warning: xAlign is used for element alignment, not text. if sAlign is not None: # yTextAlign must be solved by parent container element. fs.align(sAlign) sParagraphTopSpacing = css('paragraphTopSpacing', e, style) rParagraphTopSpacing = css('rParagraphTopSpacing', e, style) if sParagraphTopSpacing or (rParagraphTopSpacing and sFontSize): fs.paragraphTopSpacing((sParagraphTopSpacing or 0) + (rParagraphTopSpacing or 0) * (sFontSize or 0)) sParagraphBottomSpacing = css('paragraphBottomSpacing', e, style) rParagraphBottomSpacing = css('rParagraphBottomSpacing', e, style) if sParagraphBottomSpacing or (rParagraphBottomSpacing and sFontSize): fs.paragraphBottomSpacing((sParagraphBottomSpacing or 0) + (rParagraphBottomSpacing or 0) * (sFontSize or 0)) sTracking = css('tracking', e, style) rTracking = css('rTracking', e, style) if sTracking or (rTracking and sFontSize): fs.tracking((sTracking or 0) + (rTracking or 0) * (sFontSize or 0)) sBaselineShift = css('baselineShift', e, style) rBaselineShift = css('rBaselineShift', e, style) if sBaselineShift or (rBaselineShift and sFontSize): fs.baselineShift((sBaselineShift or 0) + (rBaselineShift or 0) * (sFontSize or 0)) sOpenTypeFeatures = css('openTypeFeatures', e, style) if sOpenTypeFeatures is not None: fs.openTypeFeatures([], **sOpenTypeFeatures) sTabs = css('tabs', e, style) if sTabs is not None: fs.tabs(*sTabs) sFirstLineIndent = css('firstLineIndent', e, style) rFirstLineIndent = css('rFirstLineIndent', e, style) # TODO: Use this value instead, if current tag is different from previous tag. How to get this info? # sFirstParagraphIndent = style.get('firstParagraphIndent') # rFirstParagraphIndent = style.get('rFirstParagraphIndent') # TODO: Use this value instead, if currently on top of a new string. sFirstColumnIndent = css('firstColumnIndent', e, style) rFirstColumnIndent = css('rFirstColumnIndent', e, style) if sFirstLineIndent or (rFirstLineIndent and sFontSize): fs.firstLineIndent((sFirstLineIndent or 0) + (rFirstLineIndent or 0) * (sFontSize or 0)) sIndent = css('indent', e, style) rIndent = css('rIndent', e, style) if sIndent is not None or (rIndent is not None and sFontSize is not None): fs.indent((sIndent or 0) + (rIndent or 0) * (sFontSize or 0)) sTailIndent = css('tailIndent', e, style) rTailIndent = css('rTaildIndent', e, style) if sTailIndent or (rTailIndent and sFontSize): fs.tailIndent((sTailIndent or 0) + (rTailIndent or 0) * (sFontSize or 0)) sLanguage = css('language', e, style) if sLanguage is not None: fs.language(sLanguage) sUpperCase = css('uppercase', e, style) sLowercase = css('lowercase', e, style) sCapitalized = css('capitalized', e, style) if sUpperCase: t = t.upper() elif sLowercase: t = t.lower() elif sCapitalized: t = t.capitalize() newt = fs + t # Format plain string t onto new formatted fs. if w is not None: # There is a target width defined, calculate again with the fontSize ratio correction. tw, _ = textSize(newt) fontSize = w / tw * sFontSize newt = newFS(t, e, style, fontSize=fontSize, styleName=styleName, tagName=tagName) elif h is not None: # There is a target height defined, calculate again with the fontSize ratio correction. _, th = textSize(newt) fontSize = h / th * sFontSize newt = newFS(t, e, style, fontSize=fontSize, styleName=styleName, tagName=tagName) return newt
cw=8 * U, ch=5 * baselineGrid - U, # Approx. square and fitting with baseline. listIndent=listIndent, # Indent for bullet lists listTabs=[(listIndent, LEFT)], # Match bullet+tab with left indent. # Display option during design and testing showGrid=SHOW_GRID, showGridColumns=SHOW_GRID_COLUMNS, showBaselineGrid=SHOW_BASELINE_GRID, showFlowConnections=SHOW_FLOW_CONNECTIONS, BOX_COLOR=BOX_COLOR, # Text measures leading=14, rLeading=0, rTracking=0, fontSize=9) FS = newFS(FormattedString(''), style=RS) # LANGUAGE-SWITCH Language settings RS['language'] = 'en' Monospaced = False Headline_Tracking = False Body_Tracking = False Single = False Ligatures = False # [liga] Slashed_Zero = True # [zero] Fraction = True # [frac] Italic = False Italic_Shapes = False # [ss08] Condensed = False # [ss07] Excludes Double if selected Smallcaps = False # [smcp] Caps_As_Smallcaps = False # [c2cs]