Jump to content
abyss616

Problems with LoadChars2 and get TextAtEx

Recommended Posts

Hi, i need to read text at specified coordinates, so i think GetTextAtEx will get the job done for me. But for some reason it do not work as i want.

program New;
var
 x, y, f,c,font : integer;
 s, name,test : string;
 flag:boolean;
begin
 SetFontSmoothing(False);
 font:=LoadChars2('C:\Windows\Fonts\Arial\ariblk.ttf')
//c:= LoadCharsFromFont2('C:\Windows\Fonts\Arial\ariblk.ttf', 10, False, False, False, False);
s:=GetTextAtEx(1173, 80, 0, font, False, False, 0, 0, -1, 10, True, tr_AllChars);
flag:=IsTextInAreaEx(1160, 80, 1135, 174,x,y,'Test',0,font,False,False,0,0,-1);
end.

 

What problems i have:

1) LoadChars2 Function ALWAYS returns -1, no matter what font i choose or i leave it blank

2) Everytime when it gets to GetTextAtEx i get this exception:

 

Access violation at address 0040BA24 in module scar.exe. Read of Address 000000000

 

 

For additional information i am usin scara 3.35(tried 3.34 and 3.38) and windows 7 proffesional 32 bits version.

 

Any help will be aprreciate.

 

Thank you and have a nice day :)

Link to comment
Share on other sites

To load a Windows font use something like this:

 

[sCAR]font := LoadCharsFromFont2('Arial Black', 10, False, False, False, False);[/sCAR]

 

You use the name of the font rather than specifying the actual path to the font.

 

I already tried that, but still. no matter what font I specify it returns 0 every time. I assume it shouldnt be like that..

Link to comment
Share on other sites

No that is normal (just tried it). If you want to find out if your font is loading correctly try something like this:

 

[sCAR]program New;

 

var

Font: Integer;

B: TSCARBitmap;

 

begin

Font := LoadCharsFromFont2('Arial Black', 10, False, False, False, False);

B := CreateBitmapFromText('Bixby rocks my world.', Font, clRed);

DebugBitmap(B);

B.Free();

FreeChars2(Font);

end.[/sCAR]

Link to comment
Share on other sites

No that is normal (just tried it). If you want to find out if your font is loading correctly try something like this:

 

[sCAR]program New;

 

var

Font: Integer;

B: TSCARBitmap;

 

begin

Font := LoadCharsFromFont2('Arial Black', 10, False, False, False, False);

B := CreateBitmapFromText('Bixby rocks my world.', Font, clRed);

DebugBitmap(B);

B.Free();

FreeChars2(Font);

end.[/sCAR]

 

I tried your example and it returns debug image with text Bixby rocks my world and its red. So fonts are working, right?

 

P. S Sorry for picture below, at begining i thought that it doesnt work, thats why i added picture, but then i saw second window and edited my post, still couldnt remove picture.

Capture.JPG

Edited by abyss616
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...