Search code examples
phpmysqlhtmlfont-face

FONT not displaying certain characters


I am using a custom font on the website i'm developing and some basic characters are not being displayed. What seems to be the problem?

Also i am fetching the content from MYSQL.

font characters

Is the font bad?

@font-face {font-family: Cabin_Regular; src: url('fonts/Cabin_Regular.ttf');}
@font-face {font-family: Lobster; src: url('fonts/Lobster.ttf');}
body, select, input, textarea {font-family: 'Cabin_Regular';color:white;font-size: 16px;text-shadow: 0.1em 0.1em 0.2em black;}
h1, h2, h3, h4, h5, h6 {font-family: 'Lobster'; margin-bottom: 0;padding-bottom: 0;margin-top: 0; padding-top: 0;}

Solution

  • Check the encoding in your MySQL database. If it's not UTF-8 you're going to have issues

    if it isn't UTF-8 use the following after you've connected to the database and are about to execute a Query

    mysql_set_charset('utf8',$database_Connection);
    

    Also make sure you have the charset defined in the <head> of your html document

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    

    ... I actually ran into this problem myself once when using a client's database which was set to Latin1. A real pain to figure out the first time.