Loading custom fonts...

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Loading custom fonts...

Postby Farooq » Tue Jul 12, 2011 9:01 am

Hi All,

My HTML interface when rendered in Chromium embedded framework is not loading custom fonts. On the other hand when I open HTML page in Safari or Chrome there is no issue.

Following is the CSS code I am using to include font files:

@font-face {
font-family: "BankGothicLight";
src: local("BankGothic Lt BT"), url(fonts/bankgthl.ttf) format("truetype");
}
@font-face {
font-family: "MyriadPro";
src: local("Myriad Pro Light"), url(fonts/MyriadPro-Light.ttf) format("truetype");
}
@font-face {
font-family: "MyriadProSemiBold";
src: local("Myriad Pro Light"), url(fonts/MyriadPro-Semibold.ttf) format("truetype");
}

Could anybody please help me to fix font's problem? So far CEF has been a great help to implement the interface but I am kinda stuck with fonts. Any help would be highly appreciated.

Farooq-
Farooq
Techie
 
Posts: 15
Joined: Tue Jun 21, 2011 8:52 pm

Re: Loading custom fonts...

Postby magreenblatt » Tue Jul 12, 2011 9:19 am

If you're using the HTTP/HTTPS schemes then remote font loading should work. It may not work for non-HTTP schemes. You can set a break point in third_party/WebKit/Source/WebCore/css/CSSFontSelector.cpp CSSFontSelector::addFontFaceRule() near 'bool foundSVGFont' to debug it.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Loading custom fonts...

Postby cagret » Tue Jul 12, 2011 10:09 am

I'm using this code to load a custom ttf font in my cef app:

Code: Select all
@font-face {
   font-family: Britanica;
   src: url(Britanica.ttf) format(truetype);
}


And it works fine, the only difference compared to yours is that I don't use `local("...")` in my code.

Edit: I've added `local("Britannic Bold"), ` and it works fine too.
Check your paths, they should be relative to the location of the css file and not the html file.
User avatar
cagret
Techie
 
Posts: 41
Joined: Fri Mar 11, 2011 11:42 am
Location: Poland

Re: Loading custom fonts...

Postby Farooq » Tue Jul 12, 2011 1:00 pm

Thank you very much for your help. Moving fonts folder relative to CSS file worked for me.
Farooq
Techie
 
Posts: 15
Joined: Tue Jun 21, 2011 8:52 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 20 guests