DevelopperTools: render-sfont22.scm

Line 
1 ;
2 ; SFont Renderer
3 ;
4 ; Render a font to be used with the SFont library
5 ;
6 ; Written by Mike Oliphant (http://nostatic.org)
7 ; Based on other logo examples that came with the gimp
8 ;
9
10 ; Modified  by  fraca7@free.fr  on   may  21  2006:  render  the  full
11 ; ISO-8859-1 character set
12
13 (define (apply-create-sfont-effect img
14                                    logo-layer
15                                    top-color
16                                    bottom-color
17                                    do-bumpmap)
18   (let* ((width (car (gimp-drawable-width logo-layer)))
19          (height (car (gimp-drawable-height logo-layer)))
20          (shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Shadow" 100 MULTIPLY)))
21          (old-fg (car (gimp-palette-get-foreground)))
22          (old-bg (car (gimp-palette-get-background))))
23     (gimp-selection-none img)
24                                         ;    (script-fu-util-image-resize-from-layer img logo-layer)
25     (gimp-image-resize img width height 0 0)
26     (gimp-image-add-layer img shadow-layer 1)
27     (gimp-palette-set-foreground '(0 0 0))
28     (gimp-layer-set-preserve-trans logo-layer 100)
29     (gimp-edit-fill logo-layer FOREGROUND-FILL)
30     (gimp-edit-clear shadow-layer)
31     (gimp-selection-layer-alpha logo-layer)
32     (gimp-context-set-background '(0 0 0))
33     (gimp-selection-grow img 1)
34     (gimp-edit-fill shadow-layer BACKGROUND-FILL)
35     (gimp-selection-none img)
36     (gimp-context-set-foreground top-color)
37     (gimp-context-set-background bottom-color)
38     (gimp-edit-blend logo-layer FG-BG-RGB-MODE NORMAL-MODE GRADIENT-LINEAR 100 20 REPEAT-NONE FALSE FALSE 0 0 FALSE (/ width 2) 0 (/ width 2) height)
39
40     (gimp-layer-set-preserve-trans logo-layer 0)
41
42     (if (= do-bumpmap TRUE)
43         (plug-in-bump-map 1 img logo-layer logo-layer 115 40 1 0 0 0 15
44                           TRUE FALSE 0))
45
46     (gimp-context-set-background old-bg)
47     (gimp-context-set-foreground old-fg)))
48
49 (define (script-fu-render-sfont size
50                                 font
51                                 top-color
52                                 bottom-color
53                                 do-bumpmap)
54   (let* ((text  "! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ ¡ ¢ £ € Â¥ Š § š © ª « ¬ ­ ® ¯ ° ± ² ³ ÂŽ µ ¶ · ž ¹ º » ÂŒ œ Ÿ ¿ À Á Â Ã Ä Ã
55  Ã† Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã À Ã¥ Ê ç Ú é ê ë ì í î ï ð ñ ò ó ÃŽ õ ö ÷ Þ ù ú û ÃŒ Ü ß ÿ")
56          (img (car (gimp-image-new 256 256 RGB)))
57          (extents (gimp-text-get-extents-fontname text size PIXELS font))
58          (descent (cadr (cddr extents)))
59          (text-layer (car (gimp-text-fontname img -1 0 0 text 2 TRUE size PIXELS font)))
60          (width (car (gimp-drawable-width text-layer)))
61          (height (car (gimp-drawable-height text-layer))))
62     (gimp-image-undo-disable img)
63     (gimp-layer-set-name text-layer "font")
64     (gimp-layer-resize text-layer width (+ height descent) 0 descent)
65     (gimp-layer-set-offsets text-layer 0 0)
66     (apply-create-sfont-effect img text-layer top-color bottom-color
67                                do-bumpmap)
68     (gimp-image-undo-enable img)
69     (gimp-display-new img)))
70
71 (script-fu-register "script-fu-render-sfont"
72                     _"<Toolbox>/Xtns/Script-Fu/SFont/Create SFont"
73                     "Creates font for use with the SFont library"
74                     "Mike Oliphant"
75                     "Mike Oliphant"
76                     "2004"
77                     ""
78                     SF-ADJUSTMENT _"Font Size (pixels)" '(28 2 1000 1 10 0 1)
79                     SF-FONT       _"Font" "Sans"
80                     SF-COLOR      _"Top Color" '(16 23 229)
81                     SF-COLOR      _"Bottom Color" '(156 241 244)
82                     SF-TOGGLE     _"Apply 3D effect" TRUE)