[pangomm] Attribute: Add several create_attr_*() methods
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pangomm] Attribute: Add several create_attr_*() methods
- Date: Wed, 12 Sep 2018 11:55:19 +0000 (UTC)
commit 6db6b30c92f64250d2fe4e209af533b31f72ceb5
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Sep 3 17:11:53 2018 +0200
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 | 42 +++++++++++++++++++++++
pango/src/attributes.hg | 89 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 130 insertions(+), 1 deletion(-)
---
diff --git a/pango/src/attributes.ccg b/pango/src/attributes.ccg
index 9e42335..ded3762 100644
--- a/pango/src/attributes.ccg
+++ b/pango/src/attributes.ccg
@@ -17,6 +17,8 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <pangomm/context.h>
+
namespace Pango
{
@@ -109,6 +111,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 +146,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 +171,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(GravityHint 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 395fe5f..76c2b4b 100644
--- a/pango/src/attributes.hg
+++ b/pango/src/attributes.hg
@@ -57,6 +57,8 @@ class AttrFloat;
class AttrFontDesc;
class AttrShape;
+enum class GravityHint;
+
/** 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.
@@ -157,11 +159,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 +210,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 +255,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 +287,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.
+ * @return An attribute of type AttrInt.
+ */
+ static AttrInt create_attr_gravity_hint(GravityHint 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]