<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span style="font-weight: bold;">Hi, I try to use freetype with xlib, I , I need to pass a char type array (RGBA/pixel) to a xlib function.</span></div><div><span style="font-weight: bold;"><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">from freetype I got :<br></span></div><div> face->glyph->bitmap.pixel_mode = 2</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">so if I understood corectly in face->glyph->bitmap.<span style="text-decoration: underline;">buffer</span> datas are stored in gray level.</span></div><div
style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"> face->glyph->bitmap.rows=16<br> face->glyph->bitmap.width=8</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"> face->glyph->bitmap.pitch=8<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">so I guess, length of face->glyph->bitmap.<span style="text-decoration: underline;">buffer</span> = 1(gray lvl)*16(width)*8(rows)=128 unsigned chars, right ?</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style:
normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">then I create an array of char for xlib from </span><span style="font-weight: bold;">face->glyph->bitmap.<span style="text-decoration: underline;">buffer<br></span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; font-style: normal;"><span style="background-color: rgb(255, 255, 255);"><span> for(i=0;i<128;i++){ <br> Xdata[4*i] =
face->glyph->bitmap.buffer[i];<br> Xdata[4*i+1] = face->glyph->bitmap.buffer[i];<br> Xdata[4*i+2] = face->glyph->bitmap.buffer[i];<br> Xdata[4*i+3] = 255; <br> } </span><br><span style="font-weight: bold;">and I try to create a
XImage :</span></span></div><div style="font-size: 16px; font-family: times new roman,new york,times,serif; font-style: normal; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);"><span><span><span><span><span><span><span> ximage = XCreateImage(display, DefaultVisual(display,0), 24, ZPixmap, 0, <br></span></span></span></span></span></span></span></span></div><div style="font-size: 16px; font-family: times new roman,new york,times,serif; font-style: normal; color: rgb(0, 0, 0);"><span style="background-color: rgb(255, 255, 255);"><span> &Xdata[0], 8<span style="color: rgb(208, 208, 208);"><span
style="color: rgb(139, 139, 139);"><span>/*rows*/</span></span>,</span> 16<span style="color: rgb(139, 139, 139);">/*width*/</span>, 32<span style="color: rgb(139, 139, 139);">/*RGBA*/</span>, 8<span style="color: rgb(139, 139, 139);">/*pitch??*/</span>);</span></span></div><div style="font-size: 16px; font-family: times new roman,new york,times,serif; font-style: normal;"><span style="background-color: rgb(64, 160, 255);"><span style="background-color: rgb(255, 255, 255);"><span><span><span> XPutImage(display,XP,gc,ximage,0,0,0,0,8<span style="color: rgb(139, 139, 139);"><span><span><span>/*rows*/</span></span></span></span>,16<span style="color: rgb(139, 139, 139);"><span>/*width*/</span></span>); </span></span>
</span></span><br></span></div><div style="color: rgb(139, 139, 139); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;"><span style="color: rgb(0, 0, 0);"><span><span>unfornatly I got a segmentation fault at XPutImage, </span></span><span id="result_box" class="short_text" lang="en"><span class="hps">I'm stuck</span> <span class="hps alt-edited">with this</span> <span class="hps">for two days now... I join the full code, to compile :</span></span></span></span></div><div style="font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;">g++ testFT.cpp -lX11 -I/usr/include/freetype2 -lfreetype<br></div><div style="font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="font-size: 16px; font-family: times new
roman,new york,times,serif; background-color: transparent; font-style: normal; color: rgb(0, 0, 0);">-Nicoo</div></div></body></html>