Hello Behdad,
Thanks for your inputs.
I have fixed the issue by adding the a few lines of code (additional code, colored in blue) in the process_item() function of pango_layout.c
I have tested this in English only and it works fine.
Issue
When space is encountered at the end of the current line and it cannot be accommodated there,
the word breaks at the previous glyph.
This is because break_num_chars does not count the current glyph (i.e. space)
Proposed Solution
In case of above scenario, increase the value of break_num_chars by 1.
And also take into account the break_width.
Modification in code
retry_break:
/* See how much of the item we can stuff in the line. */
width = 0;
for (num_chars = 0; num_chars < item->num_chars; num_chars++)
{
if (width > state->remaining_width && break_num_chars < item->num_chars)
break;
/* If there are no previous runs we have to take care to grab at least one char. */
if (can_break_at (layout, state->start_offset + num_chars, retrying_with_char_breaks) &&
(num_chars > 0 || line->runs))
{
break_num_chars = num_chars;
break_width = width;
}
else
{
if( (layout->log_attrs[state->start_offset + num_chars].is_white) &&
(layout->wrap == PANGO_WRAP_CHAR || layout->wrap == PANGO_WRAP_WORD_CHAR) )
{
break_num_chars = num_chars + 1;
break_width = width + state->log_widths[state->log_widths_offset + num_chars];
}
}
width += state->log_widths[state->log_widths_offset + num_chars];
}
------
Do you think that this would work fine in other languages also ?
Thanks and regards,
Parth Kanungo
------- Original Message -------
Sender : Behdad Esfahbod<behdad behdad org>
Date : Sep 09, 2013 21:44 (GMT+05:30)
Title : Re: issue with line break option PANGO_WRAP_CHAR
On 13-09-06 08:22 AM, Parth Kanungo wrote: