From d21c05013743b6bf99688687108471baba978df6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 18 May 2020 18:33:36 +0200 Subject: [PATCH] Update Speedometer.js --- CockpitSpace/Speedometer.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/CockpitSpace/Speedometer.js b/CockpitSpace/Speedometer.js index 12f8cc14e..b2e26df1f 100644 --- a/CockpitSpace/Speedometer.js +++ b/CockpitSpace/Speedometer.js @@ -181,18 +181,6 @@ function newSpeedometer () { /* We put the thisObject.params.VALUE in the middle */ - fontSize = 22 - if (thisObject.params.VALUE > 999) { - fontSize = 18 - } - if (thisObject.params.VALUE > 9999) { - fontSize = 14 - } - if (thisObject.params.VALUE > 99999) { - fontSize = 10 - } - browserCanvasContext.font = 'bold ' + fontSize + 'px ' + UI_FONT.PRIMARY - label = thisObject.params.VALUE if (isNaN(label) === false) { @@ -202,6 +190,22 @@ function newSpeedometer () { if (label === 0) { label = label.toFixed(2) } } + fontSize = 22 + if (label.length > 8) { + fontSize = 18 + } + if (label.length > 10) { + fontSize = 14 + } + if (label.length > 12) { + fontSize = 10 + } + if (label.length > 14) { + fontSize = 8 + } + + browserCanvasContext.font = 'bold ' + fontSize + 'px ' + UI_FONT.PRIMARY + // label = label.substring(0, 6) xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO + 7