mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
hyphenations for very long words
This commit is contained in:
parent
a910503f2f
commit
50d4b0c3fd
3 changed files with 25 additions and 14 deletions
|
@ -6,6 +6,7 @@
|
|||
* Library view: background search
|
||||
* 'invisible if pressed' issue for description in book information dialog has been fixed
|
||||
* LitRes: username forgetting issue has been fixed
|
||||
* Hyphenations for very long words (including multi-line words) has been implemented
|
||||
|
||||
===== 1.1.2 (Jul 05, 2011) =====
|
||||
* Misc Litres fixes
|
||||
|
|
|
@ -714,7 +714,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
final ZLTextElement element = paragraph.getElement(wordIndex);
|
||||
final ZLTextElementArea area = page.TextElementMap.get(index);
|
||||
if (element == area.Element) {
|
||||
index++;
|
||||
++index;
|
||||
if (area.ChangeStyle) {
|
||||
setTextStyle(area.Style);
|
||||
}
|
||||
|
@ -748,11 +748,13 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
if (area.ChangeStyle) {
|
||||
setTextStyle(area.Style);
|
||||
}
|
||||
int len = info.EndCharIndex;
|
||||
final int start = info.StartElementIndex == info.EndElementIndex
|
||||
? info.StartCharIndex : 0;
|
||||
final int len = info.EndCharIndex - start;
|
||||
final ZLTextWord word = (ZLTextWord)paragraph.getElement(info.EndElementIndex);
|
||||
drawWord(
|
||||
area.XStart, area.YEnd - context.getDescent() - getTextStyle().getVerticalShift(),
|
||||
word, 0, len, area.AddHyphenationSign,
|
||||
word, start, len, area.AddHyphenationSign,
|
||||
mySelection.isAreaSelected(area)
|
||||
? getSelectedForegroundColor() : getTextColor(getTextStyle().Hyperlink)
|
||||
);
|
||||
|
@ -920,27 +922,35 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
ZLTextHyphenationInfo hyphenationInfo = ZLTextHyphenator.Instance().getInfo(word);
|
||||
int hyphenationPosition = word.Length - 1;
|
||||
int subwordWidth = 0;
|
||||
for(; hyphenationPosition > 0; hyphenationPosition--) {
|
||||
for(; hyphenationPosition > currentCharIndex; hyphenationPosition--) {
|
||||
if (hyphenationInfo.isHyphenationPossible(hyphenationPosition)) {
|
||||
subwordWidth = getWordWidth(word, 0, hyphenationPosition,
|
||||
word.Data[word.Offset + hyphenationPosition - 1] != '-');
|
||||
subwordWidth = getWordWidth(
|
||||
word,
|
||||
currentCharIndex,
|
||||
hyphenationPosition - currentCharIndex,
|
||||
word.Data[word.Offset + hyphenationPosition - 1] != '-'
|
||||
);
|
||||
if (subwordWidth <= spaceLeft) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hyphenationPosition == 0 && info.EndElementIndex == startIndex) {
|
||||
hyphenationPosition = word.Length == 1 ? 1 : word.Length - 1;
|
||||
subwordWidth = getElementWidth(word, 0);
|
||||
for(; hyphenationPosition > 1; hyphenationPosition--) {
|
||||
subwordWidth = getWordWidth(word, 0, hyphenationPosition,
|
||||
word.Data[word.Offset + hyphenationPosition - 1] != '-');
|
||||
if (hyphenationPosition == currentCharIndex && info.EndElementIndex == startIndex) {
|
||||
hyphenationPosition = word.Length == currentCharIndex + 1 ? word.Length : word.Length - 1;
|
||||
subwordWidth = getWordWidth(word, currentCharIndex, word.Length - currentCharIndex, false);
|
||||
for(; hyphenationPosition > currentCharIndex + 1; hyphenationPosition--) {
|
||||
subwordWidth = getWordWidth(
|
||||
word,
|
||||
currentCharIndex,
|
||||
hyphenationPosition - currentCharIndex,
|
||||
word.Data[word.Offset + hyphenationPosition - 1] != '-'
|
||||
);
|
||||
if (subwordWidth <= spaceLeft) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hyphenationPosition > 0) {
|
||||
if (hyphenationPosition > currentCharIndex) {
|
||||
info.IsVisible = true;
|
||||
info.Width = newWidth + subwordWidth;
|
||||
if (info.Height < newHeight) {
|
||||
|
|
|
@ -190,7 +190,7 @@ abstract class ZLTextViewBase extends ZLView {
|
|||
final void drawWord(int x, int y, ZLTextWord word, int start, int length, boolean addHyphenationSign, ZLColor color) {
|
||||
final ZLPaintContext context = myContext;
|
||||
context.setTextColor(color);
|
||||
if ((start == 0) && (length == -1)) {
|
||||
if (start == 0 && length == -1) {
|
||||
drawString(x, y, word.Data, word.Offset, word.Length, word.getMark(), 0);
|
||||
} else {
|
||||
if (length == -1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue