개정판 5192709e
issue #000: fix text size
Change-Id: I4f2a824a8d71cac89fac46acfeb84336f12885a3
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
347 | 347 |
x = self.loc[0] |
348 | 348 |
y = self.loc[1] |
349 | 349 |
rect = None |
350 |
lineCount = self.text().count('\n') if self.text().count('\n') is not 0 else 1 |
|
350 | 351 |
transform = QTransform() |
351 | 352 |
if (1.57 == self.angle) or (4.71 == self.angle): |
352 | 353 |
font = QFont(fontName, width if fontSize == -1 else fontSize) |
353 | 354 |
|
354 | 355 |
x_factor = width / QFontMetricsF(font).height() |
355 |
y_factor = height / QFontMetricsF(font).width(self.text())
|
|
356 |
y_factor = height / (QFontMetricsF(font).width(self.text()) / lineCount)
|
|
356 | 357 |
factor = min(x_factor, y_factor) |
357 | 358 |
font.setPointSizeF(font.pointSizeF()*factor) |
358 | 359 |
|
... | ... | |
369 | 370 |
elif 3.14 == self.angle: |
370 | 371 |
font = QFont(fontName, height if fontSize == -1 else fontSize) |
371 | 372 |
|
372 |
x_factor = width / QFontMetricsF(font).width(self.text())
|
|
373 |
x_factor = width / (QFontMetricsF(font).width(self.text()) / lineCount)
|
|
373 | 374 |
y_factor = height / QFontMetricsF(font).height() |
374 | 375 |
factor = min(x_factor, y_factor) |
375 | 376 |
font.setPointSizeF(font.pointSizeF()*factor) |
... | ... | |
386 | 387 |
else: |
387 | 388 |
font = QFont(fontName, height if fontSize == -1 else fontSize) |
388 | 389 |
|
389 |
x_factor = width / QFontMetricsF(font).width(self.text())
|
|
390 |
x_factor = width / (QFontMetricsF(font).width(self.text()) / lineCount)
|
|
390 | 391 |
y_factor = height / QFontMetricsF(font).height() |
391 | 392 |
factor = min(x_factor, y_factor) |
392 | 393 |
font.setPointSizeF(font.pointSizeF()*factor) |
내보내기 Unified diff