<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I want to apply foreground color to each of string "the" like below using pangomm:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:#c0c0c0"></span><span style="color:#808000">     auto</span><span style="color:#c0c0c0">
</span><span style="color:#092e64">layout</span><span style="color:#c0c0c0"> </span>
=<span style="color:#c0c0c0"> </span><span style="color:#00677c">create_pango_layout</span>(<span style="color:#008000">"the"</span>);
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">layout</span>-><span style="color:#00677c">set_font_description</span>(<span style="color:#092e64">font</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">Pango</span>::<span style="color:#800080">AttrList</span><span style="color:#c0c0c0"> </span><span style="color:#092e64">attrlist</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">Pango</span>::<span style="color:#800080">Attribute</span><span style="color:#c0c0c0"> </span><span style="color:#092e64">attr1</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr1</span>.<span style="color:#00677c">create_attr_foreground</span>(<span style="color:#000080">255</span>,<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>,<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr1</span>.<span style="color:#00677c">set_start_index</span>(<span style="color:#000080">0</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr1</span>.<span style="color:#00677c">set_end_index</span>(<span style="color:#000080">1</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attrlist</span>.<span style="color:#00677c">insert</span>(<span style="font-style:italic;color:#092e64">attr1</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">Pango</span>::<span style="color:#800080">Attribute</span><span style="color:#c0c0c0"> </span><span style="color:#092e64">attr2</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr2</span>.<span style="color:#00677c">create_attr_foreground</span>(<span style="color:#000080">0</span>,<span style="color:#c0c0c0"> </span><span style="color:#000080">255</span>,<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr2</span>.<span style="color:#00677c">set_start_index</span>(<span style="color:#000080">1</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr2</span>.<span style="color:#00677c">set_end_index</span>(<span style="color:#000080">2</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attrlist</span>.<span style="color:#00677c">insert</span>(<span style="font-style:italic;color:#092e64">attr2</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">Pango</span>::<span style="color:#800080">Attribute</span><span style="color:#c0c0c0"> </span><span style="color:#092e64">attr3</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr3</span>.<span style="color:#00677c">create_attr_foreground</span>(<span style="color:#000080">0</span>,<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>,<span style="color:#c0c0c0"> </span><span style="color:#000080">255</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr3</span>.<span style="color:#00677c">set_start_index</span>(<span style="color:#000080">2</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attr3</span>.<span style="color:#00677c">set_end_index</span>(<span style="color:#000080">3</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#092e64">attrlist</span>.<span style="color:#00677c">insert</span>(<span style="font-style:italic;color:#092e64">attr3</span>);</pre>
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
When I debug using Qt creator, step over attr1.set_start_index(0), it crash, says:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
"The inferior stopped because it received a signal from the operating system.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Signal name: SIGSEGV</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Signal meaning: Segmentation fault</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Anybody can shed a light on it, thanks!</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
</body>
</html>