feat: add write() module for advanced 3D text with auto-sizing and wrapping (#1642)#1963
Open
junhinhow wants to merge 1 commit intoBelfrySCAD:masterfrom
Open
feat: add write() module for advanced 3D text with auto-sizing and wrapping (#1642)#1963junhinhow wants to merge 1 commit intoBelfrySCAD:masterfrom
junhinhow wants to merge 1 commit intoBelfrySCAD:masterfrom
Conversation
…apping (BelfrySCAD#1642) New write.scad module with advanced 3D text API for BOSL2: write(text, h, font_size, font, width, height, box, align, valign, line_spacing, letter_space, margin, anchor, spin, orient): - Auto-sizing: without font_size, scales text to fit box - Word wrapping: with font_size + width, breaks at word boundaries - Multi-line: accepts array of strings or string with newlines - Alignment: horizontal (left/center/right) and vertical (top/center/bottom/baseline) - Configurable margin inside box - Full integration with BOSL2 attachable() system get_font_size(font_size, em_size, cap_height, cap_ratio): - Converts between typographic units (font_size, em, cap_height) - Automatically corrects OpenSCAD 0.72 factor Helper functions _wrap_line() and _wrap_words() for recursive word wrapping respecting width limits. Tests covering: get_font_size with 3 units, basic text, multi-line, auto-sizing, wrapping, alignments and attachment. Module not included in std.scad (use: include <BOSL2/write.scad>).
c92dd36 to
43be5a6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
write.scadmodule (not included in std.scad, requires separate include):write()module: advanced 3D text with:font_size+ providebox/width/height→ text scales to fitfont_size+width→ automatic line breaks at word boundaries\nnewlinesleft/center/right) and vertical (top/center/bottom/baseline)attachable()integration with anchor/spin/orientget_font_size()function: converts between typographic unitsfont_size(traditional point-like size)em_size(em square / font design box)cap_height(capital letter height, with configurable ratio)Usage:
include <BOSL2/std.scad>theninclude <BOSL2/write.scad>Test plan
get_font_size()returns correct values for all 3 unit typesAddresses #1642
🤖 Generated with Claude Code