Re: [LAD] Setting fonts in pixels rather than points

From: Jens M Andreasen <jens.andreasen@email-addr-hidden>
Date: Sat Dec 26 2009 - 23:38:32 EET

On Sat, 2009-12-26 at 19:53 +0100, Arnold Krille wrote:

> There is a reason why some people use 9px Times and others use 20pt bold
> Verdana. [*] And an applications programmer trying to be smarter than the user
> ends destroying the users experience...
>
It is like this: If the fontsize for the (mostly decorative) labels is
too big, the application window will become absolutely huge and for no
apparent reason won't fit on the desktop. This destroys the users
experience... Playing it safe and just setting the labels to a small
size won't work always either. I can't read the labels in Ardour when
run from Gnome without zooming in or changing my normal settings. It
works the way I believe it was intended with WindowMaker though.

> Arnold
>
> [*] And there is a reason why modern toolkits have dynamic layouts and such
> stuff.

And sometimes you just have reasons to outsmart the Toolkit, the WM, the
Desktop, the Theme and the Xconfig (as well as the user having more or
less lost control of it all) - to get things done right for the sake of
a consistent user experience!

Anyways, here is what I do for 'Sans' with a max height of 13 that is to
be used for labeling some 16x16 px checkboxes:

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  {
    GtkWidget *label = gtk_label_new
      ("ABCD EFG HIJKLMNO PQR STUVWXY Za bcde fghijk lmn opqest uvw xyz
123 45 67 890!");

    g_object_ref (label);
    gtk_container_add (GTK_CONTAINER (window), label);
    

    GtkRequisition rq;
    int i = 5;
    char buf[32];

    do {
      sprintf(buf,"%s %2d","Sans",i);
      
      gtk_widget_modify_font (label,pango_font_description_from_string
(buf));
      gtk_widget_size_request ((GtkWidget *)label,&rq);

      printf("'%7s' h:%3d w:%4d \n",buf,rq.height,rq.width);

    } while(rq.height < 13 && ++i < 42);

    label_font = strdup(buf); // <--
    gtk_container_remove (GTK_CONTAINER (window), label);
  }

> _______________________________________________
> Linux-audio-dev mailing list
> Linux-audio-dev@email-addr-hidden
> http://lists.linuxaudio.org/listinfo/linux-audio-dev

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Sun Dec 27 00:15:02 2009

This archive was generated by hypermail 2.1.8 : Sun Dec 27 2009 - 00:15:03 EET