Page 1 of 2 12 LastLast
Results 1 to 25 of 29

Thread: Auto-Updating fonts?!

  1. #1
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default Auto-Updating fonts?!

    Easy & Quick method of updating fonts!

    As some of you know, OpenGL can be used to extract the RuneScape font as a single .png file:



    Each time JaGeX deciedes to update their fonts, we go bananas and our OCR would be down for a day or two because it's kinda hard to update the fonts using our current method (which is manually grabbing each and every character we can find).
    Now we don't have to do that anymore. Why not?

    By using OpenGL and Simba, we can now automatically update the fonts in matter of seconds after RuneScape updates. All we need to do is to have a program hook RuneScape and get the fonts we need (like the ones I've added further up in this post). Once we have done that, we can then 'chop' this image into smaller cells.

    Simba Code:
    type
      TCharSet = record
        Path : String;
        BMP : Integer;
        Characters : array [0..255] of Integer;
        Spacing : TPoint;
      end;

    const
      FONT_PATH = '';

      CHARSET_HIGH  = 0;

    var
      CharSet : array [0..CHARSET_HIGH] of TCharSet;

    function GetSpacing(var Bitmap : Integer) : TPoint;
    var
      W, H : Integer;
    begin
      GetBitmapSize(Bitmap, W, H);
      Result := Point(W div 16, H div 16);
    end;

    procedure LoadCharsets;
    var
      I : Integer;
    begin

      for I := 0 to CHARSET_HIGH do
      begin
        with CharSet[I] do
        begin

          Path := FONT_PATH + IntToStr(I) + '.png';
          if FileExists(Path) then
            BMP  := LoadBitmap(Path)
          else
          begin
            WriteLn(FONT_PATH + IntToStr(I) + '.png, does not exist!');
            TerminateScript;
          end;
          Spacing := GetSpacing(BMP);

        end;
      end;

    end;

    procedure ExtractCharacters;
    var
      I, C,
      W, H,
      X, Y, sX, sY,
      Col, t : Integer;
    begin

      for I := 0 to CHARSET_HIGH do
      begin
        t := GetSystemTime;
        GetBitmapSize(CharSet[I].BMP, W, H);
        for C := 0 to 255 do // Extended ASCII Table.
        begin
          CharSet[I].Characters[C] := CreateBitmap(CharSet[I].Spacing.X, CharSet[I].Spacing.Y);
          FastDrawClear(CharSet[I].Characters[C], clBlack);
          for Y := 0 to CharSet[I].Spacing.X-1 do
            for X := 0 to CharSet[I].Spacing.Y-1 do
            begin
              sX := ((C mod CharSet[I].Spacing.X)*CharSet[I].Spacing.X) + X;
              sY := ((C div CharSet[I].Spacing.Y)*CharSet[I].Spacing.Y) + Y;
              try
                Col := FastGetPixel(CharSet[I].BMP, sX, sY);
                FastSetPixel(Charset[I].Characters[C], X, Y, Col);
              except end;
            end;
        end;
        WriteLn(GetSystemTime - t);
      end;

    end;

    procedure SaveCharacters;
    var
      I, J : Integer;
    begin
      if not DirectoryExists(FONT_PATH + 'Extracted') then
        CreateDirectory(FONT_PATH + 'Extracted');
      for I := 0 to CHARSET_HIGH do
      begin
        if not DirectoryExists(FONT_PATH + 'Extracted\' + IntToStr(I)) then
          CreateDirectory(FONT_PATH + 'Extracted\' + IntToStr(I));
        for J := 0 to 255 do
          SaveBitmap(CharSet[I].Characters[J], FONT_PATH + 'Extracted\' + IntToStr(I) + '\' + IntToStr(J) + '.bmp');
      end;
    end;

    procedure FreeCharsets;
    var
      I, J : Integer;
    begin
      for I := 0 to CHARSET_HIGH do
      begin
        FreeBitmap(CharSet[I].BMP);
        for J := 0 to 255 do
          FreeBitmap(CharSet[I].Characters[J]);
      end;
    end;

    begin
      LoadCharsets;
      ExtractCharacters;
      SaveCharacters;
      FreeCharsets;
    end.
    Using this script, I've been able to turn the RuneScape UpText into a folder in only 3 seconds, and we might be able to make it even faster.
    This is the images the script produced (put into a .rar file for easier uploading/downloading):
    UpText, ChatChars or XPChars

    Unfortunately we can't use those images just yet, as we have to trim those images a little more before Simba is able to handle them, but that would not be a big problem at all.

    HOW-TO: Using the script:
    First you have to create a folder named something like "Charsets", once you have done that, fill in the path to that folder into FONT_PATH. In my case it would be "C:\Users\User\Pictures\SRL\Charsets".
    Next you download this image:

    Save it as "0.png" inside the newly created folder.

    Now you're done! Hit the run button and wait for the script to finish, then look inside your Charsets folder


    EDIT: Now this script doesn't produce bmps with different widths like we use in Simba, but it will be fairly easy to alter the bmps (using a script) to match the ones we're using with simba today.
    EDIT2: I'll do that ^ in the weekend.
    Last edited by Zyt3x; 12-20-2022 at 05:13 PM. Reason: Updated script

  2. #2
    Join Date
    May 2007
    Location
    Some where fun.
    Posts
    2,891
    Mentioned
    1 Post(s)
    Quoted
    5 Post(s)

    Default

    Nice job! Repped!

    You deserve 100 reps for this post

  3. #3
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Camaro' View Post
    Nice job! Repped!

    You deserve 100 reps for this post
    Hahaha thanks mate

    EDIT: Now I got 5 rep balls :P thanks

  4. #4
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    I can dump the fonts from the cache if you guys would like. Here's one I did pretty quickly with the three (I think there are only three) fonts. Let me know if you need something different.

    http://www.mediafire.com/?8f11f0xu55hlq1y
    :-)

  5. #5
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Unfortunately this does not fully solve the spacing problem (yet)

  6. #6
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    That too could be used, Method!
    How did you do that? Using Java?
    The problem right now is to make the fonts go hand in hand with Simba's font. As it is now, Simba has different widths for each bmp (Which imho is an easy problem to fix).

    I'll be off to bed now, but I'll check this thread tomorrow to answer any questions (if there is any)

    EDIT: Wait a few days James, and you'll see

  7. #7
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    That too could be used, Method!
    How did you do that? Using Java?
    The problem right now is to make the fonts go hand in hand with Simba's font. As it is now, Simba has different widths for each bmp (Which imho is an easy problem to fix).

    I'll be off to bed now, but I'll check this thread tomorrow to answer any questions (if there is any)
    Yes, I wrote a program that can load data from the cache into some of the different internal formats Jagex uses.
    Last edited by Method; 12-08-2010 at 12:34 AM.
    :-)

  8. #8
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Nice cup you got there mate!

    Also, would you mind posting the OpenGL stuff in the Development Lounge? I'm about to make an OpenGL Forum there

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  9. #9
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    Unfortunately this does not fully solve the spacing problem (yet)
    To my knowledge the spacing is only relevant for the actual generation of a bitmap for ``FindText''; Simba's OCR doesn't use spacing of the bitmaps. That is if I recall correctly, but I'm fairly sure.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  10. #10
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Sir R. Magician View Post
    Nice cup you got there mate!

    Also, would you mind posting the OpenGL stuff in the Development Lounge? I'm about to make an OpenGL Forum there

    ~RM
    Oh wow!! Thanks!!!

    Will do! I am so glad you added an OpenGL subforum! I am really looking forward to doing some more OpenGL hooking

  11. #11
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    It's sad that this has been posted 3 times (at least) before, yet this is the first time it's getting any attention.

  12. #12
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by TomTuff View Post
    It's sad that this has been posted 3 times (at least) before, yet this is the first time it's getting any attention.
    Links?
    I think this is the first time someone makes a script to update the fonts though..

    EDIT:
    Quote Originally Posted by Wizzup? View Post
    To my knowledge the spacing is only relevant for the actual generation of a bitmap for ``FindText''; Simba's OCR doesn't use spacing of the bitmaps. That is if I recall correctly, but I'm fairly sure.
    Does this mean that Simba could use bmps like this for it's OCR: ?
    Last edited by Zyt3x; 12-08-2010 at 04:40 PM.

  13. #13
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Does this mean that Simba could use bmps like this for it's OCR: ?
    I think so? You'd just have to increase the height and min/max spacing parameters in the function call.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  14. #14
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Links?
    I think this is the first time someone makes a script to update the fonts though..

    EDIT:

    Does this mean that Simba could use bmps like this for it's OCR: ?
    Yes. Simba truncates the bitmap fonts anyway. It only remembers the values it has truncates for the CreateBitmapFromText stuff. I'm not sure if it is as trivial as this, but it is surely possible.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  15. #15
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    To my experience, the width of the bitmaps has been absolutely essential.

  16. #16
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    had an idea on how to make this fully auto

    have it so it searches for the white, if it does it gets as close to the char as it can, so l will just be one line of pixels, basicly the left and right would have no pixels

    then when it searches for it, you can set the min spacing and max spacing when you go searching for it

    ~shut

  17. #17
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Has anyone tested out the characters I uploaded? They all have the same dimensions, but I wouldn't know if they need to be spaced out any differently.
    :-)

  18. #18
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by TomTuff View Post
    It's sad that this has been posted 3 times (at least) before, yet this is the first time it's getting any attention.
    silentwolf was auto-memberized for it.

    It got no attention? huh?

    Method, I don't think anyone started any testing on the fonts just yet

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  19. #19
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    had an idea on how to make this fully auto

    have it so it searches for the white, if it does it gets as close to the char as it can, so l will just be one line of pixels, basicly the left and right would have no pixels

    then when it searches for it, you can set the min spacing and max spacing when you go searching for it

    ~shut
    I already made it do that
    Those letters (Srl) were made by the script. The problem is with characters such as " ' ^ and so on

  20. #20
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    have it so it searches for the white, if it does it gets as close to the char as it can, so l will just be one line of pixels, basicly the left and right would have no pixels
    No, SplitTPA son, I think 2 as max space would work for every character (ones with accent marks and i).

  21. #21
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Ping. This is useful.
    I made a new script, check it out!.

  22. #22
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Markus View Post
    Ping. This is useful.
    Are there any requirements for the fonts (spacing, background color, symbol color, etc.)? pyroryan asked me about fonts the other day, and I'm able to grab the images for every character in every font (including some obscure ones like the fairy language font).
    :-)

  23. #23
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    To succesfully use CreateBitmapFromText and others, you'll need the correct spacing. There's probably a rule that you can generalize for that though. (e.g. if you have them without spacing, add a space on all sides...)

    For the actual rs_GetUpTextAt, all spacing in the bitmaps is disregarded.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  24. #24
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    To succesfully use CreateBitmapFromText and others, you'll need the correct spacing. There's probably a rule that you can generalize for that though. (e.g. if you have them without spacing, add a space on all sides...)

    For the actual rs_GetUpTextAt, all spacing in the bitmaps is disregarded.
    I can look into that later, but here are the fonts from the latest cache, if they are of any use. Each image in a font has the same size for the moment. I've also labeled the three core fonts with the names the client uses to identify them.
    :-)

  25. #25
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    I guess it would be p12_full?

    E: Confirmed p12_full
    Last edited by Wizzup?; 11-22-2011 at 04:35 PM.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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