From 67e42182d7a3fafb11bdb75ec8a1eefef5a58dde Mon Sep 17 00:00:00 2001 From: jacopods Date: Thu, 1 Feb 2018 01:28:41 -0500 Subject: [PATCH] Vertical correction to legends MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a bit fragile but better than nothing… --- import_keyboard.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/import_keyboard.py b/import_keyboard.py index 40e1756..ac5da99 100644 --- a/import_keyboard.py +++ b/import_keyboard.py @@ -1009,6 +1009,15 @@ def read(filepath): m.link(mixShader, 'Shader', materialOutput, 'Surface') + # This requires an explanation: Blender text vertival alignment accounts for line spacing, which is apparently set to ~1/.6 + # when aligning at top one + legendVerticalCorrection = [ + 0.6, 0.6, 0.6, + 0.8, 0.8, 0.8, + 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0 + ] + alignText = [ ["LEFT", "TOP"], ["CENTER", "TOP"], @@ -1026,11 +1035,11 @@ def read(filepath): return { "DCS": [0.25, 0.15, 0.25, 0.325], "DSA": [0.2, 0.25, 0.2, 0.25], - "SA1": [0.2, 0.15, 0.2, 0.15], - "SA2": [0.2, 0.15, 0.2, 0.07], - "SA3": [0.2, 0.15, 0.2, 0.01], - "SA3D": [0.2, 0.15, 0.2, 0.01], - "SA4": [0.2, 0.15, 0.2, 0.01] + "SA1": [0.2, 0.18, 0.2, 0.07], + "SA2": [0.2, 0.18, 0.2, 0.00], + "SA3": [0.2, 0.18, 0.2, -0.07], + "SA3D": [0.2, 0.18, 0.2, -0.07], + "SA4": [0.2, 0.18, 0.2, -0.07] }.get(p, [0.25, 0.15, 0.25, 0.325]) # the SA caps are thicker and we need to lift the label more @@ -1050,8 +1059,9 @@ def read(filepath): 0] - (alignLegendsProfile(key["p"])[0] + alignLegendsProfile(key["p"])[2]) new_label.data.text_boxes[0].height = new_obj_tl.dimensions[ 1] - (alignLegendsProfile(key["p"])[1] + alignLegendsProfile(key["p"])[3]) + new_label.data.text_boxes[ - 0].y = -1 * (key["f"][pos] / 15) + 0].y = -1 * (key["f"][pos] / 15) * legendVerticalCorrection[pos] new_label.data.align_x = alignText[pos][0] new_label.data.align_y = alignText[pos][1] @@ -1097,7 +1107,7 @@ def read(filepath): new_label.data.text_boxes[0].height = new_obj_tl.dimensions[ 1] - (alignLegendsProfile(key["p"])[1] + alignLegendsProfile(key["p"])[3]) new_label.data.text_boxes[ - 0].y = -1 * (key["f"][pos] / 15) + 0].y = -1 * (key["f"][pos] / 15) * legendVerticalCorrection[pos] new_label.data.align_x = alignText[pos][0] new_label.data.align_y = alignText[pos][1]