MCPcopy Create free account
hub / github.com/PageBot/PageBot / drawStacked

Method drawStacked

Lib/pagebot/elements/variablefonts/paragraphs.py:101–130  ·  view source on GitHub ↗

Draws the content of the element, responding to size, styles, font and content. Creates 2 columns for the self.fontSizes ranges that show the text with and without [opsz] if the axis exists. TODO: If the axis does not exist, do something else with the right column.

(self, view, origin, **kwargs)

Source from the content-addressed store, hash-verified

99 return text
100
101 def drawStacked(self, view, origin, **kwargs):
102 """Draws the content of the element, responding to size, styles, font
103 and content. Creates 2 columns for the self.fontSizes ranges that show
104 the text with and without [opsz] if the axis exists.
105
106 TODO: If the axis does not exist, do something else with the right
107 column.
108 """
109 # Start on top left, with respect to optional padding value.
110 x = self.pl
111 y = self.h-self.pt
112
113 fontSizes = (7, 8, 9, 10, 11)
114 for fontSize in fontSizes:
115 # Don't update to the new y, next colomn needs to be on the right,
116 # starting at the same y.
117 s1 = self.getText(self.headlineTag, cnt=6)
118 if not s1[-1] in ',.!?':
119 s1 += '.'
120 s2 = self.getText(self.textTag) + ' ' + self.getText(self.textTag)
121 x, _ = self.buildText(s1, s2, origin, x, y,
122 w=(self.pw-self.gw)/2, h=self.ph/len(fontSizes)-self.gh,
123 fontSize=fontSize, alignment=LEFT, labelSize=self.labelSize or self.DEFAULT_LABEL_SIZE,
124 Bwght=0.4, Bwdth=-0.1)
125
126 # Same text in same fontSize, without optical size axis used
127 _, y = self.buildText(s1, s2, origin, x+(self.pw+self.gw)/2, y,
128 w=(self.pw-self.gw)/2, h=self.ph/len(fontSizes)-self.gh,
129 fontSize=fontSize, alignment=LEFT, labelSize=self.labelSize or self.DEFAULT_LABEL_SIZE,
130 label='No optical size axis used.\n\n', Bwght=0.6, Bwdth=-0.1, useOpsz=False)
131
132if __name__ == '__main__':
133 import doctest

Callers 1

buildMethod · 0.95

Calls 2

getTextMethod · 0.95
buildTextMethod · 0.80

Tested by

no test coverage detected