AI-native design editor. Open-source Figma alternative.
Remove duplicate estimateTextSize and GLYPH_WIDTH_FACTOR declarations
Anton A S6c8ba63aa724
diff --git a/packages/core/src/layout.ts b/packages/core/src/layout.tsindex b3dc9ae36..7a626654d 100644--- a/packages/core/src/layout.ts+++ b/packages/core/src/layout.ts@@ -26,6 +26,20 @@ let globalTextMeasurer: TextMeasurer | null = nullconst GLYPH_WIDTH_FACTOR = 0.6+// Rough estimate for text size when CanvasKit/font is not available.+// DO NOT REMOVE: without this, text nodes keep their 100×100 default size+// and blow up every HUG container. The real MeasureFunc (CanvasKit) overrides+// this when available — this is only the fallback.+function estimateTextSize(node: SceneNode): { width: number; height: number } {+ const fontSize = node.fontSize || 14+ const text = node.characters || node.text || ''+ const charWidth = fontSize * GLYPH_WIDTH_FACTOR+ return {+ width: Math.ceil(text.length * charWidth),+ height: Math.ceil(fontSize * 1.2),+ }+}+export function setTextMeasurer(measurer: TextMeasurer | null): void {globalTextMeasurer = measurer}@@ -333,22 +347,6 @@ function configureChildAsAutoLayout(}}-// Rough estimate for text size when CanvasKit/font is not available.-// Uses ~0.6 × fontSize per character as average glyph width.-// DO NOT REMOVE: without this, text nodes keep their 100×100 default size-// and blow up every HUG container. The real MeasureFunc (CanvasKit) overrides-// this when available — this is only the fallback.-const GLYPH_WIDTH_FACTOR = 0.6-function estimateTextSize(node: SceneNode): { width: number; height: number } {- const fontSize = node.fontSize || 14- const text = node.characters || node.text || ''- const lineHeight = fontSize * 1.2- const charWidth = fontSize * GLYPH_WIDTH_FACTOR- const width = Math.ceil(text.length * charWidth)- const height = Math.ceil(lineHeight)- return { width, height }-}-function configureChildAsLeaf(yogaChild: YogaNode, child: SceneNode, parent: SceneNode): void {const isRow = parent.layoutMode === 'HORIZONTAL'const selfOverride = child.layoutAlignSelf !== 'AUTO'@@ -387,8 +385,6 @@ function configureChildAsLeaf(yogaChild: YogaNode, child: SceneNode, parent: SceapplyMinMaxConstraints(yogaChild, child)}--function configureTextLeaf(yogaChild: YogaNode,child: SceneNode,