0

I cant find any specified fonts names, styles or samples to implement it inside setFont() can anyone help ?

1

First, you search the documentation of setFont(). I found this:

void setFont(GLabel label, string font);

Changes the font used to display the GLabel as specified by the string font, which has the following format:

family-style-size

where both style and size are optional. If any of these elements are missing or specified as an asterisk, the existing value is retained.

Usage:
setFont(label, font);

Then you search for font family. In Google the first result I get it from Wikipedia https://en.wikipedia.org/wiki/Font_family_(HTML)#Generic_fonts

Here are some for example:

  • Arial
  • Calibri
  • Comic Sans
  • Courier
  • Cursive
  • Sans-serif
  • ...

And I'm sure you can find many more. So you do it like this:

setFont(label, "SansSerif-18");

or

setFont(label, "ComicSans-Bold-12");

or

setFont(label, "Arial");

The actual documentation has the following example for GLabel:

int main(void) {
    GWindow gw;
    GLabel label;
    double x, y;

    printf("This program draws the 'hello, world' message.\n");
    gw = newGWindow(600, 400);
    label = newGLabel("hello, world");
    setFont(label, "SansSerif-18");
    x = (getWidth(gw) - getWidth(label)) / 2;
    y = (getHeight(gw) + getFontAscent(label)) / 2;
    setLocation(label, x, y);
    add(gw, label);
}

If this answers your question please accept it by clicking the gray check-mark to the left, so that it becomes green. You can also vote it up by pressing the up arrow above the check-mark. And don't forget to keep coding!

0

You can find a number of examples of how to use setFont() simply by entering setfont in the search box at the top of this page. That will give you the format. From there, it's just a matter of finding the one that you like and plugging in the size that you desire.

If this answers your question, please click the check mark to accept this and remove the question from the unanswered pool. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .