Changes

Line 1: Line 1: −
<noinclude>{{GoogleTrans-en}}{{TOCright}}</noinclude>
+
<noinclude>{{GoogleTrans-en}}{{TOCright}}
 +
[[Category:Feature Accepted 0.88]]
 +
[[Category:Feature|Font configuration]]
 +
</noinclude>
      Line 9: Line 12:     
== Current status ==
 
== Current status ==
* Targeted release: (SUGAR_VERSION)
+
* Targeted release: 0.88
* Last updated: (DATE)
+
* Last updated: 11.01.2010
* Percentage of completion: XX%
+
* Percentage of completion: 10%
 +
 
 +
The GConf keys have been implemented:
 +
* During startup, sugar-session sets the default GTK+ font based on them.
 +
* The font settings in sugar.graphics.style are now based on the same GConf keys.
 +
* sugar.activity.activity sets the default GTK+ font based on them.
 +
 
 +
Next steps (implemented in [http://git.sugarlabs.org/projects/sugar-settings-manager sugar-settings-manager]) :
 +
* Implement an xsettings daemon (hopefully in-process).
 +
** This will eliminate the need to manually set GTK+ fonts in sugar-session and sugar.activity.activity, since GTK+ init routines will contact the settings daemon and learn of the settings.
 +
** It will also mean that activities that are not based on sugar.activity.activity have an easy way to find out the font settings, and all GTK+ apps will "just work"
 +
 
 +
TODO
 +
* Deprecate FONT settings in sugar.graphics.style
 +
* Add user interface
    
== Detailed Description ==
 
== Detailed Description ==
Line 24: Line 41:  
=== Solution for distributors ===
 
=== Solution for distributors ===
   −
Sugar will have a new gconf setting named "default_font_face" with default value "Sans" and "default_font_size" with value "10." This font would be used across the desktop in the places where the current default from the gtkrc and the value in style.py are used now (both are currently "Sans 10" as distributed).
+
Sugar will have a new gconf setting named "font/default_face" with default value "Sans Serif" and font/default_size" with value "10." This font would be used across the desktop in the places where the current default from the gtkrc and the value in style.py are used now (both are currently "Sans 10" as distributed).
    
Distributors can then customize the font size by shipping different gconf defaults (as already happens for various other Sugar settings).
 
Distributors can then customize the font size by shipping different gconf defaults (as already happens for various other Sugar settings).
Line 36: Line 53:  
These buttons will cause the default_font_size value to move incrementally up and down through these values: 5 6 7 8 9 10 11 12 13 14 16 18 20 22 24 26 28 32 36 40 48  
 
These buttons will cause the default_font_size value to move incrementally up and down through these values: 5 6 7 8 9 10 11 12 13 14 16 18 20 22 24 26 28 32 36 40 48  
   −
When clicking, font size changes will be instantly applied.
+
Instant application of this change could be achieved by generating an XChangeProperty() event on the Gtk/FontName xsettings property, otherwise the user could be requested to restart Sugar.
FIXME: describe exactly how this is implemented in GNOME
      
I am not proposing a UI design for changing font face, I think that is unnecessary and am trying to keep this feature request simple (but could certainly be added later).
 
I am not proposing a UI design for changing font face, I think that is unnecessary and am trying to keep this feature request simple (but could certainly be added later).
Line 48: Line 64:  
* In general, font sizes should never be specified. Use the default Sugar font (e.g. which is what you get if you create a gtk.Label), as this is what the user has chosen as their preferred font size.
 
* In general, font sizes should never be specified. Use the default Sugar font (e.g. which is what you get if you create a gtk.Label), as this is what the user has chosen as their preferred font size.
 
** also use variations using pango markup e.g. <nowiki><big> <small> <b></nowiki>
 
** also use variations using pango markup e.g. <nowiki><big> <small> <b></nowiki>
** FIXME: document how the point sizes of<nowiki> <big> and <small></nowiki> can be read by an activity (I think it's just based on scale factor 1.2) and maybe propose helper functions to make these values dead-easy to retrieve.
+
** If the user cannot or does not want to use pango markup in a particular scenario, Sugar could provide a helper function to scale the font size from the default for a given widget (see suggested code below)
 
* There may be exceptional cases where applications want to scale a font to fit nicely in a given space. In this situation, they should use the standard Pango rendering pipelines to render text offscreen (using a sensible seed size value), measure the resultant pixel size, and then retry the rendering based on a new font size if the result was too big or too small.
 
* There may be exceptional cases where applications want to scale a font to fit nicely in a given space. In this situation, they should use the standard Pango rendering pipelines to render text offscreen (using a sensible seed size value), measure the resultant pixel size, and then retry the rendering based on a new font size if the result was too big or too small.
 
** The Memorize activity is one example of this - it dynamically chooses a font size which causes the text to fit nicely within the tiles of the game.
 
** The Memorize activity is one example of this - it dynamically chooses a font size which causes the text to fit nicely within the tiles of the game.
Line 54: Line 70:  
** They should assume that the DPI value is correct, so rendering at size 12 will always cause the resultant glyphs to be about 12/72" in size.
 
** They should assume that the DPI value is correct, so rendering at size 12 will always cause the resultant glyphs to be about 12/72" in size.
 
** This may come with downsides for the activity in question -- can you be sure that size 12 looks sensible on the display it will be run on in the field? If not, then users/distributors might file bug reports or simply reject your activity.
 
** This may come with downsides for the activity in question -- can you be sure that size 12 looks sensible on the display it will be run on in the field? If not, then users/distributors might file bug reports or simply reject your activity.
 +
* sugar.style.FONT_* should be deprecated. They are pointless, a NORMAL font should be what you get by default, and a BOLD font is just the default font with a bold weighting applied.
 +
** The deprecation could be done with a simple code comment for 1 release cycle, then a removal in the following one. This should be done after an effort has been made to remove all existing users.
    
Not (unnecessarily) messing with font sizes will just become another step in "effective Sugarization" of an activity.
 
Not (unnecessarily) messing with font sizes will just become another step in "effective Sugarization" of an activity.
 +
 +
Here is sample code for scaling fonts as described above:
 +
def scale_font(widget, scale_steps):
 +
    if scale_steps == 0:
 +
        return
 +
    font = widget.get_pango_context().get_font_description()
 +
    font.set_size(int(font.get_size() * pango.SCALE_LARGE * scale_steps))
 +
    widget.modify_font(font)
 +
 +
The above function will work for any GtkWidget, allowing the font to be scaled. A scape_steps value of 0 will cause no scaling, -1 is equivalent to <nowiki><small>,  2 is equivalent to <big><big> or <span font_size="x-large">, </nowiki> etc. It works based on the fact that pango.SCALE_LARGE is the scaling factor for a single step up, which has value 1.2 as used in all pango font scaling (and the CSS world).
    
=== Additional fonts ===
 
=== Additional fonts ===
Line 78: Line 106:  
== How To Test ==
 
== How To Test ==
 
# Set font settings in GConf then launch sugar - do they take effect?
 
# Set font settings in GConf then launch sugar - do they take effect?
# Go into the control panel and change the font - whole desktop should be instantly updated.
+
## To set the GConf key manually, use the gconftool-2 command from Terminal (''gconftool-2 --set -t string /desktop/sugar/font/default_face Serif'' and ''gconftool-2 --set -t float /desktop/sugar/font/default_size 16'')
 +
## After setting the key, you need to restart Sugar
 +
# (WARNING: This part of the Feature has not landed yet) Go into the control panel and change the font - whole desktop should be instantly updated.
    
== User Experience ==
 
== User Experience ==
Line 99: Line 129:  
== Comments and Discussion ==
 
== Comments and Discussion ==
 
* See [[{{TALKPAGENAME}}|discussion tab for this feature]]
 
* See [[{{TALKPAGENAME}}|discussion tab for this feature]]
  −
  −
[[Category:Feature Page Incomplete]]
  −
[[Category:Feature]]