kpuchalski / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

getStringWidth() logic errorious/not correct #254

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Define a core font
2. Create a cell, pass some chars including an undefined char to it (abÖm) and 
align the cell on the right side

What is the expected output? What do you see instead?
I expect a right aligned output of all characters.
The chars are not aligned correctly.

What version of the product are you using? On what operating system?
I'm using 0.1.5Beta but it seems to be the same code as in the current SVN.

Please provide any additional information below.
This issue covers 2 possible bugs:
1) The logic of getStringWidth():

while (l--) 
{   
    cwAux += charactersWidth[content.charAt(l)] as int;

    if ( cwAux == 0 ) // <--- this will only arise if the char is the last one
        cwAux = FontMetrics.DEFAULT_WIDTH;
}

It should be something like:
while (l--) 
{   
    cw = charactersWidth[content.charAt(l)] as int;

    if ( cw == 0 ) 
        cw = FontMetrics.DEFAULT_WIDTH;

    cwAux += cw;
}

Anyhow... Bug no 2: I'm wondering why the "Ö" is missing in the characterWidth 
array. It's normally covered by cp1252 and also included in the core fonts.

Thanks!
Jan

Original issue reported on code.google.com by jan.sla...@googlemail.com on 23 Jun 2010 at 9:51

GoogleCodeExporter commented 9 years ago
Bug #1 reported in this issue is fixed in latest.

Original comment by cgauth...@gmail.com on 27 Feb 2015 at 4:00