-
Notifications
You must be signed in to change notification settings - Fork 22
/
diff.txt
150 lines (139 loc) · 6.69 KB
/
diff.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
diff --git a/textLayout/src/flashx/textLayout/compose/BaseCompose.as b/textLayout/src/flashx/textLayout/compose/BaseCompose.as
index e8ddb7b..2ad0506 100644
--- a/textLayout/src/flashx/textLayout/compose/BaseCompose.as
+++ b/textLayout/src/flashx/textLayout/compose/BaseCompose.as
@@ -1435,7 +1435,7 @@ package flashx.textLayout.compose
// advance to the next element, using the rootElement of the container as a limitNode
// to prevent going past the content bound to this container
- _curElementOffset += _curLine.textLength;
+ _curElementOffset = _curLine.absoluteStart + _curLine.textLength - _curElementStart;
if (_curElementOffset >= _curElement.textLength)
{
// We may have composed ahead over several spans; skip until we match up
diff --git a/textLayout/src/flashx/textLayout/compose/ComposeState.as b/textLayout/src/flashx/textLayout/compose/ComposeState.as
index bdddf85..ce7bddc 100644
--- a/textLayout/src/flashx/textLayout/compose/ComposeState.as
+++ b/textLayout/src/flashx/textLayout/compose/ComposeState.as
@@ -340,6 +340,11 @@ package flashx.textLayout.compose
var line:TextFlowLine = _curLineIndex < _flowComposer.numLines ? (_flowComposer as StandardFlowComposer).lines[_curLineIndex] : null;
var useExistingLine:Boolean = line && (!line.isDamaged() || line.validity == FlowDamageType.GEOMETRY);
+ // if the line ends with a hyphen, don't use existing line because the player seems to mis-handle
+ // starting the next line.
+ if (useExistingLine && line.textLength > 0 &&
+ line.paragraph.getCharCodeAtPosition(line.absoluteStart + line.textLength - 1) == 0xAD)
+ useExistingLine = false;
var numberLine:TextLine;
// create numberLine if in a listElement
diff --git a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as b/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
index 04bc2a3..b03592a 100644
--- a/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
+++ b/textLayout/src/flashx/textLayout/compose/FlowComposerBase.as
@@ -296,6 +296,16 @@ package flashx.textLayout.compose
*/
public function damage(startPosition:int, damageLength:int, damageType:String):void
{
+ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
+ {
+ // damage everything from the beginning.
+ // The player tends to screw up if you start
+ // composition in the middle and there are lines above broken on
+ // hyphens.
+ damageLength += startPosition;
+ startPosition = 0;
+ }
+
// find the line at damageStart
if (_lines.length == 0 || textFlow.textLength == 0)
return;
diff --git a/textLayout/src/flashx/textLayout/container/ContainerController.as b/textLayout/src/flashx/textLayout/container/ContainerController.as
index 50161ee..528c26d 100644
--- a/textLayout/src/flashx/textLayout/container/ContainerController.as
+++ b/textLayout/src/flashx/textLayout/container/ContainerController.as
@@ -111,6 +111,8 @@ package flashx.textLayout.container
*/
public class ContainerController implements IInteractionEventHandler, ITextLayoutFormat, ISandboxSupport
{
+ static tlf_internal var usesDiscretionaryHyphens:Boolean = true;
+
private var _textFlowCache:TextFlow;
private var _rootElement:ContainerFormattedElement;
diff --git a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as b/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
index 8571ca8..22bfe40 100644
--- a/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
+++ b/textLayout/src/flashx/textLayout/elements/FlowLeafElement.as
@@ -574,7 +574,7 @@ package flashx.textLayout.elements
if (blockProgression == BlockProgression.RL && (parent is TCYElement))
return 0;
CONFIG::debug { assert(_computedFormat != null,"Missing _computedFormat in FlowLeafElement.getEffectiveLineHeight"); }
- return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(_computedFormat.lineHeight, getEffectiveFontSize());
+ return TextLayoutFormat.lineHeightProperty.computeActualPropertyValue(computedFormat.lineHeight, getEffectiveFontSize());
}
/** @private
diff --git a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
index f58e1d4..13590a5 100644
--- a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
+++ b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as
@@ -33,7 +33,9 @@ package flashx.textLayout.elements
import flash.text.engine.TextRotation;
import flash.utils.getQualifiedClassName;
+ import flashx.textLayout.tlf_internal;
import flashx.textLayout.compose.TextFlowLine;
+ import flashx.textLayout.container.ContainerController;
import flashx.textLayout.debug.Debugging;
import flashx.textLayout.debug.assert;
import flashx.textLayout.formats.BlockProgression;
@@ -48,7 +50,6 @@ package flashx.textLayout.elements
import flashx.textLayout.formats.TextJustify;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.property.Property;
- import flashx.textLayout.tlf_internal;
import flashx.textLayout.utils.CharacterUtil;
import flashx.textLayout.utils.LocaleUtil;
@@ -477,6 +478,25 @@ package flashx.textLayout.elements
public function findPreviousAtomBoundary(relativePosition:int):int
{
+ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
+ {
+ var textBlock:TextBlock = getTextBlock();
+ var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
+ var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
+ if (currentAtomIndex == 0)
+ {
+ tl = tl.previousLine;
+ if (!tl)
+ return -1;
+ return tl.textBlockBeginIndex + tl.rawTextLength;
+ }
+ while (--relativePosition)
+ {
+ if (tl.getAtomIndexAtCharIndex(relativePosition) < currentAtomIndex)
+ break;
+ }
+ return relativePosition;
+ }
return getTextBlock().findPreviousAtomBoundary(relativePosition);
}
@@ -500,6 +520,25 @@ package flashx.textLayout.elements
public function findNextAtomBoundary(relativePosition:int):int
{
+ if (ContainerController.tlf_internal::usesDiscretionaryHyphens)
+ {
+ var textBlock:TextBlock = getTextBlock();
+ var tl:TextLine = textBlock.getTextLineAtCharIndex(relativePosition);
+ var currentAtomIndex = tl.getAtomIndexAtCharIndex(relativePosition);
+ if (currentAtomIndex == tl.atomCount - 1)
+ {
+ tl = tl.nextLine;
+ if (!tl)
+ return -1;
+ return tl.textBlockBeginIndex;
+ }
+ while (++relativePosition)
+ {
+ if (tl.getAtomIndexAtCharIndex(relativePosition) > currentAtomIndex)
+ break;
+ }
+ return relativePosition;
+ }
return getTextBlock().findNextAtomBoundary(relativePosition);
}