Welcome to Gaia! ::

Profilist Tools

Back to Guilds

Profile dumpage 

Tags: profile, coding, guide, media, free 

Reply [CSS] Guides and Resources
[Mini Guide] Using @font-face to Import Fonts

Quick Reply

Enter both words below, separated by a space:

Can't read the text? Click here

Submit


Profilist

Captain

Hardworking Regular

PostPosted: Thu Oct 13, 2016 7:49 am


[ Mini Guide ]
    Using @font-face to Import Fonts

    You may see some users with fancy fonts on their profile or an @font-face line in their coding.
    The @font-face rule is a bit of a unique area of CSS.
    What it does is allow you to import font files from host sites in order to use various web fonts on your page.

    At the moment, the only sites which support font hosting are Google Fonts and Font Library.
    You can find directions for each site below.
PostPosted: Sat Oct 15, 2016 6:47 am


General Notes

  • To make your font work, you need two parts:
    1. A @font-face line in your CSS which has a src (source) for the font family URL
    This will notify your browser that "hey, we are inserting a font from (this location) so that it can be used on your page"
    2. A property targeting at least one of your selectors and applying this font to them
    Ex: .panel{font-family: 'Open Sans';}

  • Different browsers support different font src URLs
    The latest versions of Firefox, Chrome, and Microsoft edge should support .woff2 files, but Safari and Internet Explorer only support .woff
    You can check MDN for more compatibility

  • You cannot use @import to import fonts
    Simply put, Gaia doesn't support it, so it won't work.

  • You cannot import fonts from other sites like DaFont, Font Squirrel, etc.
    They do not support the EULA (End User License Agreement). You can read more about it in this post.
    If you see profiles with fonts from those locations, it is because the font is displayed through graphics (images), not imported.


Profilist

Captain

Hardworking Regular



Profilist

Captain

Hardworking Regular

PostPosted: Sat Oct 15, 2016 6:47 am


Google Fonts

    Google Fonts is the most reliable host for importing fonts.
    You can check out their website at fonts.google.com

    STEP 1: Pick a Font
    Simply head over to the Google Fonts site and browse their catalog for fonts you want to use.
    As you find ones you like, click the ( + ) symbol in the top right of them.
    This will add them to your font collection window at the bottom of the page.

    STEP 2: Get the font family URL
    Open the window at the bottom of your page which says "# Family Selected"
    In this window, you can customize your fonts and choose if you want different weights/styles of them to be imported onto your page.
    Once you are done with that, click the EMBED tab of this window and click the STANDARD tab slightly below that.
    You will get code which looks somewhat like this:

    We only want the URL in there, so copy this part:
    https://fonts.googleapis.com/css?family=Open+Sans
    And paste that into your browser address bar

    STEP 3: Copying the @font-face coding
    The font family URL should lead you to a page which contains lines of code looking somewhat like this:

    /* cyrillic-ext */
    @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    src: local('Open Sans'), local('OpenSans'), url(https://fonts.gstatic.com/s/opensans/v13/K88pR3goAWT7BTt32Z01mxJtnKITppOI_IvcXXDNrsc.woff2) format('woff2')
    unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
    }
    /* cyrillic */
    @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    src: local('Open Sans'), local('OpenSans'), url(https://fonts.gstatic.com/s/opensans/v13/RjgO7rYTmqiVp7vzi-Q5URJtnKITppOI_IvcXXDNrsc.woff2) format('woff2')
    unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
    }
    /* greek-ext */
    @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    src: local('Open Sans'), local('OpenSans'), url(https://fonts.gstatic.com/s/opensans/v13/LWCjsQkB6EMdfHrEVqA1KRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2')
    unicode-range: U+1F00-1FFF;
    }
    /* greek */
    @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    src: local('Open Sans'), local('OpenSans'), url(https://fonts.gstatic.com/s/opensans/v13/xozscpT2726on7jbcb_pAhJtnKITppOI_IvcXXDNrsc.woff2) format('woff2')
    unicode-range: U+0370-03FF;
    }
    /* vietnamese */
    @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    src: local('Open Sans'), local('OpenSans'), url(https://fonts.gstatic.com/s/opensans/v13/59ZRklaO5bWGqF5A9baEERJtnKITppOI_IvcXXDNrsc.woff2) format('woff2')
    unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
    }
    /* latin-ext */
    @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    src: local('Open Sans'), local('OpenSans'), url(https://fonts.gstatic.com/s/opensans/v13/u-WUoqrET9fUeobQW7jkRRJtnKITppOI_IvcXXDNrsc.woff2) format('woff2')
    unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
    }
    /* latin */
    @font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400;
    src: local('Open Sans'), local('OpenSans'), url(https://fonts.gstatic.com/s/opensans/v13/cJZKeOuBrn4kERxqtaUH3VtXRa8TVwTICgirnJhmVJw.woff2) format('woff2')
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
    }
    You only really need the /* latin */ part of this code, so just copy the @font-face coding under that part and ignore the rest.

    STEP 4: Inserting the @font-face into your code
    Once you have your @font-face CSS copied, all you have to do is paste it into your profile's Theme Override box!
    The location does not really matter, but I would suggest putting it towards the top, so that it is easy to locate
    (and it speeds up its loading time a bit, since the browser will read that line first)
PostPosted: Sat Oct 15, 2016 7:09 am


Font Library

    Font Library had a smaller collection of fonts, but it also has some more unique and fancier options.
    You can check out their website at fontlibrary.org

    STEP 1: Pick a Font
    Simply head over to the Font Library site and browse their catalog for fonts you want to use.
    Once you find one you like, click on it to go to the font page. Ex: Megrim

    STEP 2: Get the font family URL
    On the right side of the font page, there will be an area which says "USE THIS FONT"
    You will want to copy part of the HTML coding it has listed under here...

    Specifically, you just want the "https://fontlibrary.org/face/megrim" URL in there
    Take that URL and paste it into your browser's address field.

    STEP 3: Copying the @font-face coding
    The font family URL should lead you to a page which contains lines of code looking somewhat like this:

    @font-face {
    font-family: 'MegrimMedium';
    src: url('/assets/fonts/megrim/7c7ebbace2b20afe253743b779da3044/c7bb56ac0f25b99edffbab43ba943e45/MegrimMedium.ttf') format('truetype')
    font-weight: normal;
    font-style: normal;
    }

    /* The following rules are deprecated. */

    @font-face {
    font-family: 'Megrim';
    src: url('/assets/fonts/megrim/7c7ebbace2b20afe253743b779da3044/c7bb56ac0f25b99edffbab43ba943e45/MegrimMedium.ttf') format('truetype')
    font-weight: normal;
    font-style: normal;
    }
    You can ignore any coding under the "The following rules are deprecated." text.
    Copy everything above there and paste it into your profile's Theme Override box

    STEP 4: Correcting the source URL
    Font Library requires one extra step: You need to correct the src line, since it is incomplete.
    To do so, locate the "src" line of your @font-face block. It should look like:
    src: url('/assets/fonts/name/blahblahblah...');

    Add "https://fontlibrary.org" onto the front of that URL, so it turns into:
    src: url('https://fontlibrary.org/assets/fonts/name/blahblahblah...');

    And then you are good to go!


Profilist

Captain

Hardworking Regular

Reply
[CSS] Guides and Resources

 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum