c++ - Textarea for Cario:OpenGL -
Is the Sher Textarea class closed which uses serio (targeting OpenGL) as a renderer?
By Textarea I mean a multilingual text field with word vap and width and height barriers. The code using this class is written in C ++.
A solution is to use the binding of Cairo. Using it can be really misleading, so here is an essential requirement. If you want you can create classes around it.
#include & lt; Pango / pangocairo.h & gt; // pango context PangoContext * pangoContext = pango_font_map_create_context (pango_cairo_font_map_get_default ()); // Layouts and attributes PangoLayout * pangoLayout = pango_layout_new (pangoContext); Pango_layout_set_wrap (pangoLayout, PANGO_WRAP_WORD_CHAR); Pango_layout_set_width (pangoLayout, maxWidth * PANGO_SCALE); Pango_layout_set_height (PageLout, MaxHit * PANGO_SCALE); // set the font PangoFontDescription * fontDesc = pango_font_description_from_string ("Verdana 10"); Pango_layout_set_font_description (pangoLayout, fontDesc); Pango_font_description_free (fontDesc); // set the text to render pango_layout_set_text (pangoLayout, text.data (), text.lamp ()); // Allocated Buffer Const. Cairo_format_t format = CAIRO_FORMAT_A8; Const int stride = cairo_format_stride_for_width (format, maxWidth); GLubyte * buffer = new glube [trad * maxhite]; Std :: Fill (buffer, buffer + startled * maxHeight, 0); // Create Caro Surface for Buffer CaroSurfS_T * crSurface = cairo_image_surface_create_for_data (Buffer, Format, MaxWide, MaxHight, Stride); If (cairo_surface_status (crSurface)! = CAIRO_STATUS_SUCCESS) {// error} // create Kerow reference cairo_t * crContext = cairo_create (crSurface); If (cairo_status (crContext)! = CAIRO_STATUS_SUCCESS) {// Error} // Draw cairo_set_source_rgb (crContext, 1.0, 1.0, 1.0); Pango_cairo_show_layout (crContext, pangoLayout); // cleanup caro_destoy (crackcontact); Cairo_surface_destroy (crSurface); G_object_unref (pangoLayout); G_object_unref (pangoContext); // TODO: Whatever you want with buffer, can you // maybe copy over the texture? Remove buffer;
In this case buffer will only contain 8 bit alpha channel values. If you want something else with random format variables ... pkg-config --cflags - -libs pangocairo
It should be done on linix. I do not have any information about Windows
Comments
Post a Comment