[pangomm] Wrap pango_shape_with_flags()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pangomm] Wrap pango_shape_with_flags()
- Date: Mon, 16 Nov 2020 08:55:23 +0000 (UTC)
commit ab6ffa60a0d18f4ded3ecbf00d809a57da413a2d
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Nov 16 09:52:28 2020 +0100
Wrap pango_shape_with_flags()
* configure.ac:
* meson.build: Require pangocairo >= 1.44.3
* pango/src/glyphstring.[ccg|hg]: Add constructor
GlyphString(const Glib::ustring& item_text,
const Glib::ustring& paragraph_text, const Analysis& analysis,
ShapeFlags flags = ShapeFlags::NONE).
* pango/src/item.[ccg|hg]: Add enum ShapeFlags and
shape(const Glib::ustring& item_text, const Glib::ustring& paragraph_text,
ShapeFlags flags = ShapeFlags::NONE).
* tools/m4/convert_pango.m4: Add conversions for ShapeFlags.
See #9
configure.ac | 2 +-
meson.build | 2 +-
pango/src/glyphstring.ccg | 15 ++++++++++-----
pango/src/glyphstring.hg | 42 +++++++++++++++++++++++++++++++++++-------
pango/src/item.ccg | 8 +++++++-
pango/src/item.hg | 32 ++++++++++++++++++++++++++------
tools/m4/convert_pango.m4 | 3 ++-
7 files changed, 82 insertions(+), 22 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a5d397c..c537d7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ MM_AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
AC_DISABLE_STATIC
LT_INIT([win32-dll])
-AC_SUBST([PANGOMM_MODULES], ['giomm-2.66 >= 2.65.1 cairomm-1.16 >= 1.15.1 pangocairo >= 1.41.0'])
+AC_SUBST([PANGOMM_MODULES], ['giomm-2.66 >= 2.65.1 cairomm-1.16 >= 1.15.1 pangocairo >= 1.44.3'])
AC_SUBST([MSVC_TOOLSET_VER], [''])
PKG_CHECK_MODULES([PANGOMM], [$PANGOMM_MODULES])
diff --git a/meson.build b/meson.build
index 5cedae6..33c3eb7 100644
--- a/meson.build
+++ b/meson.build
@@ -100,7 +100,7 @@ glibmm_req = '>= 2.65.1'
# Pango supported pkg-config files on MSVC files for a good while,
# so just use that
-pangocairo_req = '>= 1.41.0'
+pangocairo_req = '>= 1.44.3'
pangocairo_dep = dependency('pangocairo', version: pangocairo_req)
glibmm_req_minor_ver = '66'
diff --git a/pango/src/glyphstring.ccg b/pango/src/glyphstring.ccg
index 9b055f9..b8dd6ea 100644
--- a/pango/src/glyphstring.ccg
+++ b/pango/src/glyphstring.ccg
@@ -1,8 +1,4 @@
-// -*- c++ -*-
-/* $Id: glyphstring.ccg,v 1.2 2006/05/30 17:14:21 murrayc Exp $ */
-
/*
- *
* Copyright 1998-2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
@@ -30,7 +26,16 @@ GlyphString::GlyphString(const Glib::ustring& text, const Analysis& analysis)
:
gobject_(pango_glyph_string_new())
{
- pango_shape(text.c_str(), text.bytes(), const_cast<PangoAnalysis*>(analysis.gobj()), gobj());
+ pango_shape(text.c_str(), text.bytes(), analysis.gobj(), gobj());
+}
+
+GlyphString::GlyphString(const Glib::ustring& item_text, const Glib::ustring& paragraph_text,
+ const Analysis& analysis, ShapeFlags flags)
+:
+ gobject_(pango_glyph_string_new())
+{
+ pango_shape_with_flags(item_text.c_str(), item_text.bytes(), paragraph_text.c_str(),
+ paragraph_text.bytes(), analysis.gobj(), gobj(), static_cast<PangoShapeFlags>(flags));
}
Rectangle GlyphString::get_ink_extents(const Glib::RefPtr<const Font>& font) const
diff --git a/pango/src/glyphstring.hg b/pango/src/glyphstring.hg
index a04636c..8577905 100644
--- a/pango/src/glyphstring.hg
+++ b/pango/src/glyphstring.hg
@@ -19,16 +19,14 @@
#include <pangomm/font.h>
#include <pangomm/glyph.h>
-#include <pangomm/item.h>
+#include <pangomm/item.h> // for Analysis and ShapeFlags
#include <cairomm/context.h>
#include <pango/pango-glyph.h>
-#include <pango/pango-item.h> //For PangoAnalysis.
_DEFS(pangomm,pango)
namespace Pango
{
-
/** A Pango::GlyphString is used to store strings of glyphs with geometry and visual attribute information.
* It can be measured or drawn to the screen.
*/
@@ -39,15 +37,45 @@ class PANGOMM_API GlyphString
_IGNORE(pango_glyph_string_index_to_x, pango_glyph_string_x_to_index,
pango_glyph_string_get_logical_widths)
public:
- /** Construct a string of glyphs from a string of characters.
+
+ /** Constructs a string of glyphs from a string of characters.
+ *
* Given a segment of text and the corresponding Pango::Analysis structure
* returned from Pango::Context::itemize(), convert the characters into glyphs.
- * You may also pass in only a sub-string of the item.
- * @param text The text to process. You must pass the same string into those member functions expecting a
const Glib::ustring&.
- * @param analysis The analysis information return from Pango::Context::itemize().
+ * You may also pass in only a substring of the item.
+ *
+ * It is recommended that you use the constructor with @a item_text and
+ * @a paragraph_text parameters instead, since that API allows for shaping
+ * interaction happening across text item boundaries.
+ *
+ * @param text The text to process. You must pass the same string into those
+ * member functions expecting a const Glib::ustring&.
+ * @param analysis The analysis information returned from Pango::Context::itemize().
*/
GlyphString(const Glib::ustring& text, const Analysis& analysis);
+ /** Constructs a string of glyphs from a string of characters.
+ *
+ * Given a segment of text and the corresponding Pango::Analysis structure
+ * returned from Pango::Context::itemize(), convert the characters into glyphs.
+ * You may also pass in only a substring of the item.
+ *
+ * This is similar to the constructor with only one @a text parameter, except
+ * it also takes @a flags and the full paragraph text as input, which will then
+ * be used to perform certain cross-item shaping interactions. If you have
+ * access to the broader text of which @a item_text is a part, provide the
+ * broader text as @a paragraph_text.
+ *
+ * @newin{2,44}
+ *
+ * @param item_text Valid UTF-8 text to shape.
+ * @param paragraph_text Text of the paragraph (see details).
+ * @param analysis The analysis information returned from Pango::Context::itemize().
+ * @param flags Flags influencing the shaping process.
+ */
+ GlyphString(const Glib::ustring& item_text, const Glib::ustring& paragraph_text,
+ const Analysis& analysis, ShapeFlags flags = ShapeFlags::NONE);
+
_WRAP_METHOD(void set_size (int new_len), pango_glyph_string_set_size)
_WRAP_METHOD(void get_extents(const Glib::RefPtr<const Font>& font, Rectangle& ink_rect, Rectangle&
logical_rect) const, pango_glyph_string_extents)
diff --git a/pango/src/item.ccg b/pango/src/item.ccg
index c79a186..199a554 100644
--- a/pango/src/item.ccg
+++ b/pango/src/item.ccg
@@ -15,6 +15,7 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <pango/pango-enum-types.h> // for pango_shape_flags_get_type()
#include <pangomm/font.h>
#include <pangomm/attributes.h>
#include <pangomm/glyphstring.h>
@@ -100,6 +101,12 @@ Pango::GlyphString Item::shape(const Glib::ustring& text) const
return GlyphString(text, get_analysis());
}
+Pango::GlyphString Item::shape(const Glib::ustring& item_text,
+ const Glib::ustring& paragraph_text, ShapeFlags flags) const
+{
+ return GlyphString(item_text, paragraph_text, get_analysis(), flags);
+}
+
} /* namespace Pango */
@@ -122,4 +129,3 @@ Pango::Item wrap(PangoItem* object, bool take_copy)
}
} /* namespace Glib */
-
diff --git a/pango/src/item.hg b/pango/src/item.hg
index e79e017..37b8fce 100644
--- a/pango/src/item.hg
+++ b/pango/src/item.hg
@@ -23,12 +23,13 @@ _DEFS(pangomm,pango)
namespace Pango
{
+_WRAP_ENUM(ShapeFlags, PangoShapeFlags, newin "2,44", decl_prefix PANGOMM_API)
class Font;
class GlyphString;
-/** A Pango::Analysis stores information about the properties of a segment of text.
- * Pango::Analysis is used as an output type only so there is no public default constructor.
+/** A %Pango::Analysis stores information about the properties of a segment of text.
+ * %Pango::Analysis is used as an output type only so there is no public default constructor.
* You can retrieve an object of this type from an object of type Pango::Item by
* calling Pango::Item::get_analysis(). Objects of this class can be used for some
* calculations in Pango::GlyphString.
@@ -134,12 +135,33 @@ public:
*/
Glib::ustring get_segment(const Glib::ustring& text) const;
- /** Convert a segment of text into a string of glyphs.
- * @param text The text to process. This must either be the whole segment of text that corresponds to the
item as returned by get_segment() or a sub-string of that segment. You need to pass the same text to the
member functions of Pango::GlyphString for further calculations.
+ /** Converts a segment of text into a string of glyphs.
+ *
+ * @param text The text to process. This must either be the whole segment of text
+ * that corresponds to the item as returned by get_segment() or a
+ * substring of that segment. You need to pass the same text to
+ * the member functions of Pango::GlyphString for further calculations.
* @return A Pango::GlyphString object that can be measured or drawn.
*/
GlyphString shape(const Glib::ustring& text) const;
+ /** Converts a segment of text into a string of glyphs.
+ *
+ * @newin{2,44}
+ *
+ * @param item_text The text to process. This must either be the whole segment of text
+ * that corresponds to the item as returned by get_segment() or a
+ * substring of that segment. You need to pass the same text to
+ * the member functions of Pango::GlyphString for further calculations.
+ * @param paragraph_text Text of the paragraph. See GlyphString::GlyphString(
+ * const Glib::ustring& item_text, const Glib::ustring& paragraph_text,
+ * const Analysis& analysis, ShapeFlags flags).
+ * @param flags Flags influencing the shaping process.
+ * @return A Pango::GlyphString object that can be measured or drawn.
+ */
+ GlyphString shape(const Glib::ustring& item_text, const Glib::ustring& paragraph_text,
+ ShapeFlags flags = ShapeFlags::NONE) const;
+
/// Provides access to the underlying C GObject.
PangoItem* gobj() { return gobject_; }
/// Provides access to the underlying C GObject.
@@ -151,7 +173,6 @@ protected:
} // namespace Pango
-
namespace Glib
{
@@ -168,4 +189,3 @@ PANGOMM_API
Pango::Item wrap(PangoItem* object, bool take_copy=true);
} // namespace Glib
-
diff --git a/tools/m4/convert_pango.m4 b/tools/m4/convert_pango.m4
index ece2b49..1c9b093 100644
--- a/tools/m4/convert_pango.m4
+++ b/tools/m4/convert_pango.m4
@@ -16,9 +16,10 @@ _CONV_ENUM(Pango,WrapMode)
_CONV_ENUM(Pango,TabAlign)
_CONV_ENUM(Pango,Script)
_CONV_ENUM(Pango,EllipsizeMode)
-_CONV_INCLASS_ENUM(Pango,Render,Part)
+_CONV_INCLASS_ENUM(Pango,Renderer,Part,PangoRenderPart)
_CONV_ENUM(Pango,Gravity)
_CONV_ENUM(Pango,GravityHint)
+_CONV_ENUM(Pango,ShapeFlags)
# General conversions:
_CONVERSION(`gchar*',`const char*',`($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]