Selected Font Style

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Selected Font Style

Post by IdeasVacuum »

The help suggests that PB only supports Bold and Italic Font Styles. However, it seems PB does support the four common styles used by many TTF and open Fonts:

Regular = 0
Italic = 512
Bold = 256
Bold Italic = 768

It would nice to have the Get/Set/Requester Font functions working in the same way by having all four values as PB constants:

#PB_Font_Regular
#PB_Font_Bold
#PB_Font_Italic
#PB_Font_Bold_Italic
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Selected Font Style

Post by Trond »

The help suggests that PB only supports Bold and Italic Font Styles.
It says that flags can be combined, which means you combine Bold and Italic flags to get bold italic. I admit there should be an example of this.

Code: Select all

OpenWindow(0, 200, 200, 512, 384, "", #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_SystemMenu)
LoadFont(0, "Monospace", 14, #PB_Font_Italic)
LoadFont(1, "Monospace", 14, #PB_Font_Italic | #PB_Font_Bold)

TextGadget(0, 10, 10, 300, 20, "Monotype Font 1")
TextGadget(1, 10, 40, 300, 20, "Monotype Font 2")

SetGadgetFont(0, FontID(0))
SetGadgetFont(1, FontID(1))


Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

common way = basic knowledge ...?

Post by Kaeru Gaman »

it is the common way to combine flags. look at the window call in your code.
so the question is, where to put an example how to combine flags, in every command that can use it?
it is mentioned somewhere in the help, don't recall now wich command it was.
so the question is now, whether to put a short sentence in every command's paragraph,
or to consider this basic knowledge that belongs into a beginner's tutorial.
oh... and have a nice day.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Selected Font Style

Post by IdeasVacuum »

Certainly there are ample examples of flags being combined. My point is that PB is effectively out of synch with the information that is delivered. If there are four styles, then there is no harm in having four constants to match - yes you can code around it (by simply defining your own constants), but it would be better if PB was not ambiguous in this case.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: Selected Font Style

Post by Kaeru Gaman »

sorry, there are TONS of constants that define FLAGS wich are one single bit.
do you think EVERY combination should have it's own constant? Image

that would mean THOUSANDS of redundant constants, that is ridiculous!

combining BITFLAG constants by 'bitwise or' just is the correct way to go, it's not to the merest some "coding around".
Last edited by Kaeru Gaman on Mon Jan 25, 2010 12:19 am, edited 1 time in total.
oh... and have a nice day.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Selected Font Style

Post by ts-soft »

Code: Select all

#PB_Font_Bold
#PB_Font_Italic
#PB_Font_StrikeOut
#PB_Font_Underline
How many combinations a available :wink:
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Selected Font Style

Post by IdeasVacuum »

Hi Kaeru

I don't believe there are thousands of constants specific to font style :). Is there a pair of PB font style constants that can be combined to define the style 'regular'? The point and beauty of standard constants is their simplicity. It is certainly not the most important feature request but I think everyone is entitled to have a view about what "would be nice". It's just one more thing that a dynamic app does not need to worry about.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: Selected Font Style

Post by Kaeru Gaman »

it's not only about fontstyles, there are thousands of constants that are bitflags defining anything.

take the windows' style flags:

Code: Select all

#PB_Window_BorderLess     10000000000000000000000000000000
#PB_Window_Invisible      00010000000000000000000000000000
#PB_Window_Maximize       00000001000000000000000000000000
#PB_Window_MaximizeGadget 00000000110010010000000000000000
#PB_Window_Minimize       00100000000000000000000000000000
#PB_Window_MinimizeGadget 00000000110010100000000000000000
#PB_Window_NoGadgets      00000000000000000000000000001000
#PB_Window_Normal         00000000000000000000000000000000
#PB_Window_ScreenCentered 00000000000000000000000000000001
#PB_Window_SizeGadget     00000000110001000000000000000000
#PB_Window_SystemMenu     00000000110010000000000000000000
#PB_Window_TitleBar       00000000110000000000000000000000
#PB_Window_Tool           00000000000000000000000000000100
#PB_Window_WindowCentered 00000000000000000000000000000010
as you can see, three basic bits are set in three, two in five, but the rest are single bitflags.
you need to combine them "manually" if you want them combined.
those are 14 constants each different in at least one bit.
according to your argumentation, we should introduce a special constant for each possible combination.
2^14 are 16384...
do you want 16384 new constants for opening a window?
it would take YEARS just to find that much new names...
... and this is only one more purpose, there are hundred more purposes where single-bit constants are defined.

when you ask it for fontstyles, you could ask it for everything that is flagged via bitflags and has predifined constants.

... now you see, this is what I meant with "ridiculous"...
oh... and have a nice day.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Selected Font Style

Post by IdeasVacuum »

Hi Kaeru

Can we agree to disagree? My feature request is only about font styles. There are font styles that you cannot support by combination of the existing PB constants. That is it.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Selected Font Style

Post by Demivec »

IdeasVacuum wrote:Hi Kaeru

Can we agree to disagree? My feature request is only about font styles. There are font styles that you cannot support by combination of the existing PB constants. That is it.
@IdeasVacuum: Kaeru makes a good point that it is easier to combine the constants instead of having one for each possible unique value. You mention only three values, ts-soft mentioned 2 more, plus one not mentioned (#PB_Font_HighQuality). That brings the number of combinations to 31 (we ignore 'Regular' for this computation). That's still a lot of constants. If your goal is simplicity then you would have to deal with looking up the right constant or coming up with a naming convention of putting all the attributes in alphabetical order in the constant name.

In practice it is much simpler to just combine the individual constant using 'bitwise or'. If you use a particular combination enough then create your own constant that combines them.

What were the font styles that were not currently supported?


And yes, I can agree to disagree. :)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Selected Font Style

Post by IdeasVacuum »

Hello Demivec

Well, #PB_Font_StrikeOut, #PB_Font_Underline and #PB_Font_HighQuality are not strictly font styles but of course can be combined as required/as available. The four physical font styles are:

Regular
Italic
Bold
Bold Italic

To match that list in PB Constants would raise the font style constant total from two to four.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: Selected Font Style

Post by Kaeru Gaman »

since #PB_Font_StrikeOut, #PB_Font_Underline and #PB_Font_HighQuality
are bitflags for exactly the same style flag-'register' as Bold and Italic,
you'll need to put them into new constants if it should make the merest sense.
as Devivec kindly pointed out, this would mean 31 combinations => 26 new constants.

if you say, you only want Bold and Italic combined to one new constant - where exactly is your problem?
where is the difficulty in writing

Code: Select all

#PB_Font_Italic | #PB_Font_Bold
introducing one little constant and not the other 25 would not mean "being less ambigous",
it would mean creating an inconsistency.

every little status of every single element that could be flagged with one bit has a constant for this bit.
there are no combined constants, in no context.


you did not answer this question:
Demivec wrote:What were the font styles that were not currently supported?
when a flag is missing, ok, it should be implemented.
but I see no Flag missing so far....

PS:
maybe you are puzzled by the decimal numbers.
when you debug it binary, you'll see the single bits.

Code: Select all

#PB_Font_Underline    0000000000000100
#PB_Font_StrikeOut    0000000000001000
#PB_Font_HighQuality  0000000000010000
#PB_Font_Bold         0000000100000000
#PB_Font_Italic       0000001000000000
see? each style has a bit, all five style could be arbitryrily combined.

also, when you look at a text editor like Word, you have TWO buttons, one for Bold and one for Italic, that can be pressed or not, each for each.
there is no third "IB" button...
oh... and have a nice day.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Selected Font Style

Post by IdeasVacuum »

Hi Kaeru

Well, there isn't a font style that is not supported, as I mentioned in the original post. However, there is no constant for the 'Regular' font style and to my mind if you then add it, 3 of the 4 styles are then an individual constant, it is logical to also have the fourth (Bold_Italic). I never met anyone that could be puzzled by a bunch of decimal numbers :) There are exceptions to every rule, so it is down to whether one thinks my suggestion is logical/helpful or not. It is natural that those who dislike an idea are more vociferous. If people don't find any merit in it, that's fine. I use my own constants in this case, it suits my coding style.

There are old pilots and there are bold pilots - but there are no old bold pilots!
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: Selected Font Style

Post by Kaeru Gaman »

> There are old pilots and there are bold pilots - but there are no old bold pilots!

well, there are very few :lol: *


you keep saying "the fourth constant". ... poor twenty-five orphants you don't mention...

see, I just wanted to show you why your request is redundant.
you should not be too disappointed if it is not taken into the least account.

if it was introduced, I would not mock the inconsistency, I would just shrug and move on.


*<offtopic>
Radio: "I'm f*king bored!"
Tower: "Aircraft last transmitting. Identify yourself immediately!"
Radio: "I said I'm f*king bored, not f*king stupid."
</offtopic>
oh... and have a nice day.
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: Selected Font Style

Post by Perkin »

But there are a lot of old bald pilots :lol:
%101010 = $2A = 42
Post Reply