Closed luadebug closed 3 months ago
Could you please elaborate on your request? It's not super clear.
I'm not sure where such a feature would belong in the current API -- it seems like it has nothing to do with hudhook
and it depends on imgui
instead.
For the record, font size can be controlled already by the clients, see this, but again it is not strictly dependent on hudhook
and it is a feature from imgui
.
If you mean changing the font size across widgets in the same frame, I don't think that is supported by imgui
outside of pushing/popping preinitialized fonts. Fonts are rasterized to a texture at initialization time, and that texture then gets sampled when drawing text.
ImGui::GetBackgroundDrawList()->AddText(esp_text, 19, ImVec2(ESPLeft, ESPTop - 20.f), ImColor(var::enemyColor[0], var::enemyColor[1], var::enemyColor[2]), Enemy->Name); This C++ code does not use any push or either pop for font, and second parameter being passed is text size. I was assuming that asking here is much better idea, rather go to imgui-rs that is being abandoned for months. https://github.com/imgui-rs/imgui-rs/pull/787
// 200 IQ conversion mechanism
pub fn f32_to_u8(value: f32) -> u8 {
// Scale and clamp the value to the range [0, 255]
let scaled = (value * 255.0).clamp(0.0, 255.0);
scaled as u8
}
unsafe {
let custom_font = ui.push_font(font_id);
// Get the entity name and create a CString
let text = entity.name().unwrap();
let c_text = CString::new(text).unwrap(); // Convert to C-compatible string
let font_handle = igGetFont();
// Get the pointer to the C string
let start: *const c_char = c_text.as_ptr(); // Use CString to ensure null termination
// The end pointer is not necessary when using CString, as you can pass the string slice
let end: *const c_char = start.add(c_text.as_bytes().len());
// Call the function
sys::ImDrawList_AddText_FontPtr(
sys::igGetBackgroundDrawList_Nil(),
font_handle,
SETTINGS.deref().name_text_thickness,
ImVec2::from([espleft, esptop - 80.0f32]),
if LOCAL_PLAYER.team().unwrap() == entity.team().unwrap() {
ImColor32::from_rgba(f32_to_u8(SETTINGS.deref().ally_name_text_color[0]), f32_to_u8(SETTINGS.deref().ally_name_text_color[1]), f32_to_u8(SETTINGS.deref().ally_name_text_color[2]), f32_to_u8(SETTINGS.deref().ally_name_text_color[3])).to_bits()
} else {
ImColor32::from_rgba(f32_to_u8(SETTINGS.deref().enemy_name_text_color[0]), f32_to_u8(SETTINGS.deref().enemy_name_text_color[1]), f32_to_u8(SETTINGS.deref().enemy_name_text_color[2]), f32_to_u8(SETTINGS.deref().enemy_name_text_color[3])).to_bits()
},
start,
end,
0.0f32,
std::ptr::null() // Assuming you don't want to specify a clipping rectangle
);
custom_font.pop();
}
When I drag slider that is bound to name_text_thickness I am able to change text size during this function call. What resolves my problem.
That seems to be part of imgui-rs.
Add a way to call add_text with specific Font Size, please.
Push and pop for font seems to be working, but I lose a way to control font size itself.