Here are the steps to customize the script.
$ cd ~/.gimp.scripts $ cp /usr/share/gimp/scripts/beveled-button.scm foo-button.scm.orig $ cp foo-button.scm.orig foo-button.scm
Using a text editor like pico, edit foo-button.scm as follows: Change all occurrances of 'button00' to 'button01', and "beveled button" to "beveled button #2". This should affect three lines:
(define (script-fu-button00 textshould become
(define (script-fu-button01 textand
(script-fu-register "script-fu-button00" "should become/Xtns/Script-Fu/Buttons/Simple beveled button"
(script-fu-register "script-fu-button01" "Then write the file./Xtns/Script-Fu/Buttons/Simple beveled button #2"
(If you get any errors, stop and check the differences between your script and the original, with the command
$ diff foo-button.scm.orig foo-button.scmIt ought to match the changes listed above.)
SF-VALUE "Size" "16" SF-VALUE "Foundry" "\"adobe\"" SF-VALUE "Family" "\"helvetica\""to have the font size, foundry, and exact name that you chose in the section above. Save the file, and have Gimp refresh its scripts as above, then try out your new script. It should default to the right font now.
*** foo-button.old Sat Apr 3 12:58:16 1999 --- foo-button.scm Sat Apr 3 13:06:48 1999 *************** *** 50,55 **** --- 50,56 ---- y2)) (define (script-fu-button01 text + reftext size foundry family *************** *** 66,72 **** (let* ((old-fg-color (car (gimp-palette-get-foreground))) (old-bg-color (car (gimp-palette-get-background))) ! (text-extents (gimp-text-get-extents text size PIXELS foundry --- 67,73 ---- (let* ((old-fg-color (car (gimp-palette-get-foreground))) (old-bg-color (car (gimp-palette-get-background))) ! (text-extents (gimp-text-get-extents reftext size PIXELS foundry *************** *** 171,176 **** --- 172,178 ---- "Apr 1999" "" SF-VALUE "Text" "\"Hello world!\"" + SF-VALUE "Reftext" "\"This is how wide it is\"" SF-VALUE "Size" "16" SF-VALUE "Foundry" "\"adobe\"" SF-VALUE "Family" "\"helvetica\""Try out the new script (after doing the usual save and refresh). It should set the button to be as wide as the reference text; the other text field (cleverly named Text) is displayed at its normal width, but inside a wide button.
*** foo-button.old2 Sat Apr 3 13:06:48 1999 --- foo-button.scm Sat Apr 3 13:00:31 1999 *************** *** 67,72 **** --- 67,81 ---- (let* ((old-fg-color (car (gimp-palette-get-foreground))) (old-bg-color (car (gimp-palette-get-background))) + (real-text-extents (gimp-text-get-extents text + size + PIXELS + foundry + family + weight + slant + set-width + spacing)) (text-extents (gimp-text-get-extents reftext size PIXELS *************** *** 76,81 **** --- 85,94 ---- slant set-width spacing)) + (foo-width (text-width text-extents) ) + (foo-realwidth (text-width real-text-extents) ) + (foo-diff-x (- foo-width foo-realwidth ) ) + (foo-offset-x (/ foo-diff-x 2 ) ) (ascent (text-ascent text-extents)) (descent (text-descent text-extents)) *************** *** 151,157 **** (let ((textl (car (gimp-text img -1 0 0 text 0 TRUE size PIXELS foundry family weight slant set-width spacing)))) (gimp-layer-set-offsets textl ! (+ bevel-width padding) (+ bevel-width padding descent))) ; Done --- 164,170 ---- (let ((textl (car (gimp-text img -1 0 0 text 0 TRUE size PIXELS foundry family weight slant set-width spacing)))) (gimp-layer-set-offsets textl ! (+ (+ bevel-width padding) foo-offset-x) (+ bevel-width padding descent))) ; Done