New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Column width calculation #27

Closed
jkyeung opened this Issue Jun 26, 2013 · 1 comment

Comments

2 participants
@jkyeung
Contributor

jkyeung commented Jun 26, 2013

Minor bug, but still a bug, and easily fixable: The width conversion in _write_col_info currently gets widths less than one grossly wrong (by percentage), and widths greater than one occasionally off by a pixel. Instead of

    # Convert column width from user units to character width.
    if width > 0:
        # For Calabri 11.
        max_digit_width = 7
        padding = 5
        width = int((float(width) * max_digit_width + padding)
                    / max_digit_width * 256.0) / 256.0

it should really just use the pixel calculation from _size_col and divide by 7.0. For example:

    # Convert column width from user units to character width.
    if width > 0:
        # For Calabri 11.
        max_digit_width = 7
        padding = 5

        if width < 1:
            pixels = int(width * 12 + 0.5)
        else:
            pixels = int(width * max_digit_width + 0.5) + padding
        width = float(pixels) / max_digit_width

(I would have gone for pixels / 7.0 myself. If you're serious about using your named values instead of magic numbers, maybe 12 should be replaced by (max_digit_width + padding).)

@ghost ghost assigned jmcnamara Jun 26, 2013

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Jun 26, 2013

Owner

Hi John,

Thanks for that. There were a couple of issues there.

I'll push a fix and some tests shortly.

Thanks for the input.

John

Owner

jmcnamara commented Jun 26, 2013

Hi John,

Thanks for that. There were a couple of issues there.

I'll push a fix and some tests shortly.

Thanks for the input.

John

@jmcnamara jmcnamara closed this in 8d90277 Jun 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment