[pangomm] Attribute: Add some create_attr_*() methods



commit 3f9242b1f522926367e8d00313315bac4d8e3e19
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Dec 6 17:00:11 2021 +0100

    Attribute: Add some create_attr_*() methods
    
    and add TextTransform, BaselineShift and FontScale enums.

 pango/src/attributes.ccg  | 35 ++++++++++++++++++
 pango/src/attributes.hg   | 93 ++++++++++++++++++++++++++++++++++++++++++++++-
 tools/m4/convert_pango.m4 |  3 ++
 3 files changed, 129 insertions(+), 2 deletions(-)
---
diff --git a/pango/src/attributes.ccg b/pango/src/attributes.ccg
index 47c64c2..ecec4f7 100644
--- a/pango/src/attributes.ccg
+++ b/pango/src/attributes.ccg
@@ -181,6 +181,16 @@ AttrInt Attribute::create_attr_rise(int rise)
   return Glib::wrap((PangoAttrInt*)pango_attr_rise_new(rise));
 }
 
+AttrInt Attribute::create_attr_baseline_shift(int shift)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_baseline_shift_new(shift));
+}
+
+AttrInt Attribute::create_attr_font_scale(FontScale scale)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_font_scale_new((PangoFontScale)scale));
+}
+
 AttrFloat Attribute::create_attr_scale(double scale_factor)
 {
   return Glib::wrap((PangoAttrFloat*)pango_attr_scale_new(scale_factor));
@@ -221,6 +231,16 @@ AttrInt Attribute::create_attr_allow_breaks(bool allow_breaks)
   return Glib::wrap((PangoAttrInt*)pango_attr_allow_breaks_new(allow_breaks));
 }
 
+AttrInt Attribute::create_attr_word()
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_word_new());
+}
+
+AttrInt Attribute::create_attr_sentence()
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_sentence_new());
+}
+
 AttrInt Attribute::create_attr_insert_hyphens(bool insert_hyphens)
 {
   return Glib::wrap((PangoAttrInt*)pango_attr_insert_hyphens_new(insert_hyphens));
@@ -231,6 +251,21 @@ AttrInt Attribute::create_attr_show(ShowFlags show)
   return Glib::wrap((PangoAttrInt*)pango_attr_show_new((PangoShowFlags)show));
 }
 
+AttrFloat Attribute::create_attr_line_height(double factor)
+{
+  return Glib::wrap((PangoAttrFloat*)pango_attr_line_height_new(factor));
+}
+
+AttrInt Attribute::create_attr_line_height_absolute(int height)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_line_height_new_absolute(height));
+}
+
+AttrInt Attribute::create_attr_text_transform(TextTransform transform)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_text_transform_new((PangoTextTransform)transform));
+}
+
 
 AttrString::AttrString()
 {}
diff --git a/pango/src/attributes.hg b/pango/src/attributes.hg
index 99bdf71..16e3af6 100644
--- a/pango/src/attributes.hg
+++ b/pango/src/attributes.hg
@@ -39,6 +39,9 @@ _WRAP_ENUM(AttrType, PangoAttrType, s#^SCALE$#SCALE_FACTOR#, decl_prefix PANGOMM
 _WRAP_ENUM(Underline, PangoUnderline, decl_prefix PANGOMM_API)
 _WRAP_ENUM(Overline, PangoOverline, decl_prefix PANGOMM_API)
 _WRAP_ENUM(ShowFlags, PangoShowFlags, decl_prefix PANGOMM_API)
+_WRAP_ENUM(TextTransform, PangoTextTransform, newin "2,50", decl_prefix PANGOMM_API)
+_WRAP_ENUM(BaselineShift, PangoBaselineShift, CONV_TO_INT, newin "2,50", decl_prefix PANGOMM_API)
+_WRAP_ENUM(FontScale, PangoFontScale, newin "2,50", decl_prefix PANGOMM_API)
 
 /** A Pango::LogAttr stores information about the attributes of a single character.
  */
@@ -55,7 +58,7 @@ class PANGOMM_API AttrShape;
 
 enum class PANGOMM_API GravityHint;
 
-/** The Pango::Attribute structure represents the common portions of all attributes.
+/** The %Pango::Attribute structure represents the common portions of all attributes.
  * Particular types of attributes derive this class. It holds the range in which the
  * value in the type-specific part of the attribute applies.
  *
@@ -65,7 +68,7 @@ enum class PANGOMM_API GravityHint;
 class PANGOMM_API Attribute
 {
   _CLASS_GENERIC(Attribute, PangoAttribute)
-  _IGNORE(pango_attribute_copy,pango_attribute_destroy)
+  _IGNORE(pango_attribute_copy, pango_attribute_destroy, pango_attribute_init)
 
 public:
   /** Constructs an invalid attribute.
@@ -283,6 +286,33 @@ public:
    */
   static AttrInt create_attr_rise(int rise);
 
+  /** Create a new baseline displacement attribute.
+   *
+   * The effect of this attribute is to shift the baseline of a run,
+   * relative to the run of preceding run.
+   *
+   * @newin{2,50}
+   *
+   * @param shift Either a Pango::BaselineShift enumeration value or an absolute value (> 1024)
+   *   in %Pango units, relative to the baseline of the previous run.
+   *   Positive values displace the text upwards.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_baseline_shift(int shift);
+
+  /** Create a new font scale attribute.
+   *
+   * The effect of this attribute is to change the font size of a run,
+   * relative to the size of preceding run.
+   *
+   * @newin{2,50}
+   *
+   * @param scale A Pango::FontScale value, which indicates font size change relative
+   *   to the size of the previous run.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_font_scale(FontScale scale);
+
   /** Create a new font size scale attribute.
    * The base font for the affected text will have its size multiplied by scale_factor.
    * @param scale_factor Factor to scale the font.
@@ -361,6 +391,28 @@ public:
    */
   static AttrInt create_attr_allow_breaks(bool allow_breaks);
 
+  /** Marks the range of the attribute as a single word.
+   *
+   * Note that this may require adjustments to word and
+   * sentence classification around the range.
+   *
+   * @newin{2,50}
+   *
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_word();
+
+  /** Marks the range of the attribute as a single sentence.
+   *
+   * Note that this may require adjustments to word and
+   * sentence classification around the range.
+   *
+   * @newin{2,50}
+   *
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_sentence();
+
   /** Create a new insert-hyphens attribute.
    *
    * Pangomm will insert hyphens when breaking lines in the middle
@@ -382,6 +434,43 @@ public:
    */
   static AttrInt create_attr_show(ShowFlags show);
 
+  /** Modify the height of logical line extents by a factor.
+   *
+   * This affects the values returned by Pango::LayoutLine::get_extents(),
+   * Pango::LayoutLine::get_pixel_extents() and Pango::LayoutIter::get_line_extents().
+   *
+   * @newin{2,50}
+   *
+   * @param factor The scaling factor to apply to the logical height.
+   * @return An attribute of type AttrFloat.
+   */
+  static AttrFloat create_attr_line_height(double factor);
+
+  /** Override the height of logical line extents to be @a height.
+   *
+   * This affects the values returned by Pango::LayoutLine::get_extents(),
+   * Pango::LayoutLine::get_pixel_extents() and Pango::LayoutIter::get_line_extents().
+   *
+   * @newin{2,50}
+   *
+   * @param height The line height, in Pango::SCALE-ths of a point.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_line_height_absolute(int height);
+
+  /** Create a new attribute that influences how characters are transformed during shaping.
+   *
+   * @newin{2,50}
+   *
+   * @param transform Pango::TextTransform to apply.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_text_transform(TextTransform transform);
+
+  _IGNORE(pango_attribute_as_string, pango_attribute_as_language, pango_attribute_as_int)
+  _IGNORE(pango_attribute_as_size, pango_attribute_as_float, pango_attribute_as_color)
+  _IGNORE(pango_attribute_as_font_desc, pango_attribute_as_shape, pango_attribute_as_font_features)
+
 protected:
   PangoAttribute* gobject_;
 };
diff --git a/tools/m4/convert_pango.m4 b/tools/m4/convert_pango.m4
index fc4a6c3..1825792 100644
--- a/tools/m4/convert_pango.m4
+++ b/tools/m4/convert_pango.m4
@@ -4,6 +4,9 @@ _CONV_ENUM(Pango,AttrType)
 _CONV_ENUM(Pango,Underline)
 _CONV_ENUM(Pango,Overline)
 _CONV_ENUM(Pango,ShowFlags)
+_CONV_ENUM(Pango,TextTransform)
+_CONV_ENUM(Pango,BaselineShift)
+_CONV_ENUM(Pango,FontScale)
 _CONV_ENUM(Pango,Direction)
 _CONV_INCLASS_ENUM(Pango,Coverage,Level)
 _CONV_ENUM(Pango,Style)


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