惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
腾讯CDC
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
美团技术团队
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
博客园_首页
Recent Announcements
Recent Announcements
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
博客园 - Franky
Jina AI
Jina AI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Overhauling a CAD Engine: Rebuilding Multileader Text Lay...
kulman Lab · 2026-06-18 · via DEV Community

kulman Lab

Hey everyone! 👋

I just shipped a massive architectural overhaul to our Multileader (MLEADER) graphics engine alongside some long-overdue quality-of-life updates to our canvas Text Editor[cite: 1]. Here is a quick look at what changed, why I changed it, and how I solved it[cite: 1].


🛠 1. Moving to Structured Rich Text Data (TextSegment[])

The Problem

Previously, multileaders treated text as a single string block[cite: 1]. This made formatting highly rigid and prone to failure when dealing with native DXF inline codes (\H, \f, \L, etc.)[cite: 1]. Worse yet, a legacy layout constraint meant that only the first line of text would actually render[cite: 1].

The Solution

I completely decoupled text storage from raw string fields[cite: 1]. Multileader content is now processed into an array of typed segments (TextSegment[]), bringing true multi-line and per-character rich text formatting support[cite: 1]. I also isolated the recursive parsing logic into a unified utility: text-parser-utils.ts[cite: 1].


🎨 2. Solving Variable Row Heights & Text Overlaps

The Problem

When text strings contain varying font sizes or special character drops (like g, j, p, y), standard static height offsets cause lines to overlap, clip, or look completely crushed[cite: 1].

The Solution

I migrated from a static "entity-wide" height constant to a dynamic per-row ribbon architecture[cite: 1]:

  • First-Row Scaling: The attachment offset is now dynamically scaled using the maximum character height of the first row only, preventing inconsistent alignment[cite: 1].
  • Per-Row Ribbon Bounds: Each row computes its own bounding box on layout passes[cite: 1]. Mixed font sizes on a single line will never bleed into adjacent rows[cite: 1].
  • Coordinate Tree Alignment: I aligned the rendering coordinate space to mirror our primary canvas Text entity[cite: 1]. This explicitly resolves selection box overflows for unusually tall or accented characters[cite: 1].
  • Line-Weight Inheritance: Underline thickness now dynamically inherits its thickness from the adjacent leader line weight[cite: 1].

🖱 3. Inline Canvas Text Editor Integration

Building a modern CAD experience means getting rid of modal popups or manual text prompt windows[cite: 1].

  • Double-Click-To-Edit: Users can now double-click a multileader to activate an in-place text editor directly on the canvas with real-time cursor tracking, character selection, and accurate hit-testing[cite: 1].
  • Creation Flow Hooks: The moment a user places the final point of a new leader, the application automatically kicks into the inline text editor state right at the text-placement position[cite: 1].
  • Layout Anchoring: The editor popup accurately anchors to the stub side of the leader[cite: 1]. Frame-resize handles (grips) allow word-wrap behaviors to scale exactly like standard canvas text bodies[cite: 1].

⚡ 4. General UX & Framework Refinements

I polished out some of the most annoying workflow friction points inside the core workspace:

  • Command Optimization: Commands like Leader+ or Leader- now check your active canvas selection first[cite: 1]. If a valid multileader is highlighted, it bypasses the manual item selection step[cite: 1].
  • Canvas Focus Locks: Pressing Enter while adjusting the text height input box immediately returns viewport focus back to the canvas context[cite: 1].
  • The Ghost Height Bug: Fixed a silent bug where modifying the font size on specific multileader elements would run fine but result in a no-op due to a missing internal text height setter[cite: 1].
  • Clean Closures: Clicking outside the boundaries of an active text editor gracefully closes out and saves the current state without accidentally registering a brand new selection window on your canvas[cite: 1].