The custom font does not work.Codeigniter

心已入冬 提交于 2019-12-25 06:55:52

问题


I want to added custom font in my app, but it does not work. Here it is path when font located

@font-face {    font-family: PF Din Text Cond Pro;
                 src: url('/fonts/JtNLnKEa.ttf'); }

font located in system/fonts/JtNLnKEa

UPD

@font-face {
    font-family: PF Din Text Cond Pro;
        src: url('http://contrast-energo.ru/fonts/JtNLnKEa.ttf');
}

body,html { 
  font-family: PF Din Text Cond Pro;
  height: 100%; 
  min-height: 100%; 
  margin-top: 0px;
}

How fix?

Sorry for my bad English


回答1:


Add your font a directory accessible to your CodeIgniter.

@font-face {
  font-family: 'YourFontName'; /*a name to be used later*/
  src: url('http://domain.com/fonts/JtNLnKEa.ttf'); /*URL to font*/
}

And use your font name like:

.classname {
  font-family: 'YourFontName';
}

EDIT:

body,html { 
  font-family: "PF Din Text Cond Pro"; /* Add double quotes around your custom font name */
  height: 100%; 
  min-height: 100%; 
  margin-top: 0px;
}



回答2:


@font-face {
  font-family:'Lucida Grande';
  font-style: normal;
  font-weight: 100;
  src: url(../fonts/6216.ttf) format('ttf');
}
@font-face {
  font-family:'Myriad Set Pro';
  font-style: normal;
  font-weight: 100;
  src: url(../fonts/myriad.woff) format('woff');
}
@font-face {
  font-family:'Helvetica Neue';
  font-style: normal;
  font-weight: 100;
  src: url(../fonts/helvetica-neue-medium.ttf) format('ttf');
}
@font-face {
  font-family:'Roboto';
  font-style: normal;
  font-weight: 100;
  src: url(../fonts/helvetica-neue-medium.ttf) format('ttf');
}
body
{
    font-family:"Myriad Set Pro","Lucida Grande","Helvetica Neue","Helvetica","Arial","Verdana","sans-serif";
    overflow-x:hidden !important;
}

in root folder assets/css/fonts




回答3:


your appliation structuer should be like this

- application
- system
- assets
    - css
    - js
    - fonts

etc..

then your access url should be like http://contrast-energo.ru/assets/fonts/JtNLnKEa.ttf




回答4:


Your problem isn't related to CodeIgniter. You have a problem in the CSS/HTML.

You need to use the following CSS code to add properly your fonts to a HTML document:

@font-face {
    font-family: 'PF Din Text Cond Pro';
    src: url('fonts/PF-Din-Text-Cond-Pro.eot');
    src: url('fonts/PF-Din-Text-Cond-Pro.woff') format('woff'), 
         url('fonts/PF-Din-Text-Cond-Pro.ttf') format('truetype'), 
         url('fonts/PF-Din-Text-Cond-Pro.svg') format('svg');
    font-weight: normal;
    font-style: normal;
}

The custom font will be displayed on all the browsers.

In case you want to assign the font to the body element, you can use the following:

body {font-family:'PF Din Text Cond Pro', Arial, sans-serif;}

You need to add the font name between single quotes or double quotes, because it's a custom font.

In case you have only a ".otf" or ".ttf" font file, then you need to convert this file to the other formats.

Online Font Converter is the best free font converter out there.



来源:https://stackoverflow.com/questions/27377927/the-custom-font-does-not-work-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!