Send plymouth mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.freedesktop.org/mailman/listinfo/plymouth
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of plymouth digest..."


Today's Topics:

   1. [PATCH 0/3] Add font selection for themes (Anisse Astier)
   2. [PATCH 1/3] [label] factorize some font init code (Anisse Astier)
   3. [PATCH 3/3] [script] Add font selection argument to text to
      image     capability (Anisse Astier)
   4. [PATCH 2/3] [label] Add font control (Anisse Astier)
   5. Re: [PATCH 0/3] Add font selection for themes (Charlie Brej)
   6. new format for commits (Ray Strode)


----------------------------------------------------------------------

Message: 1
Date: Thu,  2 Sep 2010 16:59:35 +0200
From: Anisse Astier <[email protected]>
Subject: [PATCH 0/3] Add font selection for themes
To: [email protected]
Cc: Charlie Brej <[email protected]>, Ray Strode <[email protected]>
Message-ID: <[email protected]>

Hi,

The following patches enable to select font in themes using plymouth native
label APIs and script themes.

Behavior should not change in case nothing is specified : default font
"Sans 12" will still be used.

Regards,

Anisse

--
Anisse Astier (3):
  [label] factorize some font init code
  [label] Add font control
  [script] Add font selection argument to text to image capability

 src/libply-splash-graphics/ply-label-plugin.h     |    2 +
 src/libply-splash-graphics/ply-label.c            |   27 +++++++++
 src/libply-splash-graphics/ply-label.h            |    2 +
 src/plugins/controls/label/plugin.c               |   65 ++++++++++++++++-----
 src/plugins/splash/script/script-lib-image.c      |   16 +++++-
 src/plugins/splash/script/script-lib-image.script |    4 +-
 6 files changed, 99 insertions(+), 17 deletions(-)



------------------------------

Message: 2
Date: Thu,  2 Sep 2010 16:59:36 +0200
From: Anisse Astier <[email protected]>
Subject: [PATCH 1/3] [label] factorize some font init code
To: [email protected]
Cc: Charlie Brej <[email protected]>, Ray Strode <[email protected]>
Message-ID: <[email protected]>

---
 src/plugins/controls/label/plugin.c |   40 ++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/plugins/controls/label/plugin.c 
b/src/plugins/controls/label/plugin.c
index 7babb9e..c9c744e 100644
--- a/src/plugins/controls/label/plugin.c
+++ b/src/plugins/controls/label/plugin.c
@@ -135,6 +135,30 @@ get_cairo_context_for_sizing (ply_label_plugin_control_t 
*label)
   return cairo_context;
 }
 
+static PangoLayout*
+init_pango_text_layout (cairo_t *cairo_context,
+                       char *text,
+                       char *font_description)
+{
+  PangoLayout          *pango_layout;
+  PangoFontDescription *description;
+
+  pango_layout = pango_cairo_create_layout (cairo_context);
+
+  if (!font_description)
+    description = pango_font_description_from_string ("Sans 12");
+  else
+    description = pango_font_description_from_string (font_description);
+
+  pango_layout_set_font_description (pango_layout, description);
+  pango_font_description_free (description);
+
+  pango_layout_set_text (pango_layout, text, -1);
+  pango_cairo_update_layout (cairo_context, pango_layout);
+
+  return pango_layout;
+}
+
 static void
 size_control (ply_label_plugin_control_t *label)
 {
@@ -149,14 +173,8 @@ size_control (ply_label_plugin_control_t *label)
 
   cairo_context = get_cairo_context_for_sizing (label);
 
-  pango_layout = pango_cairo_create_layout (cairo_context);
-
-  description = pango_font_description_from_string ("Sans 12");
-  pango_layout_set_font_description (pango_layout, description);
-  pango_font_description_free (description);
+  pango_layout = init_pango_text_layout(cairo_context, label->text, "Sans 12");
 
-  pango_layout_set_text (pango_layout, label->text, -1);
-  pango_cairo_update_layout (cairo_context, pango_layout);
   pango_layout_get_size (pango_layout, &text_width, &text_height);
   label->area.width = (long) ((double) text_width / PANGO_SCALE);
   label->area.height = (long) ((double) text_height / PANGO_SCALE);
@@ -184,14 +202,8 @@ draw_control (ply_label_plugin_control_t *label,
 
   cairo_context = get_cairo_context_for_pixel_buffer (label, pixel_buffer);
 
-  pango_layout = pango_cairo_create_layout (cairo_context);
-
-  description = pango_font_description_from_string ("Sans 12");
-  pango_layout_set_font_description (pango_layout, description);
-  pango_font_description_free (description);
+  pango_layout = init_pango_text_layout(cairo_context, label->text, "Sans 12");
 
-  pango_layout_set_text (pango_layout, label->text, -1);
-  pango_cairo_update_layout (cairo_context, pango_layout);
   pango_layout_get_size (pango_layout, &text_width, &text_height);
   label->area.width = (long) ((double) text_width / PANGO_SCALE);
   label->area.height = (long) ((double) text_height / PANGO_SCALE);
-- 
1.7.0.6



------------------------------

Message: 3
Date: Thu,  2 Sep 2010 16:59:38 +0200
From: Anisse Astier <[email protected]>
Subject: [PATCH 3/3] [script] Add font selection argument to text to
        image   capability
To: [email protected]
Cc: Charlie Brej <[email protected]>, Ray Strode <[email protected]>
Message-ID: <[email protected]>

Enables scripts to choose the font they want with a sixth argument to
Image.Text API:
new_image = Image.Text("Hello", 1, 1, 1, 1, "DejaVu Bold,Italic 18")

See Pango documentation for font description usage:
http://library.gnome.org/devel/pango/stable/pango-Fonts.html#pango-font-description-from-string
---
 src/plugins/splash/script/script-lib-image.c      |   16 +++++++++++++++-
 src/plugins/splash/script/script-lib-image.script |    4 ++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/plugins/splash/script/script-lib-image.c 
b/src/plugins/splash/script/script-lib-image.c
index 12c3278..20aec36 100644
--- a/src/plugins/splash/script/script-lib-image.c
+++ b/src/plugins/splash/script/script-lib-image.c
@@ -158,8 +158,9 @@ static script_return_t image_text (script_state_t *state,
   script_lib_image_data_t *data = user_data;
   ply_pixel_buffer_t *image;
   ply_label_t *label;
-  script_obj_t *alpha_obj;
+  script_obj_t *alpha_obj, *font_obj;
   int width, height;
+  char *font;
   
   char *text = script_obj_hash_get_string (state->local, "text");
   
@@ -178,10 +179,21 @@ static script_return_t image_text (script_state_t *state,
     alpha = 1;
   script_obj_unref(alpha_obj);
 
+  font_obj = script_obj_hash_peek_element (state->local, "font");
+
+  if (script_obj_is_string (font_obj))
+    font = script_obj_as_string (font_obj);
+  else
+    font = NULL;
+
+  script_obj_unref(font_obj);
+
   if (!text) return script_return_obj_null ();
 
   label = ply_label_new ();
   ply_label_set_text (label, text);
+  if (font)
+    ply_label_set_font (label, font);
   ply_label_set_color (label, red, green, blue, alpha);
   ply_label_show (label, NULL, 0, 0);
   
@@ -192,6 +204,7 @@ static script_return_t image_text (script_state_t *state,
   ply_label_draw_area (label, image, 0, 0, width, height);
   
   free (text);
+  free (font);
   ply_label_free (label);
   
   return script_return_obj (script_obj_new_native (image, data->class));
@@ -245,6 +258,7 @@ script_lib_image_data_t *script_lib_image_setup 
(script_state_t *state,
                               "green",
                               "blue",
                               "alpha",
+                              "font",
                               NULL);
 
   script_obj_unref (image_hash);
diff --git a/src/plugins/splash/script/script-lib-image.script 
b/src/plugins/splash/script/script-lib-image.script
index 015a2f5..4fa377f 100644
--- a/src/plugins/splash/script/script-lib-image.script
+++ b/src/plugins/splash/script/script-lib-image.script
@@ -14,9 +14,9 @@ Image.Scale = fun (width, height)
   return Image.Adopt (this._Scale(width, height));
 };
 
-Image.Text = fun (text, red, green, blue, alpha)
+Image.Text = fun (text, red, green, blue, alpha, font)
 {
-  return Image.Adopt (Image._Text (text, red, green, blue, alpha));
+  return Image.Adopt (Image._Text (text, red, green, blue, alpha, font));
 };
 
 Image |= fun (filename)
-- 
1.7.0.6



------------------------------

Message: 4
Date: Thu,  2 Sep 2010 16:59:37 +0200
From: Anisse Astier <[email protected]>
Subject: [PATCH 2/3] [label] Add font control
To: [email protected]
Cc: Charlie Brej <[email protected]>, Ray Strode <[email protected]>
Message-ID: <[email protected]>

---
 src/libply-splash-graphics/ply-label-plugin.h |    2 +
 src/libply-splash-graphics/ply-label.c        |   27 +++++++++++++++++++++++
 src/libply-splash-graphics/ply-label.h        |    2 +
 src/plugins/controls/label/plugin.c           |   29 +++++++++++++++++++++++-
 4 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/src/libply-splash-graphics/ply-label-plugin.h 
b/src/libply-splash-graphics/ply-label-plugin.h
index bd3bae9..cf3cedd 100644
--- a/src/libply-splash-graphics/ply-label-plugin.h
+++ b/src/libply-splash-graphics/ply-label-plugin.h
@@ -52,6 +52,8 @@ typedef struct
 
   void (* set_text_for_control) (ply_label_plugin_control_t *label,
                                  const char                 *text);
+  void (* set_font_for_control) (ply_label_plugin_control_t *label,
+                                 const char                 *fontdesc);
   void (* set_color_for_control) (ply_label_plugin_control_t *label,
                                   float                       red,
                                   float                       green,
diff --git a/src/libply-splash-graphics/ply-label.c 
b/src/libply-splash-graphics/ply-label.c
index b00874c..b97bb62 100644
--- a/src/libply-splash-graphics/ply-label.c
+++ b/src/libply-splash-graphics/ply-label.c
@@ -46,6 +46,7 @@ struct _ply_label
   ply_label_plugin_control_t *control;
 
   char *text;
+  char *fontdesc;
   float red;
   float green;
   float blue;
@@ -127,6 +128,9 @@ ply_label_load_plugin (ply_label_t *label)
   if (label->text != NULL)
     label->plugin_interface->set_text_for_control (label->control,
                                                    label->text);
+  if (label->fontdesc != NULL)
+    label->plugin_interface->set_font_for_control (label->control,
+                                                   label->fontdesc);
 
   label->plugin_interface->set_color_for_control (label->control,
                                                   label->red,
@@ -220,6 +224,29 @@ ply_label_set_text (ply_label_t *label,
                                                  text);
 }
 
+/*
+ * Please see pango documentation, for fontdesc format:
+ * 
http://library.gnome.org/devel/pango/stable/pango-Fonts.html#pango-font-description-from-string
+ * If you pass NULL, it will use default font.
+ */
+void
+ply_label_set_font (ply_label_t *label,
+                    const char  *fontdesc)
+{
+
+  free (label->fontdesc);
+  if (fontdesc)
+    label->fontdesc = strdup (fontdesc);
+  else
+    label->fontdesc = NULL;
+
+  if (label->plugin_interface == NULL)
+    return;
+
+  label->plugin_interface->set_font_for_control (label->control,
+                                                 fontdesc);
+}
+
 void
 ply_label_set_color (ply_label_t *label,
                      float        red,
diff --git a/src/libply-splash-graphics/ply-label.h 
b/src/libply-splash-graphics/ply-label.h
index bca9b7b..d79b996 100644
--- a/src/libply-splash-graphics/ply-label.h
+++ b/src/libply-splash-graphics/ply-label.h
@@ -53,6 +53,8 @@ bool ply_label_is_hidden (ply_label_t *label);
 
 void ply_label_set_text (ply_label_t *label,
                          const char  *text);
+void ply_label_set_font (ply_label_t *label,
+                         const char  *fontdesc);
 void ply_label_set_color (ply_label_t *label,
                           float        red,
                           float        green,
diff --git a/src/plugins/controls/label/plugin.c 
b/src/plugins/controls/label/plugin.c
index c9c744e..2cfab3b 100644
--- a/src/plugins/controls/label/plugin.c
+++ b/src/plugins/controls/label/plugin.c
@@ -56,6 +56,7 @@ struct _ply_label_plugin_control
   ply_rectangle_t     area;
 
   char               *text;
+  char               *fontdesc;
   float               red;
   float               green;
   float               blue;
@@ -173,7 +174,7 @@ size_control (ply_label_plugin_control_t *label)
 
   cairo_context = get_cairo_context_for_sizing (label);
 
-  pango_layout = init_pango_text_layout(cairo_context, label->text, "Sans 12");
+  pango_layout = init_pango_text_layout(cairo_context, label->text, 
label->fontdesc);
 
   pango_layout_get_size (pango_layout, &text_width, &text_height);
   label->area.width = (long) ((double) text_width / PANGO_SCALE);
@@ -202,7 +203,7 @@ draw_control (ply_label_plugin_control_t *label,
 
   cairo_context = get_cairo_context_for_pixel_buffer (label, pixel_buffer);
 
-  pango_layout = init_pango_text_layout(cairo_context, label->text, "Sans 12");
+  pango_layout = init_pango_text_layout(cairo_context, label->text, 
label->fontdesc);
 
   pango_layout_get_size (pango_layout, &text_width, &text_height);
   label->area.width = (long) ((double) text_width / PANGO_SCALE);
@@ -246,6 +247,29 @@ set_text_for_control (ply_label_plugin_control_t *label,
 }
 
 static void
+set_font_for_control (ply_label_plugin_control_t *label,
+                      const char                 *fontdesc)
+{
+  ply_rectangle_t dirty_area;
+
+  if (label->fontdesc != fontdesc)
+    {
+      dirty_area = label->area;
+      free (label->fontdesc);
+      if (fontdesc)
+        label->fontdesc = strdup (fontdesc);
+      else
+        label->fontdesc = NULL;
+      size_control (label);
+      if (!label->is_hidden && label->display != NULL)
+        ply_pixel_display_draw_area (label->display,
+                                     dirty_area.x, dirty_area.y,
+                                     dirty_area.width, dirty_area.height);
+
+    }
+}
+
+static void
 set_color_for_control (ply_label_plugin_control_t *label,
                        float                       red,
                        float                       green,
@@ -321,6 +345,7 @@ ply_label_plugin_get_interface (void)
       .draw_control = draw_control,
       .is_control_hidden = is_control_hidden,
       .set_text_for_control = set_text_for_control,
+      .set_font_for_control = set_font_for_control,
       .set_color_for_control = set_color_for_control,
       .get_width_of_control = get_width_of_control,
       .get_height_of_control = get_height_of_control
-- 
1.7.0.6



------------------------------

Message: 5
Date: Thu, 02 Sep 2010 16:59:40 +0100
From: Charlie Brej <[email protected]>
Subject: Re: [PATCH 0/3] Add font selection for themes
To: Anisse Astier <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 02/09/10 15:59, Anisse Astier wrote:
> Hi,
>
> The following patches enable to select font in themes using plymouth native
> label APIs and script themes.

Great. Correct formatting, style and functionality. Accepted all three.

Thank you.

-- 
Dr Charles Brej, Research Associate, APT Group
IT412, IT Building, School of Computer Science
University of Manchester, Manchester,  M13 9PL
Web: http://brej.org/ Tel: +44 (0)161 275 7274


------------------------------

Message: 6
Date: Thu, 2 Sep 2010 13:54:12 -0400
From: Ray Strode <[email protected]>
Subject: new format for commits
To: plymouth <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

Hi guys,

We've been using

[category] Summary goes here

for the top line of git commits for a while. I made up that convention
and it differs from what the kernel and a lot of other projects use.
They use something like

category: Summary goes here

Being different than most other projects wouldn't be a big deal,
except our way breaks git-am

>From now on, we should probably use the more conventional format.

--Ray


------------------------------

_______________________________________________
plymouth mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/plymouth


End of plymouth Digest, Vol 23, Issue 1
***************************************

Reply via email to