diff --git a/devel-docs/GIMP3-plug-in-porting-guide/porting_scriptfu_scripts.md b/devel-docs/GIMP3-plug-in-porting-guide/porting_scriptfu_scripts.md index 8907059784..741c407637 100644 --- a/devel-docs/GIMP3-plug-in-porting-guide/porting_scriptfu_scripts.md +++ b/devel-docs/GIMP3-plug-in-porting-guide/porting_scriptfu_scripts.md @@ -28,6 +28,8 @@ This table summarizes the changes: | pass drawable | GimpDrawable | gint, GimpObjectArray | int (an ID) | int (a length) vector | | Pass obj array | gint, GimpInt32Array | gint, GimpObjectArray | int vector | int vector | | Recv obj array | gint, GimpInt32Array | gint, GimpObjectArray | int vector | int vector | +| Pass set of str | gint, GimpStringArray | GStrv | int list | list | +| Recv set of str | gint, GimpStringArray | GStrv | int list | list | (Where "obj" means an object of a GIMP type such as GimpDrawable or similar.) @@ -123,6 +125,21 @@ would print: Meaning a list length of zero, and an empty vector. (Since a new image has no layers.) +### Passing or receiving a set of strings + +Formerly, you passed an integer count of strings, and a list of strings. +Now you only pass the list. +ScriptFu converts to/from the C type GStrv +(which is an object knowing its own length.) +An example is the PDB procedure file-gih-save. + +Formerly, you received an integer count of strings, and a list of strings. +Now you only receive the list +(and subsequently get its length using "(length list)"). +Examples are the many PDB procedures whose name ends in "-list". +Remember that the result of a call to the PDB is a list of values, +in this case the result is a list containing a list, +and for example you get the list of strings like "(car (gimp-fonts-get-list ".*"))" ## Changes in error messages diff --git a/plug-ins/script-fu/scripts/font-map.scm b/plug-ins/script-fu/scripts/font-map.scm index 7481d28892..b3b64fe4b1 100644 --- a/plug-ins/script-fu/scripts/font-map.scm +++ b/plug-ins/script-fu/scripts/font-map.scm @@ -1,6 +1,14 @@ -;; font-select +;; font-map ;; Spencer Kimball +;; To test, open the Font tool dialog, +;; press right mouse button in the list of fonts, choose "Render Font Map" + +;; Test cases for font filter regex +;; ".*" expect render all installed fonts +;; "foo" expect render blank image (no matching fonts) +;; "Sans" expect render subset of installed fonts + (define (script-fu-font-map text use-name labels @@ -64,9 +72,10 @@ ) (let* ( - (font-data (gimp-fonts-get-list font-filter)) - (font-list (cadr font-data)) - (num-fonts (car font-data)) + ; gimp-fonts-get-list returns a one element list of results, + ; the only element is itself a list of fonts, possibly empty. + (font-list (car (gimp-fonts-get-list font-filter))) + (num-fonts (length font-list)) (label-size (/ font-size 2)) (border (+ border (* labels (/ label-size 2)))) (y border)