-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add readme, license, copyright and .gitignore
- Loading branch information
Christian Blichmann
committed
Dec 30, 2015
1 parent
9204188
commit b0a8859
Showing
4 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*~ | ||
*.sw[op] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
headline.sh version 0.1 | ||
Copyright (c)2015,2016 Christian Blichmann | ||
|
||
ASCII-art font renderer | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL CHRISTIAN BLICHMANN BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
``` | ||
_ _ _ _ ___ _ | ||
| |-.---.---.-| | ||-|---.---. | __| |-. | ||
| | -_| - | - | || | | -_| _|__ | | | ||
|_|_|___|__.|__.|__|_|_|_|___||_|___|_|_| | ||
``` | ||
|
||
headline.sh is a small Bash shell script to print banner text to the terminal | ||
in different fonts. | ||
|
||
Examples | ||
-------- | ||
|
||
The default font is called Shell Sans (in file shell-sans.sf) and is expected | ||
to be in the same directory as the main script. | ||
|
||
```bash | ||
./headline.sh 'bash rules!' | ||
_ ___ _ _ ___ _ | ||
| |-.---| __| |-. .---.-.-| |.---| __|| | | ||
| - | - |__ | | | _| | | || -_|__ ||_| | ||
|.__|__.|___|_|_| |_| |__.|__|___|___||_| | ||
``` | ||
|
||
You can also change the font by setting the `HEADLINE_FONT` environment | ||
variable: | ||
```bash | ||
HEADLINE_FONT=midnight.sf ./headline.sh Midnight | ||
┌─┬─┐ ┐ ┐ | ||
│ │ │ . │ . │ | ||
│ │ │ ┐ ┌─┤ ┬─┐ ┐ ┌─┬ ├─┐ ┼ | ||
│ │ │ │ │ │ │ │ │ │ │ │ │ │ | ||
┴ ┴ ┴ └─┴ ┴ ┴ ┴ └─┤ ┴ ┴ └┘ | ||
─┘ | ||
``` | ||
|
||
Font format | ||
----------- | ||
|
||
Font files are themselves simple Bash scripts that are sourced from the main | ||
script. They define a few variables followed by the raw font data in heredoc | ||
syntax. | ||
|
||
The format for a font with only the letters 'a' and 'b' looks like this: | ||
``` | ||
# Letter height of the font in terminal lines | ||
letter_height=1 | ||
# Number of the first line of this file with actual font data | ||
data_start=13 | ||
# The characters this font defines | ||
characters='ab' | ||
# Simple kerning support, see below. Not used in this font. | ||
declare -A kern_map=() | ||
kern_width=1 | ||
# Make this file sourceable. After this line, headline.sh expects | ||
# length(characters) * letter_height lines of font data. | ||
return; cat <<EOF | ||
a | ||
b | ||
EOF | ||
``` | ||
The lines defining each letter should be of the same lenght and end in the | ||
amount of whitespace that optimally separates adjacent letters in the final | ||
output. | ||
|
||
### "Kerning" | ||
|
||
If you want -- like in Shell Sans - letters to line up and/or merge nicely, | ||
there is some faux kerning support. | ||
To use this, first decide on a "kerning width", which is the number of | ||
trailing characters of each letter definition to be looked at for kerning, | ||
the default being 1. | ||
headline.sh first renders the text as if no kerning was specified. | ||
Sub-strings are then replaced according to the defined `kern_map`. Each key | ||
consists of 2 * kern_with characters to be replaced at the end of each letter. | ||
The value specifies the replacement characters. Unmapped strings get replaced | ||
with whitespace. | ||
|
||
Shell Sans defines its `kern_map` as follows: | ||
```bash | ||
declare -A kern_map=( ['|.']='|' ['. ']='.' ['| ']='|' ['/ ']='/' ['\ ']='\') | ||
``` | ||
|
||
Compare Shell Sans with and without `kern_map`: | ||
``` | ||
headline.sh a b | HEADLINE_FONT=/tmp/nokern.sf headline.sh a b | ||
_ | _ | ||
.---. | |-. | .--- | |-. | ||
| - | | - | | | - | - | | ||
|__.| |.__| | |__. |.__| | ||
``` | ||
The version with kerning replaced the combination `. ` and `| ` with `.` and | ||
`|`, respectively. | ||
|
||
Bugs | ||
---- | ||
|
||
- Many missing characters. Completed so far are: | ||
* Digital: ` .:ABCDEFGHIJKLMNOPQRSTUVWXYZ` | ||
* Shell Sans: ` !"#$%+,-.12345:;[]_abcdefghijklmnopqrstuvwxyz|äöüCNST` | ||
* Midnight: `dghintM` | ||
* Null: ` -_.!|abcdefghijklmnopqrstuvwxyzäöüCNST` | ||
- Uses Bash-isms | ||
- Error messages could be nicer | ||
- No distribution packages | ||
|
||
|
||
Copyright/License | ||
----------------- | ||
|
||
headline.sh version 0.1 | ||
Copyright (c)2015,2016 Christian Blichmann <headline-sh@blichmann.eu> | ||
|
||
headline.sh is licensed under a two-clause BSD license, see the LICENSE file | ||
for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters