addons qtcontribs Courier fonts

12 views
Skip to first unread message

Zoran Sibinovic

unread,
Jun 3, 2026, 12:02:36 PM (5 days ago) Jun 3
to QtContribs
Hi to all,
in the addons qtcontribs folders there are several prg-s that used the "Courier" or "Courier New" fonts to display gets, messages, etc. but what if you want to change them with some other mono font? I choose the DroidSansMonoSW.ttf.
 
Before the qtcontribs build I replaced these names with a variable name -  mDefaultFontName and later declared it at the top of my main app as PUBLIC mDefaultFontName:= .... Also set in the qtcontribs hbp-s  -w3 to -w0 to avoid the AMBIGUOS REFERENCE mDefaultFontName message.

The thing works, just thinking there is some nicer way to do it?

Thought using MEMVAR  in the qtcontribs prg-s and a if/else/endif to chek if  mDefaultFontName exist when it hits it and, if not, to set to "Courier new".

Regards Zoran

Pritpal Bedi

unread,
Jun 3, 2026, 4:55:37 PM (5 days ago) Jun 3
to QtContribs
Better is to write a set/get public function to retrieve the name

FUNCTION SetFontName( cFontName )
   STATIC s_cFontName := "Courier New"
   LOCAL l_cFontName :=  s_cFontName 
   IF HB_ISSTRING(  cFontName  ) .AND. ! Empty(  cFontName  )
       s_cFontName  := cFontName 
   ENDIF
   RETURN  l_cFontName 

// then in Main() just call 
    SetFontName(   "DroidSansMonoSW_OR_Whatever" )

// And when building your gets
HbQtSetFont(  SetFontName(), 20 )

Hope this helps. I hate PUBLICS. File-wide statics are ok but then those are visible only in that source. Clipper's SET/GET functions approach is best for such implementations. Write once / use nnnn times.


Pritpal Bedi
a student of software analysis & concepts

Zoran Sibinovic

unread,
Jun 4, 2026, 5:47:01 AM (4 days ago) Jun 4
to QtContribs
Thanks!
I will try it

Zoran 

Reply all
Reply to author
Forward
0 new messages