Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8733831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:43:39+00:00 2026-06-13T09:43:39+00:00

I’m looking for a way to add fonts on an ‘as-needed’ basis. I originally

  • 0

I’m looking for a way to add fonts on an ‘as-needed’ basis.

I originally had 4 Google API Fonts chosen from when I build this particular site. Now that it’s grown, I’d like to up the font selection to 9 choices.

I’m trying to figure out a way to get this done via PHP, but I’m a designer so my php is ‘eh’.

Here’s the “rough draft” from what I know of php.

Anybody want to help me out real quick?

<?php //This is in an External PHP Command Page
$aladin = "Aladin";
$cardo = "Cardo:400,400italic";
$crimson = "Crimson+Text:700italic";
$euphoria = "Euphoria+Script";
$josefin = "Josefin+Slab:400,700";
$philosopher = "Philosopher:400,400italic";
$redressed = "Redressed";
$rouge = "Rouge+Script";
$vollkorn = "Vollkorn:400,400italic,700";

//Factory Presets
$all = "$aladin, $cardo, $crimson, $euphoria, $josefin, $philosopher, $redressed, $rouge, $vollkorn";
$main = "$cardo, $crimson, $philosopher,";

    function insertFonts ($fonts) {
        echo '<link href=\"//fonts.googleapis.com/css?family=';
        echo $fonts;
        echo '\' rel="stylesheet" type="text/css" />';  
        };
?>

Then this in the web page.

<?php //This goes inside the <head> of X page
insertFonts($main); // OR insertFonts($aladin, $redressed, $euphoria); as needed
?>

Also, the link tag needs a | in between the font names… I have no idea how to do this.
The format for all of them provided by google is
< link href=’http://fonts.googleapis.com/css?family=Cardo:400,400italic|Crimson+Text:700italic|Euphoria+Script|Philosopher:400,400italic|Vollkorn:400,400italic,700|Josefin+Slab:400,700|Redressed|Aladin|Rouge+Script’ rel=’stylesheet’ type=’text/css’ >

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:43:40+00:00Added an answer on June 13, 2026 at 9:43 am
    function insertFonts($f){
        $output = '';
        $fonts = array(
            'aladin'        =>  "Aladin",
            'cardo'         =>  "Cardo:400,400italic",
            'crimson'       =>  "Crimson+Text",
            'euphoria'      =>  "Euphoria+Script",
            'josefin'       =>  "Josefin+Slab, serif",
            'philosopher'   =>  "Philosopher, italic",
            'redressed'     =>  "Redressed, cursive",
            'rouge'         =>  "Rouge+Script, cursive",
            'vollkorn'      =>  "Vollkorn, serif"
        );
    
    foreach ($f as $val) {
        if(array_key_exists($val, $fonts)){
            if(strlen($output)>0) $output .="|";
            $output .="$fonts[$val]";
        }
    }
    return strlen($output)>0 ? "<link href=\"//fonts.googleapis.com/css?family=$output\" rel='stylesheet' type='text/css' />" : '';
    }
    
    // Usage
    echo insertFonts(array('cardo','josefin'));
    

    But if you want to load each fonts seperatey, change the method this way:

    foreach ($f as $val) {
        if(array_key_exists($val, $fonts)){
            $output .="<link href=\"//fonts.googleapis.com/css?family=$fonts[$val]\" rel='stylesheet' type='text/css' />\n";
        }
    }
    
    return $output;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.