How to find out values from C2 font property?

0 favourites
  • 2 posts
From the Asset Store
Creepy Sprite Font suitable font for your Dark/Horror/Halloween games.
  • Hello everyone!

    I am porting the rex_bbcodetext plugin to C3Runtime and I am running into a problem.

    How to find out values (such as font, font size, bold, italic) from the Construct 2 font property, and then set individual properties ​​in the text plugin to their values?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I solved the problem. All you need to do is write code below, in the LoadC2Property method in instance.js:

    			switch (name) {
    				case "font":
    					valueString = valueString.split(",");
    					let z = {
    						name: "Arial",
    						size: 12,
    						bold: false,
    						italic: false
    					};
    					0 < valueString.length && (z.name = valueString[0]);
    					this._inst.SetPropertyValue("font", z.name); // Set font name
    					if (1 < valueString.length) {
    						let A = parseFloat(valueString[1]);
    						0 > A && (A = 72 * -A / 96);
    						z.size = A || 16
    					}
    					this._inst.SetPropertyValue("font-size", Math.round(z.size)); // Set font size
    					2 < valueString.length && (z.bold = 700 <= parseInt(valueString[2]));
    					this._inst.SetPropertyValue("bold", z.bold); // Set bold
    					3 < valueString.length && (z.italic = !!parseInt(valueString[3]));
    					this._inst.SetPropertyValue("italic", z.italic); // Set italic
    					true;
    			}
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)