Adding new fonts

I have followed threw the adding new fonts on the installation page as below NOTE running selfhosted version 2.7.2 on Ubuntu 14.04 Trusty

First i am having difficulty with the grunt_dump step did some googling mostly unclear to me to do with nodejs something or other. Not sure what grunt is or how to get it on my Ubuntu system. Tried a couple ways to add it but did not manage to make it work

Also i am not sure why but my FontsSeeder.php file may get overwritten on upgrade, and i am still not sure if i have the CSS font stack correct as i really have no idea what i am doing :slight_smile:

Custom Fonts

Follow these steps to add custom ttf fonts: ie, Google fonts

Create a new folder in public/fonts/invoice-fonts/ and copy over the ttf files

bil-1:/# ls -l /var/www/ninja/public/fonts/invoice-fonts/
total 155
<..snip...>
drwxr-xr-x 2 www-data www-data 6 Sep  7 06:33 open_sans_light
drwxr-xr-x 2 www-data www-data 7 Sep  7 19:52 orbitron
drwxr-xr-x 2 www-data www-data 6 Sep  7 06:33 pt_sans
<..snip...>
<strong>Run grunt dump_dir</strong>
root@bil-1:/var/www/ninja/public/fonts# grunt_dump
grunt_dump: command not found
<strong>Add the font to database/seeds/FontsSeeder.php</strong>
     `  [
            'folder' =&gt; 'orbitron',
            'name' =&gt; 'Orbitron',
            'css_stack' =&gt; "'Orbitron', Georgia, serif",
            'google_font' =&gt; 'Orbitron',
            'normal' =&gt; 'Orbitron-Regular.ttf',
            'bold' =&gt; 'Orbitron-Bold.ttf',
            'italics' =&gt; 'Orbitron-Medium.ttf',
            'bolditalics' =&gt; 'Orbitron-Black.ttf',
            'sort_order' =&gt; 150 
        ],`

I did’nt bother with these steps as i cannot get grunt to dump

<strong>Run php artisan db:seed --class=FontsSeeder
Clear the cache by adding ?clear_cache=true to the end of the URL</strong>

It looks like you’re running grunt_dump instead of grunt dump_dir

Opps so i was however now i get this

/var/www/ninja/public/fonts/invoice-fonts# grunt dump_dir
grunt-cli: The grunt command line interface (v1.2.0)

Fatal error: Unable to find local grunt.

If you’re seeing this message, grunt hasn’t been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

http://gruntjs.com/getting-started

You need to install grunt

I have tried

apt-get install grunt
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package grunt
root@bil-1:/var/www/ninja/public/fonts/invoice-fonts# apt-cache search grunt
sdl-ball - brick-breaking game like DX-Ball/Arkanoid
sdl-ball-data - brick-breaking game like DX-Ball/Arkanoid - data files
sdl-ball-data - brick-breaking game like DX-Ball/Arkanoid - data files
sdl-ball-data - brick-breaking game like DX-Ball/Arkanoid - data files
root@bil-1:/var/www/ninja/public/fonts/invoice-fonts# npm install -g grunt
usr/bin/grunt -> /usr/lib/node_modules/grunt/bin/grunt /
grunt@1.0.1 /usr/lib/node_modules/grunt
├── path-is-absolute@1.0.0
├── grunt-known-options@1.1.0
├── eventemitter2@0.4.14
├── rimraf@2.2.8
├── exit@0.1.2
├── nopt@3.0.6 (abbrev@1.0.9)
├── minimatch@3.0.3 (brace-expansion@1.1.6)
├── findup-sync@0.3.0 (glob@5.0.15)
├── iconv-lite@0.4.13
├── coffee-script@1.10.0
├── glob@7.0.6 (inherits@2.0.3, fs.realpath@1.0.0, inflight@1.0.5, once@1.4.0)
├── grunt-cli@1.2.0 (resolve@1.1.7)
├── js-yaml@3.5.5 (esprima@2.7.3, argparse@1.0.7)
├── dateformat@1.0.12 (get-stdin@4.0.1, meow@3.7.0)
├── grunt-legacy-util@1.0.0 (getobject@0.1.0, which@1.2.11, async@1.5.2, hooker@0.2.3, underscore.string@3.2.3, lodash@4.3.0)
└── grunt-legacy-log@1.0.0 (hooker@0.2.3, colors@1.1.2, underscore.string@3.2.3, lodash@3.10.1, grunt-legacy-log-utils@1.0.0)
root@bil-1:/var/www/ninja/public/fonts/invoice-fonts# npm install -g grunt-cli
pm ERR! Refusing to delete: /usr/bin/grunt not in /usr/lib/node_modules/grunt-cli n
File exists: /usr/bin/grunt
Move it away, and try again.

npm ERR! System Linux 4.4.16-1-pve
npm ERR! command “/usr/bin/node” “/usr/bin/npm” “install” “-g” “grunt-cli”
npm ERR! cwd /var/www/ninja/public/fonts/invoice-fonts
npm ERR! node -v v0.10.37
npm ERR! npm -v 1.4.28
npm ERR! path /usr/bin/grunt
npm ERR! code EEXIST
npm ERR! error rolling back Error: Refusing to delete: /usr/bin/grunt not in /usr/lib/node_modules/grunt-cli
npm ERR! error rolling back at clobberFail (/usr/lib/node_modules/npm/lib/utils/gently-rm.js:57:12)
npm ERR! error rolling back at next (/usr/lib/node_modules/npm/lib/utils/gently-rm.js:43:14)
npm ERR! error rolling back at /usr/lib/node_modules/npm/lib/utils/gently-rm.js:52:12
npm ERR! error rolling back at Object.oncomplete (evalmachine.<anonymous>:108:15)
npm ERR! error rolling back { [Error: Refusing to delete: /usr/bin/grunt not in /usr/lib/node_modules/grunt-cli] code: ‘EEXIST’, path: ‘/usr/bin/grunt’ }
npm ERR! not ok code 0
root@bil-1:/var/www/ninja/public/fonts/invoice-fonts# cd /var/www/ninja/public/fonts/invoice-fonts/^C
root@bil-1:/var/www/ninja/public/fonts/invoice-fonts# grunt dump_dir
grunt-cli: The grunt command line interface (v1.2.0)

Fatal error: Unable to find local grunt.

If you’re seeing this message, grunt hasn’t been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

http://gruntjs.com/getting-started

Try sudo apt-get install grunt

I ran that as root see the first couple of lines in my post

File exists: /usr/bin/grunt
Move it away, and try again.

Have you tried deleting it then running with sudo?

Looks like grunt is install however i still get the error when running grunt dump_dir

grunt-cli@1.2.0 /usr/lib/node_modules/grunt-cli
├── grunt-known-options@1.1.0
├── resolve@1.1.7
├── nopt@3.0.6 (abbrev@1.0.9)
└── findup-sync@0.3.0 (glob@5.0.15)
root@bil-1:/var/www/ninja/public/fonts/invoice-fonts# npm install -g grunt
usr/bin/grunt -> /usr/lib/node_modules/grunt/bin/grunt /
grunt@1.0.1 /usr/lib/node_modules/grunt
├── path-is-absolute@1.0.0
├── grunt-known-options@1.1.0
├── eventemitter2@0.4.14
├── rimraf@2.2.8
├── exit@0.1.2
├── nopt@3.0.6 (abbrev@1.0.9)
├── minimatch@3.0.3 (brace-expansion@1.1.6)
├── glob@7.0.6 (inherits@2.0.3, fs.realpath@1.0.0, inflight@1.0.5, once@1.4.0)
├── iconv-lite@0.4.13
├── coffee-script@1.10.0
├── findup-sync@0.3.0 (glob@5.0.15)
├── grunt-cli@1.2.0 (resolve@1.1.7)
├── js-yaml@3.5.5 (esprima@2.7.3, argparse@1.0.7)
├── dateformat@1.0.12 (get-stdin@4.0.1, meow@3.7.0)
├── grunt-legacy-util@1.0.0 (getobject@0.1.0, hooker@0.2.3, async@1.5.2, which@1.2.11, underscore.string@3.2.3, lodash@4.3.0)
└── grunt-legacy-log@1.0.0 (hooker@0.2.3, colors@1.1.2, underscore.string@3.2.3, lodash@3.10.1, grunt-legacy-log-utils@1.0.0)
root@bil-1:/var/www/ninja/public/fonts/invoice-fonts# grunt dump_dir
grunt-cli: The grunt command line interface (v1.2.0)

Fatal error: Unable to find local grunt.

If you’re seeing this message, grunt hasn’t been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:

http://gruntjs.com/getting-started
root@bil-1:/var/www/ninja/public/fonts/invoice-fonts

Sorry, I’m not sure there’s any more help I can provide here.

I guess it is just a font, but i do not like to give up on a problem and Ubuntu is a popular and modern distro, must be my environment? Could you let me know what distro Invoice Ninja uses maybe i can get grunt working on that.

I use Ubuntu myself as my main development machine.

It has been awhile and I thought i might try to get my custom font working again some new details and a review as i have not visited this problem for awhile

Running Ubuntu 14.04 Trusty and Invoice Ninja version 3.0.4

bil-1:/# ls -l /var/www/ninja/public/fonts/invoice-fonts/
total 155
<..snip...>
drwxr-xr-x 2 www-data www-data 6 Sep  7 06:33 open_sans_light
drwxr-xr-x 2 www-data www-data 7 Sep  7 19:52 orbitron
drwxr-xr-x 2 www-data www-data 6 Sep  7 06:33 pt_sans
<..snip...>
root@bil-1:~# ls -l /var/www/ninja/public/fonts/invoice-fonts/orbitron/
total 103
-rwxr-xr-x 1 www-data www-data  4488 Dec 14  2010 OFL.txt
-rwxr-xr-x 1 www-data www-data 37584 Dec 14  2010 Orbitron-Black.ttf
-rwxr-xr-x 1 www-data www-data 38580 Dec 14  2010 Orbitron-Bold.ttf
-rwxr-xr-x 1 www-data www-data 39816 Dec 14  2010 Orbitron-Medium.ttf
-rwxr-xr-x 1 www-data www-data 39484 Dec 14  2010 Orbitron-Regular.ttf
root@bil-1:~# 

root@bil-1:/var/www/ninja# grunt dump_dir

<snip>
Running "dump_dir:open_sans_light" (dump_dir) task
File "public/js/vfs_fonts/open_sans_light.js" created.
 
Running "dump_dir:orbitron" (dump_dir) task
File "public/js/vfs_fonts/orbitron.js" created.
 
Running "dump_dir:pt_sans" (dump_dir) task
File "public/js/vfs_fonts/pt_sans.js" created.
<snip>

Done, without errors.

I then added the following to database/seeds/FontsSeeder.php

[ 'folder' => 'orbitron', 'name' => 'Orbitron', 'css_stack' => "'Orbitron', Arial, Helvetica, sans-serif", 'google_font' => 'Orbitron', 'normal' => 'Orbitron-Regular.ttf', 'bold' => 'Orbitron-Bold.ttf', 'italics' => 'Orbitron-Medium.ttf', 'bolditalics' => 'Orbitron-Black.ttf', 'sort_order' => 500 ],

I then ran

root@bil-1:/var/www/ninja# php artisan db:seed --class=FontsSeeder
**************************************
*     Application In Production!     *
**************************************
 
 Do you really wish to run this command? (yes/no) [no]:
 > yes

Finally i cleared the cache using ?clear_cache=true

So i think i have made some progress and i see orbitron in the list of available fonts, however when i select and save it my invoice preview area goes blank and i get the error below with debug turned on.

var/www/ninja/bootstrap/cache/compiled.php#8970Symfony\Component\HttpKernel\Exception\NotFoundHttpException
    if (count($others) &gt; 0) {
        return $this-&gt;getRouteForMethods($request, $others);
    }
    throw new NotFoundHttpException();
}
protected function checkForAlternateVerbs($request)
{

Is there more to the error? You may need to check in storage/logs/laravel-error.log.

laravel-error.log is not showing any errors when i try to change to orbitron font

Line 8970 is below in bold i though i may include some extra might be helpful?

public function match(Request $request) { $routes = $this->get($request->getMethod()); $route = $this->check($routes, $request); if (!is_null($route)) { return $route->bind($request); } $others = $this->checkForAlternateVerbs($request); if (count($others) > 0) { return $this->getRouteForMethods($request, $others); if (count($others) > 0) { return $this->getRouteForMethods($request, $others); } throw new NotFoundHttpException(); } protected function checkForAlternateVerbs($request) { $methods = array_diff(Router::$verbs, [$request->getMethod()]); $others = []; foreach ($methods as $method) { if (!is_null($this->check($this->get($method), $request, false))) { $others[] = $method; } } return $others; } protected function getRouteForMethods($request, array $methods)

Is there more of the trace shown on the screen?