15m18 成书115→105治UI视口裁剪留空 + 末页并入阈值25/115(治末页19字太短)
This commit is contained in:
@@ -396,7 +396,7 @@ public class CustomScreenManager implements Listener {
|
||||
if (!body.isEmpty()) {
|
||||
// 15m10 封页统一整字符硬切100(封页不再往回扫句末, 与正文页同策略):
|
||||
// 先验证"整字符切"会不会断标点。封页/正文页都先歇着句末切点, 纯按字数切。
|
||||
int coverLimit = 115;
|
||||
int coverLimit = 105;
|
||||
// [15m8 句末切点歇着] int best=-1; for(i..) if(。!?;\n){best=i+1;break;}
|
||||
// [15m8 句末切点歇着] int cut = (best<55)? Math.min(body.length(),coverLimit) : Math.min(body.length(),best);
|
||||
int cut = Math.min(body.length(), coverLimit);
|
||||
@@ -416,19 +416,19 @@ public class CustomScreenManager implements Listener {
|
||||
|
||||
// 当前页为空:直接开始新段落
|
||||
if (page.length() == 0) {
|
||||
if (p.length() > 115) {
|
||||
if (p.length() > 105) {
|
||||
java.util.List<String> sentences = splitSentences(p);
|
||||
for (String s : sentences) {
|
||||
// ★ 15m:单句本身超 85(长句无句末可拆)→ 硬切 85,残句进下一页
|
||||
while (s.length() > 115) {
|
||||
if (page.length() + 115 + 1 > 115 && page.length() > 0) {
|
||||
while (s.length() > 105) {
|
||||
if (page.length() + 105 + 1 > 105 && page.length() > 0) {
|
||||
pages.add(page.toString().trim());
|
||||
page = new StringBuilder();
|
||||
}
|
||||
page.append(s.substring(0, 115));
|
||||
s = s.substring(115);
|
||||
page.append(s.substring(0, 105));
|
||||
s = s.substring(105);
|
||||
}
|
||||
if (page.length() + s.length() + 1 > 115 && page.length() > 0) {
|
||||
if (page.length() + s.length() + 1 > 105 && page.length() > 0) {
|
||||
pages.add(page.toString().trim());
|
||||
page = new StringBuilder();
|
||||
}
|
||||
@@ -441,14 +441,14 @@ public class CustomScreenManager implements Listener {
|
||||
}
|
||||
|
||||
// 当前页已有内容:判断段落是否能整段放入
|
||||
if (page.length() + p.length() + 1 <= 115) {
|
||||
if (page.length() + p.length() + 1 <= 105) {
|
||||
page.append("\n").append(p);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 整段放不进:在「当前页 + 段落」里找语义边界截断
|
||||
String candidate = page.toString() + "\n" + p;
|
||||
int cut = findSemanticCut(candidate, 115);
|
||||
int cut = findSemanticCut(candidate, 105);
|
||||
// ★ 15l-7f 修复:不 trim,保留语义边界(。!?;\n)在页内,避免吃掉前面整段
|
||||
String firstHalf = candidate.substring(0, cut);
|
||||
String secondHalf = candidate.substring(cut);
|
||||
@@ -459,8 +459,8 @@ public class CustomScreenManager implements Listener {
|
||||
page = new StringBuilder(secondHalf);
|
||||
|
||||
// 若剩余段仍超页,继续按语义截断或按句拆
|
||||
while (page.length() > 115) {
|
||||
int nextCut = findSemanticCut(page.toString(), 115);
|
||||
while (page.length() > 105) {
|
||||
int nextCut = findSemanticCut(page.toString(), 105);
|
||||
String chunk = page.substring(0, nextCut);
|
||||
String remain = page.substring(nextCut);
|
||||
while (chunk.endsWith("\n") || chunk.endsWith(" ")) chunk = chunk.substring(0, chunk.length() - 1);
|
||||
@@ -481,7 +481,7 @@ public class CustomScreenManager implements Listener {
|
||||
if (pages.size() > 2) {
|
||||
String last = pages.get(pages.size() - 1);
|
||||
String prev = pages.get(pages.size() - 2);
|
||||
if (last.length() < 20 && (prev.length() + last.length() + 1) <= 115) {
|
||||
if (last.length() < 25 && (prev.length() + last.length() + 1) <= 115) {
|
||||
pages.set(pages.size() - 2, prev + "\n" + last);
|
||||
pages.remove(pages.size() - 1);
|
||||
}
|
||||
@@ -492,7 +492,7 @@ public class CustomScreenManager implements Listener {
|
||||
String cur = pages.get(pi);
|
||||
String nxt = pages.get(pi + 1);
|
||||
// 15m16 放宽中间孤短页合并: 上限165→175, 阈值50→55(治"残句刚好50字合不了")
|
||||
if (cur.length() < 55 && (cur.length() + nxt.length() + 1) <= 175) {
|
||||
if (cur.length() < 55 && (cur.length() + nxt.length() + 1) <= 165) {
|
||||
pages.set(pi + 1, cur + "\n" + nxt);
|
||||
pages.remove(pi);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user