Category: | Bug report |
Priority: | Normal |
Status: | Resolved |
Project: | Severity: | Minor |
Resolution: | No Change Required |
|
Component: | Reproducibility: | Always |
Assigned to: |
We have detected a problem with line wrapping in text fields in Jasper Reports library 5.6.0 on linux systems:
If the text fits exactly into the text field, the line seems to be wrapped after the last word of the line and an empty line is added. I will add a snapshot from a generated report.
If the line is longer than the text field, the line is wrapped corrrectly. If the line is shorter than the length of the text field, the line is not wrapped which is also correct.
Definition of the text field in jrxml:
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement key="textField-25" positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="172" y="0" width="122" height="12" uuid="f5617e21-e2db-4ea7-9311-82c83805827f">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{Leistungsname}]]></textFieldExpression>
</textField>
4 Comments:
Hi,
This is most likely because you are not specifying any font to be used by the text fields in your report. Without specifying which font to use and by not making sure that font really exists on the machine that runs the report, you cannot pretent pixel-perfect quality of texts.
You need to use the fontName attribute in JRXML and point to a font that is available to JR as a font extension. Our samples show the used of fonts from font extensions and we even provide a jasperreports-fonts-x.x.x.jar download containing the DejaVu open souce fonts packaged as JR font extension.
I hope this helps.
Teodor
I added
fontName="SansSerif"
to the text field but it did not change.
In the jasperreports header I have defined styles for linux and windows, which I had already done previously:
<style name="FontWindows" fontName="SansSerif" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
<style name="FontLinux" fontName="SansSerif" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="UTF-8" isPdfEmbedded="true"/>
<style name="HeaderFontLinux" fontName="Serif" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="UTF-8" isPdfEmbedded="true"/>
<style name="ListFontLinux" fontName="Serif" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="UTF-8" isPdfEmbedded="true"/>
Obviously this does not help.
Next, I added to the report element the style option: style="FontLinux":
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-25" style="FontLinux" positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="170" y="0" width="124" height="12" uuid="f5617e21-e2db-4ea7-9311-82c83805827f">
This did not have any effect either.
It still works fine on Windows and does the early linebreak on Linux.
Hi,
SansSerif and Serif are Java virtual fonts, which map to different physical fonts on different platforms, thus having different font metrics. I suggest you use the same font for all systems and this is again achieved using font extension as I explained in my first reply. Please try use the DejaVu fonts we ship in a ready-to-use font extension. These are real fonts and would look the same on all systems.
With the use of font extensions, you only need to specify fontName attribute in your JRXML and forget about the pdfFontName, pdfEncoding and isPdfEmbedded, which are configurations present in the font extension configuration file itself.
Thanks,
Teodor