If you know your string is ASCII then the number of glyphs is equal to 
the number of bytes. This may be reasonable if you are just trying to 
print numbers.

Even using fltk's calls, you can use utf8_fwd to move from the start of 
the string to find the Nth code point. This has the advantage that it 
will count errorneous sequences correctly (1 code for each byte). This 
is a lot more efficient than going from the end and measuring over and over.

On 09/21/2011 08:58 AM, MacArthur, Ian (SELEX GALILEO, UK) wrote:
>
>> OK. I have string with some length (m = strlen(s);) and I have n -
>> quantity of characters which I can print.
>> I can calculate k = fl_utf_nb_char(s, m);
>>
>> If k<= n then no problem : fl_draw(s,x,y);
>>
>> Otherwise?
>> In cycle decrease the source text  by one byte and check for
>> length, yes?
>
> It's pretty easy to scan a UTF8 string and determine where each glyph
> begins, so you'd want to chop a whole glyph off the end of your string,
> not just one byte, I imagine.
>
> I think there might even be a fltk helper function for finding the glyph
> positions in the string - or am I remembering some other toolkit...?
>
>
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
> 3EL
> A company registered in England&  Wales.  Company no. 02426132
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>

_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to