Home | History | Annotate | Download | only in wsfont

Lines Matching refs:font

213 /* Make sure we always have at least one bitmap font. */
231 #define WSFONT_STATIC 0x02 /* Font structures not malloc()ed */
232 #define WSFONT_COPY 0x04 /* Copy of existing font in table */
235 struct font {
236 TAILQ_ENTRY(font) chain;
237 struct wsdisplay_font *font;
244 static struct font builtin_fonts[] = {
347 static TAILQ_HEAD(,font) list;
386 static struct font *wsfont_find0(int, int);
387 static struct font *wsfont_add0(struct wsdisplay_font *, int);
401 wsfont_revbit(struct wsdisplay_font *font)
405 p = (u_char *)font->data;
406 m = p + font->stride * font->numchars * font->fontheight;
413 wsfont_revbyte(struct wsdisplay_font *font)
418 if (font->stride == 1)
421 rp = (u_char *)font->data;
422 nr = font->numchars * font->fontheight;
426 r = font->stride - 1;
435 rp += font->stride;
443 struct font *ent;
446 f = ent->font;
454 wsfont_rotate_internal(struct wsdisplay_font *font, int rotate)
461 bool alpha = FONT_IS_ALPHA(font), cw = (rotate == WSFONT_ROTATE_CW);
463 /* Duplicate the existing font... */
464 newfont = malloc(sizeof(*font), M_DEVBUF, M_WAITOK);
466 *newfont = *font;
468 namelen = strlen(font->name) + 4;
470 strlcpy(newname, font->name, namelen);
474 /* Allocate a buffer big enough for the rotated font. */
475 newstride = alpha ? font->fontheight : howmany(font->fontheight, 8);
476 newdata = malloc(newstride * font->fontwidth * font->numchars,
483 /* Rotate the font a pixel at a time. */
484 for (n = 0; n < font->numchars; n++) {
485 ch = (u_char *)font->data +
486 (n * font->stride * font->fontheight);
488 (n * newstride * font->fontwidth);
489 for (h = 0; h < font->fontheight; h++) {
490 for (w = 0; w < font->fontwidth; w++) {
491 p = ch + (h * font->stride) +
503 ((font->fontwidth - 1 - w) *
524 /* Update font sizes. */
526 newfont->fontwidth = font->fontheight;
527 newfont->fontheight = font->fontwidth;
531 * If we seem to have rotated this font already, drop the
546 struct wsdisplay_font *font;
547 struct font *origfont;
559 font = wsfont_rotate_internal(origfont->font, rotate);
560 if (font == NULL)
569 ncookie = wsfont_find(font->name, font->fontwidth, font->fontheight,
570 font->stride, 0, 0, WSFONT_FIND_ALL);
580 struct font *ent;
591 for (i = 0; builtin_fonts[i].font != NULL; i++, ent++) {
594 ent->font->bitorder, ent->font->byteorder);
599 static struct font *
602 struct font *ent;
613 wsfont_matches(struct wsdisplay_font *font, const char *name,
619 if (FONT_IS_ALPHA(font)) {
629 if (height != 0 && font->fontheight != height)
634 if (font->fontwidth != width)
637 if (font->fontwidth > width) {
638 score -= uimin(font
643 score -= uimin(width - font->fontwidth, 9999);
651 if (stride != 0 && font->stride != stride)
654 if (name != NULL && strcmp(font->name, name) != 0)
663 struct font *ent, *bestent = NULL;
667 score = wsfont_matches(ent->font, name,
684 struct font *ent;
687 matchfunc(ent->font, cookie, ent->cookie);
691 static struct font *
692 wsfont_add0(struct wsdisplay_font *font, int copy)
694 struct font *ent;
697 ent = malloc(sizeof(struct font), M_DEVBUF, M_WAITOK | M_ZERO);
699 /* Is this font statically allocated? */
701 ent->font = font;
707 ent->font = malloc(sizeof(struct wsdisplay_font), M_DEVBUF,
709 memcpy(ent->font, font, sizeof(*ent->font));
711 size = font->fontheight * font->numchars * font->stride;
713 memcpy(data, font->data, size);
714 ent->font->data = data;
716 name = malloc(strlen(font->name) + 1, M_DEVBUF, M_WAITOK);
717 strlcpy(name, font->name, strlen(font->name) + 1);
718 ent->font->name = name;
726 wsfont_add(struct wsdisplay_font *font, int copy)
728 struct font *ent;
731 if (wsfont_find(font->name, font->fontwidth, font->fontheight,
732 font->stride, 0, 0, WSFONT_FIND_ALL) >= 0)
735 ent = wsfont_add0(font, copy);
738 ent->cookie = wsfont_make_cookie(ident, font->bitorder,
739 font->byteorder);
747 struct font *ent;
756 free(ent->font->data, M_DEVBUF);
757 free(__UNCONST(ent->font->name), M_DEVBUF); /*XXXUNCONST*/
758 free(ent->font, M_DEVBUF);
770 struct font *ent, *neu;
781 neu = wsfont_add0(ent->font, 1);
784 aprint_debug("wsfont: font '%s' bito %d byteo %d "
786 ent->font->name,
787 ent->font->bitorder, ent->font->byteorder,
793 if (bito && bito != ent->font->bitorder) {
794 wsfont_revbit(ent->font);
795 ent->font->bitorder = bito;
798 if (byteo && byteo != ent->font->byteorder) {
799 wsfont_revbyte(ent->font);
800 ent->font->byteorder = byteo;
807 *ptr = ent->font;
814 struct font *ent;
820 panic("wsfont_unlock: font not locked");
829 * Unicode to font encoding mappings
833 * To save memory, font encoding tables use a two level lookup. First the
1077 wsfont_map_unichar(struct wsdisplay_font *font, int c)
1083 if (font->encoding < 0 || font->encoding >= __arraycount(encodings))
1088 map1 = &encodings[font->encoding];
1096 if (hi == 0 && font->encoding == WSDISPLAY_FONTENC_ISO)