Wrapping of ImFont.calc_word_wrap_position_a #308
-
Hello! I am using the python bindings and looking for a way to change colors mid-text in a text_wrapped. But the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width); It even returns returns an inner pointer in the original string. Python's way of handling strings (which are immutable) is very different from this. Adding a binding for this would require a substantial modification to the API, e.g (untested): // Returns an index in the string
IMGUI_API int CalcWordWrapPositionA_ForPython(float scale, const char* text, float wrap_width); (I'm not even sure this API is the correct way to go: what do you think?) Related question: The API below is available in the ImGui namespace: C++: IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); Python: def calc_text_size(
text: str, text_end: Optional[str] = None, hide_text_after_double_hash: bool = False, wrap_width: float = -1.0
) -> ImVec2: Would that be enough for you need? |
Beta Was this translation helpful? Give feedback.
-
See commit c371bcf It adds |
Beta Was this translation helpful? Give feedback.
See commit c371bcf
It adds
calc_word_wrap_position_a_python
which returns an index in the string.