GIMP-Xyzzy for generating Salahzar's UTF-8 special fonts
Data pubblicazione: 1-giu-2008 14.18.00
Eventually I succeeded in generating fonts with gimp.
Here is the script-fu program (call with your font and 45 points font size when asked from GIMP and save then as .tga.
You must save it under .gimp-xxxx/script with .scm extension
It will generate a white font 512x1024 with transparent background.
rows must be updated with your UNICODE characters and attached the tga produced.
This must be used with Xyzzy v3.0
Major modification on master/slave xyzzy standard text rely mainly in the following code blocks:
ResetCharIndex() {
gCharIndex = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`";
gCharIndex += "abcdefghijklmnopqrstuvwxyz{|}~\n\n\n\n\n";
// special UTF-8 chars for European languages
// these 80 chars correspond to the following chars in CP850 codepage: (some are not viewable in editor)
// Ç ü é â ä à å ç ê ë
decode= [ "%C3%87", "%C3%BC", "%C3%A9", "%C3%A2", "%C3%A4", "%C3%A0", "%C3%A5", "%C3%A7", "%C3%AA", "%C3%AB",
// è ï î ì Ä Å É æ Æ BLACK RIGHT-POINTING TRIANGLE
"%C3%A8", "%C3%AF", "%C3%AE", "%C3%AC", "%C3%84", "%C3%85", "%C3%89", "%C3%A6", "%C3%AE", "%E2%96%B6",
// ö ò û ù ÿ Ö Ü ¢ £ ¥
"%C3%B6", "%C3%B2", "%C3%BB", "%C3%B9", "%C3%BF", "%C3%96", "%C3%9C", "%C2%A2", "%C2%A3", "%C2%A5",
// A^ copyright á í ó ú ñ Ñ ª º"
"%C3%82", "%C2%A9", "%C3%A1", "%C3%AD", "%C3%B3", "%C3%BA", "%C3%B1", "%C3%91", "%C2%AA", "%C2%BA",
// ¿ O^ ¬ ½ ¼ ¡ « » alfa ß"
"%C2%BF", "%C3%94", "%C2%AC", "%C2%BD", "%C2%BC", "%C2%A1", "%C2%AB", "%C2%BB", "%CE%B1", "%C3%9F",
// gamma pi bigsigma smsigma mu
"%CE%93", "%CF%80", "%CE%A3", "%CF%83", "%C2%B5" ];
// tau BIGfi theta omega delta
decode=(decode=[])+decode+ [ "%CF%84", "%CE%A6", "%CE%98", "%CE%A9", "%CE%B4",
// INFINITE FI EPS INTERS 3bars +- <= >= INTEGRUP INTEGRDOWN
"%E2%88%9E", "%CF%86", "%CE%B5", "%E2%88%A9", "%E2%89%A1", "%C2%B1", "%E2%89%A5", "%E2%89%A4", "%E2%8C%A0", "%E2%8C%A1",
// :- ~~ DEGREE E^ I^ o^ U^ sq euro ????
"%C3%B7", "%E2%89%88", "%C2%B0", "%C3%8A", "%C3%8E", "%C3%B4", "%C3%9B", "%C2%B2", "%E2%82%AC", "" ];
}
vector GetGridOffset(integer index) {
// Calculate the offset needed to display this character.
integer Row = index / 10;
integer Col = index % 10;
// Return the offset in the texture.
//return <-0.45 + 0.1 * Col, 0.45 - 0.1 * Row, 0.0>;
return <-0.45 + 0.1 * Col, 0.428 - 0.05 * Row, 0.0>;
}
While the script-fu script is the following:
(define (script-fu-xytext inText inFont inFontSize inTextColor)
(let*
(
; define our local variables
; create a new image:
(theImageWidth 512)
(theImageHeight 1024)
(theImage)
(theLayer )
(x 0)
(y 0)
(p 32)
(theText)
(rows #(
" " ; first row blank to be compatible with previous script here additional chars might be put
" !\"#$%&'()"
"*+,-./0123"
"456789:;<="
">?@ABCDEFG"
"HIJKLMNOPQ"
"RSTUVWXYZ["
"\\]^_`abcde"
"fghijklmno"
"pqrstuvwxy"
(list #\z #\{ #\| #\} #\~ #x387 #x3F4 #x3A9r #x221A #x387 ) ;"z{|}~·thetaOmegaRadix.o "
(list #xC7, #xFC, #xE9, #xE2, #xE4, #xE0, #xE5, #xE7, #xEA, #xEB) ;"Çüéâäàåçêë"
(list #xE8, #xEF, #xEE, #xEC, #xC4, #xC5, #xC9, #xE6, #xC6, #x25B6);"èïîìÄÅÉæÆ?"
(list #xF6, #xF2, #xFB, #xF9, #xFF, #xD6, #xDC, #xA2, #xA3, #xA5);"öòûùÿÖÜ¢£¥"
(list #xC2, #xAE, #xE1, #xED, #xF3, #xFA, #xF1, #xD1, #xAA, #xBA);"PƒáíóúñѪº"
(list #xBF, #xD4, #xAC, #xBD, #xBC, #xA1, #xAB, #xBB, #x3B1, #x3B2);"¿¬¬½¼¡«»aß"
(list #x3B3, #x3C0, #x3A3, #x3C3, #x3BC, #x3C4, #x3D5, #x3B8, #x3A9, #x3B4);"GpSsµtFTOd"
(list #x221E, #x3C6, #x3B5, #x2252, #x2261, #xB1, #x2264, #x2265, #x2320, #x2321);"inf.fen=±==()"
(list #xF7, #x2248, #xB0, #xCA, #xCE, #xF4, #xDB, #xB2, #x20AC, #x387);"÷˜°··vn²€ "))
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
" "
))
(el)(ch)
) ;end of our local variables
; builds image
(set! theImage (car (gimp-image-new theImageWidth theImageHeight RGB)))
; builds layer
(set! theLayer (car (gimp-layer-new theImage theImageWidth theImageHeight RGB-IMAGE "layer 1" 100 NORMAL) ) )
; add layer to image
(gimp-image-add-layer theImage theLayer 0)
; add alpha and set foreground
(gimp-layer-add-alpha theLayer)
(gimp-palette-set-foreground inTextColor)
; clear all the image and remove selection
(gimp-selection-all theImage)
(gimp-edit-clear theLayer)
(gimp-selection-none theImage)
; do actual plot of characters
(while (< x 20)
(while (< y 10)
(set! el (vector-ref rows x))
(set! ch (if (string? el) (substring el y (+ y 1)) (list-ref el (+ y 1))))
(if (integer? ch) (set! ch (integer->char ch)))
(if (char? ch)(set! ch (string ch)))
(set! p ch)
;(set! p (string (integer->char #x221A)))
(set! theText (car (gimp-text-fontname theImage theLayer
(+ (* y 51.2) 12) (- (* x 51.2) 5)
p 0 TRUE
inFontSize PIXELS
inFont)))
; go on next char
;(set! p (+ p 1))
(set! y (+ y 1))
)
(set! y 0)
(set! x (+ x 1))
)
; apply the layers (apply transparence
(gimp-image-merge-visible-layers theImage 0)
(gimp-display-new theImage)
))
(script-fu-register
"script-fu-xytext" ;func name
"XYText" ;menu label
"Generate font for xytext" ;description
"Salahzar Stenvaag" ;author
"copyright 2008, Salahzar Stenvaag" ;copyright notice
"October 27, 1997" ;date created
"" ;image type that the script works on
SF-STRING "Text:" "Text Box" ;a string variable
SF-FONT "Font:" "Andale Mono" ;a fixed font variable
SF-ADJUSTMENT "Font size" '(50 1 1000 1 10 0 1)
;a spin-button
SF-COLOR "Color:" '(255 255 255) ;color variable
)
(script-fu-menu-register "script-fu-xytext" "<Toolbox>/Xtns/Script-Fu/Text")
When launching the script-fu select a mono type with 45 points and save then as tga for transparence.