[Sugar-devel] [FEATURE] Fonts-configuration

Art Hunkins abhunkin at uncg.edu
Mon Jan 11 13:55:46 EST 2010


First off: my apologies to all that I speak Linux and Sugar and all things 
related, so poorly. I'm just trying to finish off a couple of activities 
(OurMusic and OurMusicMC) so they work as I would like, and so they continue 
to work that way in the future. I also apologize to Daniel for 
misrepresenting his code. I simply assert that I have incorporated it and 
built upon it in a way that does not interfere with default font settings 
(as Daniel states is so important to do; default settings should rightly 
remain the domain of users and deployments).

As all are aware, my particular interest is in sizing displayed text to 
appropriately fill any particular screen width. Furthermore, anytime a user 
(or deployment) opts for a larger-than-default size (via the proposed UI or 
other method) displayed text is to be larger (thus activating scrollbars), 
but *if smaller-than-default* (though it's hard to imagine such a 
selection), still fills any given screen width.

My code, given in full below, does this - for XO1/1.5, SoaS Strawberry, SoaS 
Blueberry (and hopefully future incarnations of Fedora SoaS), as well as 
potential future non-Fedora SoaSes. It works fine and has been tested on 
varying systems except for XO1.5 and non-Fedora SoaSes (obviously - and I 
may be way off base here; I've assumed a similar set of font conditions to 
SoaS Blueberry).

My only concern is whether my code will still work once the proposed UI is 
implemented. I'd appreciate any and all insight to this end.

    def scale_font(self, widget):
      settings = gtk.settings_get_default()
      font_name = settings.get_property("gtk-font-name")
      font_size = int(font_name[-2:])
      scale_steps = font_size - 10
      font = widget.get_pango_context().get_font_description()
      width = gtk.gdk.screen_width()
      size = width * .0008
      if os.path.exists("/etc/olpc-release") or 
os.path.exists("/sys/power/olpc-pm"):
        if scale_steps > -3:
          font.set_size(int(font.get_size() + 3) * pango.SCALE_LARGE * 
(scale_steps + 3) * size)
        else:
          font.set_size(int(font.get_size() + 3) * size)
      elif os.path.exists("/etc/fedora-release"):
        if open("/etc/fedora-release").read().find("Strawberry") != -1:
          size = width * .00135
          if scale_steps > 0:
            font.set_size(int(font.get_size() + 3) * pango.SCALE_LARGE * 
scale_steps * size)
          else:
            font.set_size(int(font.get_size() + 3) * size)
        else:
          if scale_steps > 0:
            font.set_size(int(font.get_size() * pango.SCALE_LARGE * 
scale_steps * size))
          else:
            font.set_size(int(font.get_size() * size))
      else:
        if scale_steps > 0:
          font.set_size(int(font.get_size() * pango.SCALE_LARGE * 
scale_steps * size))
        else:
          font.set_size(int(font.get_size() * size))
      widget.modify_font(font)


Art Hunkins

----- Original Message ----- 
From: "Daniel Drake" <dsd at laptop.org>
To: "Art Hunkins" <abhunkin at uncg.edu>
Cc: "Simon Schampijer" <simon at schampijer.de>; 
<sugar-devel at lists.sugarlabs.org>
Sent: Monday, January 11, 2010 12:40 PM
Subject: Re: [Sugar-devel] [FEATURE] Fonts-configuration


2010/1/11 Art Hunkins <abhunkin at uncg.edu>:
> With respect to the proposed UI and "low-hanging fruit":
>
> The font-configuring code I use in OurMusic-2 strictly adheres to Daniel's
> suggestions.
>
> Basicly, Daniel's suggestion would pick up the proposed UI-set font value
> from:
> settings = gtk.settings_get_default()
> font_name = settings.get_property("gtk-font-name")
> then manipulate and display individual text instances with:
> font = widget.get_pango_context().get_font_description()
> font.set_size(int(font.get_size() [and whatever])

I don't understand why you need to get the gtk-font-name property.
That is not part of my suggestion. Activities should never be
concerned with this property.

> This presumes that the UI would change the value found with the first set 
> of
> two code lines above, and have nothing to do with the second set. However,
> this latter set is based on system defaults which *remain unchanged* under
> the proposed feature. These defaults are not likely to change for other
> reasons either.
>
> Am I correct concerning these defaults, and should code based on the above
> continue to work on all XO and SoaS systems?

I don't understand your description or questions, sorry.  Perhaps you
could explain what you're trying to do. Eithre way, I get the feeling
that you are deviating from the guidelines I am proposing.

Daniel 



More information about the Sugar-devel mailing list