Код: Выделить всё
I implemented functions to draw text frames, handle keyboard input for text editing, and display text using Cairo. I expected the text editing functionalities to work smoothly, allowing users to insert, delete, and move the cursor within the text frame. However, I encountered issues with cursor positioning and text selection, leading to unexpected behaviour during editing have attached my code file as follows
Код: Выделить всё
#include "text_display.hpp"
// Function to create a texture for cairo surface
ImTextureID TextDisplay::createTextureForFillingTheShape(unsigned char *imageData, int width, int height)
{
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
// Set texture parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Upload the image data to the GPU
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
// Return the texture ID that ImGui can use
return reinterpret_cast(texture);
}
// Function to load a custom font face using FreeType and create a cairo font face
cairo_font_face_t *load_custom_font_face(cairo_t *cr, const char *font_path)
{
FT_Library library;
FT_Face face;
FT_Error error = FT_Init_FreeType(&library);
if (error)
{
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/78427735/seeking-dear-imgui-and-cairo-codebase-for-text-editing-functionality[/url]