default font

Linux specific forum
sartic
Enthusiast
Enthusiast
Posts: 143
Joined: Thu Aug 26, 2010 8:26 am

default font

Post 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?
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: default font

Post by #NULL »

for gadgets:

Code: Select all

SetGadgetFont(#PB_Default, FontID)
it's in the manual.
for 2d drawing i don't know.
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: default font

Post 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 ?
sartic
Enthusiast
Enthusiast
Posts: 143
Joined: Thu Aug 26, 2010 8:26 am

Re: default font

Post 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?
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
sartic
Enthusiast
Enthusiast
Posts: 143
Joined: Thu Aug 26, 2010 8:26 am

Re: default font

Post by sartic »

ok, i will try both.

same app (win exe) under wine have no big problems.
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: default font

Post 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
sartic
Enthusiast
Enthusiast
Posts: 143
Joined: Thu Aug 26, 2010 8:26 am

Re: default font

Post by sartic »

thx ;)
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
lakomet
User
User
Posts: 53
Joined: Mon Apr 04, 2011 3:56 am
Location: Russia,Angarsk

Re: default font

Post by lakomet »

How to know the name of the default font Gadget?
Linux Mint Maya(Mate), x86, PureBasic 5.00(5.10b1)
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: default font

Post 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
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: default font

Post 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
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: default font

Post 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..)
Athlon64 3700+, 1024MB Ram, Radeon X1600
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: default font

Post 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... :oops:
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
mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Re: default font

Post by mestnyi »

How to get the name of the font by the font id?
Post Reply