Widget of the Day for Y'all
-
@ustk the limitation to 32 slots is one of the main reasons why they are so fast :)
-
@Christoph-Hart Sure! I wouldn't need more anyway... When I reach that number I always get back to another design because it means I overdid something... (By the way, it would be cool to have an alert when reaching the limitation because I already struggled multiple times to find the origin of a bug while I was simply having too many regs within a namespace )
And what about declaring them inside a LAF function like @clevername27 did?
-
@d-healey Thank you - I simply don't know how to do that with fonts, could you please tell me?
-
@Christoph-Hart Are these literally register variables?
-
@ustk yes good idea, I‘ll make it throw an error (no idea why I didn‘t do this earlier, lol)
-
@clevername27 said in Widget of the Day for Y'all:
@Christoph-Hart Are these literally register variables?
no, there are about 20 layers of abstraction between these variables and the CPU registers…
-
@ustk I've added your code as a comment - thank you.
-
@d-healey Thank you for your suggestion - I've revised the code to use 'g' and "obj".
-
@clevername27 said in Widget of the Day for Y'all:
@d-healey Thank you - I simply don't know how to do that with fonts, could you please tell me?
You can't, if you load a font in your snippet then the user must have that font. So don't use them in snippets.
-
@d-healey How do I draw text then - don't I have to specify some font?
-
@clevername27
loadFontAs
but just give the name of an embedded font (that you can find in the property of a Label)
If you just want to draw a text for an example snippet, just do:g.setFont("Arial", 14.0); // or whatever embedded font
inside a paint routine (or LAF function), you don't even need to loadFontAs...
And if you just ignore this line, a default font will be used anyway so you don't even have to bother setting a font (but then you lose the ability to set its size) -
How do I draw text then - don't I have to specify some font?
If you don't call
g.setFont()
, it will default to Arial or whatever is the standard font.For a "real" project, I would always embed the fonts, but if you want to pass around snippets that need to be self-contained, you can just assume that the user has installed the font on his system and if it isn't found, it will fall back to Arial (or Comic Sans MS on April 1st).
-
@Christoph-Hart said in Widget of the Day for Y'all:
(or Comic Sans MS on April 1st).
-
@clevername27 said in Widget of the Day for Y'all:
@d-healey How do I draw text then - don't I have to specify some font?
No need to specify a font at all, it will use the default
-
Thank you, everyone. Fonts sorted.