| 2667 | } |
| 2668 | |
| 2669 | void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque) |
| 2670 | { |
| 2671 | stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque; |
| 2672 | IM_ASSERT(pack_context != NULL); |
| 2673 | |
| 2674 | ImVector<ImFontAtlasCustomRect>& user_rects = atlas->CustomRects; |
| 2675 | IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong. |
| 2676 | #ifdef __GNUC__ |
| 2677 | if (user_rects.Size < 1) { __builtin_unreachable(); } // Workaround for GCC bug if IM_ASSERT() is defined to conditionally throw (see #5343) |
| 2678 | #endif |
| 2679 | |
| 2680 | ImVector<stbrp_rect> pack_rects; |
| 2681 | pack_rects.resize(user_rects.Size); |
| 2682 | memset(pack_rects.Data, 0, (size_t)pack_rects.size_in_bytes()); |
| 2683 | for (int i = 0; i < user_rects.Size; i++) |
| 2684 | { |
| 2685 | pack_rects[i].w = user_rects[i].Width; |
| 2686 | pack_rects[i].h = user_rects[i].Height; |
| 2687 | } |
| 2688 | stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size); |
| 2689 | for (int i = 0; i < pack_rects.Size; i++) |
| 2690 | if (pack_rects[i].was_packed) |
| 2691 | { |
| 2692 | user_rects[i].X = (unsigned short)pack_rects[i].x; |
| 2693 | user_rects[i].Y = (unsigned short)pack_rects[i].y; |
| 2694 | IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height); |
| 2695 | atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h); |
| 2696 | } |
| 2697 | } |
| 2698 | |
| 2699 | void ImFontAtlasBuildRender8bppRectFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char, unsigned char in_marker_pixel_value) |
| 2700 | { |
no test coverage detected