|
Post by SunBurnt on Sept 9, 2012 6:57:27 GMT 1
The usual font selector dialogs are not very user friendly. I dislike having to click through the fonts over and over to see them.
All this needs is the addition of a font size selector. # What happens if the font does not have the chosen size?
INCLUDE "/usr/share/BaCon/hug_imports.bac" INIT ' std. array for button IDs GLOBAL id_[60] TYPE int ' array for button indexes GLOBAL btns ASSOC int ' std. array for fonts GLOBAL Fonts$[60] TYPE STRING ' put system fonts in array fc$ = EXEC$("fc-list |cut -d',' -f1 |sort") SPLIT fc$ BY NL$ TO FontLst$ SIZE size ' get column split col = size / 2 H = col*25 ' text to display font text$ = "abcdefgABCDEFG0123456789.?%=+-*_"
win_ = WINDOW(" Font Selector", 1200, H) ' cancel button SUB CANCEL() END END SUB ' font button click event SUB CLICK(int widget) PRINT Fonts$[btns(STR$(widget))] END END SUB
i = 0 FOR X = 0 TO 600 STEP 600 FOR Y = 0 TO col IF FontLst$[i] = "" THEN BREAK SPLIT FontLst$[i] BY ":" TO Font$ SIZE sz style$ = RIGHT$(Font$[1], LEN(Font$[1])-6) Fonts$[i] = CONCAT$(Font$[0], " ", style$)
id_[i] = MARK(text$, 300, 25) ATTACH(win_, id_[i], X+300, Y*25) FONT(id_[i], Fonts$[i])
id_[i] = BUTTON(Fonts$[i], 300, 25) ATTACH(win_, id_[i], X, Y*25) CALLBACK(id_[i], CLICK)
btns(STR$(id_[i])) = i INCR i NEXT NEXT
cancel_ = BUTTON("Cancel", 100, 25) ATTACH(win_, cancel_, 1100, H-25) : CALLBACK(cancel_, CANCEL)
DISPLAY
|
|
|
Post by vovchik on Sept 9, 2012 12:35:38 GMT 1
Dear Terry,
Nice, but I had some problems with fonts that had foreign language descriptions. This all can be fixed, I think, by changing:
fc$ = EXEC$("fc-list |sort") with this:
fc$ = EXEC$("fc-list | cut -d',' -f1 | sort -i ")
With kind regards, vovchik
|
|
|
Post by SunBurnt on Sept 9, 2012 20:50:02 GMT 1
Many thanks again vovchik, there`s always one more detail to address...
I modified the code with your fix. Terry B.
|
|
|
Post by elvishholic on Sept 25, 2012 21:16:31 GMT 1
Hello friends,
Thanks for sharing your information, Really I am highly appreciated here.
Best regards Elvish Holic
|
|