Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default [RELEASE] Habbo Text Generator

    A friend of mine was asking how to do this earlier today.. so I thought I would give it a try.

    No, this isn't one of those that just display the images lined up side by side.. this actually generates the image.

    The image is also transparent. Here is an example:













    Download (fonts + code): http://u.dopaul.com/text_generator.zip

    Fonts List:
    ------------------------
    Bathroom
    Battleball
    Bling
    Chinese
    Disco
    Explore
    Football
    Habboclub
    Habbowood
    Iced
    KEyboard
    Lido
    Love
    Original
    Recycler
    Simple
    Space
    Tele
    Trophy
    Code (no fonts) - http://dentafrice.pastebin.com/m15f158ed
    ------------------------
    PHP Code:
    <?php
    ##########################################################################
    /**
     * Text Generation Script
     * Author: Caleb Mingle
     * Website: http://dentafrice.com
     * 
     * I know this code isn't the best.. there are plenty of better ways to do it probably.. but this was just a 
     * few minutes of work to get this going, I know people use it.
     */
    ##########################################################################


    /**
     * Settings
     */
    $default_style 'chinese'// this is the default font to use, if $style is not set.
    $space_px 8// this is how many pixels we want to use for a space character.
    $letter_space 2// this is the space we want between each letter. NOT A SPACE CHARACTER.

    /**
     * Data
     */
    $text $_GET["text"]; // get text
    $text = ($text == '') ? 'no text' $text// if text is blank, show 'no text' in the image.

    $style $_GET["style"]; // get style.
    $style = ($style == '') ? $default_style $style// if style is blank, use default style.


    /**
     * Text Handling
     */
    $style ucfirst($style); // turns the style's first letter uppercase for the folder.

    $length strlen($text); // counts the length of the text string.
    $lower strtolower($text); // puts the string to all lower, array.

    /**
     * Image Calculations
     */
    $height 0// starts image height as 0
    $width 0// stars image width as 0
    $data_a = array();

    for (
    $i 0$i $length$i++) {

        if (
    $lower[$i] == ' ') {
            
    $width $width 8// if the letter is a space, add 8px to the width.
            
    $data_a[$i]['letter'] = $lower[$i]; // letter = space.
        
    } else {
            
    $filename $style '/' $lower[$i] . '.gif'// sets the filename in the style folder..
            
    $data = @getimagesize($filename); // gets the image size: width + height of the image.

            
    $width $width $data[0] + $letter_space// sets the width of the image as the original plus the new with of the letter, as well as pixels for spacing.

            
    if ($height $data[1]) {
                
    $height $data[1]; // if the current height is less then this letter's height, replace the height with this one.
            
    }

            
    $data_a[$i]['letter'] = $lower[$i]; // sets this as the letter.
            
    $data_a[$i]['image'] = @imagecreatefromgif($filename); // sets this as the actual image of the letter.
            
    $data_a[$i]['data'] = $data// sets this as the width and height of the image, data.

        
    }

    }

    /**
     * Image Creation
     */
    $image = @imagecreatetruecolor($width$height); // creates the image based on the width + height we determined.

    /**
     * Transparency
     */
    @imagesavealpha($imagetrue); // turns image alpha, transparent.
    $trans_colour = @imagecolorallocatealpha($image000127); // transparent color.
    @imagefill($image00$trans_colour); // fills the image with this color.

    /**
     * Letter Placement
     */

    $x 0// sets the starting x as 0.  top left corner.
    $w 0// sets the starting y as 0.  top left corner.


    foreach ($data_a as $letter) {
        if (
    $letter['letter'] == ' ') {
            
    $x $x $space_px// if the letter is a space, add the correct amount of pixels.
        
    } else {
            @
    imagecopy($image$letter['image'], $x000$letter['data'][0], $letter['data'][1]); // copies the letter to the image we created earlier, in the spot that is indicated by $x, and $y.

            
    $x $x $letter['data'][0] + $letter_space// ads to the placement x and y, width of the letter and the spacing for the letters.
        
    }
    }

    /**
     * Display Image
     */
    header('Content-type: image/png'); // sets the header as a PNG image.
    @imagepng($image); // displays the image.
    @imagedestroy($image); // destroys the image.

    ?>

    Hope you enjoy!

    Caleb

  2. #2
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Hai, Mr. Mingle.

    Nice release, code is excellent as usual.

    *jealous*

  3. #3
    Join Date
    Jun 2004
    Location
    Reading, Berkshire
    Posts
    2,260
    Tokens
    12,202
    Habbo
    :Jin:

    Latest Awards:

    Default

    Good stuff Caleb, May see this on the Habbox site in a short while.


  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Awesome!

    You can also make your own fonts for it.. ignore the badly positioned and ugly text.. that was my fault on photoshop.


  5. #5
    Join Date
    May 2008
    Posts
    1,160
    Tokens
    11

    Latest Awards:

    Default

    How do you add your custom fonts?
    I'm a bit confused as to why you can't type what font you want and then choose font style...?
    Last edited by Cushioned; 12-01-2009 at 03:46 AM.
    Previously a Habbo fanatic, web designer/developer, fansite owner, & trusted member of the community.

  6. #6
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by Cushioned View Post
    How do you add your custom fonts?
    You have to create each letter one by one and save them in a directory..

  7. #7
    Join Date
    May 2008
    Posts
    1,160
    Tokens
    11

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    You have to create each letter one by one and save them in a directory..
    Yeah I figured that much out

    Make it like a normal font gen where you type your font, then choose the font style and click generate, then it shows up on page.
    http://www.habbotimes.net/fancenter/schriftgenerator

    There are font previews and you click on them for the style you choose
    Previously a Habbo fanatic, web designer/developer, fansite owner, & trusted member of the community.

  8. #8
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    I can't be bothered to do that. Someone can if they want. This is just the coding for it

  9. #9
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    I can't be bothered to do that. Someone can if they want. This is just the coding for it
    I could do this if more details could be specified of what needs adding.

  10. #10
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by Calon View Post
    I could do this if more details could be specified of what needs adding.
    We'll see later today. Shouldn't be too hard.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •