Example #1
0
static bool nsfont_split(const plot_font_style_t *fstyle,
		const char *string, size_t length,
		int x, size_t *char_offset, int *actual_x)
{

        const struct fb_font_desc* fb_font = fb_get_font(fstyle);
        int c_off = *char_offset = x / fb_font->width;
        if (*char_offset > length) {
                *char_offset = length;
        } else {
                while (*char_offset > 0) {
                        if (string[*char_offset] == ' ')
                                break;
                        (*char_offset)--;
                }
                if (*char_offset == 0) {
                        *char_offset = c_off;
                        while (*char_offset < length &&
                                        string[*char_offset] != ' ') {
                                (*char_offset)++;
                        }
                }
        }
        *actual_x = *char_offset * fb_font->width;
	return true;
}
Example #2
0
static bool nsfont_width(const plot_font_style_t *fstyle,
                         const char *string, size_t length,
                         int *width)
{
        const struct fb_font_desc* fb_font = fb_get_font(fstyle);
        *width = fb_font->width * utf8_bounded_length(string, length);
	return true;
}
Example #3
0
static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
		const char *string, size_t length,
		int x, size_t *char_offset, int *actual_x)
{
        const struct fb_font_desc* fb_font = fb_get_font(fstyle);
        *char_offset = (x + fb_font->width / 2) / fb_font->width;
        if (*char_offset > length)
                *char_offset = length;
        *actual_x = *char_offset * fb_font->width;
	return true;
}
Example #4
0
static bool fb_1bpp_text(int x, int y, const struct css_style *style,
                  const char *text, size_t length, colour bg, colour c)
{
        const struct fb_font_desc* fb_font = fb_get_font(style);
        u8_t *video_char_start;
        const u8_t *font_data;
        int yloop;
        unsigned char row;
        int chr;

        LOG(("%s(%d, %d, %p, %.*s , %d, 0x%lx, 0x%lx)\n", __func__, 
             x,y,style,length,text,length,bg,c));

        for (chr=0; chr < length; chr++) {
                video_char_start = fb_plotters_get_xy_loc(x + (chr * (fb_font->width)), y, fbinfo);

                /* move our font-data to the correct position */
                font_data = fb_font->data + (text[chr] * fb_font->height);

                for (yloop = 0; yloop < fb_font->height; yloop++) {
                        row = font_data[yloop];
                        *video_char_start = row;
                        video_char_start += fbinfo->line_len;
                }
        }
        return true;


        /* copied from css/css.h - need to open the correct font here
         * font properties *
         css_font_family font_family;
         struct {
         css_font_size_type size;
         union {
         struct css_length length;
         float absolute;
         float percent;
         } value;
         } font_size;
         css_font_style font_style;
         css_font_variant font_variant;
         css_font_weight font_weight;
        */
	return true;
}
Example #5
0
static bool framebuffer_plot_text(int x, int y, const char *text, size_t length,
		const plot_font_style_t *fstyle)
{
    const struct fb_font_desc* fb_font = fb_get_font(fstyle);
    const uint32_t *chrp;
    char *buffer = NULL;
    int chr;
    int blen;
    nsfb_bbox_t loc;

    utf8_to_font_encoding(fb_font, text, length, &buffer);
    if (buffer == NULL)
        return true;

        /* y is given as the baseline, at 3/4 from top.
         * we need it to the top */
        y -= ((fb_font->height * 3) / 4);

        /* the coord is the bottom-left of the pixels offset by 1 to make
         *   it work since fb coords are the top-left of pixels
         */
        y += 1;

    blen = strlen(buffer);

    for (chr = 0; chr < blen; chr++) {
        loc.x0 = x;
        loc.y0 = y;
        loc.x1 = loc.x0 + fb_font->width;
        loc.y1 = loc.y0 + fb_font->height;

        chrp = fb_font->data + ((unsigned char)buffer[chr] * fb_font->height);
        nsfb_plot_glyph1(nsfb, &loc, (uint8_t *)chrp, 32, fstyle->foreground);

        x += fb_font->width;

    }

    free(buffer);
    return true;
}