From 5ac25a159a2157e57ae10f4e4e88b7ee80aa7f32 Mon Sep 17 00:00:00 2001 From: Zhang Muyu Date: Sun, 17 Sep 2023 11:57:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=92=E7=89=88=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/express_way.py | 9 +++++---- test/main.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/components/express_way.py b/components/express_way.py index 88ac27d..cee2b2f 100644 --- a/components/express_way.py +++ b/components/express_way.py @@ -12,9 +12,10 @@ class ExpressWayBaseComponent: self.sub_name = sub_name self.head_bg_color = head_bg_color self.head_text_color = head_text_color - self.main_text_height = 40 * SCALE + self.main_text_height = 50 * SCALE self.main_text_width = FontSize.get_font_width(self.main_name, 'resources/B.ttf', self.main_text_height) - self.sub_text_width = FontSize.get_font_width(self.sub_name, 'resources/B.ttf', 24 * SCALE) + self.sub_text_height = int(self.main_text_height * 0.6) + self.sub_text_width = FontSize.get_font_width(self.sub_name, 'resources/B.ttf', self.sub_text_height) self.inset = 5 * SCALE self.stroke_width = 2 * SCALE self.r = 8 * SCALE @@ -59,8 +60,8 @@ class ExpressWayBaseComponent: big_text.draw(container, name_start_x, y + self.head_height) if len(self.sub_name): - small_text = TextBComponent(self.sub_name, '#ffffff', 24 * SCALE) - small_text.draw(container, name_start_x + self.main_text_width, y + self.head_height + self.main_text_height * 0.33) + small_text = TextBComponent(self.sub_name, '#ffffff', self.sub_text_height) + small_text.draw(container, name_start_x + self.main_text_width, y + self.head_height + self.main_text_height * 0.32) class NationalExpressWayComponent(ExpressWayBaseComponent): diff --git a/test/main.py b/test/main.py index 48d6a10..1ae5103 100644 --- a/test/main.py +++ b/test/main.py @@ -108,12 +108,12 @@ for line in lines: elif item_type == 4: main_name = item_info.get('main_name') - sub_name = item_info.get('sub_name') + sub_name = item_info.get('sub_name') if item_info.get('sub_name') is not None else '' ele = NationalExpressWayComponent(main_name, sub_name) elif item_type == 5: main_name = item_info.get('main_name') - sub_name = item_info.get('sub_name') + sub_name = item_info.get('sub_name') if item_info.get('sub_name') is not None else '' prov = item_info.get('prov') ele = ProvincialExpressWayComponent(prov, main_name, sub_name)