• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Need help

simong1993

Active Coder
Staff Team
Guardian
Hey Mike,

Something like that is really simple to make in all honesty. The fun bit is building or manually getting the fonts, i mean you could build a python scraper to download all of the fonts from somewhere. Have you started?
 

Ghost

Active Coder
It shouldn't be too difficult, but it will take a little bit of time like anything else.
You'll want to do something like this...
-> Database table to store font name, description, permalink/UID (like: times-new-roman) so you can auto load the font file like $permalink.$extension where the permalink comes from DB and extension is the font file type. You could also just store a raw file name in your table. I prefer to use a permalink/UID so that I can do things like... site.com/load-font?id=$permalink and then autoload everything I need based on the $_GET['id']...

-> Directory to store font files (you might even have multiple sub directories if fonts have different styles like bold, italic, etc...
===> folder/fontfile, fontfile2, fontfile3
===> folder/fontfile/boldfile, italicfile ... folder/fontfile2/boldfile, italicfile...

-> PHP page to show the fonts... simple example:
foreach($fonts as $font){ echo $font['name'] . "<br>" . $font['description'] . "<br><a href='load.php?id={$font['permalink']}'>Use This Font</a>"; }

-> PHP page to load 1 font:
if(isset($_GET['id'])){ // check if font is real in database // check if font file exists // load the font in if not already // show HTML page, probably with textarea for typing in font, and preview div that shows the text w/ the font choice as its style }

This is the jist of it... Very simple :)
 

MIke33

New Coder
It shouldn't be too difficult, but it will take a little bit of time like anything else.
You'll want to do something like this...
-> Database table to store font name, description, permalink/UID (like: times-new-roman) so you can auto load the font file like $permalink.$extension where the permalink comes from DB and extension is the font file type. You could also just store a raw file name in your table. I prefer to use a permalink/UID so that I can do things like... site.com/load-font?id=$permalink and then autoload everything I need based on the $_GET['id']...

-> Directory to store font files (you might even have multiple sub directories if fonts have different styles like bold, italic, etc...
===> folder/fontfile, fontfile2, fontfile3
===> folder/fontfile/boldfile, italicfile ... folder/fontfile2/boldfile, italicfile...

-> PHP page to show the fonts... simple example:
foreach($fonts as $font){ echo $font['name'] . "<br>" . $font['description'] . "<br><a href='load.php?id={$font['permalink']}'>Use This Font</a>"; }

-> PHP page to load 1 font:
if(isset($_GET['id'])){ // check if font is real in database // check if font file exists // load the font in if not already // show HTML page, probably with textarea for typing in font, and preview div that shows the text w/ the font choice as its style }

This is the jist of it... Very simple :)
thanks sir for your effort❤️ but i think it will be very difficult for me to make it by myself cuz i am newbie.
 

Ghost

Active Coder
thanks sir for your effort❤️ but i think it will be very difficult for me to make it by myself cuz i am newbie.
I understand. There are a few things that need to be done, so it definitely is a fair bit of work. If you have any specific PHP or other code that you can post here for us to help you with then I am definitely willing to take a look! Have you checked out any plugins for a CMS or other site software you can use?

You can try to use something like PHP Imagick which allows you to find a list of installed fonts. You can then use this list to show them on pages with a PHP loop of the data... And then on the pages for each font you would just load in the font by its ID or filename.
Code:
<?php
    $imagick = new Imagick();
    $fonts = $imagick->queryFonts();
    foreach($fonts as $font)
    {
        echo $font;
    }
?>
The above code is from halfer on Stackoverflow
Note: you may need to install Imagick if it's not already enabled on your server for the PHP version you're using

On the other hand, if you are interested in hiring an experienced developer then please let me know! I can shoot you over some rates in PM and create this site for you.
 

Top