Mercurial > MadButterfly
comparison src/shape_stext.c @ 423:3ba48126c49c
Check bearing and advance of text_extents.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 28 Jul 2009 15:11:42 +0800 |
parents | c6c0d017dc8e |
children | 585baa462778 |
comparison
equal
deleted
inserted
replaced
422:c6c0d017dc8e | 423:3ba48126c49c |
---|---|
595 } | 595 } |
596 | 596 |
597 static | 597 static |
598 void test_compute_text_extents(void) { | 598 void test_compute_text_extents(void) { |
599 co_aix matrix[6] = {10, 0, 0, 0, 10, 0}; | 599 co_aix matrix[6] = {10, 0, 0, 0, 10, 0}; |
600 co_aix x_adv1, x_adv2; | |
601 co_aix x_bearing1, x_bearing2; | |
600 mb_font_face_t *face; | 602 mb_font_face_t *face; |
601 mb_scaled_font_t *scaled; | 603 mb_scaled_font_t *scaled; |
602 mb_text_extents_t ext; | 604 mb_text_extents_t ext; |
603 | 605 |
604 face = query_font_face("serif", MB_FONT_SLANT_ROMAN, 100); | 606 face = query_font_face("serif", MB_FONT_SLANT_ROMAN, 100); |
607 CU_ASSERT(scaled != NULL); | 609 CU_ASSERT(scaled != NULL); |
608 | 610 |
609 compute_text_extents(scaled, "test", &ext); | 611 compute_text_extents(scaled, "test", &ext); |
610 CU_ASSERT(MBE_GET_HEIGHT(&ext) >= 5 && MBE_GET_HEIGHT(&ext) <= 12); | 612 CU_ASSERT(MBE_GET_HEIGHT(&ext) >= 5 && MBE_GET_HEIGHT(&ext) <= 12); |
611 CU_ASSERT(MBE_GET_WIDTH(&ext) >= 16 && MBE_GET_WIDTH(&ext) <= 48); | 613 CU_ASSERT(MBE_GET_WIDTH(&ext) >= 16 && MBE_GET_WIDTH(&ext) <= 48); |
612 | 614 x_adv1 = MBE_GET_X_ADV(&ext); |
615 x_bearing1 = MBE_GET_X_BEARING(&ext); | |
613 scaled_font_free(scaled); | 616 scaled_font_free(scaled); |
617 | |
618 matrix[2] = 5; | |
619 scaled = make_scaled_font_face_matrix(face, matrix); | |
620 CU_ASSERT(scaled != NULL); | |
621 | |
622 compute_text_extents(scaled, "test", &ext); | |
623 CU_ASSERT(MBE_GET_HEIGHT(&ext) >= 5 && MBE_GET_HEIGHT(&ext) <= 12); | |
624 CU_ASSERT(MBE_GET_WIDTH(&ext) >= 16 && MBE_GET_WIDTH(&ext) <= 48); | |
625 x_adv2 = MBE_GET_X_ADV(&ext); | |
626 x_bearing2 = MBE_GET_X_BEARING(&ext); | |
627 scaled_font_free(scaled); | |
628 | |
629 CU_ASSERT(x_adv1 == x_adv2); | |
630 CU_ASSERT((x_bearing1 + 5) == x_bearing2); | |
631 | |
614 free_font_face(face); | 632 free_font_face(face); |
615 } | 633 } |
616 | 634 |
617 static | 635 static |
618 void test_extent_extents(void) { | 636 void test_extent_extents(void) { |