[pangomm/pangomm-2-42] Attribute: Add several create_attr_*() methods



commit 9c30775f566d246c7046d5d4532c06346d5edfb7
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Nov 5 16:32:12 2018 +0100

    Attribute: Add several create_attr_*() methods
    
    * pango/src/attributes.[ccg|hg]: Add create_attr_size_absolute(),
    create_attr_underline_color(), create_attr_strikethrough_color(),
    create_attr_fallback(), create_attr_letter_spacing(),
    create_attr_gravity(), create_attr_gravity_hint(),
    create_attr_font_features(). Fixes #2

 pango/src/attributes.ccg | 40 ++++++++++++++++++++++
 pango/src/attributes.hg  | 87 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 126 insertions(+), 1 deletion(-)
---
diff --git a/pango/src/attributes.ccg b/pango/src/attributes.ccg
index f7ecc64..9759bce 100644
--- a/pango/src/attributes.ccg
+++ b/pango/src/attributes.ccg
@@ -109,6 +109,11 @@ AttrInt Attribute::create_attr_size(int size)
   return Glib::wrap((PangoAttrInt*)pango_attr_size_new(size));
 }
 
+AttrInt Attribute::create_attr_size_absolute(int size)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_size_new_absolute(size));
+}
+
 AttrInt Attribute::create_attr_style(Style style)
 {
   return Glib::wrap((PangoAttrInt*)pango_attr_style_new((PangoStyle)style));
@@ -139,11 +144,21 @@ AttrInt Attribute::create_attr_underline(Underline underline)
   return Glib::wrap((PangoAttrInt*)pango_attr_underline_new((PangoUnderline)underline));
 }
 
+AttrColor Attribute::create_attr_underline_color(guint16 red, guint16 green, guint16 blue)
+{
+  return Glib::wrap((PangoAttrColor*)pango_attr_underline_color_new(red, green, blue));
+}
+
 AttrInt Attribute::create_attr_strikethrough(bool strikethrough)
 {
   return Glib::wrap((PangoAttrInt*)pango_attr_strikethrough_new(strikethrough));
 }
 
+AttrColor Attribute::create_attr_strikethrough_color(guint16 red, guint16 green, guint16 blue)
+{
+  return Glib::wrap((PangoAttrColor*)pango_attr_strikethrough_color_new(red, green, blue));
+}
+
 AttrInt Attribute::create_attr_rise(int rise)
 {
   return Glib::wrap((PangoAttrInt*)pango_attr_rise_new(rise));
@@ -154,11 +169,36 @@ AttrFloat Attribute::create_attr_scale(double scale_factor)
   return Glib::wrap((PangoAttrFloat*)pango_attr_scale_new(scale_factor));
 }
 
+AttrInt Attribute::create_attr_fallback(bool enable_fallback)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_fallback_new(enable_fallback));
+}
+
+AttrInt Attribute::create_attr_letter_spacing(int letter_spacing)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_letter_spacing_new(letter_spacing));
+}
+
 AttrShape Attribute::create_attr_shape(const Rectangle& ink_rect, const Rectangle& logical_rect)
 {
   return Glib::wrap((PangoAttrShape*)pango_attr_shape_new(ink_rect.gobj(), logical_rect.gobj()));
 }
 
+AttrInt Attribute::create_attr_gravity(Gravity gravity)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_gravity_new((PangoGravity)gravity));
+}
+
+AttrInt Attribute::create_attr_gravity_hint(int hint)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_gravity_hint_new((PangoGravityHint)hint));
+}
+
+AttrString Attribute::create_attr_font_features(const Glib::ustring& features)
+{
+  return Glib::wrap((PangoAttrString*)pango_attr_font_features_new(features.c_str()));
+}
+
 
 AttrString::AttrString()
 {}
diff --git a/pango/src/attributes.hg b/pango/src/attributes.hg
index 14f8a9b..6180964 100644
--- a/pango/src/attributes.hg
+++ b/pango/src/attributes.hg
@@ -157,11 +157,20 @@ public:
   static AttrInt create_attr_background_alpha(guint16 alpha);
 
   /** Create a new font-size attribute.
-   * @param size The font size, in 1000ths of a point.
+   * @param size The font size, in 1024ths of a point.
    * @return An attribute of type AttrInt.
    */
   static AttrInt create_attr_size(int size);
 
+  /** Create a new font-size attribute.
+   *
+   * @newin{2,42}
+   *
+   * @param size The font size, in 1024ths of a device unit.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_size_absolute(int size);
+
   /** Create a new font slant style attribute.
    * @param style The slant style.
    * @return An attribute of type AttrInt.
@@ -199,12 +208,38 @@ public:
    */
   static AttrInt create_attr_underline(Underline underline);
 
+  /** Create a new underline color attribute.
+   * This attribute modifies the color of underlines. If not set,
+   * underlines will use the foreground color.
+   *
+   * @newin{2,42}
+   *
+   * @param red The red value (ranging from 0 to 65535).
+   * @param green The green value (ranging from 0 to 65535).
+   * @param blue The blue value (ranging from 0 to 65535).
+   * @return An attribute of type AttrColor.
+   */
+  static AttrColor create_attr_underline_color(guint16 red, guint16 green, guint16 blue);
+
   /** Create a new font strike-through attribute.
    * @param strikethrough True indicates the text should be struck-through.
    * @return An attribute of type AttrInt.
    */
   static AttrInt create_attr_strikethrough(bool strikethrough);
 
+  /** Create a new strikethrough color attribute.
+   * This attribute modifies the color of strikethrough lines. If not set,
+   * strikethrough lines will use the foreground color.
+   *
+   * @newin{2,42}
+   *
+   * @param red The red value (ranging from 0 to 65535).
+   * @param green The green value (ranging from 0 to 65535).
+   * @param blue The blue value (ranging from 0 to 65535).
+   * @return An attribute of type AttrColor.
+   */
+  static AttrColor create_attr_strikethrough_color(guint16 red, guint16 green, guint16 blue);
+
   /** Create a new baseline displacement attribute.
    * @param rise The amount that the text should be displaced vertically, in 10'000ths of an em. Positive 
values displace the text upwards.
    * @return An attribute of type AttrInt.
@@ -218,6 +253,29 @@ public:
    */
   static AttrFloat create_attr_scale(double scale_factor);
 
+  /** Create a new font fallback attribute.
+   * If fallback is disabled, characters will only be used from the
+   * closest matching font on the system. No fallback will be done to
+   * other fonts on the system that might contain the characters in the text.
+   *
+   * @newin{2,42}
+   *
+   * @param enable_fallback <tt>true</tt> if we should fall back on other fonts
+   *                        for characters the active font is missing.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_fallback(bool enable_fallback);
+
+  /** Create a new letter-spacing attribute.
+   *
+   * @newin{2,42}
+   *
+   * @param letter_spacing Amount of extra space to add between graphemes
+   *                       of the text, in Pango units.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_letter_spacing(int letter_spacing);
+
   /** Create a new shape attribute.
    * A shape is used to impose a particular ink and logical rect on the result of shaping a particular glyph.
    * This might be used, for instance, for embedding a picture or a widget inside a PangoLayout.
@@ -227,6 +285,33 @@ public:
    */
   static AttrShape create_attr_shape(const Rectangle& ink_rect, const Rectangle& logical_rect);
 
+  /** Create a new gravity attribute.
+   *
+   * @newin{2,42}
+   *
+   * @param gravity The gravity value; should not be Pango::Gravity::AUTO.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_gravity(Gravity gravity);
+
+  /** Create a new gravity hint attribute.
+   *
+   * @newin{2,42}
+   *
+   * @param hint The gravity hint value. Shall be a Pango::GravityHint value.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_gravity_hint(int hint);
+
+  /** Create a new font features tag attribute.
+   *
+   * @newin{2,42}
+   *
+   * @param features A string with OpenType font features, in CSS syntax.
+   * @return An attribute of type AttrString.
+   */
+  static AttrString create_attr_font_features(const Glib::ustring& features);
+
 protected:
   PangoAttribute* gobject_;
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]