Formatting plugin output text into columns

Discussion in 'Plugin Development' started by ddj, Mar 14, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    ddj

    I am pretty sure I have read something about this previously, but cannot remember where.

    Would really like it, if I can output my text into nice columns; tried it with space filled strings, but they dont do the job, since the default output is a truetype font.

    Can anybody advice me on the best approach, or even better, provide me with a method that does this?
     
  2. Offline

    Plague

    I don't think the client chat supports tabs for that, so is there even a way?
     
  3. Offline

    ddj

    If there is, I will find it, but I cannot think of a way to do it, that why I was asking:)
     
  4. Offline

    Edward Hand

    Well, you could measure the width of every letter in the font pack and work out how many spaces you need to get everything lined up...
     
  5. Offline

    Sammy

    I saw someone doing a plugin for this some time ago, I don't remember if it was still on hmod or in bukkit...
    Still, I think that the general idea was like Edward suggested.
    I'm going to try to find it :)
     
  6. Offline

    Plague

    But you will stil be limited by the size of a space character so it will still not line up everytime.
     
  7. Offline

    Sammy

    Maybe is was a clientside mod ? now I'm confused, tomorrow I'll look into' it...
     
  8. Offline

    Plague

    Yes clientside mod changing the font to a fixed-width one would work.
     
  9. Offline

    ddj

    I think that was what I remembered then, this client mod.
    Really dont like these, so guess I am diving into the font thing.
    Thanks for the replies!
     
  10. Offline

    Edward Hand

    I remembered seeing some code in one of the client's rendering classes that calculated out the pixel width of the characters in the font file ages and ages ago. I tracked it down, and a few script injections later I managed to get it to spit out this:

    (see attached file)

    The file shows all the characters that you can print to the screen (including a few you might not have been aware of) along with the pixel width it will display them with. There's no extra per-character padding on top of those sizes or anything so you should be able to use them directly. I formatted so that it should be easy to just load the file into your plugin in and parse it if you want.

    And as you can see, @Plague was right. A space is 4 pixels wide, so slightly limiting.
     

    Attached Files:

    Amirs11 likes this.
  11. Offline

    Sammy

    Awesome info Edward, this would be a great tool for making a table based material list, still, bigger words would screw up the table...
    @ddj You and me both... using a clientside mod for this would be non-sence ^^

     
  12. Offline

    ddj

    Thanks Edward!

    This saves me from taking a crash-course on the fonts:)

    To bad also this solution is never gonna be perfect, but perfect enough for my needs.
     
  13. Offline

    cwingrav

    Since I can't see attached file... (this was returned by Spout's GenericLabel.getCharacterWidth on the ASCII characters starting with space):
    : 4
    !: 2
    ": 5
    #: 6
    $: 6
    %: 6
    &: 6
    ': 3
    :) 5
    ): 5
    *: 5
    +: 6
    ,: 2
    -: 6
    .: 2
    /: 6
    0: 6
    1: 6
    2: 6
    3: 6
    4: 6
    5: 6
    6: 6
    7: 6
    8: 6
    9: 6
    :: 2
    ;: 2
    <: 5
    =: 6
    >: 5
    ?: 6
    @: 7
    A: 6
    B: 6
    C: 6
    D: 6
    E: 6
    F: 6
    G: 6
    H: 6
    I: 4
    J: 6
    K: 6
    L: 6
    M: 6
    N: 6
    O: 6
    P: 6
    Q: 6
    R: 6
    S: 6
    T: 6
    U: 6
    V: 6
    W: 6
    X: 6
    Y: 6
    Z: 6
    [: 4
    \: 6
    ]: 4
    ^: 6
    _: 6
    `: 0
    a: 6
    b: 6
    c: 6
    d: 6
    e: 6
    f: 5
    g: 6
    h: 6
    i: 2
    j: 6
    k: 5
    l: 3
    m: 6
    n: 6
    o: 6
    p: 6
    q: 6
    r: 6
    s: 6
    t: 4
    u: 6
    v: 6
    w: 6
    x: 6
    y: 6
    z: 6
    {: 5
    |: 2
    }: 5
    ~: 7
     
Thread Status:
Not open for further replies.

Share This Page