Page 1 of 1
default font
Posted: Mon Oct 18, 2010 10:09 am
by sartic
How to set default font?
story:
i wrote (2) test app (irc server and client)
compiled client in ubuntu 10.10 width demo 4.5
it works but fonts are bigger than in win
another question... visual designer in linux how? any link?
Re: default font
Posted: Tue Oct 19, 2010 11:43 am
by #NULL
for gadgets:
Code: Select all
SetGadgetFont(#PB_Default, FontID)
it's in the manual.
for 2d drawing i don't know.
Re: default font
Posted: Tue Oct 19, 2010 1:44 pm
by Vera
sartic wrote:it works but fonts are bigger than in win
but doesn't that depend on the local OS / user settings or monitor resolutions ?
sartic wrote:visual designer in linux how?
how to what ?
Re: default font
Posted: Tue Oct 19, 2010 3:48 pm
by sartic
Vera wrote:sartic wrote:it works but fonts are bigger than in win
but doesn't that depend on the local OS / user settings or monitor resolutions ?
sartic wrote:visual designer in linux how?
how to what ?

or better where is it ?
is there a designer in linux demo?
Re: default font
Posted: Tue Oct 19, 2010 3:50 pm
by sartic
ok, i will try both.
same app (win exe) under wine have no big problems.
Re: default font
Posted: Tue Oct 19, 2010 5:22 pm
by Vera
sartic wrote: 
or better where is it ?
is there a designer in linux demo?
No - the Visual Designer for Linux is not part of any distribution but you can find all you need here:
Visual Designer V4 Alpha 16 Windows and Linux Released
and this might be of interest too:
Does Visual Designer actually work in Linux?
and for more infos you may also use this
SEARCH feature
good luck ~ Vera
Re: default font
Posted: Tue Oct 19, 2010 8:31 pm
by sartic
thx

Re: default font
Posted: Sun Apr 29, 2012 12:20 pm
by lakomet
How to know the name of the default font Gadget?
Re: default font
Posted: Wed Jan 02, 2013 3:16 pm
by Shardik
lakomet wrote:How to know the name of the default font Gadget?
A gadget's current font name and font's size can be obtained with the following code:
Code: Select all
EnableExplicit
ImportC ""
pango_context_get_font_description(*PangoContext)
pango_font_description_to_string(*PangoFontDescription)
EndImport
Procedure GetGadgetFontInfos(GadgetID.I)
Protected *FontDescription
Protected PangoContext.I
Protected PangoFontDescription.I
PangoContext = gtk_widget_get_pango_context_(GadgetID(GadgetID))
If PangoContext
PangoFontDescription = pango_context_get_font_description(PangoContext)
If PangoFontDescription
*FontDescription = pango_font_description_to_string(PangoFontDescription)
If *FontDescription
MessageRequester("Info", PeekS(*FontDescription))
EndIf
EndIf
EndIf
EndProcedure
OpenWindow(0, 270, 100, 170, 45, "Font infos")
ButtonGadget(0, 10, 10, WindowWidth(0) - 20, 25, "Get font infos")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
GetGadgetFontInfos(0)
EndIf
EndSelect
ForEver
Re: default font
Posted: Sun Jan 06, 2013 3:14 pm
by Poshu
Does work on Ubuntu, thank you :3
Just a small correction so it work in unicode compilation mode:
Code: Select all
EnableExplicit
ImportC ""
pango_context_get_font_description(*PangoContext)
pango_font_description_to_string(*PangoFontDescription)
EndImport
Procedure GetGadgetFontInfos(GadgetID.I)
Protected *FontDescription
Protected PangoContext.I
Protected PangoFontDescription.I
PangoContext = gtk_widget_get_pango_context_(GadgetID(GadgetID))
If PangoContext
PangoFontDescription = pango_context_get_font_description(PangoContext)
If PangoFontDescription
*FontDescription = pango_font_description_to_string(PangoFontDescription)
If *FontDescription
MessageRequester("Info", PeekS(*FontDescription,MemorySize(*FontDescription),#PB_Ascii))
EndIf
EndIf
EndIf
EndProcedure
OpenWindow(0, 270, 100, 170, 45, "Font infos")
ButtonGadget(0, 10, 10, WindowWidth(0) - 20, 25, "Get font infos")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
GetGadgetFontInfos(0)
EndIf
EndSelect
ForEver
Re: default font
Posted: Sun Jan 06, 2013 6:00 pm
by remi_meier
You should call g_free_() on the *FontDescription memory.
See:
http://developer.gnome.org/pango/stable ... -to-string
Also MemorySize() is wrong. Use -1 and hope Pango does
return correct strings. (Btw, it may be possible that the string
is UTF8, but I don't know anything about font families..)
Re: default font
Posted: Mon Jan 07, 2013 9:44 am
by Shardik
Thank you Poshu for pointing out that the flag #PB_Ascii has to be added for compilation in Unicode mode and
thank you Remi for pointing out that the *FontDescription string has to be freed. I totally overlooked that...

I have updated my first code example:
Code: Select all
EnableExplicit
ImportC ""
pango_context_get_font_description(*PangoContext)
pango_font_description_to_string(*PangoFontDescription)
EndImport
Procedure GetGadgetFontInfos(GadgetID.I)
Protected *FontDescription
Protected PangoContext.I
Protected PangoFontDescription.I
PangoContext = gtk_widget_get_pango_context_(GadgetID(GadgetID))
If PangoContext
PangoFontDescription = pango_context_get_font_description(PangoContext)
If PangoFontDescription
*FontDescription = pango_font_description_to_string(PangoFontDescription)
If *FontDescription
MessageRequester("Info", PeekS(*FontDescription, -1, #PB_Ascii))
g_free_(*FontDescription)
EndIf
EndIf
EndIf
EndProcedure
OpenWindow(0, 270, 100, 170, 45, "Font infos")
ButtonGadget(0, 10, 10, WindowWidth(0) - 20, 25, "Get font infos")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
GetGadgetFontInfos(0)
EndIf
EndSelect
ForEver
Re: default font
Posted: Tue Jun 09, 2020 10:13 pm
by mestnyi
How to get the name of the font by the font id?