
2006-10-15 Kevin Cozens <kcozens@cvs.gnome.org> With this commit we finally say goodbye to SIOD. This large set of changes updates the Script-Fu plug-in to use the TinyScheme Scheme interpreter. These changes originated with changes originally made to Script-Fu which created Tiny-Fu (aka. the gimp-tiny-fu module). * plug-ins/script-fu/Makefile.am * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-interface.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-scripts.h * plug-ins/script-fu/script-fu-server.c * plug-ins/script-fu/script-fu-text-console.c * plug-ins/script-fu/script-fu.c: Updated with the changes made to these files as part of the work on the Tiny-Fu project. * plug-ins/script-fu/scheme-wrapper.c * plug-ins/script-fu/scheme-wrapper.h: Renamed from siod-wrapper.[ch] and updated based on differences to ts-wrapper.[ch] from gimp-tiny-fu. * plug-ins/script-fu/ftx/* * plug-ins/script-fu/re/* * plug-ins/script-fu/tinyscheme/* * plug-ins/script-fu/scripts/script-fu.init * plug-ins/script-fu/scripts/script-fu-compat.init * plug-ins/script-fu/scripts/contactsheet.scm * plug-ins/script-fu/scripts/script-fu-set-cmap.scm * plug-ins/script-fu/scripts/script-fu-util-setpt.scm * plug-ins/script-fu/scripts/ts-helloworld.scm: Added all of these files and directories from Tiny-Fu. Updated the Makefile.am files of ftx, re, and tinyscheme now they are in the GIMP source tree. * plug-ins/script-fu/scripts/*.scm: All scripts have been updated as needed to ensure they will work with the TinyScheme interpreter. Most of the files have been reformatted making it easier to see the syntax of Scheme and making them easier to read. * plug-ins/script-fu/scripts/Makefile.am: Updated script file lists. * plug-ins/script-fu/siod-wrapper.c * plug-ins/script-fu/siod-wrapper.h * plug-ins/script-fu/siod/*: Removed obsolete files. * configure.in: Updated list of files in AC_CONFIG_FILES. Changed --disable-script-fu to --without-script-fu which it should have been when originally added. * INSTALL: Updated to show change to --without-script-fu.
171 lines
5.4 KiB
Scheme
171 lines
5.4 KiB
Scheme
;; font-select
|
|
;; Spencer Kimball
|
|
|
|
(define (script-fu-font-map text
|
|
use-name
|
|
labels
|
|
font-filter
|
|
font-size
|
|
border
|
|
colors)
|
|
|
|
(define (max-font-width text use-name font-list font-size)
|
|
(let* ((list (cadr font-list))
|
|
(list-cnt (car font-list))
|
|
(count 0)
|
|
(width 0)
|
|
(maxwidth 0)
|
|
(font "")
|
|
(extents '()))
|
|
(while (< count list-cnt)
|
|
(set! font (aref list count))
|
|
|
|
(if (= use-name TRUE)
|
|
(set! text font))
|
|
(set! extents (gimp-text-get-extents-fontname text
|
|
font-size PIXELS
|
|
font))
|
|
(set! width (car extents))
|
|
(if (> width maxwidth)
|
|
(set! maxwidth width))
|
|
|
|
(set! count (+ count 1))
|
|
)
|
|
|
|
maxwidth
|
|
)
|
|
)
|
|
|
|
(define (max-font-height text use-name font-list font-size)
|
|
(let* ((list (cadr font-list))
|
|
(list-cnt (car font-list))
|
|
(count 0)
|
|
(height 0)
|
|
(maxheight 0)
|
|
(font "")
|
|
(extents '()))
|
|
(while (< count list-cnt)
|
|
(set! font (aref list count))
|
|
|
|
(if (= use-name TRUE)
|
|
(set! text font)
|
|
)
|
|
(set! extents (gimp-text-get-extents-fontname text
|
|
font-size PIXELS
|
|
font))
|
|
(set! height (cadr extents))
|
|
(if (> height maxheight)
|
|
(set! maxheight height)
|
|
)
|
|
|
|
(set! count (+ count 1))
|
|
)
|
|
|
|
maxheight
|
|
)
|
|
)
|
|
|
|
(let* (
|
|
(font "")
|
|
(count 0)
|
|
(font-list (gimp-fonts-get-list font-filter))
|
|
(num-fonts (car font-list))
|
|
(label-size (/ font-size 2))
|
|
(border (+ border (* labels (/ label-size 2))))
|
|
(y border)
|
|
(maxheight (max-font-height text use-name font-list font-size))
|
|
(maxwidth (max-font-width text use-name font-list font-size))
|
|
(width (+ maxwidth (* 2 border)))
|
|
(height (+ (+ (* maxheight num-fonts) (* 2 border))
|
|
(* labels (* label-size num-fonts))))
|
|
(img (car (gimp-image-new width height (if (= colors 0)
|
|
GRAY RGB))))
|
|
(drawable (car (gimp-layer-new img width height (if (= colors 0)
|
|
GRAY-IMAGE RGB-IMAGE)
|
|
"Background" 100 NORMAL-MODE)))
|
|
)
|
|
|
|
(gimp-context-push)
|
|
|
|
(gimp-image-undo-disable img)
|
|
|
|
(set! font-list (cadr font-list))
|
|
|
|
(if (= colors 0)
|
|
(begin
|
|
(gimp-context-set-background '(255 255 255))
|
|
(gimp-context-set-foreground '(0 0 0))))
|
|
|
|
(gimp-image-add-layer img drawable 0)
|
|
(gimp-edit-clear drawable)
|
|
|
|
(if (= labels TRUE)
|
|
(begin
|
|
(set! drawable (car (gimp-layer-new img width height
|
|
(if (= colors 0)
|
|
GRAYA-IMAGE RGBA-IMAGE)
|
|
"Labels" 100 NORMAL-MODE)))
|
|
(gimp-image-add-layer img drawable -1)))
|
|
(gimp-edit-clear drawable)
|
|
|
|
(while (< count num-fonts)
|
|
(set! font (aref font-list count))
|
|
|
|
(if (= use-name TRUE)
|
|
(set! text font))
|
|
|
|
(gimp-text-fontname img -1
|
|
border
|
|
y
|
|
text
|
|
0 TRUE font-size PIXELS
|
|
font)
|
|
|
|
(set! y (+ y maxheight))
|
|
|
|
(if (= labels TRUE)
|
|
(begin
|
|
(gimp-floating-sel-anchor (car (gimp-text-fontname img drawable
|
|
(- border
|
|
(/ label-size 2))
|
|
(- y
|
|
(/ label-size 2))
|
|
font
|
|
0 TRUE
|
|
label-size PIXELS
|
|
"Sans")))
|
|
(set! y (+ y label-size))
|
|
)
|
|
)
|
|
|
|
(set! count (+ count 1))
|
|
)
|
|
|
|
(gimp-image-set-active-layer img drawable)
|
|
|
|
(gimp-image-undo-enable img)
|
|
(gimp-display-new img)
|
|
|
|
(gimp-context-pop)
|
|
)
|
|
)
|
|
|
|
(script-fu-register "script-fu-font-map"
|
|
_"Render _Font Map..."
|
|
_"Create an image filled with previews of fonts matching a fontname filter"
|
|
"Spencer Kimball"
|
|
"Spencer Kimball"
|
|
"1997"
|
|
""
|
|
SF-STRING _"_Text" "How quickly daft jumping zebras vex."
|
|
SF-TOGGLE _"Use font _name as text" FALSE
|
|
SF-TOGGLE _"_Labels" TRUE
|
|
SF-STRING _"_Filter (regexp)" "Sans"
|
|
SF-ADJUSTMENT _"Font _size (pixels)" '(32 2 1000 1 10 0 1)
|
|
SF-ADJUSTMENT _"_Border (pixels)" '(10 0 200 1 10 0 1)
|
|
SF-OPTION _"_Color scheme" '(_"Black on white" _"Active colors")
|
|
)
|
|
|
|
(script-fu-menu-register "script-fu-font-map"
|
|
"<Fonts>")
|