Hello guys,
I am trying to create some Reaction labels with different font size, which should be the screen font, only reduced by specific points.
I was looking at the autodocs and I saw that IA_FONT is deprecated, and we need to use LABEL_DrawInfo, which actually includes a TextAttr, which looks similar to the one that IA_FONT used.
What I would like to ask is, am I at the right path? Is LABEL_DrawInfo what I should use?
Is there a way to get the current font and font size and reduce it by some points?
Is there an automatic process that does that, i.e. like saying screen->fontSize - 2
?
Where can I find more info on LABEL_DrawInfo?
Thanks a lot for your help.
@walkero
A long time ago a built these two functions, one being the counterpart of the other and finally the way they are called:
Maybe this can be of help to you?
OldFart
@walkero
The problem with IA_Font (a general tag defined at the Image Class level) is that different image subclasses may use it differently. The original documentation did not specify clearly whether the tag should take a struct TextAttr pointer, or a struct TextFont pointer. So you can come across both uses in the wild.
The Label Image class expects a struct TextAttr pointer in IA_Font, and this is what I use in my ToolBar Gadget class. But you can use LABEL_DrawInfo instead if you have the struct DrawInfo pointer. You just have to make sure that they precede the LABEL_Text tag, otherwise the font will not be set for the label.
As for the font size adjustment: I just obtain the screen font (struct TextAttr) pointer from the struct Screen and decrease the size by the required number of pixels, i.e something like
mySize = scr->Font->ta_YSize - 2;
Hope this helps.
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
Thank you both for the explanation. I will try these out and let you know how it goes.
If LABEL_Font does not exist, then IA_Font is probably the way to go.
LABEL_DrawInfo is not a solution. You can get a DrawInfo from the screen using GetScreenDrawInfo(), you should not try to build your own. But what you get is read-only, you should not poke different values into it.
Reading the prefs files should not be necessary. You can get the screen font from Screen->Font (struct TextAttr) or Screen->RastPort.Font (struct TextFont).
The fixed-width system font can be read from GfxBase->DefaultFont or from the Font field of a freshly initialized RastPort. (Both point to a struct TextFont).
And BTW, the current prefs settings should be read from Env: not from Envarc:
@walkero
It should be, according to the label.image autodoc. (Never tried myself, though: I always use IA_Font with label.image.) I assume the font information for the label text is taken from drawInfo->dri_Font, which is a struct TextFont pointer.
For the sake of completeness, you can also query SA_Font via IIntuition->GetScreenAttr().
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
This is the text from the autodocs:
It clearly says that DrawInfo is required for the label to know the correct default (a.k.a. screen) font.
If you want a custom font, you have to use IA_Font to override the default.
@thomas
You're right of course - for a moment I forgot what Walkero was after (i.e. setting a smaller version of the screen font, not the screen font itself).
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2