CSS font including not shown in browser - html

I'm linking a CSS file in HTML. The CSS file is uploaded on another server and the CSS file import fonts from the same place and the path is correct, but gives an error and doesn't work.
Here are the screenshots: https://pasteboard.co/Ig0ORen.jpg
This the font error: https://pasteboard.co/Ig0KwNlP.jpg
It is was working when the CSS was on my localhost but I want to upload the CSS and JS and fonts in this server.
This is the HTML code:
<link rel="stylesheet" href="http://www.example.com/lib/styles/process.css">
This is the CSS codeL
#font-face {
font-family: pp-sans-small-light;
src: url(../fonts/p_small_light.eot);
src: url(../fonts/p_small_light.eot) format("embedded-opentype"), url(../fonts/p_small_light.woff) format("woff"), url(../fonts/p_small_light.svg) format("svg")
}
#font-face {
font-family: pp-sans-small-regular;
src: url(../fonts/p_small_regular.eot);
src: url(../fonts/p_small_regular.eot) format("embedded-opentype"), url(../fonts/p_small_regular.woff) format("woff"), url(../fonts/p_small_regular.svg) format("svg")
}
#font-face {
font-family: 'consumer-icons';
src: url(../fonts/icons_sans.eot);
src: url(../fonts/icons_sans.eot) format('embedded-opentype'), url(../fonts/icons_sans.woff) format('woff'), url(../fonts/icons_sans.ttf) format('truetype'), url(../fonts/icons_sans.svg) format('svg');
font-style: normal;
font-weight: 400
}
#font-face {
font-family: p_big_sans;
font-style: normal;
font-weight: 200;
src: url(../fonts/p_big_sans.eot);
src: url(../fonts/p_big_sans.woff2) format('woff2'), url(../fonts/p_big_sans.woff) format('woff'), url(../fonts/p_big_sans.svg) format('svg')
}
*,
*:before,
*:after {
box-sizing: inherit
}
html,
body {
height: 100%;
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: pp-sans-small-regular, Helvetica Neue, Arial, sans-serif;
}

Check permission in your server for those font files which are not getting loaded. I have attached screenshot for you reference. Right click on files & folder and change permission to 755.

You have only referenced the #font-face fonts here -
#font-face {
font-family: pp-sans-small-light;
src: url(../fonts/p_small_light.eot);
src: url(../fonts/p_small_light.eot) format("embedded-opentype"),
url(../fonts/p_small_light.woff) format("woff"), url(../fonts/p_small_light.svg)
format("svg")
}
..but you haven't declared their use anywhere.
You need to assign the fonts where you want to use them, for example;
body { font-family: pp-sans-small-regular; }
p { font-family: pp-sans-small-light; }

Related

Pagedjs: how to render PDF while keeping text selectable/editable?

I am using pagedjs to render a pdf and using their starter kit: https://gitlab.coko.foundation/pagedjs/starter-kits/book-spread_esm
When I export a pdf via the page print function, the text is selectable as you would expect.
But when I change the font, the text is not selectable.
In other examples, they have changed the font and the pdf has rendered properly (text is selectable) example: https://gitlab.coko.foundation/pagedjs/starter-kits/book_avanced-interface
So I know this must be possible.
What I have tried
I initially imported the fonts from Google Fonts as follows:
Style.css:
#import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght#0,100;0,300;0,400;0,500;0,600;1,100;1,300;1,400;1,500;1,600&display=swap');
body{
font-family: 'Montserrat', 'sans-serif';
}
...
The fonts render correctly, but text is not selectable.
Next, I looked at the advanced example with fonts and saw that they defined local fonts as follows:
Inside: /fonts/VG5000/stylesheet.css:
#font-face {
font-family: 'VG5000';
src: url('VG5000-Regular_web.eot');
src: url('VG5000-Regular_web.eot?#iefix') format('embedded-opentype'),
url('VG5000-Regular_web.woff') format('woff'),
url('VG5000-Regular_web.woff2') format('woff2'),
url('VG5000-Regular_web.ttf') format('truetype'),
url('VG5000-Regular_web.svg#svgFontName') format('svg');
font-weight: normal;
font-style: normal;
}
Then it is used in /style-print.css as:
h1{
font-family: 'VG5000';
text-align: center;
}
So I mimicked this with my fonts (albeit a bit more complicated):
File structure in /fonts/Montserrat/:
static/
\_Montserrat-Black.ttf
\_Montserrat-BlackItalic.ttf
\_Montserrat-Bold.ttf
\_Montserrat-BoldItalic.ttf
\_Montserrat-ExtraBold.ttf
\_Montserrat-ExtraBoldItalic.ttf
\_Montserrat-ExtraLight.ttf
\_Montserrat-ExtraLightItalic.ttf
\_Montserrat-Italic.ttf
\_Montserrat-Light.ttf
\_Montserrat-LightItalic.ttf
\_Montserrat-Medium.ttf
\_Montserrat-MediumItalic.ttf
\_Montserrat-Regular.ttf
\_Montserrat-SemiBold.ttf
\_Montserrat-SemiBoldItalic.ttf
\_Montserrat-Thin.ttf
\_Montserrat-ThinItalic.ttf
Montserrat-Italic-VariableFont_wght.ttf
Montserrat-VariableFont_wght.ttf
stylesheet.css
Inside /fonts/Montserrat/stylesheet.css:
#font-face {
font-family: 'Montserrat';
src: url('static/Montserrat-Thin.ttf') format('truetype');
font-weight: 100;
font-style: normal;
}
#font-face {
font-family: 'Montserrat';
src: url('static/Montserrat-Light.ttf') format('truetype');
font-weight: 300;
font-style: normal;
}
#font-face {
font-family: 'Montserrat';
src: url('static/Montserrat-Regular.ttf') format('truetype');
font-weight: 400;
font-style: normal;
}
#font-face {
font-family: 'Montserrat';
src: url('static/Montserrat-Medium.ttf') format('truetype');
font-weight: 500;
font-style: normal;
}
#font-face {
font-family: 'Montserrat';
src: url('static/Montserrat-SemiBold.ttf') format('truetype');
font-weight: 600;
font-style: normal;
}
This renders properly on the website, but on PDF the font does not load:
Web rendering:
PDF rendering:
It is the same as before, text is not selectable.
The final thing I have tried is looking in the docs, specifically searching font site:pagedjs.org, but there is nothing specific in the documentation about fonts and editable pdfs.

Add a custom font with #font-face don't work at all

I'm trying to add an external font to a website, the site does not respond at all. I'm a beginner and just learning, I work on it all day, thank you for your help.
#font-face {
font-family: "Alex";
src: url(fonts/AlexBrush-Regular.ttf) format('truetype'),
url(fonts/AlexBrush-Regular.woff) format('woff'),
url(fonts/AlexBrush-Regular.woff2) format('woff2');
}
body {
text-align: center;
}
h1 {
color: black;
font-family: "Alex";
}
.space p {
font-size: 40px;
font-family: "Alex";
}
Put the archive path inside a string
Ex:
url("fonts/AlexBrush-Regular.ttf") format("truetype"),
url("fonts/AlexBrush-Regular.woff") format("woff"),
url("fonts/AlexBrush-Regular.woff2") format("woff2");

Why my STYLE to import external font-face doesn't work

Why doesn't the following <style> change my font to "Computer Modern Typewriter"?
The URL is effective.
<style type="text/css">
#font-face {
font-family: 'Computer Modern Typewriter';
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmuntt.otf');
font-weight: normal;
font-style: normal;
}
body {
font-size: 1em;
font-family: 'Computer Modern Typewriter'
}
</style>
Link you provided doesn't support HTTPS, so if your site have HTTPS connection and headers which restrict access to unsecured HTTP it's can be the problem.
Also, OpenType isn't so suitable for web now, you can use WOFF or WOFF2 version of the same font. I found one here: https://github.com/dreampulse/computer-modern-web-font. Use it like this:
#font-face {
font-family: 'Computer Modern Typewriter';
src: url('cmuntt.eot');
src: url('cmuntt.eot?#iefix') format('embedded-opentype'),
url('cmuntt.woff') format('woff'),
url('cmuntt.ttf') format('truetype'),
url('cmuntt.svg#cmuntt') format('svg');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'Computer Modern Typewriter';
src: url('cmuntb.eot');
src: url('cmuntb.eot?#iefix') format('embedded-opentype'),
url('cmuntb.woff') format('woff'),
url('cmuntb.ttf') format('truetype'),
url('cmuntb.svg#cmuntb') format('svg');
font-weight: bold;
font-style: normal;
}
#font-face {
font-family: 'Computer Modern Typewriter';
src: url('cmunit.eot');
src: url('cmunit.eot?#iefix') format('embedded-opentype'),
url('cmunit.woff') format('woff'),
url('cmunit.ttf') format('truetype'),
url('cmunit.svg#cmunit') format('svg');
font-weight: normal;
font-style: italic;
}
#font-face {
font-family: 'Computer Modern Typewriter';
src: url('cmuntx.eot');
src: url('cmuntx.eot?#iefix') format('embedded-opentype'),
url('cmuntx.woff') format('woff'),
url('cmuntx.ttf') format('truetype'),
url('cmuntx.svg#cmuntx') format('svg');
font-weight: bold;
font-style: italic;
}
You can use this css
#font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');
}
#font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunsx.otf');
font-weight: bold;
}
#font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunsi.otf');
font-style: italic, oblique;
}
#font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunbxo.otf');
font-weight: bold;
font-style: italic, oblique;
}
body {
font-family: "Computer Modern", sans-serif;
}
Probably because that's an OTF font.
You should get or create other font formats - you mainly need the WOFF format for websites.
If the font allows it (copyright-wise) you can create that here: https://www.fontsquirrel.com/tools/webfont-generator
Just .otf is not enough.
You've to add other formats as well.. check here. For you ease just click check fontface and necessary formats will be made available. Also, check here how to add multiple src for font-face.
I think it's not OTF problem, it is with the URL
http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmuntt.otf
Althoght it is accessible but it's NOT HTTPS and the browser doesn't load it.
I saved a copy to GitHub and then applied the same STYLE (with URL replaced to new https url). It worked!

Font awesome using font face

I'm looking for something like this
#font-face {
font-family: "FontAwesome";
font-weight: normal;
font-style : normal;
src : url("http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.eot?v=4.3.0");
src : url("http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0") format("embedded-opentype"),
url("http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff2?v=4.3.0") format("woff2"),
url("http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff?v=4.3.0") format("woff"),
url("http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.ttf?v=4.3.0") format("truetype"),
url("http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular") format("svg");
}
.myClass:before {
font-family: FontAwesome;
content: "\f024";
}
<a class="myClass" href="#">This is a link</a>
I want to load font file using CSS property. And to create a custom class for font icon. The above didn't work. It failed to load respective icon. Instead it show bar
Try opening the Javascript console and adding the error messages that appear there to your question.
When I tried your code in JSFiddle, all it needed was for the maxcdn links to be SSL-based HTTPS links as opposed to insecure HTTP links.
That may be the solution to your issue, but it's hard to tell without the console error output.
#font-face {
font-family: "FontAwesome";
font-weight: normal;
font-style : normal;
src : url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.eot?v=4.3.0");
src : url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.eot?#iefix&v=4.3.0") format("embedded-opentype"),
url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff2?v=4.3.0") format("woff2"),
url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff?v=4.3.0") format("woff"),
url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.ttf?v=4.3.0") format("truetype"),
url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular") format("svg");
}
.myClass:before {
font-family: FontAwesome;
content: "\f024";
}
use cdn link to create #font-face as following way
#font-face {
font-family: "FontAwesome";
font-weight: normal;
font-display: auto;
font-style: normal;
src: url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.woff2") format("woff2");
}
Please note that if are including font-awesome.min.css in your page (as explained in Font-awesome's documentation) then it already includes the following #font-face, at the very beginning of the file, and you wouldn't need to add your own:
#font-face {
font-family: 'FontAwesome';
src: url('../fonts/fontawesome-webfont.eot?v=4.7.0');
src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'),
url('../fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'),
url('../fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'),
url('../fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'),
url('../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
If you are looking for FontAwesome then you're probably looking for this-
<link rel="stylesheet" id="champion-fontawesome-css" href="wp-content/themes/bla/inc/font-awesome-4.7.0/css/font-awesome.min.css?ver=4.7.3" type="text/css" media="all">
If you are looking to load a custom font of your own then try this-
#font-face {
font-family: 'FFDINRoundWebPro';
font-weight: normal;
font-style: normal;
src: url('assets/fonts/3103D9_0_0.eot');
src: url('assets/fonts/3103D9_0_0.eot?#iefix') format('embedded-opentype'), url('assets/fonts/3103D9_0_0.woff2') format('woff2'), url('assets/fonts/3103D9_0_0.woff') format('woff'), url('assets/fonts/3103D9_0_0.ttf') format('truetype');
}
#font-face {
font-family: 'FFDINRoundWebPro';
font-weight: 700;
src: url('assets/fonts/3103D9_1_0.eot');
src: url('assets/fonts/3103D9_1_0.eot?#iefix') format('embedded-opentype'), url('assets/fonts/3103D9_1_0.woff2') format('woff2'), url('assets/fonts/3103D9_1_0.woff') format('woff'), url('assets/fonts/3103D9_1_0.ttf') format('truetype');
}
#font-face {
font-family: 'FFDINRoundWebPro';
font-weight: 500;
src: url('assets/fonts/3103D9_2_0.eot');
src: url('assets/fonts/3103D9_2_0.eot?#iefix') format('embedded-opentype'), url('assets/fonts/3103D9_2_0.woff2') format('woff2'), url('assets/fonts/3103D9_2_0.woff') format('woff'), url('assets/fonts/3103D9_2_0.ttf') format('truetype');
}
#font-face {
font-family: 'FFDINRoundWebPro';
font-weight: 300;
src: url('assets/fonts/3103D9_3_0.eot');
src: url('assets/fonts/3103D9_3_0.eot?#iefix') format('embedded-opentype'), url('assets/fonts/3103D9_3_0.woff2') format('woff2'), url('assets/fonts/3103D9_3_0.woff') format('woff'), url('assets/fonts/3103D9_3_0.ttf') format('truetype');
}
As you can see, for each font-weight i create another #font-face with the same font-family name.

HTML signature on macosx font

I have macosx and I made a html signature for mail.app but when I send email and someone pick it with windows property font-family does not work.
When I send from MAC to MAC everything is okey.
Here are my styles:
#font-face {
font-family: 'open_sansitalic';
src: url('opensans-italic-webfont.eot');
}
#font-face {
font-family: 'open_sansitalic';
src: url(data:application/x-font-woff;charset=utf-8;base64,...) format('woff'),
url('opensans-italic-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'open_sanssemibold';
src: url('opensans-semibold-webfont.eot');
}
#font-face {
font-family: 'open_sanssemibold';
src: url(data:application/x-font-woff;charset=utf-8;base64,...) format('woff'),
url('opensans-semibold-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'open_sanslight';
src: url('opensans-light-webfont.eot');
}
#font-face {
font-family: 'open_sanslight';
src: url(data:application/x-font-woff;charset=utf-8;base64,...) format('woff'),
url('opensans-light-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'open_sansregular';
src: url('opensans-regular-webfont.eot');
}
#font-face {
font-family: 'open_sansregular';
src: url(data:application/x-font-woff;charset=utf-8;base64,...) format('woff'),
url('opensans-regular-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
And also this:
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,400,300,600,700' rel='stylesheet' type='text/css'>
You must give absolute url
url('opensans-italic-webfont.ttf') format('truetype');
src: url('opensans-semibold-webfont.eot');
Note1: Maybe it´s a good ideia to put the fonts in a remote server or use CDN
Note2: It only works on Apple Mail and iPhone