Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Justification/Character width size

squall leonhart

2007-09-03



Hello,

With Courier font i can get the text alignment properly. For example i can
fix one line with 12 characters and it was align perfectly.

But if i use other font (in my case ST-Song) it will not align correctly.
Spaces will take less space and each character have it's own width size.

How can i set ST-Song font behave the same like Courier in term of character
width size.

I can set the character width using below code for Courier but not for
ST-Song

//Working
Font FontCourier = new Font(Font.COURIER);
FontCourier.setSize(12f);
BaseFont bfChinese = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252,
BaseFont.EMBEDDED);
     
int[] widths = bfChinese.getWidths();
for (int k = 0; k < widths.length; ++k) {
 if (widths[k] != 0)
 widths[k] = 1000;
}
bfChinese.setForceWidthsOutput(true);      
Font FontChinese = new Font(bfChinese, 12, Font.NORMAL);

//NOT WORKING
BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H",
BaseFont.NOT_EMBEDDED);
     
int[] widths = bfChinese.getWidths();
for (int k = 0; k < widths.length; ++k) {
 if (widths[k] != 0)
 widths[k] = 1000000;
}
bfChinese.setForceWidthsOutput(true);      
Font FontChinese = new Font(bfChinese, 12, Font.NORMAL);

Thank you.

Regards,
Squall
--
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.