Hi @Deltakosh !
Sorry been a long time since I updated this. I found the issue but can’t recreate it on the playground because it always has a canvas even if give allowCanvas=false during serialization. Same goes for my dev env.
I don’t mind making a PR but I can’t get this error to fire with normal testing because there is always a canvas.
This error occurs when I run my Figma to Babylonjs plugin.
This is happening in the _prepareFont() function here (during serialization)
this._font =
this._getStyleProperty("fontStyle", "") +
" " +
this._getStyleProperty("fontWeight", "") +
" " +
this.fontSizeInPixels +
"px " +
this._getStyleProperty("fontFamily", "Arial");
this._fontOffset = Control._GetFontOffset(this._font, this._host?.getScene()?.getEngine());
//children need to be refreshed
const descendants = this.getDescendants();
for (const child of descendants) {
child._markAllAsDirty();
}
}
/**
* A control has a dimension fully defined if that dimension doesn't depend on the parent's dimension.
But it should be skipped with allowCanvas=false
idealHeight = this.host.idealHeight;
idealWidth = this.host.idealWidth;
this.host.idealWidth = 0;
this.host.idealHeight = 0;
}
SerializationHelper.Serialize(this, serializationObject);
serializationObject.name = this.name;
serializationObject.className = this.getClassName();
// Call prepareFont to guarantee the font is properly set before serializing
if (allowCanvas) {
this._prepareFont();
}
if (this._fontFamily) {
serializationObject.fontFamily = this._fontFamily;
}
if (this.fontSize) {
serializationObject.fontSize = this.fontSize;
}
if (this.fontWeight) {
serializationObject.fontWeight = this.fontWeight;
I think it maybe due to Button ioverriding the serialize function but not passing/acknowledge the allowCanvas param.
}
super._onPointerUp(target, coordinates, pointerId, buttonIndex, notifyClick, pi);
}
/**
* Serializes the current button
* @param serializationObject defines the JSON serialized object
* @param force force serialization even if isSerializable === false
*/
public override serialize(serializationObject: any, force: boolean) {
super.serialize(serializationObject, force);
if (!this.isSerializable && !force) {
return;
}
if (this._textBlock) {
serializationObject.textBlockName = this._textBlock.name;
}
if (this._image) {
serializationObject.imageName = this._image.name;
This isn’t an issue on normal TextBlocks, only happens on Buttons but I assume could happen in Grids too since they also have an override during serialization.
Do you think I’m on the right track?