From 8d2e83dd652ed74f6e59ab5de237d2549c4000dc Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Fri, 9 Jul 2021 20:00:02 +0200 Subject: Let the config have all the styling --- glyphs/en.scm | 17 +++++++++++++++-- stickers.scm | 55 +++++++++++++++++-------------------------------------- 2 files changed, 32 insertions(+), 40 deletions(-) diff --git a/glyphs/en.scm b/glyphs/en.scm index c84dc2c..255bf2e 100644 --- a/glyphs/en.scm +++ b/glyphs/en.scm @@ -12,5 +12,18 @@ ;(define fn '("Fn")) (define fn-keys (string->list "")) -;(define extra-sybols (string->list "☠⌨☭☮☢☣☥⚓")) -(define extra-sybols (string->list "☠⌨⌨☮☢☣☥")) +;(define extra-symbols (string->list "☠⌨☭☮☢☣☥⚓")) +(define extra-symbols (string->list "☠⌨⌨☮☢☣☥")) + +(define glyphs + (concatenate + (list + (map (lambda (l) (glyph l "6" "white" "none")) letters) + (map (lambda (l) (glyph l "6" "lightgreen" "none")) symbols) + (map (lambda (l) (glyph l "6" "white" "none")) key-symbols) + (map (lambda (l) (glyph l "6" "white" "none")) numbers) + (map (lambda (l) (glyph l "3" "white" "italic")) modifiers) + (map (lambda (l) (glyph l "6" "red" "none")) brackets) + (map (lambda (l) (glyph l "6" "steelblue" "none")) fn-keys) + (map (lambda (l) (glyph l "6" "white" "none")) extra-symbols) + (map (lambda (l) (glyph l "6" "white" "none")) punct)))) diff --git a/stickers.scm b/stickers.scm index cdc70f7..05a22a0 100644 --- a/stickers.scm +++ b/stickers.scm @@ -3,8 +3,17 @@ (chibi string) (chibi sxml) (srfi 1) + (srfi 9) (srfi 41)) +(define-record-type :glyph + (glyph char size color style) + glyph? + (char glyph-char glyph-set-char!) + (size glyph-size glyph-set-size!) + (color glyph-color glyph-set-color!) + (style glyph-style glyph-set-style!)) + ; Load here the glyphs you need, the only ones that are more or less defined ; are the English ones (load "glyphs/en.scm") @@ -24,7 +33,6 @@ ; Move this to a configuration file or something -(define font-size 6) ;mm (define sticker-radius 4); mm (define style (string-append " @@ -34,29 +42,11 @@ text { stroke: black; stroke-width: 0.01; } -.letter { - font-size: "(num font-size)"; - fill: white; -} -.modifier { - font-style: italic; - font-size: "(num (- font-size 3))"; - fill: white; -} .cuts { fill: none; stroke-width: 0.1; stroke: grey; } -.fn-color{ - fill: steelblue; -} -.brackets-color{ - fill: red; -} -.symbol-color{ - fill: lightgreen; -} ")) @@ -99,17 +89,19 @@ text { (ry ,r) (class ,class)))) -(define (text-unpositioned text class) +(define (text-unpositioned glyph) "Returns a `text` object that is defined to be centered vertically and horizontally wrapped in a procedure that must be called to provide it the - center position of the text" + center position of the text. It gets a `glyph` record as an input." (lambda (cx cy) `(text (@ (x ,cx) (y ,cy) - (class ,class) + (style ,(string-append "font-style: " (glyph-style glyph) + "; font-size: " (glyph-size glyph) + "; fill: " (glyph-color glyph))) (text-anchor middle) (dominant-baseline central)) - ,text))) + ,(glyph-char glyph)))) (define stickers @@ -131,21 +123,8 @@ text { 1 "cuts") (contents (x position) (y position))))) - (concatenate - (list - (map (lambda (x) (text-unpositioned x "letter symbol-color")) symbols) - (map (lambda (x) (text-unpositioned x "letter")) key-symbols) - (map (lambda (x) (text-unpositioned x "letter")) letters) - (map (lambda (x) (text-unpositioned x "letter")) numbers) - (map (lambda (x) (text-unpositioned x "modifier")) modifiers) - - (map (lambda (x) (text-unpositioned x "letter brackets-color")) brackets) - - ;(map (lambda (x) (text-unpositioned x "modifier fn-color")) fn) - (map (lambda (x) (text-unpositioned x "letter fn-color")) fn-keys) - (map (lambda (x) (text-unpositioned x "letter")) extra-sybols) - (map (lambda (x) (text-unpositioned x "letter")) punct) - ))))) + + (map text-unpositioned glyphs)))) (define cuts (map car stickers)) -- cgit v1.2.3