diff --git a/lib/network/modules/components/shared/Label.js b/lib/network/modules/components/shared/Label.js index 9f01a721f..86e633c00 100644 --- a/lib/network/modules/components/shared/Label.js +++ b/lib/network/modules/components/shared/Label.js @@ -381,11 +381,16 @@ class Label { // // In all cases, only own properties apply! // - // newOptions.font.bold -> newOptions.font -> - // this.fontOptions.bold -> this.fontOptions -> - // this.fontOptions.proto.bold -> this.fontOptions.proto -> - // nodeOptions.font.bold -> nodeOptions.font -> - // defaultOptions.font.bold -> defaultOptions.font + // newOptions.font.bold -> + // this.fontOptions.bold -> + // this.fontOptions.proto.bold -> + // nodeOptions.font.bold -> + // defaultOptions.font.bold -> + // newOptions.font -> + // this.fontOptions -> + // this.fontOptions.proto -> + // nodeOptions.font -> + // defaultOptions.font // // Assumptions: // - newOptions multi-fonts have no chained prototype; if they do, they are the same as proto's in @@ -422,10 +427,10 @@ class Label { }; var getFontOption = (multiName, option) => { + // First, the multi font for (var n in pile) { var [fontOptions, handleProto] = pile[n]; - // First, the multi font if (fontOptions.hasOwnProperty(multiName)) { var multiFont = fontOptions[multiName]; if (multiFont.hasOwnProperty(option)) { @@ -433,11 +438,6 @@ class Label { } } - // Try the local font-options - if (fontOptions.hasOwnProperty(option)) { - return fontOptions[option]; - } - if (handleProto) { // Do the same thing as above, but not for own properties // The proto for the multi-font is expressly skipped @@ -447,7 +447,19 @@ class Label { return multiFont[option]; } } - + } + } + + + // Try the local font-options + for (var n in pile) { + var [fontOptions, handleProto] = pile[n]; + + if (fontOptions.hasOwnProperty(option)) { + return fontOptions[option]; + } + + if (handleProto) { if (!font.hasOwnProperty(option)) { return font[option]; } @@ -1139,7 +1151,7 @@ class Label { return fontOptions[option]; } - if (fontOptions[mod][option]) { + if (fontOptions[mod][option] !== undefined) { // Grumbl leaving out test on undefined equals false for "" return fontOptions[mod][option]; } else { // Take from parent font option @@ -1165,7 +1177,14 @@ class Label { } } } - ctx.font = (values.mod + " " + values.size + "px " + values.face).replace(/"/g, ""); + + var fontString = ""; + if (values.mod !== undefined && values.mod !== "") { // safeguard for undefined - this happened + fontString += values.mod = " "; + } + fontString += values.size + "px " + values.face; + + ctx.font = fontString.replace(/"/g, ""); values.font = ctx.font; values.height = values.size; return values;