Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 6685050

Browse files
author
clittle
committed
Rebase + minor patch for header width at small scale
1 parent 1562cf3 commit 6685050

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

layers/exporters/svg_objects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def _findSpace(words, width, height, maxFontSize):
7474
fitTextHeight = min(breakTextHeight, height) * 0.8
7575

7676
longestWordLength = -9999
77+
fitTextWidth = 9999
7778
for w in range(0, len(words)):
7879
word = words[w]
7980
longestWordLength = max(longestWordLength, len(word))
@@ -220,7 +221,7 @@ def build(height, width, label, config, variant='text', t1text=None, t2text=None
220221
upper = G(tx=0, ty=2.1)
221222
internal.append(upper)
222223
if t1text is not None:
223-
fs, patch_text = _optimalFontSize(t1text, width, (height-80/2), maxFontSize=28)
224+
fs, patch_text = _optimalFontSize(t1text, width, (height-5)/2, maxFontSize=28)
224225
lines = len(patch_text)
225226
y = (height-5)/4 + 2.1
226227
if lines > 1:

layers/exporters/svg_templates.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
try:
77
from exporters.matrix_gen import MatrixGen
8-
from exporters.svg_objects import G, SVG_HeaderBlock, SVG_Technique, Text, convertToPx,_optimalFontSize
8+
from exporters.svg_objects import G, SVG_HeaderBlock, SVG_Technique, Text, convertToPx,_optimalFontSize, \
9+
_getstringwidth
910
from core.gradient import Gradient
1011
from core.filter import Filter
1112
except ModuleNotFoundError:
1213
from ..exporters.matrix_gen import MatrixGen
13-
from ..exporters.svg_objects import G, SVG_HeaderBlock, SVG_Technique, Text, convertToPx, _optimalFontSize
14+
from ..exporters.svg_objects import G, SVG_HeaderBlock, SVG_Technique, Text, convertToPx, _optimalFontSize, \
15+
_getstringwidth
1416
from ..core.gradient import Gradient
1517
from ..core.filter import Filter
1618

@@ -232,7 +234,6 @@ def export(self, showName, showID, lhandle, config, sort=0, scores=[], colors=[]
232234
tech_height = (convertToPx(config.height, config.unit) - header_offset -
233235
convertToPx(config.border, config.unit)) / max(lengths)
234236
incre = tech_width + 10
235-
set = 0
236237
for x in self.codex:
237238
disp = ''
238239
if showName and showID:
@@ -243,12 +244,11 @@ def export(self, showName, showID, lhandle, config, sort=0, scores=[], colors=[]
243244
disp = x.tactic.id
244245

245246
g = G(tx=index, ty=header_offset)
246-
gt = G(tx=(tech_width / 2) + 2)
247+
247248
index += incre
248249
fs, _ = _optimalFontSize(disp, tech_width, tech_height+10, maxFontSize=28)
249-
if set == 0:
250-
set = fs
251-
tx = Text(ctype='TacticName', font_size=set, text=disp, position='middle')
250+
tx = Text(ctype='TacticName', font_size=fs, text=disp, position='middle')
251+
gt = G(tx=(tech_width)/2)
252252
gt.append(tx)
253253
a = self.get_tactic(x, tech_height, tech_width, colors=colors, subtechs=subtechs, exclude=exclude,
254254
mode=(showName, showID), scores=scores, config=config)

0 commit comments

Comments
 (0)