% abcm2ps format file to provide guitar chord diagrams % % Version 1.0 % Copyright Gek S. Low, 31 July 2006 % % Required fonts: FretQwik.ttf and FretQwikC.ttf (free guitar construction fonts) % Postscript fontmap names: FretQwik and FretQwikC % % I wrote this format file because I didn't like the approach used by the abcm2ps examples to add guitar chord diagrams. % The examples use user-defined decorations, which are limited to a max of 128, and is way too much programming. % My method is to "hook" into the gcshow abcm2ps postscript routine to draw the diagrams. % And because I'm lazy, I'm using the excellent and free FretQwik fonts by Robert Allgeyer. % I suggest using FretQwikC for guitar chords and FretQwik for mandolin/ukulele chords. % I'm sure you can draw better diagrams with custom Postscript routines, but I'm not going to try... :-) % % Please look for the fonts yourself. I will not provide the fonts and I will not entertain requests for them. % % DISCLAIMER: This abcm2ps format file is provided as is, is written for my personal use. % I tested this format file with abcm2ps 4.12.22 at the time of writing. It is always possible that it may not % work with future versions of abcm2ps. Use at your own risk. Contributions and suggestions are welcome. % % Free for personal and non-commercial use only. % -- Layout section staffsep 100 % need more space to fit in the chord diagrams % -- Postscript section beginps % This sets up the chord library % abcm2ps will encode sharp accidentals as octal 201, and flat accidentals as octal 201 % Each chord is an array of 2 elements: the fret position and a string describing the frets relative to that position % If fret position is zero, then it is not printed /chorddict 10 dict def /createchords { chorddict begin % major chords (C) [0 (032010)] def (D) [0 (xx0232)] def (E) [0 (022100)] def (F) [0 (133211)] def (G) [3 (320003)] def (A) [0 (002220)] def (B) [0 (x24442)] def (B\202) [0 (x13331)] def % minor chords (Dm) [0 (xx0231)] def % 7th chords (C7) [0 (x32310)] def (G7) [3 (131211)] def % m7 chords %(Dm7) [0 (xx0211)] def (Dm7) [5 (x13121)] def (Em7) [7 (x13121)] def (Am7) [5 (131111)] def % maj7 chords (Cmaj7) [3 (x13231)] def (Gmaj7) [3 (1x221x)] def % dim7 chords (C\201dim7) [3 (x23131)] def (D\201dim7) [5 (x23131)] def % m7b5 chords (Dm7\2025) [5 (x1212x)] def end } def createchords % the drawing routines /fretboard {(\320) show}! % empty fretboard, no nut /showgchord { % array showgchord % first element - fret number, if any dup 0 get dup 0 ne { % there's a fret position number -4 0 RM % move everything left dup 10 lt { 177 add ( ) dup 0 4 -1 roll put show (\240) show} { dup 10 idiv 177 add ( ) dup 0 4 -1 roll put show (\240) show 10 mod 177 add dup 177 eq {22 add} if % digit 0 is stored somewhere else ( ) dup 0 4 -1 roll put show (\240) show } % greater than 10, must display two digits ifelse fretboard} % draw fretboard without nut { pop (\260) show } ifelse % second element, the chord 1 get { dup 120 eq { pop (\300\240) show } %x { dup 48 eq { pop (\241\240) show } %0 { dup 49 eq { pop (\261\240) show } %1 { dup 50 eq { pop (\301\240) show } %2 { dup 51 eq { pop (\321\240) show } %3 { dup 52 eq { pop (\341\240) show } %4 { dup 53 eq { pop (\361\240) show } %5 if} ifelse} ifelse} ifelse} ifelse} ifelse} ifelse } forall}! /gcshow { % str gcshow 0 0 RM currentpoint gsave M -1 24 RM /FretQwikC 12 selectfont dup chorddict exch known { dup chorddict exch get showgchord} {fretboard} ifelse grestore /gchshow load cshow }! endps