Changeset 1221


Ignore:
Timestamp:
Oct 22, 2006, 7:40:55 PM (16 years ago)
Author:
Sam Hocevar
Message:
  • Updated documentation of fullwidth-aware functions.
  • Fullwidth support in all exporters.
Location:
libcaca/trunk/cucul
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/canvas.c

    r1218 r1221  
    5454 *  The behaviour when printing non-printable characters or invalid UTF-32
    5555 *  characters is undefined. To print a sequence of bytes forming an UTF-8
    56  *  character instead of an UTF-32 character, use the cucul_putstr() function
    57  *  instead.
     56 *  character instead of an UTF-32 character, use the cucul_putstr() function.
    5857 *
    5958 *  This function never fails.
     
    133132 *
    134133 *  If the coordinates are outside the canvas boundaries, a space (0x20)
    135  *  is returned. FIXME: explain CUCUL_MAGIC_FULLWIDTH
     134 *  is returned.
     135 *
     136 *  A special exception is when CUCUL_MAGIC_FULLWIDTH is returned. This
     137 *  value is guaranteed not to be a valid Unicode character, and indicates
     138 *  that the character at the left of the requested one is a fullwidth
     139 *  character.
    136140 *
    137141 *  This function never fails.
     
    270274 *  - \c EINVAL A mask was specified but the mask size and source canvas
    271275 *    size do not match.
     276 *
     277 *  FIXME: this function may corrupt the canvas if fullwidth characters
     278 *         appear at odd places.
    272279 *
    273280 *  \param dst The destination canvas.
  • libcaca/trunk/cucul/export.c

    r1191 r1221  
    225225            uint8_t fg, bg;
    226226
     227            if(ch == CUCUL_MAGIC_FULLWIDTH)
     228                continue;
     229
    227230            fg = ((attr & 0xffff) == CUCUL_COLOR_DEFAULT) ?
    228231                     0x10 : palette[_cucul_argb32_to_ansi4fg(attr)];
     
    298301            uint8_t bg = palette[_cucul_argb32_to_ansi4bg(lineattr[x])];
    299302            uint32_t ch = linechar[x];
     303
     304            if(ch == CUCUL_MAGIC_FULLWIDTH)
     305                ch = '?';
    300306
    301307            if(fg != prevfg || bg != prevbg)
     
    378384                len++)
    379385            {
    380                 if(linechar[x + len] <= 0x00000020)
     386                if(linechar[x + len] == CUCUL_MAGIC_FULLWIDTH)
     387                    ;
     388                else if(linechar[x + len] <= 0x00000020)
    381389                    cur += sprintf(cur, "&nbsp;");
    382390                else if(linechar[x + len] < 0x00000080)
     
    451459            for(i = 0; i < len; i++)
    452460            {
    453                 if(linechar[x + i] <= 0x00000020)
     461                if(linechar[x + i] == CUCUL_MAGIC_FULLWIDTH)
     462                    ;
     463                else if(linechar[x + i] <= 0x00000020)
    454464                    cur += sprintf(cur, "&nbsp;");
    455465                else if(linechar[x + i] < 0x00000080)
     
    511521            uint8_t bg = palette[_cucul_argb32_to_ansi4bg(attr)];
    512522            uint32_t ch = linechar[x];
     523
     524            if(ch == CUCUL_MAGIC_FULLWIDTH)
     525                continue;
    513526
    514527            if((attr & 0xffff) == CUCUL_COLOR_DEFAULT)
     
    698711                                    cv->width * 6, cv->height * 10);
    699712
    700     cur += sprintf(cur, " <g id=\"mainlayer\" font-size=\"12\">\n");
     713    cur += sprintf(cur, " <g id=\"mainlayer\" font-size=\"10\""
     714                        " style=\"font-family: monospace\">\n");
    701715
    702716    /* Background */
     
    724738            uint32_t ch = *linechar++;
    725739
     740            if(ch == ' ' || ch == CUCUL_MAGIC_FULLWIDTH)
     741            {
     742                lineattr++;
     743                continue;
     744            }
     745
    726746            cur += sprintf(cur, "<text style=\"fill:#%.03x\" "
    727747                                "x=\"%d\" y=\"%d\">",
    728748                                _cucul_argb32_to_rgb12fg(*lineattr++),
    729                                 x * 6, (y * 10) + 10);
     749                                x * 6, (y * 10) + 8);
     750
    730751            if(ch < 0x00000020)
    731752                *cur++ = '?';
Note: See TracChangeset for help on using the changeset viewer.