customizer initial

master
Ondřej Hruška 7 years ago
commit 0a0c191523
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 3
      .gitignore
  2. 3
      .gitmodules
  3. 1
      Fork-Awesome
  4. 30
      README.txt
  5. 31
      build.sh
  6. 21
      install.sh
  7. 2
      output/.gitignore
  8. 83
      patcher/apply-filter.js
  9. 23
      patcher/refresh-wanted-templates.js
  10. 2
      patcher/templates/.gitignore
  11. 15
      refresh-templates.sh
  12. BIN
      screenshot.png
  13. 12
      update-fa.sh
  14. 2
      wanted.full.ini

3
.gitignore vendored

@ -0,0 +1,3 @@
wanted.all.ini
wanted.none.ini
wanted.ini

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "Fork-Awesome"]
path = Fork-Awesome
url = https://github.com/ForkAwesome/Fork-Awesome.git

@ -0,0 +1 @@
Subproject commit 285008117b87520930524b332dbbfad1cc26cc2c

@ -0,0 +1,30 @@
# Fork-Awesome customizer
This is a little hack to let you generate custom Fork-Awesome builds with only a subset of icons.
![screenshot](screenshot.png)
## How to use
1. Make sure you cloned this repository recursively, i.e. the `Fork-Awesome/` folder is not empty.
- You can fix that by running `git submodule init` and `git submodule update`
2. Run `./install.sh`. This should prepare the FA submodule for building the font.
3. Verify that files `wanted.all.ini` and `wanted.none.ini` have been created.
4. Copy either of the "wanted" template files to `wanted.ini`, and customize it as needed.
Lines starting with `#` will be excluded. Use the [FA icons page](https://forkawesome.github.io/Fork-Awesome/icons/) for reference.
5. Run `./build.sh` to build your customized font.
6. Retrieve your output files from the `output/` directory.
Note: The "woff" file may fail to build, resulting in the make target in `Fork-Awesome/src/icons` failing, in which case you get no files.
A workaround is to comment out that line by prepending it with `#`, and trying to build again.
```patch
cp ${FA_FONTCUSTOM_OUTPUT_DIR}/forkawesome.svg ${FA_ROOT_FONTS_DIR}/forkawesome-webfont.svg
cp ${FA_FONTCUSTOM_OUTPUT_DIR}/forkawesome.ttf ${FA_ROOT_FONTS_DIR}/forkawesome-webfont.ttf
- cp ${FA_FONTCUSTOM_OUTPUT_DIR}/forkawesome.woff ${FA_ROOT_FONTS_DIR}/forkawesome-webfont.woff
+ #cp ${FA_FONTCUSTOM_OUTPUT_DIR}/forkawesome.woff ${FA_ROOT_FONTS_DIR}/forkawesome-webfont.woff
cp ${FA_FONTCUSTOM_OUTPUT_DIR}/forkawesome.woff2 ${FA_ROOT_FONTS_DIR}/forkawesome-webfont.woff2
```

@ -0,0 +1,31 @@
#!/bin/bash
if [ ! -f "./Fork-Awesome/.git" ]; then
echo -e "\x1b[31;1mFA submodule is not initialized, exit...\x1b[m"
exit
fi
if [ ! -f "./wanted.ini" ]; then
echo -e "\x1b[31;1mMissing customization file './wanted.ini'!\x1b[m"
exit
fi
if [ ! -d "./Fork-Awesome/.bundle" ]; then
echo -e "\x1b[31;1mGems not installed in the FA submodule, cannot build. Did you run install.sh?\x1b[m"
exit
fi
if [ ! -d "./Fork-Awesome/node_modules" ]; then
echo -e "\x1b[31;1mNode modules not installed in the FA submodule, cannot build. Did you run install.sh?\x1b[m"
exit
fi
bash ./refresh-templates.sh
echo "=== Starting a build... ==="
(cd patcher && node ./apply-filter.js)
(cd "./Fork-Awesome/src/icons/" && make)
cp ./Fork-Awesome/src/icons/forkawesome/* ./output
echo "=== Your font is ready in the output/ directory ==="

@ -0,0 +1,21 @@
#!/bin/bash
if [ ! -f "./Fork-Awesome/.git" ]; then
echo -e "\x1b[31;1mFA submodule is not initialized, exit...\x1b[m"
exit
fi
cd Fork-Awesome
echo "=== Installing ruby dependencies ==="
bundle install --path vendor/bundle
echo
echo "=== Installing NODE dependencies ==="
npm install
echo
echo ">>> If no errors occured, FA should be ready to build."
echo -e "\x1b[90m(npm complaining about vulnerabilities is probably okay)\x1b[m"
bash ./refresh-templates.sh

2
output/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

@ -0,0 +1,83 @@
#!/usr/bin/env node
const fs = require('fs')
function rmInDir(dirPath) {
try { var files = fs.readdirSync(dirPath) }
catch(e) { return }
if (files.length > 0) {
for (var i = 0; i < files.length; i++) {
var filePath = dirPath + '/' + files[i]
if (fs.statSync(filePath).isFile())
fs.unlinkSync(filePath)
else
rmDir(filePath)
}
}
}
function cp(src, dest) {
if (!fs.existsSync(src)) {
return false;
}
var data = fs.readFileSync(src, 'utf-8');
fs.writeFileSync(dest, data);
}
let manifest = JSON.parse(fs.readFileSync('templates/.fontcustom-manifest.json', 'utf-8'))
let desired = fs.readFileSync('../wanted.ini', 'utf-8').split('\n').filter((x) => x.length && x[0] !== '#')
// This forces a rebuild
manifest.checksum.previous = 'asdf'
console.log('Preparing fontcustom manifest...')
console.log(`Including ${desired.length} icons`)
const orig_glyphs = manifest.glyphs
manifest.glyphs = Object.keys(orig_glyphs)
.filter(key => desired.includes(key))
.reduce((obj, key) => {
obj[key] = orig_glyphs[key]
return obj
}, {})
console.log('\x1b[32m[Writing]\x1b[m .fontcustom-manifest.json')
fs.writeFileSync('../Fork-Awesome/src/icons/.fontcustom-manifest.json', JSON.stringify(manifest, null, 2))
console.log('Preparing icons.yml...')
// this would be prettier with some yaml module, but to avoid installing anything...
let iconsy = fs.readFileSync('templates/icons.yml', 'utf-8')
let pieces = iconsy.substring(iconsy.indexOf('\n')+1).split(' - name:')
pieces.shift() // remove first
// now we have the entries, without leading ' - name'
let pattern = /id:\s+(\w+)\n/
pieces = pieces.filter((x) => {
let ar = pattern.exec(x)
return ar !== null && desired.indexOf(ar[1]) !== -1
})
let combined = 'icons:\n - name:' + pieces.join(' - name:')
console.log('\x1b[32m[Writing]\x1b[m icons.yml')
fs.writeFileSync('../Fork-Awesome/src/icons/icons.yml', combined)
console.log('Deleting files in svg/ ...')
rmInDir('../Fork-Awesome/src/icons/svg')
console.log('Copying desired files from svg-all/ to svg/ ...')
for (let a of desired) {
cp(`./templates/svg/${a}.svg`, `../Fork-Awesome/src/icons/svg/${a}.svg`)
}

@ -0,0 +1,23 @@
#!/usr/bin/env node
const fs = require('fs')
let manifest = JSON.parse(fs.readFileSync('./templates/.fontcustom-manifest.json', 'utf-8'))
let all_enabled = []
let all_disabled = []
for (var key in manifest.glyphs){
if (manifest.glyphs.hasOwnProperty(key)) {
all_enabled.push(key)
all_disabled.push(`#${key}`)
}
}
console.log(`Found ${all_enabled.length} icons in manifest, writing template files`)
console.log(`\x1b[32m[Writing]\x1b[m wanted.all.ini`)
fs.writeFileSync('../wanted.all.ini', all_enabled.join('\n') + '\n')
console.log(`\x1b[32m[Writing]\x1b[m wanted.none.ini`)
fs.writeFileSync('../wanted.none.ini', all_disabled.join('\n') + '\n')

@ -0,0 +1,2 @@
*
!.gitignore

@ -0,0 +1,15 @@
#!/bin/bash
if [ ! -f "./Fork-Awesome/.git" ]; then
echo -e "\x1b[31;1mFA submodule is not initialized, exit...\x1b[m"
exit
fi
echo "=== Refreshing templates for building a customized font ==="
rm -rf "./patcher/templates/*"
cp "./Fork-Awesome/src/icons/.fontcustom-manifest.json" "./patcher/templates"
cp "./Fork-Awesome/src/icons/icons.yml" "./patcher/templates"
cp -R "./Fork-Awesome/src/icons/svg" "./patcher/templates"
(cd ./patcher && node ./refresh-wanted-templates.js)

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@ -0,0 +1,12 @@
#!/bin/bash
if [ ! -f "./Fork-Awesome/.git" ]; then
echo -e "\x1b[31;1mFA submodule is not initialized, exit...\x1b[m"
exit
fi
echo "=== Updating the Fork-Awesome submodule... ==="
(cd Fork-Awesome && git fetch && git reset --hard origin/master)
echo "=== Fork-Awesome updated ==="
bash ./refresh-templates.sh

@ -0,0 +1,2 @@
star
table
Loading…
Cancel
Save