Skip to content

0.5.0: text codes and stacked tolerances

Choose a tag to compare

@gsdali gsdali released this 19 Nov 02:55
42f5338

Text as it reads: TEXT and MTEXT codes decoded, stacked tolerances kept as data (#32).

New

  • DXF.TextContent beside each text, read with Drawing.textContent(ofEntityAt:) (and Block.textContents): the string as written (raw), its syntax (TEXT or MTEXT), its parts, the plain text and its stacks.
  • DXF.StackedText: a stacked tolerance or fraction, with upper, lower and kind (tolerance ^, fraction /, diagonal fraction #), and upperValue / lowerValue, which read a point or a comma as the decimal mark. 36{\H2.4;\S+0,011^ -0,005;} reads 36 +0,011/-0,005, upper +0,011, lower -0,005.
  • Special characters: %%c is ⌀ (U+2300), %%d °, %%p ±, %%% %, %%nnn the Unicode character up to 255; %%u, %%o and %%k are dropped. Caret notation ^ , ^I, ^J.
  • MTEXT formatting codes (\A, \C, \F, \H, \Q, \T, \W, \p and the switches and braces) are removed; \P, \N and \X are line breaks, \~ a no-break space. A code that is not understood is kept as written, so nothing is lost silently.
  • DimensionText uses the same scanner: its words hold no formatting codes, a stack is a new .stack part whose numbers are not typed numbers, and it gains stacks and plain.
  • dxfdump --texts, and tools/text_oracle.py for the same output from ezdxf. Over 23,429 strings in 3,109 real drawings the two agree on all but 25, each a Jw_cad superscript mark ezdxf reads differently, as the README notes.

Changed (see "Upgrading from 0.4" in the README)

  • The string of .text is the text as it reads. It used to keep each MTEXT code's body (36{H2.400000;S+0,011^ -0,005;}) and leave %%c, %%d and %%p as written. The .text case keeps its shape, so no consumer stops compiling.
  • A backslash in a TEXT stays a character (TEXT and MTEXT follow different rules, as AutoCAD and ezdxf do). \U+XXXX is still decoded.
  • DimensionText.Part has a new case, .stack, so an exhaustive switch over the parts needs it. Dimension.textOverride is unchanged.

Not yet: decoding through the drawing's code page (\M+nXXXX, %%nnn through $DWGCODEPAGE) is #36.