diff options
author | Carsten Haitzler <raster@rasterman.com> | 2012-06-23 02:32:30 +0000 |
---|---|---|
committer | Carsten Haitzler <raster@rasterman.com> | 2012-06-23 02:32:30 +0000 |
commit | 01c382407b89ea83b0fa1df89bd5a3baa50e520b (patch) | |
tree | eb83155d90b78dc52471df0eef136c233881adf0 /legacy/evas/src/lib/engines/common/evas_font_main.c | |
parent | 309e29f9eeca36e48cdb31be7049dbd47c85e784 (diff) |
clean up terminal char line drawing fallback to be more specific (fall
back only if 1 size and num glyphs < 513 and find failed). ALSO make
lookup a binary-search for efficiency.
SVN revision: 72710
Diffstat (limited to '')
-rw-r--r-- | legacy/evas/src/lib/engines/common/evas_font_main.c | 88 |
1 files changed, 57 insertions, 31 deletions
diff --git a/legacy/evas/src/lib/engines/common/evas_font_main.c b/legacy/evas/src/lib/engines/common/evas_font_main.c index 2240fdf57c..bd4c6785f9 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_main.c +++ b/legacy/evas/src/lib/engines/common/evas_font_main.c | |||
@@ -508,41 +508,39 @@ struct _Font_Char_Index | |||
508 | EAPI FT_UInt | 508 | EAPI FT_UInt |
509 | evas_common_get_char_index(RGBA_Font_Int* fi, Eina_Unicode gl) | 509 | evas_common_get_char_index(RGBA_Font_Int* fi, Eina_Unicode gl) |
510 | { | 510 | { |
511 | static const Eina_Unicode mapfix[] = | 511 | static const unsigned short mapfix[] = |
512 | { | 512 | { |
513 | 0x25c6, 0x1, | ||
514 | 0x2592, 0x2, | ||
515 | 0x2409, 0x3, | ||
516 | 0x240c, 0x4, | ||
517 | 0x240d, 0x5, | ||
518 | 0x240a, 0x6, | ||
519 | 0x00b0, 0x7, | 513 | 0x00b0, 0x7, |
520 | 0x00b1, 0x8, | 514 | 0x00b1, 0x8, |
521 | 0x2424, 0x9, | 515 | 0x00b7, 0x1f, |
522 | 0x240b, 0xa, | 516 | 0x03c0, 0x1c, |
523 | 0x2518, 0xb, | 517 | 0x20a4, 0xa3, |
524 | 0x2510, 0xc, | 518 | 0x2260, 0x1d, |
525 | 0x250c, 0xd, | 519 | 0x2264, 0x1a, |
526 | 0x2514, 0xe, | 520 | 0x2265, 0x1b, |
527 | 0x253c, 0xf, | ||
528 | 0x23ba, 0x10, | 521 | 0x23ba, 0x10, |
529 | 0x23bb, 0x11, | 522 | 0x23bb, 0x11, |
530 | 0x2500, 0x12, | ||
531 | 0x23bc, 0x13, | 523 | 0x23bc, 0x13, |
532 | 0x23bd, 0x14, | 524 | 0x23bd, 0x14, |
525 | 0x2409, 0x3, | ||
526 | 0x240a, 0x6, | ||
527 | 0x240b, 0xa, | ||
528 | 0x240c, 0x4, | ||
529 | 0x240d, 0x5, | ||
530 | 0x2424, 0x9, | ||
531 | 0x2500, 0x12, | ||
532 | 0x2502, 0x19, | ||
533 | 0x250c, 0xd, | ||
534 | 0x2510, 0xc, | ||
535 | 0x2514, 0xe, | ||
536 | 0x2518, 0xb, | ||
533 | 0x251c, 0x15, | 537 | 0x251c, 0x15, |
534 | 0x2524, 0x16, | 538 | 0x2524, 0x16, |
535 | 0x2534, 0x17, | ||
536 | 0x252c, 0x18, | 539 | 0x252c, 0x18, |
537 | 0x2502, 0x19, | 540 | 0x2534, 0x17, |
538 | 0x2264, 0x1a, | 541 | 0x253c, 0xf, |
539 | 0x2265, 0x1b, | 542 | 0x2592, 0x2, |
540 | 0x03c0, 0x1c, | 543 | 0x25c6, 0x1, |
541 | 0x2260, 0x1d, | ||
542 | 0x00a3, 0xa3, | ||
543 | 0x00b7, 0x1f, | ||
544 | 0x20a4, 0xa3, | ||
545 | 0x0000, 0x0 | ||
546 | }; | 544 | }; |
547 | Font_Char_Index result; | 545 | Font_Char_Index result; |
548 | //FT_UInt ret; | 546 | //FT_UInt ret; |
@@ -575,20 +573,48 @@ evas_common_get_char_index(RGBA_Font_Int* fi, Eina_Unicode gl) | |||
575 | #ifdef HAVE_PTHREAD | 573 | #ifdef HAVE_PTHREAD |
576 | // pthread_mutex_unlock(&fi->ft_mutex); | 574 | // pthread_mutex_unlock(&fi->ft_mutex); |
577 | #endif | 575 | #endif |
578 | if (result.index <= 0) | 576 | // this is a workaround freetype bugs where for a bitmap old style font |
577 | // even if it has unicode information and mappings, they are not used | ||
578 | // to find terminal line/drawing chars, so do this by hand with a table | ||
579 | if ((result.index <= 0) && (fi->src->ft.face->num_fixed_sizes == 1) && | ||
580 | (fi->src->ft.face->num_glyphs < 512)) | ||
579 | { | 581 | { |
580 | int i; | 582 | int i, min = 0, max; |
581 | 583 | ||
582 | for (i = 0; mapfix[i]; i += 2) | 584 | // binary search through sorted table of codepoints to new |
585 | // codepoints with a guess that bitmap font is playing the old | ||
586 | // game of putting line drawing chars in specific ranges | ||
587 | max = sizeof(mapfix) / (sizeof(mapfix[0]) * 2); | ||
588 | i = (min + max) / 2; | ||
589 | for (;;) | ||
583 | { | 590 | { |
584 | if (gl == mapfix[i]) | 591 | unsigned short v; |
592 | |||
593 | v = mapfix[i << 1]; | ||
594 | if (gl == v) | ||
585 | { | 595 | { |
586 | gl = mapfix[i + 1]; | 596 | gl = mapfix[(i << 1) + 1]; |
587 | FTLOCK(); | 597 | FTLOCK(); |
588 | result.index = FT_Get_Char_Index(fi->src->ft.face, gl); | 598 | result.index = FT_Get_Char_Index(fi->src->ft.face, gl); |
589 | FTUNLOCK(); | 599 | FTUNLOCK(); |
590 | break; | 600 | break; |
591 | } | 601 | } |
602 | // failure to find at all | ||
603 | if ((max - min) <= 2) break; | ||
604 | // if glyph above out position... | ||
605 | if (gl > v) | ||
606 | { | ||
607 | min = i; | ||
608 | if ((max - min) == 2) i = max; | ||
609 | else i = (min + max) / 2; | ||
610 | } | ||
611 | // if glyph below out position | ||
612 | else if (gl < v) | ||
613 | { | ||
614 | max = i; | ||
615 | if ((max - min) == 2) i = min; | ||
616 | else i = (min + max) / 2; | ||
617 | } | ||
592 | } | 618 | } |
593 | } | 619 | } |
594 | return result.index; | 620 | return result.index; |