mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Font: Fixed high-level ImGui::CalcTextSize() used by most widgets from erroneously subtracting 1.0f*scale to calculated text width. Among noticeable side-effects, it would make sequences of repeated Text/SameLine calls not align the same as a single call, and create mismatch between high-level size calculation and those performed with the lower-level ImDrawList api. (#792)
This commit is contained in:
		| @@ -63,6 +63,10 @@ Other Changes: | |||||||
| - Window: Fixed initial width of collapsed windows not taking account of contents width (broken in 1.67). (#2336, #176) | - Window: Fixed initial width of collapsed windows not taking account of contents width (broken in 1.67). (#2336, #176) | ||||||
| - ListBox: Better optimized when clipped / non-visible. | - ListBox: Better optimized when clipped / non-visible. | ||||||
| - InputTextMultiline: Better optimized when clipped / non-visible. | - InputTextMultiline: Better optimized when clipped / non-visible. | ||||||
|  | - Font: Fixed high-level ImGui::CalcTextSize() used by most widgets from erroneously subtracting 1.0f*scale to | ||||||
|  |   calculated text width. Among noticeable side-effects, it would make sequences of repeated Text/SameLine calls | ||||||
|  |   not align the same as a single call, and create mismatch between high-level size calculation and those performed | ||||||
|  |   with the lower-level ImDrawList api. (#792) [@SlNPacifist] | ||||||
| - ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle" | - ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle" | ||||||
|   with a small number of segments (e.g. an hexagon). (#2287) [@baktery] |   with a small number of segments (e.g. an hexagon). (#2287) [@baktery] | ||||||
| - ImGuiTextBuffer: Added append() function (unformatted). | - ImGuiTextBuffer: Added append() function (unformatted). | ||||||
|   | |||||||
| @@ -3909,11 +3909,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex | |||||||
|         return ImVec2(0.0f, font_size); |         return ImVec2(0.0f, font_size); | ||||||
|     ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); |     ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); | ||||||
|  |  | ||||||
|     // Cancel out character spacing for the last character of a line (it is baked into glyph->AdvanceX field) |     // Round | ||||||
|     const float font_scale = font_size / font->FontSize; |  | ||||||
|     const float character_spacing_x = 1.0f * font_scale; |  | ||||||
|     if (text_size.x > 0.0f) |  | ||||||
|         text_size.x -= character_spacing_x; |  | ||||||
|     text_size.x = (float)(int)(text_size.x + 0.95f); |     text_size.x = (float)(int)(text_size.x + 0.95f); | ||||||
|  |  | ||||||
|     return text_size; |     return text_size; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user