MCPcopy Create free account
hub / github.com/coldtype/st2 / align

Method align

ST2/typesetter.py:254–289  ·  view source on GitHub ↗
(self, p)

Source from the content-addressed store, hash-verified

252 return p
253
254 def align(self, p):
255 txty = dict(tx=not self.st2.use_horizontal_font_metrics, ty=not self.st2.use_vertical_font_metrics)
256
257 amb = p.ambit(**txty)
258
259 align_x = self.st2.align_lines_x
260 if self.st2.align_lines_x == "J":
261 align_x = "W"
262
263 p.xalign(rect=amb, x=align_x, tx=not self.st2.use_horizontal_font_metrics)
264
265 by_word = not self.st2.justify_space_letters
266
267 if self.st2.align_lines_x == "J":
268 for line in p:
269 if by_word:
270 line.wordPens()
271 la = line.ambit(tx=0, ty=0).setw(self.st2.justify_width)
272 line.trackToRect(la, pullToEdges=1)
273 if by_word:
274 line.interpose(type(line)(type(line)().data(glyphName="space")))
275 line.collapseonce(deblank=False)
276
277 ax, ay, aw, ah = p.ambit(**txty)
278
279 p.t(-ax, -ay)
280
281 if self.st2.align_x == "CX":
282 p.t(-aw/2, 0)
283 elif self.st2.align_x == "E":
284 p.t(-aw, 0)
285
286 if self.st2.align_y == "CY":
287 p.t(0, -ah/2)
288 elif self.st2.align_y == "N":
289 p.t(0, -ah)
290
291 def apply_script(self, p):
292 from runpy import run_path

Callers 2

base_vectorsMethod · 0.95
hobeauxBorderFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected