We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, i think i have an issue with the textSize() function : the size seem to be determined somewhere in the code and i couldn't find a way to change it. Even with textSize(anyNumber) the size won't change. I think i've failed somewhere in my code, but idk where, so i'm asking for help ... here's a link to my game's archive : https://mediafire.com/?t9l8g8mp3k0911b
As you can see, if you uncomment the 2 lines Game.js:54 et Game.js:55, and then run the prog in the browser (press enter to pass the first screen), even if the textSize is 12, it seem that the text is displayed with a size of 50, and i can't find why ........
I'm self taught, and this was a project made to learn and practice with DOM elts and it's totally a WiP, so it is probably a terrible mess, sorry for that ^^
Thanks in advance :) Ali
Answers
Can you post your code?
Kf
i can, but it is spread on 4 different files that's why i linked directly to the archive do you want me to post it anyway ?
I guess it won't harm to post it anyway ...
index.html
/Deleted/
sketch.js
/Deleted/
methods.js
/Deleted/
Game.js
/Deleted/
Player.js
/Deleted/
EDIT : I think i've isolated the problem : has to do with loading fonts, so i deleted the whole project and created a dummy project just to test this :
sketch.js :
Looks like if i load a font, textSize appiles well the first time, but then if i load another font for another text piece, the textSize will be set and locked to what it was before i loaded the first font. Whatever i do after, i can't modify the text size after i loaded the first font ...
Here are some other variations of the main code that i tried (only changed what was inside the draw() so i'll only post this :
/*Load the 2nd font inside the condition where the 1st is loaded */ - Expected behavior : Same text size as the first piece of text (From the p5 ref for the textSize function : "This size will be used in all subsequent calls to the text() function" ) - Actual Behavior : text() uses the text size given before the first font was loaded.
-Code :
/Set the text size before loading the first font, then setting it to another value before loading another font/ - Expected behavior : Text Size of the second text element is set by the second textSize() call - Actual behavior : text size of the second element is the same as the first, as if the second textSize() call doesn't exist.
-Code :
I think i'll try other possibilities and post them here again, i want to have your opinion on this, to see if i have to report this as a bug or if it's just me who didn't quite understood how it works !
Ali
PS : note that the first font is loaded from a file, so a custom font, and the second is a default font (i guess), idk if it has smth to do with this but i post it anyway
After some further tests, i saw that this was only happening when using a custom font loaded from an external file. I think i'll post this in a bug report
Thank you, @Alivanar -- if you do post an issue, please consider adding the issue link to this thread.
https://github.com/processing/p5.js/issues/2055