|
From: Sander J. <s.j...@gm...> - 2023-07-05 02:09:00
|
setNormalFont doesn't do anything if you want to dynamically change the
font of your UI. For certain aspects like colors, you'll have to traverse
the widget tree to update the existing thematic properties in order to
apply them immediately.
For the normal font, technically you could do something similar, but you
can take advantage of the fact that the normal font is stored as pointer in
the widget and you can simply destroy/recreate the font itself without
updating the font pointer:
void setFont(const FXFontDesc & fnt){
getApp()->getNormalFont()->destroy();
getApp()->getNormalFont()->setFontDesc(fnt);
getApp()->getNormalFont()->create();
}
The font behaviour as seen by John using FontSelector sounds to me a
Windows specific behaviour. I wouldn't even call it font substitution but
rather glyph substitution as missing glyphs in a font get substituted from
other fonts (to be honest, a highly desirable feature that's sorely missing
in FOX).
Cheers,
Sander
On Tue, Jul 4, 2023 at 2:58 PM Roland Hughes via Foxgui-users <
fox...@li...> wrote:
> Let me preface this answer with:
>
> I haven't touched Foxgui for development in quite some time. I also quit
> doing Windows development with Windows 3.1, 1) because the OS absolutely
> sucks 2) the Registry is a debacle.
>
> I have spent over 30 years in software development, both on real computers
> and x86 stuff. Part of your confusion comes from a fixation on Arial and
> the fact that it is different under Windows.
>
> https://learn.microsoft.com/en-us/globalization/input/font-technology
>
> =====
> Font substitution
>
> Font substitution is implemented by an application to replace a request
> for a font that is not available into one that is available. In general,
> applications use PANOSE information (a set of numeric values summarizing
> the font’s style) to find the most appropriate matching font.
>
> The Windows operating system allows enabling font substitution but this
> should be considered a last resort approach. Windows substitution logic is
> also sensitive to charsets, so that a request for Arial with Western
> charset (0) can be translated into a request for Arial with Greek charset
> (161), for instance. Windows font substitution is set with the registry
> entries under the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
> NT\CurrentVersion\FontSubstitutes. The registry entry of “Helvetica” with
> the value of “Arial”, for instance, indicates to substitute Helvetica font
> with Arial font; and the registry entry of “Arial,0” with the value of
> “Arial,161” will substitute Arial with ANSI_CHAERSET to Arial with
> GREEK_CHARSET.
>
> =====
>
> If you were fixated on a font the OS didn't use in a ton of places you
> would have an easier time.
>
> I assume you have already read the Font documentation (especially Matching
> and Substitution) for fox-toolkit, correct?
>
> http://www.fox-toolkit.org/fonts.html
>
> Can I ask a really stupid question now? I do not mean this as
> condescending or belittling in anyway.
>
> Why are you doing this?
>
> To me it looks like you are brute force rolling your own method of
> changing the default font.
>
> In the class reference documentation for FXApp
> void setNormalFont
> <http://www.fox-toolkit.org/ref/classFX_1_1FXApp.html#af9e24b2b523a9eb07d924b4a3e480f27>
> (FXFont <http://www.fox-toolkit.org/ref/classFX_1_1FXFont.html> *font)
> Change default font.
>
>
> void refresh
> <http://www.fox-toolkit.org/ref/classFX_1_1FXApp.html#ae833688b2cd5a0ce8fc6a8d5684041e1>
> ()
> Schedule SEL_UPDATE refreshes on the entire widget tree, to be
> performed at some future time.
>
> void forceRefresh
> <http://www.fox-toolkit.org/ref/classFX_1_1FXApp.html#a0b9b15e5df4a7a6dc82ff56b6c0abf91>
> ()
> Perform SEL_UPDATE refreshes on the entire widget tree immediately.
>
>
> Hope this helps.
>
> On 7/4/23 14:27, John Selverian wrote:
>
> OK, I read a bit more...still confused...
>
>
> In the registry key: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink
>
> There are many fonts specified with their fallbacks but is no entry for Arial.
>
> When I look at the Fox source for FXFontSelector and FxFontDialog I don’t see anything related to Uniscribe.
>
> In my code when I change the font, I get the font from the FXFontSelector and pass it to the function below to change the font of all of the widgets.
>
> I don't see how I would implement Uniscribe especially for something like FXList.
>
>
>
>
>
>
> /***************************************************************************************/
> void Utilities_jhs1::updateUIFont(FXWindow * w, FXFont * font)
> {
> if (w != nullptr)
> {
> FXString classname;
> classname.format("%s", w->getClassName());
>
> if (classname == "FXList")
> {
> FXList* widget = dynamic_cast<FXList*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXLabel")
> {
> FXLabel* widget = dynamic_cast<FXLabel*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXTextField")
> {
> FXTextField* widget = dynamic_cast<FXTextField*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXButton")
> {
> FXButton* widget = dynamic_cast<FXButton*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->update(); // only needed for FXButton
> widget->recalc();
> }
> }
> else if (classname == "FXToolTip")
> {
> FXToolTip* widget = dynamic_cast<FXToolTip*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXMenuTitle")
> {
> FXMenuTitle* widget = dynamic_cast<FXMenuTitle*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXMenuCommand")
> {
> FXMenuCommand* widget = dynamic_cast<FXMenuCommand*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXCheckButton")
> {
> FXCheckButton* widget = dynamic_cast<FXCheckButton*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXMenuCheck")
> {
> FXMenuCheck* widget = dynamic_cast<FXMenuCheck*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXRadioButton")
> {
> FXRadioButton* widget = dynamic_cast<FXRadioButton*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
> else if (classname == "FXMenuCascade")
> {
> FXMenuCascade* widget = dynamic_cast<FXMenuCascade*>(w);
> if (widget)
> {
> widget->setFont(font);
> widget->recalc();
> }
> }
>
> for (FXWindow* c = w->getFirst(); c; c = c->getNext())
> {
> if (c != nullptr)
> {
> updateUIFont(c, font);
> }
> }
> }
> }
> /***************************************************************************************/
>
>
>
>
>
>
>
> -----Original Message-----
> From: Roland Hughes <ro...@lo...> <ro...@lo...>
> Sent: Monday, July 3, 2023 8:20 AM
> To: John Selverian <joh...@ja...> <joh...@ja...>
> Cc: fox...@li...
> Subject: Re: [Foxgui-users] unexpected behavior with FXFontSelector
>
> Read the instructions/text at the bottom of the GitHub page. Don't actually use the thing and tweak your fallback information without fully understanding.
>
> While Windows ships with many fonts, Arial is one of the few System fonts. That means it is used by the OS as a default for menus, message text, etc. It will be one of the few you find configured for fallback in the Registry.
>
> Windows also has Font linking.
> https://superuser.com/questions/396160/how-to-change-configure-font-fallback
> https://learn.microsoft.com/en-us/globalization/input/font-technology
>
>
> On 7/3/2023 7:08 AM, John Selverian wrote:
>
> Font substitution only happens with Ariel font not others. I thought
> it would work for all or none. I guess I still don’t fully understand.
>
> Kind regards,
>
> js
>
>
>
> On Jul 3, 2023, at 7:30 AM, Roland Hughes via Foxgui-users <fox...@li...> <fox...@li...> wrote:
>
> You don't understand because you didn't read the link I sent about
> Font Fallback.
>
> There is a font fallback registry in windows. Here is a bit of
> reading on that.
> https://github.com/Jamesits/windows-10-font-fallback-reg
>
> Here is the original link about font fallback.
> https://learn.microsoft.com/en-us/windows/win32/intl/using-font-fallb
> ack
>
> Font fallback doesn't happen by default.
>
> Without looking at the code I will state FXFontSelector enables font
> fallback in its configuring of the font and rendering of text but
> your application does not.
>
> Windows is different front Linux here.
> https://unix.stackexchange.com/questions/254423/unicode-fallback-font
>
> Most everything uses fontconfig library which defaults to the
> configured font fallback.
>
> On 7/2/2023 2:37 PM, John Selverian wrote:
>
> I understand this. The "problem" is that Arial does not have a the
> "subscript 2" character but it gets displayed properly in the
> FXFontSelector. How does it do this? It does not display properly in
> FXFontSelector for several other fonts which do not have the
> "subscript 2" character...I just see the empty square character,
> this is what I expect.
>
> js
>
>
> -----Original Message-----
> From: je...@fo... <je...@fo...> <je...@fo...>
> Sent: Friday, June 30, 2023 1:18 PM
> To: joh...@ja...
> Cc: fox...@li...
> Subject: Re: [Foxgui-users] unexpected behavior with FXFontSelector
>
> On 2023-06-30 08:51, John Selverian wrote:
>
> I'm seeing something strange with FXFontSelector (Fox v1.7.50)
>
>
>
> I've added Unicode for a subscript 2 (\\u2082 <file://u2082> )
>
> to the
>
> preview text.
>
>
>
> I select Arial and it displays fine. Back in my program the
>
> subscript
>
> 2 shows as an empty box indicating that the character does not
>
> exist.
>
> My program should be correct since it displays the subscript 2
>
> fine
>
> with other fonts (like Segoe UI).
>
>
>
> I've also check with MS Word that the subscript 2 does not
>
> exist in
>
> the Arial.
>
>
>
> My question is how/why does it display fine in the preview in
> FXFontSelector even though it does not exist in Arial? It even
>
> looks
>
> like the Arial font. I see the same with other fonts not just
>
> Arial.
>
> Make sure both are using the same font and pitch. Not all fonts
> have the full unicode repertoire in them; in fact, most fonts have
> only a fraction of the full repertoire of glyphs.
>
> -- JVZ
>
>
>
> _______________________________________________
> Foxgui-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/foxgui-users
>
> --
> Roland Hughes, President
> Logikal Solutions
> (630)-205-1593 (cell)http://www.theminimumyouneedtoknow.comhttp://www.infiniteexposure.nethttp://www.johnsmith-book.com
>
>
>
> _______________________________________________
> Foxgui-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/foxgui-users
>
> --
> Roland Hughes, President
> Logikal Solutions
> (630)-205-1593 (cell)http://www.theminimumyouneedtoknow.comhttp://www.infiniteexposure.nethttp://www.johnsmith-book.com
>
> --
> Roland Hughes, President
> Logikal Solutions
> (630)-205-1593
> http://www.theminimumyouneedtoknow.comhttp://www.infiniteexposure.nethttp://www.johnsmith-book.comhttp://www.logikalblog.comhttp://www.interestingauthors.com/blog
>
> _______________________________________________
> Foxgui-users mailing list
> Fox...@li...
> https://lists.sourceforge.net/lists/listinfo/foxgui-users
>
|