Browse Source

Merge pull request #40 in CORE/base-third from ~KERRY/base-third:feature/10.0 to feature/10.0

* commit '33f7b816205630c308401a5ce0268bb6577af4da':
  无jira任务,单元测试失败
10.0
superman 7 years ago
parent
commit
bd3bd7a33c
  1. 33
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java

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

@ -553,38 +553,19 @@ public class PdfChunk {
* @return the width of the space trimmed, otherwise 0 * @return the width of the space trimmed, otherwise 0
*/ */
public float trimLastSpace() public float trimLastSpace() {
{
BaseFont ft = font.getFont();
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') {
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(" ")) { if (value.length() > 1 && value.endsWith(" ")) {
value = value.substring(0, value.length() - 1); value = value.substring(0, value.length() - 1);
return font.width(' '); return font.width(' ');
} }
}
return 0; return 0;
} }
public float trimFirstSpace()
{ public float trimFirstSpace() {
BaseFont ft = font.getFont();
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') {
if (value.length() > 1 && value.startsWith("\u0001")) {
value = value.substring(1);
return font.width('\u0001');
}
}
else {
if (value.length() > 1 && value.startsWith(" ")) { if (value.length() > 1 && value.startsWith(" ")) {
value = value.substring(1); value = value.substring(1);
return font.width(' '); return font.width(' ');
} }
}
return 0; return 0;
} }
@ -792,17 +773,9 @@ 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();
if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') {
while (string.endsWith("\u0001")) {
string = string.substring(0, string.length() - 1);
}
}
else {
while (string.endsWith(" ") || string.endsWith("\t")) { while (string.endsWith(" ") || string.endsWith("\t")) {
string = string.substring(0, string.length() - 1); string = string.substring(0, string.length() - 1);
} }
}
return string; return string;
} }

Loading…
Cancel
Save