bleepsix icon indicating copy to clipboard operation
bleepsix copied to clipboard

[brd] Not rendering because of invalid 'font' lookup

Open abetusk opened this issue 8 years ago • 0 comments

Implemented a hot fix to take care of some bad font issues:

diff --git a/js/core/bleepsixRender.js b/js/core/bleepsixRender.js
index 4660bfc..d5f3ff3 100644
--- a/js/core/bleepsixRender.js
+++ b/js/core/bleepsixRender.js
@@ -1202,6 +1202,7 @@ bleepsixRender.prototype._font_text_width = function(text, font, xsize)
   {
     var ch_ord = text.charCodeAt(i);
     var f = font[ch_ord];
+    if (typeof f === "undefined") { continue; }
     var dx = xsize * (parseFloat(f.xsto) - parseFloat(f.xsta)) * scale ;
     tally += dx;
   }
@@ -1277,6 +1278,7 @@ bleepsixRender.prototype.drawTextFont =


     var f = font[ch_ord];
+    if (typeof f === "undefined") { continue; }

     var xsta = scale * parseFloat(f.xsta) * sizex;
     var xsto = scale * parseFloat(f.xsto) * sizex;

From inspection, ch_ord was 0 so the lookup failed. I'm wondering how this happened in the first place.

Bug was noticed by a user that placed three resistors, deleted them, placed three more and renamed them to 'R1', 'R2' and 'R3' respectively.

This should be investigated a bit more to figure out where these errors were coming from.

abetusk avatar Oct 19 '15 13:10 abetusk