Mohammad Reza Majid Pour Mohammad Reza Majid Pour - 24 days ago 16
CSS Question

is there a way to add a font into assets folder and load it for html?

i want my text look better in web view but when i try to load a font for it,it doesnt change.
according to some questions this and this i found this code:

<style type="text/css">
@font-face {
font-family: "My Custom Font";
src: url(http://www.example.org/mycustomfont.ttf) format("truetype");
}
p.customfont {
font-family: "My Custom Font", Verdana, Tahoma;
}
</style>
<p class="customfont">Hello world!</p>


i tried this for loading it from assets:

<style type=text/css>
@font-face {
font-family: "ROYA";
src="Roya.ttf";
}
p.customfont {
font-family: "ROYA", Verdana, Tahoma;
}
<p class="ROYA">Hello world!</p>


but it doesnt working. what should i do?

Answer

use : instead or =

@font-face{
  font-family: "ROYA";
  src: url("Roya.ttf") format("truetype");
}

and change class name on the next code block

p.ROYA { 
font-family: "ROYA", Verdana, Tahoma;
}
<p class="ROYA">Hello world!</p>
Comments