Browse Author

Andrews Ang

Laravel-Dompdf custom font to support Simplified Chinese

Dompdf version >= 0.6

Laravel-dompdf version >= 0.4

Disclaimer: I’m using legacy Laravel 4.2 with Laravel-dompdf 0.4. This tutorial may not work for you if you’re using another versions. Try working around the folders and dependencies for your version.

NOTE: If you’re getting a warning message about missing lib/php-font-lib/classes/Font.php, scroll to bottom for solution.

1. Download SimHei font from

2. Copy the simhei.ttf file into vendor/dompdf/dompdf.

3. Edit vendor/dompdf/dompdf/, change these values:

define("DOMPDF_FONT_DIR", DOMPDF_DIR."/../../../app/storage/fonts/");
define("DOMPDF_FONT_CACHE", DOMPDF_DIR."/../../../app/storage/fonts/");

4. Using the command line, follow these commands (line by line, assuming you’re already in your laravel installation root folder):

cd vendor/dompdf/dompdf/
php load_font.php simhei ./simhei.ttf

5. Then in your html, simply use:

font-family: simhei;

6. Go back to step 3 (edit vendor/dompdf/dompdf/ and remove/comment these lines (because laravel-dompdf already defined them):

//define("DOMPDF_FONT_DIR", DOMPDF_DIR."/../../../app/storage/fonts/");
//define("DOMPDF_FONT_CACHE", DOMPDF_DIR."/../../../app/storage/fonts/");

7. Your fonts will be stored in your app/storage/fonts folder (remember to upload them to your production server).


For my case, when I run the command on step 4 above, I was thrown with this message:

PHP Warning:  require_once(/home/vagrant/sites/myproject/vendor/dompdf/dompdf/lib/php-font-lib/classes/Font.php): failed to open stream: No such file or directory in /home/vagrant/sites/myproject/vendor/dompdf/dompdf/ on line 334

It turns out that the dompdf installation doesn’t include the necessary files inside vendor/dompdf/dompdf/lib/php-font-lib/ (that folder is empty).

To resolve this, simply copy vendor/phenx/php-font-lib/ and paste the content into vendor/dompdf/dompdf/lib/php-font-lib/

After that, run step 4 above again and it should work.

How to setup phpMyAdmin in Homestead

Writing this for my own reference. Hope it helps someone too.

Install using Ubuntu repository:

This will install phpMyAdmin from Ubuntu’s repositories. Assuming that your projects live in /home/vagrant/Code:

  1. On your hosting machine, open a terminal, go to your homestead folder, after “vagrant up”, enter “vagrant ssh” to ssh to your virtual machine.
  2. Then enter “sudo apt-get install phpmyadmin” (Do not select apache2 nor lighttpd when prompted. Just hit tab and enter.)
  3. You will be prompted whether to set up a database, select “OK” and when prompted for password, enter “secret”. (This is the default password for Homestead’s MySQL.)
  4. Now enter “sudo ln -s /usr/share/phpmyadmin/ /home/vagrant/Code/phpmyadmin”
  5. Finally, enter “cd ~/Code && serve /home/vagrant/Code/phpmyadmin”

For Mac/Linux users, follow the following step to add a nice URL for phpMyAdmin.

  1. On your hosting machine, edit the /etc/hosts file with the command “sudo nano /etc/hosts”. I like the nano editor, feel free to use any editor.
  2. Add the following (you can use your virtual machine’s IP address instead of
  3. If you’re using nano editor, press keys Control + o (letter o) to save the changes. Then press keys Control + x to exit the editor.
  4. Now open a browser.
  5. Go to
  6. That’s it!