UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

31 lines (30 loc) 787 B
"use strict"; export function applyTextLineHeight(geometries, params) { if (geometries.length == 0) { return; } if (params.lineHeight == 1) { return; } let totalBoundingBox = null; for (const geometry of geometries) { if (!geometry) continue; geometry.computeBoundingBox(); if (geometry.boundingBox) { if (totalBoundingBox == null) { totalBoundingBox = geometry.boundingBox; } else { totalBoundingBox.union(geometry.boundingBox); } } } if (!totalBoundingBox) { return; } const expectedMin = totalBoundingBox.min.y * params.lineHeight; const delta = expectedMin - totalBoundingBox.min.y; for (const geometry of geometries) { geometry == null ? void 0 : geometry.translate(0, delta, 0); } }