| View previous topic :: View next topic |
| Author |
Message |
NexuIV Cheater
Reputation: 0
Joined: 24 Jul 2016 Posts: 26
|
Posted: Wed Jul 27, 2016 6:28 am Post subject: My First Trainer...Font problem |
|
|
Hi,
I created my first GUI via internal editor and entering some script in the lua for some sender functions but I have a problem with the font. The font I've chosen is not a standard windows font. Via Editor, I create the label, I change some parameters within section Font, then I select the font to be associated with such a label.
I create the executable and if I launch the Trainer on the computer on which the font is installed, everything works perfectly.
If I launch the executable to another computer, where it is not installed font... changes everything.
Where am I wrong? It needs to insert some function in lua for importing the font in the table ?
Thanks.
| Description: |
| Incorrect...Computer where the fon is not installed. |
|
| Filesize: |
80.73 KB |
| Viewed: |
10783 Time(s) |

|
| Description: |
| Correct...Computer where the font is installed. |
|
| Filesize: |
92.71 KB |
| Viewed: |
10783 Time(s) |

|
|
|
| Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Wed Jul 27, 2016 8:04 am Post subject: |
|
|
You may have to add the font file to the trainer when you create it. I've never tried using a non-standard font, so perhaps someone else can confirm. There is a place where you can add extra files during trainer creation.
Last edited by ++METHOS on Wed Jul 27, 2016 8:05 am; edited 1 time in total |
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed Jul 27, 2016 8:05 am Post subject: |
|
|
Hey,
Try the following script
| Code: | function TableAddFont(path) -- table file name or path to font
if (type(path)=='string') then
local font,filename
font = findTableFile(path);
if (not font) then -- Didn't find font using findTableFile
local file = io.open(path,"r") -- if its string and we can open the file for reading why not
if (not file) then
error("ERROR loading font");
else
file:close();
filename = path:match("\\(.-)$") -- for assigning the file into table, we generally could delete it afterwards..
font = findTableFile(filename) -- double check we didnt already added it, it seems C.E crashes if duplicates
if (not font) then
font = createTableFile(filename,path)
end
end
end
local pFont = font.stream.memory -- required font resource pointer for AddFontResourceExA
local length = font.stream.size -- length, of the font resource
local sAdd = "alloc(script,56)\nalloc(data,10)\nlabel(count)\nlabel(handle)\nregistersymbol(count)\nregistersymbol(handle)\nregistersymbol(script)\nregistersymbol(data)\n\nscript:\nlea eax,[count]\npush eax\npush 0\npush #%d\npush #%d\ncall AddFontMemResourceEx\nmov [handle],eax\nret\n\ndata:\ncount:\ndd -1\nhandle:\n\ndd -1\ncreatethread(script)"
sAdd = sAdd:format(length,pFont) -- place the pointer and length in the script
local status = autoAssemble(sAdd,true);
-- in case of debug, you can assign "count" and "handle" into table, count should represent # of fonts added, and handle should hold a handle (we can use to remove font later)
-- we technically don't need to remove the font as windows does it for us as soon as the program terminate
if (status) then
local sRemove = ("alloc(script,56)\nlabel(success)\nregistersymbol(success)\nregistersymbol(script)\n\nscript:\npush #%d\ncall RemoveFontMemResourceEx\nmov [success],eax\nret\n\nsuccess:\ndd -1\ncreatethread(script)")
-- sRemove success should hold how many fonts were removed, if 0 then it failed, default -1;
sRemove:format(readIntegerLocal("handle")); -- read our font handle
return true,function () return autoAssemble(sRemove); end;
end
end
end |
To use it in your trainer, simply add font table into your table, then load the font by calling
| Code: | | TableAddFont("The_Juke_Box-FFP.ttf"); -- example of font I used |
The downside of my script for now that I have no clue yet how to obtain font name from memory (currently working on it).
But generally if you know the font name just change font name to your font name.
Note: in cheat engine GUI designer the font WILL NOT show in the font list, but doing Object.Font.Name = "The Juke Box" should work.
attached a .CT as an example
PS
Please beware of copyright and license.
Edit
This script is 32bit version only, look couple of posts down for 32&64 bit version
| Description: |
|
 Download |
| Filename: |
fontExample.CT |
| Filesize: |
43.88 KB |
| Downloaded: |
557 Time(s) |
_________________
I'm rusty and getting older, help me re-learn lua.
Last edited by daspamer on Wed Jul 27, 2016 12:07 pm; edited 1 time in total |
|
| Back to top |
|
 |
NexuIV Cheater
Reputation: 0
Joined: 24 Jul 2016 Posts: 26
|
Posted: Wed Jul 27, 2016 8:13 am Post subject: |
|
|
Thank You Very Much.
Now I try and then I'll let you know
Regards
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed Jul 27, 2016 8:30 am Post subject: |
|
|
You can load fonts into a table in this script by calling this (as an example)
| Code: | local path = 'c:\\The_Juke_Box-FFP.ttf';
print(path)
TableAddFont(path) |
it will save you the few clicks of assigning the file into table.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
NexuIV Cheater
Reputation: 0
Joined: 24 Jul 2016 Posts: 26
|
Posted: Wed Jul 27, 2016 8:54 am Post subject: |
|
|
| DaSpamer wrote: | You can load fonts into a table in this script by calling this (as an example)
| Code: | local path = 'c:\\The_Juke_Box-FFP.ttf';
print(path)
TableAddFont(path) |
it will save you the few clicks of assigning the file into table. |
Thank You DaSpamer but the script don't work.
I downloaded your file, running, but under Windows 10 64 bit and CE 6.5.1 crashes.
Idem if I put the code into my trainer.
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed Jul 27, 2016 10:11 am Post subject: |
|
|
Well fixed, should work for 32 & 64 bits.
Use this example (attached)
Created a thread for this script >>
http://forum.cheatengine.org/viewtopic.php?t=593709
| Description: |
|
 Download |
| Filename: |
fontExample.CT |
| Filesize: |
43.01 KB |
| Downloaded: |
605 Time(s) |
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
NexuIV Cheater
Reputation: 0
Joined: 24 Jul 2016 Posts: 26
|
Posted: Wed Jul 27, 2016 11:21 am Post subject: |
|
|
Outstanding !!! It works perfectly . You are a God !!!
Last question ... with this function can change the font size of each label on the GUI ?
Thanks so much !!!
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed Jul 27, 2016 12:03 pm Post subject: |
|
|
Yes you can change font size
simply change the font size
e.g
| Code: | | label.font.size = 60 |
example if you have a form named UDF1 and a label named CELabel1
| Code: | | UDF1.CELabel1.font.size = 60 -- modify for your needs |
(inside the .CT above theres example of how I set the label font size and etc. since I created the GUI using lua..)
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
NexuIV Cheater
Reputation: 0
Joined: 24 Jul 2016 Posts: 26
|
Posted: Wed Jul 27, 2016 12:36 pm Post subject: |
|
|
| DaSpamer wrote: | Yes you can change font size
simply change the font size
e.g
| Code: | | label.font.size = 60 |
example if you have a form named UDF1 and a label named CELabel1
| Code: | | UDF1.CELabel1.font.size = 60 -- modify for your needs |
(inside the .CT above theres example of how I set the label font size and etc. since I created the GUI using lua..) |
Perfect !!!
It is possible that the script may have problems with partitions other than C : and subdirectories ?
I tried:
| Code: |
local path = 'D:\\Folder\\SubFolder\\Subfolder\\Font.ttf';
local path = [[D:\Folder\SubFolder\Subfolder\Font.ttf]]
local path = ([[D:\Folder\SubFolder\Subfolder\Font.ttf]])
|
But don't work. Only fonts in path like C:Root or D:Root are loaded perfectly. Other paths load in table... "_\Folder\Subfolder\Font.ttf"
Where am I wrong?
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed Jul 27, 2016 12:57 pm Post subject: |
|
|
Yes I didn't actually test it in any other dir.
Just change the regex,replace
| Code: | | filename = path:match("\\(.-)$") |
with this
| Code: | | filename = path:match(".+\\(.-)$") |
Tested with this dir for example
| Code: | | C:\Fonts\CantGoWrongIhope\MoreDirs\AndEvenMORE!\The_Juke_Box-FFP.ttf |
(Updated it in the extension thread too)
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
NexuIV Cheater
Reputation: 0
Joined: 24 Jul 2016 Posts: 26
|
Posted: Thu Jul 28, 2016 5:11 am Post subject: |
|
|
Hi DaSpamer,
I tested your last script and I think there's something wrong.
The regular expression does not work properly and could be such a thing ?
but I cannot place it in the appropriate section
I also believe that in this section:
| Code: |
-- File name inside cheat engine table
local name = '04b30'
TableAddFont(name)
|
the row | Code: | | local name = '04b30' |
It should instead be
| Code: | | local filename = '04b30' |
right ?
The first version of your script, uploading manually font in the table and replacing the font name in the appropriate sections, works perfectly.
I apologize for the time that I'm wasting
Thanks
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Thu Jul 28, 2016 11:45 pm Post subject: |
|
|
I'm not quite sure what you mean it does not work properly?
Can you post an example path that it does not work with? because it
You used the script from here or from this thread?
And no, filename is a variable set only if the font was not loaded into c.e, then it will load the from path and set the filename by detecting the file name in path.
You cannot set filename variable from outside the function, filename is a local variable that is set only in the function scope.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
NexuIV Cheater
Reputation: 0
Joined: 24 Jul 2016 Posts: 26
|
Posted: Fri Jul 29, 2016 6:34 am Post subject: |
|
|
Sorry !!!
I made a mega mistake. Damned quotes ... the script works perfectly.
Sorry again, great works and thank you so much.
|
|
| Back to top |
|
 |
|