语言

Menu
Sites
Language
Can't seem to add a custom font to my project

I'm trying to use a custom font for a watch face project, but the following code doesn't work. 

@font-face{

    font-family: "Digital";

    src: url('digital-7.ttf'),

}

 

 

div {

    font-family: Digital;

}

 

What am I doing wrong?

The file is in the same folder as the css.

响应

3 回复
Iqbal Hossain

Hi~ 

You can follow the steps

1. Put your font file (ttf) in the css file location. 

2. In the CSS file add 

@font-face { font-family: Digital7; src: url('digital-7.ttf'); } 

3. Make custom class for your font 

.DigitalFont{
    font-family: Digital7;
}

4. Use where you want to use your font 

    <div>
	<h1 class="DigitalFont">Digi7 Font</h1>
	<button class="DigitalFont">Button</button>
    </div>

Hope this will help you. 
Let me know that .

-Thanks

Marcone

honest question: what's the difference between your code and my code? can't a custom font be loaded for the whole DIV?

I will try yours but I've seen plenty of snippets like mine:

https://developer.tizen.org/category/code-snippet-tag/custom-font

https://developer.tizen.org/community/code-snippet/web-code-snippet/use-custom-font-wearablemobile-web-applications

that's why I was asking what I was doing wrong...

Iqbal Hossain

Difference is your one is not working in my project. I gave you the working code.