Gimp/plug-ins/script-fu/scripts/font-map.scm

147 lines
3.8 KiB
Scheme
Raw Normal View History

1997-11-24 14:05:25 -08:00
;; font-select
;; Spencer Kimball
(define (max-font-width text use-name font-list font-size)
(let* ((list font-list)
(width 0)
1997-11-24 14:05:25 -08:00
(maxwidth 0)
(font "")
(extents '()))
1997-11-24 14:05:25 -08:00
(while list
(set! font (car list))
(set! list (cdr list))
(if (= use-name TRUE)
(set! text font))
(set! extents (gimp-text-get-extents-fontname text
font-size PIXELS
font))
1997-11-24 14:05:25 -08:00
(set! width (nth 0 extents))
(if (> width maxwidth)
(set! maxwidth width)))
1997-11-24 14:05:25 -08:00
maxwidth))
(define (max-font-height text use-name font-list font-size)
(let* ((list font-list)
(height 0)
1997-11-24 14:05:25 -08:00
(maxheight 0)
(font "")
(extents '()))
1997-11-24 14:05:25 -08:00
(while list
(set! font (car list))
(set! list (cdr list))
(if (= use-name TRUE)
(set! text font))
(set! extents (gimp-text-get-extents-fontname text
font-size PIXELS
font))
1997-11-24 14:05:25 -08:00
(set! height (nth 1 extents))
(if (> height maxheight)
(set! maxheight height)))
1997-11-24 14:05:25 -08:00
maxheight))
(define (script-fu-font-map text
use-name
labels
font-filter
font-size
border
colors)
(let* ((font "")
(count 0)
(font-list (cadr (gimp-fonts-get-list font-filter)))
(num-fonts (length 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)
1999-10-16 17:07:55 -07:00
(gimp-image-undo-disable img)
(if (= colors 0)
(begin
tools/pdbgen/Makefile.am tools/pdbgen/groups.pl removed the "Palette" pdb 2004-09-22 Michael Natterer <mitch@gimp.org> * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/palette.pdb: removed the "Palette" pdb group... * tools/pdbgen/pdb/context.pdb: and added its functions to the "Context" namespace instead. * app/pdb/Makefile.am * app/pdb/palette_cmds.c: removed. * app/pdb/procedural_db.c: added them to the pdb_compat hash table. * libgimp/Makefile.am * libgimp/gimppalette_pdb.[ch]: removed. * libgimp/gimppalette.[ch]: new files holding compat functions which call gimp_context_*() functions. * libgimp/gimp.h * libgimp/gimpui.c: changed accordingly. * app/pdb/context_cmds.c * app/pdb/internal_procs.c * libgimp/gimp_pdb.h * libgimp/gimpcontext_pdb.[ch]: regenerated. * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/mng.c * plug-ins/common/mosaic.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gfig/gfig-style.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/pagecurl/pagecurl.c * plug-ins/pygimp/gimpmodule.c * plug-ins/script-fu/scripts/*.scm: changed accordingly.
2004-09-22 11:43:09 -07:00
(gimp-context-set-background '(255 255 255))
(gimp-context-set-foreground '(0 0 0))))
1997-11-24 14:05:25 -08:00
(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)
1997-11-24 14:05:25 -08:00
(while font-list
(set! font (car font-list))
(set! font-list (cdr font-list))
(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)))
1997-11-24 14:05:25 -08:00
(gimp-image-set-active-layer img drawable)
1999-10-16 17:07:55 -07:00
(gimp-image-undo-enable img)
(gimp-display-new img)
(gimp-context-pop)))
1997-11-24 14:05:25 -08:00
(script-fu-register "script-fu-font-map"
_"_Font Map..."
"Generate a listing of fonts matching a filter"
1997-11-24 14:05:25 -08:00
"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"
_"<Toolbox>/Xtns/Script-Fu/Utils")