Skip to content

Commit 3bf65cc

Browse files
authored
Xd 34 docs (#229)
1 parent e8f015b commit 3bf65cc

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

changes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
XD Release 34.0.12 (October 2020)
4+
-------------------------------------
5+
6+
### New feature
7+
* **Auto Height Text** -- This new "auto height" text node type will adjust (grow/shrink) its height so that it always fits the content inside. Content changes, style changes and area width changes will make the area text height resize accordingly. A new text [layoutBox](./reference/scenegraph.md#Text-layoutBox) API will return the type of text node and the text frame width and/or height contraints if applicable. This API should be used instead of the text [areaBox](./reference/scenegraph.md#Text-areaBox) API going forward.
8+
9+
310
XD Release 33.0.12 (September 2020)
411
-------------------------------------
512

reference/scenegraph.md

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,22 +1722,31 @@ Which boolean operation is used to generate the path: BooleanGroup.PATH_OP_ADD,
17221722
Text leaf node shape. Text can have a fill and/or stroke, but only a solid-color fill is allowed (gradient or image
17231723
fill will be rejected).
17241724

1725-
There are two types of Text nodes:
1725+
There are three types of Text nodes:
17261726
- **Point Text** - Expands to fit the full width of the text content. Only uses multiple lines if the text content contains hard line
17271727
breaks ("\n").
17281728
- **Area Text** - Fixed width and height. Text is automatically wrapped (soft line wrapping) to fit the width. If it does not fit the
17291729
height, any remaining text is clipped.
17301730

1731-
Check whether [<code>areaBox</code>](#Text-areaBox) is null to determine the type of a Text node.
1731+
**Since**: XD 34
1732+
- **Auto-height Text** - Fixed width. Text is automatically wrapped (soft line wrapping) to fit the width. The height is expanded to match all the text lines.
1733+
1734+
**Since**: XD 34
1735+
1736+
Use [<code>layoutBox</code>](#Text-layoutBox) to determine the type of a text node.
1737+
1738+
**Deprecated**: XD 34
1739+
1740+
Check whether [<code>areaBox</code>](#Text-areaBox) is null to determine if the type of a Text node.
17321741

17331742
Text bounds and layout work differently depending on the type of text:
17341743
- Point Text - The baseline is at y=0 in the node's local coordinate system. Horizontally, local x=0 is the _anchor point_ that the
17351744
text grows from / shrinks toward when edited. This anchor depends on the justification: for example, if the text is centered, x=0 is
17361745
the horizontal centerpoint of the text. The bounding box leaves enough space for descenders, uppercase letters, and accent marks,
17371746
even if the current string does not contain any of those characters. This makes aligning text based on its bounds behave more
17381747
consistently.
1739-
- Area Text - The baseline is at a positive y value in local coordinates, and its local (0, 0) is the top left of the areaBox. Text
1740-
always flows to the right and down from this local origin regardless of justification.
1748+
1749+
- Area Text / Auto-height text - The baseline is at a positive y value in local coordinates, and its local (0, 0) is the top left of _anchor point_ the areaBox. Text always flows to the right and down from this local origin regardless of justification.
17411750

17421751
&nbsp;<!-- prevent the bullet list above from running into this one -->
17431752
* [Text](#Text)
@@ -1757,6 +1766,7 @@ Text bounds and layout work differently depending on the type of text:
17571766
* [.lineSpacing](#Text-lineSpacing) : <code>number</code>
17581767
* [.paragraphSpacing](#Text-paragraphSpacing) : <code>number</code>
17591768
* [.areaBox](#Text-areaBox) : <code>?{width:number, height:number}</code>
1769+
* [.layoutBox](#Text-layoutBox) : <code>{type:string, ?width:number, ?height:number}</code>
17601770
* [.clippedByArea](#Text-clippedByArea) : <code>boolean</code>
17611771

17621772

@@ -1977,7 +1987,10 @@ fixed while the font size changes, shifting the spacing's proportional relations
19771987
<a name="Text-areaBox"></a>
19781988

19791989
### text.areaBox : <code>?{width:number, height:number}</code>
1980-
Null for point text. For area text, specifies the size of the rectangle within which text is wrapped and clipped.
1990+
**Deprecated**: XD 34 - Please use [`layoutBox`](#Text-layoutBox) which supports all text types.
1991+
1992+
Null for point text and starting with XD 34 null for auto height text.
1993+
For area text, specifies the size of the rectangle within which text is wrapped and clipped.
19811994

19821995
Changing point text to area text or vice versa will change the origin / anchor point of the text, thus changing its localBounds,
19831996
but it will also automatically change the node's transform so its globalBounds and boundsInParent origins remain unchanged.
@@ -1989,10 +2002,33 @@ wrapping's appearance exactly.
19892002

19902003
* * *
19912004

2005+
<a name="Text-layoutBox"></a>
2006+
2007+
### text.layoutBox : <code>{type:string, ?width:number, ?height:number}</code>
2008+
**Since**: XD 34
2009+
2010+
Type: Text.POINT (for point text also referred as auto width), FIXED_HEIGHT (for area text also referred as fixed size) or AUTO_HEIGHT (for the new auto height text)
2011+
2012+
Width: number between 0-999999. This is ignored and can be omitted for Text.POINT
2013+
2014+
Height: number between 0-999999. This is ignored and can be omitted for Text.POINT and Text.AUTO_HEIGHT
2015+
2016+
Changing POINT text to FIXED_HEIGHT or AUTO_HEIGHT text or vice versa will change the origin / anchor point of the text, thus changing its localBounds, but it will also automatically change the node's transform so its `globalBounds` and `boundsInParent` origins remain unchanged.
2017+
2018+
Changing FIXED_HEIGHT or AUTO_HEIGHT text to POINT text will automatically insert hard line break ("\n") into the text to match the previous line wrapping's appearance exactly.
2019+
2020+
Changing from FIXED_HEIGHT to AUTO_HEIGHT text will automatically change the height of the bounds to match the height of the total text (can be a no-op).
2021+
2022+
Changing from AUTO_HEIGHT to FIXED_HEIGHT text will not change the bounds, transform or origin (no-op).
2023+
2024+
**Kind**: instance property of [<code>Text</code>](#Text)
2025+
* * *
2026+
19922027
<a name="Text-clippedByArea"></a>
19932028

19942029
### text.clippedByArea : <code>boolean</code>
1995-
Always false for point text. For area text, true if the text does not fit in the content box and its bottom is being clipped.
2030+
Always false for point text and, starting with XD 34, false for auto height text.
2031+
For area text, true if the text does not fit in the content box and its bottom is being clipped.
19962032

19972033
**Kind**: instance property of [<code>Text</code>](#Text)
19982034
**Read only**: true

0 commit comments

Comments
 (0)