Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bypassing @font-face declaration that overrides "helvetica" font family

I have a bookmarklet that inserts a widget into any site's pages. The styling of the widget is being broken by a certain site that has the following CSS @font-face declaration:

@font-face {
    font-family: "helvetica";
    src: url("http://cdn2.yoox.biz/Os/fonts/helveticaneueltstdmdcn.eot?iefix") format("eot"),
         url("http://cdn2.yoox.biz/Os/fonts/helveticaneueltstdmdcn.woff") format("woff"),
         url("http://cdn2.yoox.biz/Os/fonts/helveticaneueltstdmdcn.ttf") format("truetype"),
         url("http://cdn2.yoox.biz/Os/fonts/helveticaneueltstdmdcn.svg#svgFontName") format("svg");
}

The widget that my bookmarklet inserts uses helvetica everywhere and on this one site it looks horrible because the browser is mapping helvetica to the @font-face declaration of that name rather than the standard helvetica system font.

The question: is there any way to override/bypass this @font-face declaration or create another @font-face declaration that maps to the system helvetica font?

like image 992
Tautologistics Avatar asked Jun 12 '12 15:06

Tautologistics


People also ask

Is Helvetica a Websafe?

However, some font families are considered "web-safe fonts," (e.g., Arial, Verdana, Helvetica [sans-serif fonts], Georgia, Garamond, [serif fonts], and Courier New [monospace font]) while others are not — and many web-safe fonts are pre-installed on a wide range of computer systems and devices.

Is Helvetica a default font?

Helvetica is not included as a default font on Windows computers. Many typefaces look like Helvetica that may already exist in your computer's font collection.


1 Answers

Unless the stylesheet overrides it by referencing the stylesheet with !important after your widget's stylesheet, this could work:

@font-face {
    font-family: 'ProperHelvetica'; /* Make a name for the "proper" Helvetica */
    src: local('helvetica'); /* Assign it to the Helvetica font on the user's system */
}
.your-widget {
    font-family: 'ProperHelvetica', helvetica, sans-serif !important; /* Make everything 
in your widget use the "proper" Helvetica and if the user doesn't have it,
use the site's helvetica. */
}
like image 184
Anish Gupta Avatar answered Sep 29 '22 02:09

Anish Gupta