Hi pigmenters!
I'd like to let you know that the definition of the font height for a
PgmText (pgm.Text for snake charmers) will change soon.
As of now (pigment 0.3.4 as well as trunk), the font height is defined
in canvas size, and due to some optimisations that we would like to
keep, when resizing a PgmText, we often avoid redrawing it, so that only
the texture is rescaled ...and the font height is not respected. This
leads to bugs such as #141 or #204.
The best solution to this issue (I think), is to define the font height
proportionally to the height of the drawable, ie with a font height of
1.0, your text will fill your drawable in height (provided it's got q's
and Č's or stuff like that in it).
This is what the attached patch does (against trunk). It should be on
trunk soon, and included in pigment 0.3.5 (which should be released
sometime this week).
A big side effect of this change, is that all applications using pigment
will have to change their font heights according to this new definition
to work with pigment trunk and 0.3.5, hence this message. Please try
this patch and change your applications if you don't want your texts to
be surprisingly small (or big, depending on the size you chose for your
canvas).
Hope this solves more problems than it fixes :)
Cheers,
Guillaume
=== modified file 'pigment-python/examples/implicit.py'
--- pigment-python/examples/implicit.py 2008-01-11 19:00:42 +0000
+++ pigment-python/examples/implicit.py 2008-02-05 11:57:10 +0000
@@ -96,7 +96,7 @@
# Help text properties tweaking
help.position = (0.8, 1.0, 0.0)
help.size = (2.0, 1.0)
- help.font_height = 0.077
+ help.font_height = 0.1
help.fg_color = (220, 220, 220, 255)
help.bg_color = (20, 20, 20, 255)
help.opacity = 0
=== modified file 'pigment-python/examples/text.py'
--- pigment-python/examples/text.py 2008-01-11 19:00:42 +0000
+++ pigment-python/examples/text.py 2008-02-05 11:57:10 +0000
@@ -70,7 +70,7 @@
txt.bg_color = (20, 20, 20, 255)
# Change the size of the text
- txt.font_height = 0.095
+ txt.font_height = 1/17.0 # 1/17 to ensure around 16 lines of text.
# A drawable needs to be shown
txt.show()
=== modified file 'pigment/examples/text.c'
--- pigment/examples/text.c 2008-01-22 11:00:31 +0000
+++ pigment/examples/text.c 2008-02-05 11:57:10 +0000
@@ -65,6 +65,7 @@
/* Text creation */
txt = pgm_text_new (NULL);
pgm_text_set_markup (PGM_TEXT (txt), description);
+ pgm_text_set_font_height (PGM_TEXT (txt), 0.12f);
pgm_drawable_set_size (txt, 1.0f, 1.0f);
pgm_drawable_set_position (txt, 1.5f, 1.0f, 0.0f);
pgm_drawable_set_fg_color (txt, 240, 240, 240, 255);
=== modified file 'pigment/pgm/pgmtext.c'
--- pigment/pgm/pgmtext.c 2008-02-04 17:50:55 +0000
+++ pigment/pgm/pgmtext.c 2008-02-05 11:57:10 +0000
@@ -100,7 +100,7 @@
text->style = PGM_TEXT_STYLE_NORMAL;
text->variant = PGM_TEXT_VARIANT_NORMAL;
text->weight = PGM_TEXT_WEIGHT_NORMAL;
- text->height = 0.1f;
+ text->height = 1.0f;
/* Text adjustment */
text->ellipsize = PGM_TEXT_ELLIPSIZE_NONE;
@@ -307,8 +307,8 @@
* @text: a #PgmText object.
* @font_height: the text height in canvas-coordinates.
*
- * Sets the height of @text to @font_height in canvas coordinates. The default
- * height is 0.1f.
+ * Sets the height of @text to @font_height in proportion to the height of the
+ * drawable. The default height is 1.0f, which fills the drawable in height.
* @font_height will be the maximum height of a line of text (i.e. the height of
* something like "Čq", measured from the bottom of the 'q' to the top of the
* accent on the 'Č').
=== modified file 'pigment/pgm/pgmtext.h'
--- pigment/pgm/pgmtext.h 2008-01-11 19:00:42 +0000
+++ pigment/pgm/pgmtext.h 2008-02-05 11:57:10 +0000
@@ -172,7 +172,7 @@
* @style: the text style.
* @variant: the text variant.
* @weight: the text weight.
- * @height: the text height in canvas coordinates.
+ * @height: the text height in proportion to the drawable height.
* @ellipsize: the text ellipsizing.
* @alignment: the text alignment.
* @wrap: the text wrapping.
=== modified file 'pigment/plugins/opengl/pgmgltext.c'
--- pigment/plugins/opengl/pgmgltext.c 2008-01-25 15:47:26 +0000
+++ pigment/plugins/opengl/pgmgltext.c 2008-02-05 11:57:10 +0000
@@ -200,6 +200,7 @@
gfloat requested_height, wanted_height, max_height, font_ratio;
requested_height = get_projected_height (gldrawable, text->height);
+ requested_height *= gldrawable->height;
/* The "pango height" is something like the height of an M, but we want to set
* the maximum height of a line, so we need to calculate the ratio first. */