Browse Source

无jira任务,单元测试失败

10.0
kerry 7 years ago
parent
commit
1b4d525eda
  1. 61
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java

61
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java

@ -548,42 +548,23 @@ public class PdfChunk {
return 0.0f; return 0.0f;
} }
/** /**
* Trims the last space. * Trims the last space.
* @return the width of the space trimmed, otherwise 0 * @return the width of the space trimmed, otherwise 0
*/ */
public float trimLastSpace() public float trimLastSpace() {
{ if (value.length() > 1 && value.endsWith(" ")) {
BaseFont ft = font.getFont(); value = value.substring(0, value.length() - 1);
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') { return font.width(' ');
if (value.length() > 1 && value.endsWith("\u0001")) {
value = value.substring(0, value.length() - 1);
return font.width('\u0001');
}
}
else {
if (value.length() > 1 && value.endsWith(" ")) {
value = value.substring(0, value.length() - 1);
return font.width(' ');
}
} }
return 0; return 0;
} }
public float trimFirstSpace()
{ public float trimFirstSpace() {
BaseFont ft = font.getFont(); if (value.length() > 1 && value.startsWith(" ")) {
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') { value = value.substring(1);
if (value.length() > 1 && value.startsWith("\u0001")) { return font.width(' ');
value = value.substring(1);
return font.width('\u0001');
}
}
else {
if (value.length() > 1 && value.startsWith(" ")) {
value = value.substring(1);
return font.width(' ');
}
} }
return 0; return 0;
} }
@ -792,16 +773,8 @@ public class PdfChunk {
* @return the trimmed <CODE>String</CODE> * @return the trimmed <CODE>String</CODE>
*/ */
String trim(String string) { String trim(String string) {
BaseFont ft = font.getFont(); while (string.endsWith(" ") || string.endsWith("\t")) {
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') { string = string.substring(0, string.length() - 1);
while (string.endsWith("\u0001")) {
string = string.substring(0, string.length() - 1);
}
}
else {
while (string.endsWith(" ") || string.endsWith("\t")) {
string = string.substring(0, string.length() - 1);
}
} }
return string; return string;
} }

Loading…
Cancel
Save