Page 1 of 2

FontRequest and GetAttribute

Posted: Tue Feb 11, 2020 4:51 pm
by Juan Carlos
I have found a problem when you load one font using the FontRequest I can't get the font properties because the instruction GetAttribute needs a number of Font here is the example:

Code: Select all

Fuente=FontRequest("Select one font")
SetFont(Fuente.name, Fuente.size) ;Here you get the name and size from the font.
SetFontColor(HexStr(Fuente.color)) ;I gives the font color.

 ;Here I try to get the anlialias, but the instruction GetAttribute needs a font number and with the FontRequest it is possible?
TextoAlias=GetAttribute(#FONT, Fuente, #ATTRFONTAA)
If TextoAlias=True
	SetFontStyle(#ANTIALIAS)
	SystemRequest("WARNING", "Font with antialias", "Ok", #REQICON_ERROR)
Else
	SystemRequest("WARNING", "Font without antialias", "ok", #REQICON_ERROR)
EndIf
TextOut(#CENTER, #CENTER, "TEXT OF TEST")

EscapeQuit(False)
Repeat
  WaitEvent
Forever
Is there any way to get the number of the font loaded with FontRequest for get all attributtes?
Thank you.

Re: FontRequest and GetAttribute

Posted: Wed Feb 12, 2020 10:55 am
by SamuraiCrow
I think you are looking for GetFontStyle(). GetAttribute() is only for fonts embedded using preprocessor macros because it is in the object library.

Re: FontRequest and GetAttribute

Posted: Wed Feb 12, 2020 10:24 pm
by Juan Carlos
SamuraiCrow wrote: Wed Feb 12, 2020 10:55 am I think you are looking for GetFontStyle(). GetAttribute() is only for fonts embedded using preprocessor macros because it is in the object library.
Thank you for your idea but SetFontStyle isn't the solution because is not the same situation FontRequest than SetFontStyle.

Re: FontRequest and GetAttribute

Posted: Sun Feb 16, 2020 12:07 am
by airsoftsoftwair
You cannot get whether the font supports antialiasing because the system font requester doesn't return this information. This information is only available once a font is loaded so you need to load the font first.

Re: FontRequest and GetAttribute

Posted: Sun Feb 16, 2020 2:13 pm
by Juan Carlos
airsoftsoftwair wrote: Sun Feb 16, 2020 12:07 am You cannot get whether the font supports antialiasing because the system font requester doesn't return this information. This information is only available once a font is loaded so you need to load the font first.
But un the Code already you load the Font with the requester and the antialias propertie is assigned and the Font is showed with this, but the GetAttribute hasn't this propertie.

Re: FontRequest and GetAttribute

Posted: Mon Feb 17, 2020 12:35 pm
by Juan Carlos
The idea is to can distinguish the True Type Font of Amiga traditional Font to set the anti-alysing in the True Type because if you set for default the Amiga Font isn't showed.

Re: FontRequest and GetAttribute

Posted: Mon Feb 17, 2020 4:49 pm
by airsoftsoftwair
Hollywood can't tell the type of a font without loading it so just load it, query #FONTAA and then free it again.

Re: FontRequest and GetAttribute

Posted: Mon Feb 17, 2020 9:16 pm
by Juan Carlos
But there isn't LoadFont like LoadBrush to get attributes.

Re: FontRequest and GetAttribute

Posted: Tue Feb 18, 2020 1:42 am
by PEB
Try OpenFont().

Code: Select all

OpenFont(1, "Arial", 36)
DebugPrint(GetAttribute(#FONT, 1, #ATTRFONTAA))
CloseFont(1)

Re: FontRequest and GetAttribute

Posted: Tue Feb 18, 2020 10:48 am
by Juan Carlos
PEB wrote: Tue Feb 18, 2020 1:42 am Try OpenFont().

Code: Select all

OpenFont(1, "Arial", 36)
DebugPrint(GetAttribute(#FONT, 1, #ATTRFONTAA))
CloseFont(1)
No os this, I ask the Font with FontResquest.