~ubuntu-branches/ubuntu/raring/libcaca/raring

« back to all changes in this revision

Viewing changes to cucul/canvas.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2007-10-13 20:10:44 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071013201044-35yldy9w3xe7iy2j
Tags: 0.99.beta12.debian-3
* debian/control:
  + Build-depend on texlive instead of all the other texlive-* packages so
    that we have the proper fonts at build time (Closes: #445797).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
4
4
 *                All Rights Reserved
5
5
 *
6
 
 *  $Id: canvas.c 1063 2006-11-13 23:16:35Z sam $
 
6
 *  $Id: canvas.c 1103 2006-12-12 01:53:54Z sam $
7
7
 *
8
 
 *  This library is free software; you can redistribute it and/or
9
 
 *  modify it under the terms of the Do What The Fuck You Want To
10
 
 *  Public License, Version 2, as published by Sam Hocevar. See
 
8
 *  This library is free software. It comes without any warranty, to
 
9
 *  the extent permitted by applicable law. You can redistribute it
 
10
 *  and/or modify it under the terms of the Do What The Fuck You Want
 
11
 *  To Public License, Version 2, as published by Sam Hocevar. See
11
12
 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12
13
 */
13
14
 
219
220
 */
220
221
int cucul_put_str(cucul_canvas_t *cv, int x, int y, char const *s)
221
222
{
222
 
    unsigned int read;
 
223
    unsigned int rd;
223
224
 
224
225
    if(y < 0 || y >= (int)cv->height || x >= (int)cv->width)
225
226
        return 0;
226
227
 
227
228
    while(*s && x < -1)
228
229
    {
229
 
        x += cucul_utf32_is_fullwidth(cucul_utf8_to_utf32(s, &read)) ? 2 : 1;
230
 
        s += read;
 
230
        x += cucul_utf32_is_fullwidth(cucul_utf8_to_utf32(s, &rd)) ? 2 : 1;
 
231
        s += rd;
231
232
    }
232
233
 
233
234
    while(*s && x < (int)cv->width)
234
235
    {
235
 
        uint32_t ch = cucul_utf8_to_utf32(s, &read);
 
236
        uint32_t ch = cucul_utf8_to_utf32(s, &rd);
236
237
        cucul_put_char(cv, x, y, ch);
237
238
        x += cucul_utf32_is_fullwidth(ch) ? 2 : 1;
238
 
        s += read;
 
239
        s += rd;
239
240
    }
240
241
 
241
242
    return 0;