Comments (10)
I see what you are saying and at least the usefulness in standardizing the output fields so that they can be parsed via another app similar to how many utilities have a parseable output mode that can be easily awk'd
cut'd
IFS'd
read
. Or at least possibly working on a finite structure that like you said can be easily json'd or toml'd or whatever'd...
This would be helpful with two things I am looking for on TODO is that I want to also store/cache this info, and also make the library useful to be included in other applications.
I want to be able to make this work for you but I am knee deep in another project I am trying to finish up before I want to come back to this more in-depth. If you want to start with a PR I am all for it. Your ideas seem to make sense for more than just reclist
's usecase.
If you can let me have a few days to finish this other proect I will have no problem getting the list you gave worked in as well as some of the things I want to get resolved and cleaned up.
Otherwise, like I said, if you want to take charge and PR the things you listed. Our needs seem aligned and I would hugely appreciate any help since it will also further my goals/ideas too.
Thx !
from tdfgo.
As an exercise, I applied some post-processing to fonts -v
so that I could query it with recutils'.
Here is a snippet of the output
/home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Cyan-Blu
char list:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
font: Use Green
char list:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄
font: Use Purple
char list:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄
font: Use Red
char list:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄
font: Use Silver
char list:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄
/home/crinklywrappr//.config/tdfgo/fonts/SECTOR.TDF
font: Sector
char list:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 14 height: 8 spacing: 1
preview: ▄▄▄▄▄▄▄▄▄▄▄▄
/home/crinklywrappr//.config/tdfgo/fonts/PANDEMON.TDF
font:
char list:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 10 height: 12 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
/home/crinklywrappr//.config/tdfgo/fonts/CALVIN.TDF
/home/crinklywrappr//.config/tdfgo/fonts/CATLKINX.TDF
font: CattleKingB
char list:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 7 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
In order for recutils to read it, it needs to look like this:
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Cyan-Blu
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Green
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Purple
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Red
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Silver
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 6 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄
file: /home/crinklywrappr//.config/tdfgo/fonts/SECTOR.TDF
font: Sector
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 14 height: 8 spacing: 1
preview: ▄▄▄▄▄▄▄▄▄▄▄▄
file: /home/crinklywrappr//.config/tdfgo/fonts/PANDEMON.TDF
font:
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 10 height: 12 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
file: /home/crinklywrappr//.config/tdfgo/fonts/CATLKINX.TDF
font: CattleKingB
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11 height: 7 spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
from tdfgo.
I wrote some code to do that post-processing, just to see what might be involved.
generate an outfile
remove colors and null characters
$ tdfgo fonts -v \
| sed 's/\x1b\[[^\x1b]*m//g' \
| tr -d '\0' \
> out.txt
process the outfile
I did this w/ babashka, b/c I wanted to gain some experience. This code
- places
char list: ...
on a single line - renames
char list
tochar_list
- adds the appropriate
file: ...
value to each record - replaces lines w/ nothing but whitespace with an empty line
I named this file format.clj
.
(defn add-file [[prev file xs]]
(when (seq xs)
(let [x (first xs)]
(cond
(and (not (str/starts-with? prev "file:"))
(str/starts-with? x "font:")) [(str "file: " file) file xs]
(and (not (str/blank? x))
(nil? (str/index-of x \:))) (add-file ["" x (rest xs)])
:else [x file (rest xs)]))))
(defn format-line [l]
(cond
(str/blank? l) ""
:else l))
(as-> "out.txt" $
(slurp $)
(str/replace $ #"\nchar list:\n" "\nchar_list: ")
(str/split $ #"\n")
(iterate add-file ["" (first $) (rest $)])
(rest $)
(map first $)
(take-while some? $)
(map format-line $)
(doseq [x $] (println x)))
query it
I still need to call uniq
to ensure uniform spacing between records. This was a personal goal. I'm not sure if recutils
actually requires it.
$ bb -f format.clj | uniq | recsel -p file,font
file: /home/crinklywrappr//.config/tdfgo/fonts/KANSAS.TDF
font: Kansas
file: /home/crinklywrappr//.config/tdfgo/fonts/LEGACY.TDF
font: Legacy
file: /home/crinklywrappr//.config/tdfgo/fonts/TRIBWRIT.TDF
font: Tribal Write
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Cyan-Blu
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Green
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Purple
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Red
file: /home/crinklywrappr//.config/tdfgo/fonts/USEX.TDF
font: Use Silver
file: /home/crinklywrappr//.config/tdfgo/fonts/SECTOR.TDF
font: Sector
file: /home/crinklywrappr//.config/tdfgo/fonts/PANDEMON.TDF
font:
file: /home/crinklywrappr//.config/tdfgo/fonts/CATLKINX.TDF
font: CattleKingB
from tdfgo.
The big unknown w/ this approach is COLOR. preview
, for instance, is useless w/o color, and I don't know if recutils can parse the control characters for color or not.
Based on this research, I recommend gating this feature behind a flag. e.g. tdfgo fonts --plain
.
from tdfgo.
One final thing I didn't do is separate width
, height
, and spacing
into separate lines.
from tdfgo.
I did do a bit of investigating in caching fonts data and/or bundling fonts with a single header/db chunk at the beginning to make it easier to get metadata, specifically because of the lag and/or huge reads every time it tries to lookup/find a font. Also the font completion needs to be able to lookup all the fonts each time too
Also since I was lazy and only felt like supporting the COLOR font types, the included fonts are only about 1/4 of the available fonts from RoySAC or the BBS archives. I think one of his font packs is about 4k fonts...
RoySac did come up with his own format of bundling all the fonts into a single file that was like 20Mb I believe... The originaly TheDraw spec only allows for I believe 34 fonts per font file, and there's also a size limit too.
I was trying to mimic figlet/toilet with the single directory filled with fonts and having to re-lookup the fonts every time as a starting point.
I am not too keen on another or separate utility, and also if possible keeping everything within the golang universe languages wise (lazyness again). I dont have a lot of experience with closure but learning another language isn't really the problem. It is just about maintainability/hackability and keeping it within golang makes all parts able to be hacked on similarly.
I am not shooting down your idea, but I would maybe go about it a different way? I am going to open a TODO issue and start a list of stuff if you would like to add input or converse about features/enhancements/etc in one spot.
from tdfgo.
from tdfgo.
Based on this research, I recommend gating this feature behind a flag. e.g. tdfgo fonts --plain.
I am not able to easily test it at the moment, but you should be able to export NO_COLOR=1
and have the color output be removed.
from tdfgo.
Sorry, I wrote too much last night to easily digest.
Supporting recutils does not require any additional dependency. It only requires small changes to the output format. My suggestion is to add that logic to cmd/fonts.go
, and gate it behind a flag e.g. --plain
.
- remove colors
- remove null characters
- place
char list: ...
on a single line - rename
char list
tochar_list
- add the appropriate
file: ...
value to each record - replace whitespace lines with an empty line
- width,height, & spacing should be on separate lines
- a single empty line between records (maybe?)
This is what a record looks like w/ those changes.
file: /home/crinklywrappr//.config/tdfgo/fonts/CATLKINX.TDF
font: CattleKingB
char_list: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklnopqrstuvwxyz{|}~
width: 11
height: 7
spacing: 2
preview: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
Similar changes are required for the non -v
version. Does that make sense?
You could also format to JSON and get similar usability from jq
. But recutils is no additional dependencie & less effort since tdfgo is almost in that format anyway.
from tdfgo.
I want to share an example of the sort of thing it's useful for. With this command, I am able to list all of the fonts that tdfgo
will error when rendering.
$ NO_COLOR=1 ./result/bin/tdfgo fonts | sed 's/embedded fonts/embedded_fonts/' | sed 's/font names/font_names/' | tr -d '\0' | recsel -e "!(font_names ~ '.+')" -R file
Seems like useful information to have.
from tdfgo.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tdfgo.