SRL Archive - OSR Help

getTextAt, getTextAtEx, getTextAtExpWrap


Galaxy

2012-05-24 20:39:30

So, I am fairly new to this whole Simba/SRL thing and I was just wondering if anyone could possibly explain to me what the difference between those 3 were, and which one would the best to use for reading text that is NOT runescape-related, such as reading the font "Tahoma" off a webpage or something similiar to that. Basically, I want to read a font (such as Tahoma) NOT on runescape. Any help would be greatly appreciated, thanks.

Brandon

2012-05-24 21:21:28

I don't have time to finish it but it gives a hint on how to load your own font.. When I get some time I'll edit or finish it.. Just load the font into a finder function.


{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.Simba}

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
WorldInfo := [27, 42, 45, 46, 48, 52, 59, 70, 72, 78, 79, 87, 104, 115, 117];
BoxRewards := ['XP','xp','lamp'];
LampSkill := Skill_Slayer;
Active := True;
end;
end;

Function GetTextCustomFont: String;
var
Font, Testing: TFont;
begin
Font:= TFont.Create;
Font.Style:= [fsBold, fsItalic];
Font.Color:= 65535;
Font.Name:= 'Courier';
Font.Height:= -11;
Font.PixelsPerInch:= 96;


//Result := GetTextAtExWrap(4, 4, 50, 10, 0, 5, 2, 65535, 10, Font.Name);

Font.Free;
end;

begin
{$IFDEF SMART}
SMART_SERVER:= 72;
SMART_SIGNED:= True;
SMART_MEMBERS:= True;
SMART_SUPERDETAIL:= False;
{$ENDIF}

SetupSRL;
DeclarePlayers;
GetTextCustomFont;
end.

Galaxy

2012-05-24 21:44:04

I tried doing this:

program ReadingTextUsingFont;

Function GetTextCustomFont: String;
var
Font: TFont;
begin
Font:= TFont.Create;
Font.Style:= [fsBold, fsItalic];
Font.Color:= 0;
Font.Name:= 'Tahoma';
Font.Height:= 10;
Font.PixelsPerInch:= 96;
Result := GetTextAtExWrap(3,3,35,18,0,5,1,0,20,Font.Name);
Font.Free;
end;

begin
Writeln(getTextCustomFont);
end.

And I got this error:
Error: Exception: Font [Tahoma] not found. at line 13
Line 13 is: Result := GetTextAtExWrap(3,3,35,18,0,5,1,0,20,Font.Name);

Please help?

Abu

2012-05-25 11:13:38

Not sure you're allowed to use that font. Isn't it only the fonts from Simba\Fonts that you can use and any you create yourself…

Galaxy

2012-05-25 14:49:16

From: abu_jwka
Not sure you're allowed to use that font. Isn't it only the fonts from Simba\Fonts that you can use and any you create yourself…


Well, I guess that's partially what I'm trying to ask. How can I create my own font?

Abu

2012-05-25 15:06:05

From: Galaxy
Well, I guess that's partially what I'm trying to ask. How can I create my own font?


I think this still works:
http://villavu.com/forum/showthread.php?t=60451&highlight=Font

Galaxy

2012-05-25 21:25:20

From: abu_jwka
I think this still works:
http://villavu.com/forum/showthread.php?t=60451&highlight=Font


So basically after I'm done creating the font that I want, I can just add it to the Simba/fonts folder and then I can use it inside the getTextAt methods?

honeyhoney

2012-05-26 15:49:14

From: Galaxy
So basically after I'm done creating the font that I want, I can just add it to the Simba/fonts folder and then I can use it inside the getTextAt methods?


Yes.

Your Font bitmaps would be located in:
\Simba\Fonts\FontName\ (\Simba\Fonts\Tahoma\ for example)

Galaxy

2012-05-26 16:54:31

From: honeyhoney
Yes.

Your Font bitmaps would be located in:
\Simba\Fonts\FontName\ (\Simba\Fonts\Tahoma\ for example)


Ohh alright I see. Another question, does it matter what size the letters are?
(Not referring to the size of the bitmaps, but the size of the letters themself)

honeyhoney

2012-05-26 17:08:08

From: Galaxy
Ohh alright I see. Another question, does it matter what size the letters are?
(Not referring to the size of the bitmaps, but the size of the letters themself)


Yes it does. Each font size will require a different set of bitmaps.
For example; you can't use a set of bitmaps made from Tahoma size 12 to identify Tahoma size 14 (potentially you could get close, but it wouldn't be accurate and it is much better to create a new set).

Your Fonts folder would have to contain /Tahoma12/ and /Tahoma14/ (for example) if you wanted to accurately identify the text on the page that uses the font Tahoma in both size 12 and 14.

Galaxy

2012-05-26 17:14:28

From: honeyhoney
Yes it does. Each font size will require a different set of bitmaps.
For example; you can't use a set of bitmaps made from Tahoma size 12 to identify Tahoma size 14 (potentially you could get close, but it wouldn't be accurate and it is much better to create a new set).

Your Fonts folder would have to contain /Tahoma12/ and /Tahoma14/ (for example) if you wanted to accurately identify the text on the page that uses the font Tahoma in both size 12 and 14.


Ah I see. ;P Alright thanks a lot man. And I heard that the text has to be white, and the background black, correct?

honeyhoney

2012-05-26 17:19:54

From: Galaxy
Ah I see. ;P Alright thanks a lot man. And I heard that the text has to be white, and the background black, correct?


The set of bitmaps must have white characters with a black background yes.

However, it can still identify text that is other colors (providing you set it to search for the text in a specific color).

The white characters with black background is necessary as they're used as a bitmap mask (think of your font set as a silhouette or template for the shapes it searches for).

Edit: hope that made sense… xD Don't hesitate to ask again if I confused you… :L

Galaxy

2012-05-26 17:22:15

From: honeyhoney
The set of bitmaps must have white characters with a black background yes.

However, it can still identify text that is other colors (providing you set it to search for the text in a specific color).

The white characters with black background is necessary as they're used as a bitmap mask (think of your font set as a silhouette or template for the shapes it searches for).

Edit: hope that made sense… xD Don't hesitate to ask again if I confused you… :L


Answered my next question. xD My next question was is it possible to read text of the same font & size, but different colour, but you already answered it. :P Thanks. Also, could you explain what it means by horizontal spacing and vertical spacing? (The parameters inside the getTextAt methods)

honeyhoney

2012-05-26 17:36:00

From: Galaxy
Answered my next question. xD My next question was is it possible to read text of the same font & size, but different colour, but you already answered it. :P Thanks. Also, could you explain what it means by horizontal spacing and vertical spacing? (The parameters inside the getTextAt methods)


As far as I'm aware* vertical spacing is simply the space between lines of text.
The vertical spacing (distance) between this line and the line above is 5 pixels (for example).
Often there is a minimum and maximum value required.

Horizontal spacing is the distance between each character. This is generally uniform so it only takes 1 value.

*(I'm no expert, this is all from my experience of messing around with those functions until they work lol)

Galaxy

2012-05-26 18:12:45

From: honeyhoney
As far as I'm aware* vertical spacing is simply the space between lines of text.
The vertical spacing (distance) between this line and the line above is 5 pixels (for example).
Often there is a minimum and maximum value required.

Horizontal spacing is the distance between each character. This is generally uniform so it only takes 1 value.

*(I'm no expert, this is all from my experience of messing around with those functions until they work lol)


Oh I see, so if there was more than 1 line of text you would want to read, you would put the minimal and maximum spacing between each line?

honeyhoney

2012-05-26 18:26:15

From: Galaxy
Oh I see, so if there was more than 1 line of text you would want to read, you would put the minimal and maximum spacing between each line?


I would assume so. I dont think I've ever needed to read more than 1 line at a time though! (and if I have, I've done it 1 line at a time :P)

Galaxy

2012-05-27 13:41:25

From: honeyhoney
I would assume so. I dont think I've ever needed to read more than 1 line at a time though! (and if I have, I've done it 1 line at a time :P)


Ah I see. :P Alright cool thanks.

One last question (kind of irrelevant to the thread topic) but one of my friend's wants to know if you can use this on private servers? (Like the actual runescape methods, like the walking methods, grabbing methods, etc etc, stuff like that) Is it possible?

honeyhoney

2012-05-27 13:45:24

From: Galaxy
Ah I see. :P Alright cool thanks.

One last question (kind of irrelevant to the thread topic) but one of my friend's wants to know if you can use this on private servers? (Like the actual runescape methods, like the walking methods, grabbing methods, etc etc, stuff like that) Is it possible?


From what I've seen (I've never tried personally), they don't work. I know Uptext doesn't work, but I guess the only way to find out is to try!

It'd probably still be worth checking out the SRL Functions/Procedures to see how it's done and then customise it slightly to work with the private server.

Galaxy

2012-05-27 13:47:35

From: honeyhoney
From what I've seen (I've never tried personally), they don't work. I know Uptext doesn't work, but I guess the only way to find out is to try!

It'd probably still be worth checking out the SRL Functions/Procedures to see how it's done and then customise it slightly to work with the private server.


Ah, I see, alright thanks I'll tell him. It is kind of interesting though because some of these private servers are so realistic that you'd think these methods would work on anything identical to runescape, but oh well xD

Galaxy

2012-05-27 13:56:07

Alright actually another question about the fonts & the bitmaps, I was looking at the some of the images of the fonts inside Simba/Fonts and I noticed that the images aren't perfectly cropped, does it matter how much black space you leave?

honeyhoney

2012-05-27 14:03:45

From: Galaxy
Alright actually another question about the fonts & the bitmaps, I was looking at the some of the images of the fonts inside Simba/Fonts and I noticed that the images aren't perfectly cropped, does it matter how much black space you leave?


They all look uniform to me.

Galaxy

2012-05-27 14:09:42

From: honeyhoney
They all look uniform to me.


So does it matter how much blackspace you leave?

honeyhoney

2012-05-27 14:44:10

From: Galaxy
So does it matter how much blackspace you leave?


I'd assume so. Each letter is unique and therefore has a different amount of spacing between them. (from what I can gather from the bitmaps I've seen)

Galaxy

2012-05-27 17:57:21

From: honeyhoney
I'd assume so. Each letter is unique and therefore has a different amount of spacing between them. (from what I can gather from the bitmaps I've seen)


Yeah, I'm not sure if this is a coincidence or not, but each letter's height is 13, so I'm assuming that is also important.