|
|
|
|
|
|
TextBuff _textBuf; |
|
|
|
float[] _charWidths; |
|
|
|
List<int> _breaks = new List<int>(); |
|
|
|
int _breaksCount = 0; |
|
|
|
int _widthsCount = 0; |
|
|
|
WordBreaker _wordBreaker = new WordBreaker(); |
|
|
|
float _width = 0.0f; |
|
|
|
float _preBreak; |
|
|
|
|
|
|
TabStops _tabStops; |
|
|
|
int mFirstTabIndex; |
|
|
|
List<Candidate> _candidates = new List<Candidate>(); |
|
|
|
int _candidatesCount = 0; |
|
|
|
int nCand = this._candidates.Count; |
|
|
|
int nCand = this._candidatesCount; |
|
|
|
var cand = this._candidates.last(); |
|
|
|
var cand = this._candidates[this._candidatesCount - 1]; |
|
|
|
return this._breaks.Count; |
|
|
|
return this._breaksCount; |
|
|
|
public List<int> getBreaks() { |
|
|
|
return this._breaks; |
|
|
|
public int getBreaksCount() { |
|
|
|
return this._breaksCount; |
|
|
|
} |
|
|
|
|
|
|
|
public int getBreak(int i) { |
|
|
|
return this._breaks[i]; |
|
|
|
} |
|
|
|
|
|
|
|
public float getWidth(int i) { |
|
|
|
return this._widths[i]; |
|
|
|
} |
|
|
|
|
|
|
|
public void resize(int size) { |
|
|
|
|
|
|
this._textBuf = new TextBuff(text, textOffset, textLength); |
|
|
|
this._wordBreaker.setText(this._textBuf); |
|
|
|
this._wordBreaker.next(); |
|
|
|
this._candidates.Clear(); |
|
|
|
this._candidatesCount = 0; |
|
|
|
this._candidates.Add(can); |
|
|
|
this._addCandidateToList(can); |
|
|
|
this._lastBreak = 0; |
|
|
|
this._bestBreak = 0; |
|
|
|
this._bestScore = ScoreInfty; |
|
|
|
|
|
|
public void finish() { |
|
|
|
this._wordBreaker.finish(); |
|
|
|
this._width = 0; |
|
|
|
this._candidates.Clear(); |
|
|
|
this._widths.Clear(); |
|
|
|
this._breaks.Clear(); |
|
|
|
this._candidatesCount = 0; |
|
|
|
this._breaksCount = 0; |
|
|
|
this._widthsCount = 0; |
|
|
|
public List<float> getWidths() { |
|
|
|
return this._widths; |
|
|
|
public int getWidthsCount() { |
|
|
|
return this._widthsCount; |
|
|
|
} |
|
|
|
|
|
|
|
public void setTabStops(TabStops tabStops) { |
|
|
|
|
|
|
void _addWordBreak(int offset, float preBreak, float postBreak, int preSpaceCount, int postSpaceCount, |
|
|
|
float penalty) { |
|
|
|
|
|
|
|
float width = this._candidates.last().preBreak; |
|
|
|
float width = this._candidates[this._candidatesCount - 1].preBreak; |
|
|
|
if (postBreak - width > this._lineWidth) { |
|
|
|
this._addCandidatesInsideWord(width, offset, postSpaceCount); |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void _addCandidatesInsideWord(float width, int offset, int postSpaceCount) { |
|
|
|
int i = this._candidates.last().offset; |
|
|
|
int i = this._candidates[this._candidatesCount - 1].offset; |
|
|
|
width += this._charWidths[i++]; |
|
|
|
for (; i < offset; i++) { |
|
|
|
float w = this._charWidths[i]; |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void _addCandidateToList(Candidate cand) { |
|
|
|
if (this._candidates.Count == this._candidatesCount) { |
|
|
|
this._candidates.Add(cand); |
|
|
|
this._candidatesCount++; |
|
|
|
} |
|
|
|
else { |
|
|
|
this._candidates[this._candidatesCount++] = cand; |
|
|
|
} |
|
|
|
} |
|
|
|
int candIndex = this._candidates.Count; |
|
|
|
this._candidates.Add(cand); |
|
|
|
int candIndex = this._candidatesCount; |
|
|
|
this._addCandidateToList(cand); |
|
|
|
if (cand.postBreak - this._preBreak > this._lineWidth) { |
|
|
|
if (this._bestBreak == this._lastBreak) { |
|
|
|
this._bestBreak = candIndex; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void _pushBreak(int offset, float width) { |
|
|
|
if (this.lineLimit == 0 || this._breaks.Count < this.lineLimit) { |
|
|
|
this._breaks.Add(offset); |
|
|
|
this._widths.Add(width); |
|
|
|
if (this.lineLimit == 0 || this._breaksCount < this.lineLimit) { |
|
|
|
if (this._breaks.Count == this._breaksCount) { |
|
|
|
this._breaks.Add(offset); |
|
|
|
this._breaksCount++; |
|
|
|
} |
|
|
|
else { |
|
|
|
this._breaks[this._breaksCount++] = offset; |
|
|
|
} |
|
|
|
|
|
|
|
if (this._widths.Count == this._widthsCount) { |
|
|
|
this._widths.Add(width); |
|
|
|
this._widthsCount++; |
|
|
|
} |
|
|
|
else { |
|
|
|
this._widths[this._widthsCount++] = width; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |