[liblouis-liblouisxml] Re: Help! C programmers

  • From: Bert Frees <bertfrees@xxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Wed, 7 Aug 2013 14:07:12 +0200

I think the small change in centerHeadFoot, or probably better, in
set_runninghead_string, is exactly what's Paul is looking for, but he's
having trouble understanding what widechar is all about.

What about something like this? I haven't tested it.

=============================================================
transcriber.c, line 987:
=============================================================
int
truncate (widechar * char, int length, int max_length)
{
  if (length <= max_length)
    return length;
  for (length = max_length; length > 0; length--)
    if (char[length] == ' ')
      return length;
  return max_length;
}

void
set_runninghead_string (widechar * chars, int length)
{
  ud->running_head_length = truncate (chars, length, ud->cells_per_line -
9);
  memcpy (ud->running_head, chars, ud->running_head_length * CHARSIZE);
}
=============================================================



2013/8/7 John J. Boyer <john.boyer@xxxxxxxxxxxxxxxxx>

> Paul,
>
> I'm not sure what you are trying to do. A relatively small change to the
> centerHeadFoot function would be enough to shorten the length to just
> before the last space. It seems to me that you could also determine if
> the header is too long by using the lou_allround tool. It will show you
> the translation. The length of the translation should not be more than
> the number of cells per line minus 10. That will give you a better
> header than letting a long one be truncated, even to the last space.
>
> I hope this really is of help.
>
> John
>

Other related posts: