X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 02 Sep 2014 12:51 PM by  anon
Formatting of string in text()
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:25
New Member


--
02 Sep 2014 12:51 PM
    hello, I am having trouble formatting strings in the text() function. Maybe a bug, maybe I am just missing something. I have a hash where i want to format a string so "key : value" with each field the same size and the ":" line up. See code below. Now, the strlens are the same and when printed to the console, everything lines up. But not within the text() box on the image. Why not? Is the font scaleable or something? Am I missing something? Thanks data = orderedHash('file', 'filename', 'time', timestamp(), 'data type', 'XYZ') textList = list() foreach val, data, key do begin pString = string(key, format = '(A-10)')+": "+string(val, format='(A19)') ;pString = string(format='(%"%15s: %19s")', key, val) textList->add, pString print, pString print, strlen(pString) endforeach ; Just a graphics window for the text file = FILEPATH('nyny.dat', $ SUBDIRECTORY = ['examples', 'data']) nyny = READ_BINARY(file, DATA_DIMS = [768, 512]) im = IMAGE(nyny, RGB_TABLE=36) imgText = text(.5, .5, textList->toArray(), /fill_background, fill_color = 'white')

    Deleted User



    New Member


    Posts:81
    New Member


    --
    08 Sep 2014 07:39 PM
    Hi Paul, You can use a fixed width font like Courier to allow you to easily line up your characters. For example, if you add the following statements to your program then the fields and the ":" should line up: imgText.font_name='courier' imgText.font_size=10 Regards --Jim
    You are not authorized to post a reply.