Fatal IO Error: 11 (resource temporarily unavailable)

2013-05-19 Thread First Last
Hi,


I got this error when I try to run all example I have of xlib :

Fatal IO Error: 11 (resource temporarily unavailable)

I tried some examples form the book "X WINDOW APPLICATION PROGRAMMING" from 
"ERIC F. JOHNSON & KEVIN REICHARD" some from the web, like these one 
:http://www.everything2.com/index.pl?node_id=39055

I guess in all these examples I should see the mouse pointer, particulary in 
the last example of the link I pasted before, I don't see my mouse, clicking 
doesn't works etc. I guess it's linked with my IO error.

I have to kill X from another console, I search how to fix for days now but I 
didn't found it

Don't know if it can help, (it doesn't help me), I add the Xorg.1.logas 
attachment file.


I know, I don't give many informations, simply because I don't know right now 
how to get more interesting informations.

nicoo[  5418.123] 
X.Org X Server 1.14.1
Release Date: 2013-04-17
[  5418.134] X Protocol Version 11, Revision 0
[  5418.137] Build Operating System: Linux 3.8.7-1-ARCH x86_64 
[  5418.141] Current Operating System: Linux band 3.8.11-1-ARCH #1 SMP PREEMPT Wed May 1 20:18:57 CEST 2013 x86_64
[  5418.141] Kernel command line: root=/dev/sda3 ro initrd=../initramfs-linux.img BOOT_IMAGE=../vmlinuz-linux 
[  5418.148] Build Date: 17 April 2013  02:37:06PM
[  5418.151]  
[  5418.155] Current version of pixman: 0.30.0
[  5418.162] 	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
[  5418.162] Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[  5418.177] (==) Log file: "/var/log/Xorg.1.log", Time: Sun May 19 11:14:58 2013
[  5418.181] (==) Using config directory: "/etc/X11/xorg.conf.d"
[  5418.185] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[  5418.185] (==) No Layout section.  Using the first Screen section.
[  5418.185] (==) No screen section available. Using defaults.
[  5418.185] (**) |-->Screen "Default Screen Section" (0)
[  5418.185] (**) |   |-->Monitor ""
[  5418.186] (==) No monitor specified for screen "Default Screen Section".
	Using a default monitor configuration.
[  5418.186] (==) Automatically adding devices
[  5418.186] (==) Automatically enabling devices
[  5418.186] (==) Automatically adding GPU devices
[  5418.186] (WW) `fonts.dir' not found (or not valid) in "/usr/share/fonts/100dpi/".
[  5418.186] 	Entry deleted from font path.
[  5418.186] 	(Run 'mkfontdir' on "/usr/share/fonts/100dpi/").
[  5418.186] (WW) `fonts.dir' not found (or not valid) in "/usr/share/fonts/75dpi/".
[  5418.186] 	Entry deleted from font path.
[  5418.186] 	(Run 'mkfontdir' on "/usr/share/fonts/75dpi/").
[  5418.186] (==) FontPath set to:
	/usr/share/fonts/misc/,
	/usr/share/fonts/TTF/,
	/usr/share/fonts/OTF/,
	/usr/share/fonts/Type1/
[  5418.186] (==) ModulePath set to "/usr/lib/xorg/modules"
[  5418.186] (II) The server relies on udev to provide the list of input devices.
	If no devices become available, reconfigure udev or disable AutoAddDevices.
[  5418.186] (II) Loader magic: 0x7fcc20
[  5418.186] (II) Module ABI versions:
[  5418.186] 	X.Org ANSI C Emulation: 0.4
[  5418.186] 	X.Org Video Driver: 14.1
[  5418.186] 	X.Org XInput driver : 19.1
[  5418.186] 	X.Org Server Extension : 7.0
[  5418.187] (II) config/udev: Adding drm device (/dev/dri/card0)
[  5418.190] (--) PCI:*(0:1:5:0) 1002:5955:1631:c00e rev 0, Mem @ 0x9000/268435456, 0xc000/65536, I/O @ 0xc000/256, BIOS @ 0x/131072
[  5418.194] Initializing built-in extension Generic Event Extension
[  5418.198] Initializing built-in extension SHAPE
[  5418.203] Initializing built-in extension MIT-SHM
[  5418.207] Initializing built-in extension XInputExtension
[  5418.211] Initializing built-in extension XTEST
[  5418.215] Initializing built-in extension BIG-REQUESTS
[  5418.219] Initializing built-in extension SYNC
[  5418.231] Initializing built-in extension XKEYBOARD
[  5418.233] Initializing built-in extension XC-MISC
[  5418.236] Initializing built-in extension SECURITY
[  5418.239] Initializing built-in extension XINERAMA
[  5418.242] Initializing built-in extension XFIXES
[  5418.244] Initializing built-in extension RENDER
[  5418.247] Initializing built-in extension RANDR
[  5418.250] Initializing built-in extension COMPOSITE
[  5418.253] Initializing built-in extension DAMAGE
[  5418.255] Initializing built-in extension MIT-SCREEN-SAVER
[  5418.258] Initializing built-in extension DOUBLE-BUFFER
[  5418.261] Initializing built-in extension RECORD
[  5418.264] Initializing built-in extension DPMS
[  5418.266] Initializing built-in extension X-Resource
[  5418.269] Initializing built-in extension XVideo
[  5418.272] Initializing built-in extension XVideo-MotionCompensation
[  5418.274] Initializing built-in extension XFree86-VidModeExtension
[  5418.276] Initializing built-in extension XFree86-DGA
[  54

Re: Fatal IO Error: 11 (resource temporarily unavailable)

2013-05-20 Thread First Last
I still don't know why the "hello world" code does not working as I expect. But 
I write a piece of code who works as expected. I'm not sure that's well 
written, (if someone want to take a look). Mouse pointer is rendered, when a 
button is pressed or when a key is release the while loop is stoped.


#include
#include
#include
#include
#include

#define DPYW DisplayWidth(dpy,scr)
#define DPYH DisplayHeight(dpy,scr)


int main(int argc, char *argv[]){
    Display *dpy;
    int scr, stop=0;
   
 Window rootwin;
    Window wbg;
    XEvent e;
    Cursor theCursor;

    dpy = XOpenDisplay(NULL);

    scr=DefaultScreen(dpy);
    rootwin=RootWindow(dpy, scr);
    wbg=XCreateSimpleWindow(dpy,rootwin,0,0,
    DPYW,DPYH,0,
    BlackPixel(dpy,
 scr),
    BlackPixel(dpy, scr) );


    XStoreName(dpy, wbg, "background");
    XSelectInput(dpy, wbg, 
ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask);
    XMapWindow(dpy, wbg);


    theCursor = XCreateFontCursor(dpy, XC_left_ptr);

    XDefineCursor(dpy,wbg,theCursor);

    while(stop==0) {
    XNextEvent(dpy, &e);
    if(e.type==Expose
 && e.xexpose.count<1) {
        XFlush(dpy);
    }

        switch(e.type){
            case KeyRelease     : stop=1;break;
            case ButtonPress     : stop=1;break;
        }        

    }

    XFreeCursor(dpy,theCursor);
    XCloseDisplay(dpy);

    return 0;
}___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

how to send data to Xorg.log and XQueryPointer crash

2013-05-21 Thread First Last
Hi,
I try to get the position of my pointer, I tried whit this code :
#include
#include
#include
#include
#include

#define DPYW DisplayWidth(dpy,scr)
#define DPYH DisplayHeight(dpy,scr)


int main(int argc, char *argv[]){
    Display *dpy;
    int scr, stop=0;
    Window rootwin;
    Window wbg;
    XEvent e;
    Cursor theCursor;

    dpy = XOpenDisplay(NULL);

    scr=DefaultScreen(dpy);
    rootwin=RootWindow(dpy, scr);
    wbg=XCreateSimpleWindow(dpy,rootwin,0,0,
    DPYW,DPYH,0,
    BlackPixel(dpy, scr),
    BlackPixel(dpy, scr) );


    XStoreName(dpy, wbg, "background");
    XSelectInput(dpy, wbg, 
ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask);
    XMapWindow(dpy, wbg);


    theCursor = XCreateFontCursor(dpy, XC_left_ptr);

    XDefineCursor(dpy,wbg,theCursor);


    // where is my mouse ?
    int mousex, mousey;
    XQueryPointer(dpy,rootwin,None,None,&mousex,&mousey,None,None,None); // 
problem...

    while(stop==0) {
    XNextEvent(dpy, &e);
    if(e.type==Expose && e.xexpose.count<1) {
    XFlush(dpy);
    }

    switch(e.type){
    case KeyRelease : stop=1;break;
    }

    }
    XFreeCursor(dpy,theCursor);
    XCloseDisplay(dpy);

    return 0;
}



but, when I'm running it, X exits without complains.

also, there is a function like fprintf to write directly to xorg.log through 
xlib ?

-Nicoo
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: how to send data to Xorg.log and XQueryPointer crash

2013-05-22 Thread First Last


Hi Peter,
>>     XQueryPointer(dpy,rootwin,None,None,&mousex,&mousey,None,None,None); 
>> // problem...
>
>none of these may be NULL (or None, which is just 0 anyway). you do need to
>provide some valid pointers here.

well, yesterday I tried with all pointers settled, X crashed. Today I try 
again, 
    // where is my mouse ?
    int wx, wy;
    int rootx, rooty;
    Window  theRoot, theChild;
    unsigned int    status;

    
XQueryPointer(dpy,rootwin,&theRoot,&theChild,&rootx,&rooty,&wx,&wy,&status);

and now it works. I didn't try (yet) to read datasfrom pointers but 
XQueryPointerreturn true. I guess I did some bullshit yesterday...


>> 
>>     while(stop==0) {
>>     XNextEvent(dpy, &e);
>>     if(e.type==Expose && e.xexpose.count<1) {
>>     XFlush(dpy);
>>     }
>> 
>>     switch(e.type){
>>     case KeyRelease : stop=1;break;
>>     }
>> 
>>     }
>>     XFreeCursor(dpy,theCursor);
>>     XCloseDisplay(dpy);
>> 
>>     return 0;
>> }
>> 
>> 
>> 
>> but, when I'm running it, X exits without complains.
>are you saying your X server crashes when you run this? that shouldn't
>happen and would certainly be a bug.

no this part is fine, I'm using it on some others tests I running, the crash 
occured at this line :

XQueryPointer(dpy,rootwin,None,None,&mousex,&mousey,None,None,None); 


for me setting a pointer to None, NULL, it's like sending data to the biggest 
trashcan of the universe, I guess I'm wrong...

>The Xorg.log is only for the X server, you're writing a client application
>and can't access it.

ok.



Thanks for all Peter.

-Nicoo
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

redraw, who (xlib/cairo), when...

2013-05-25 Thread First Last
Hi guys from xorgand cairomailling list, 

I sent this mail to both of you because I don't know who can explains to me 
something. I wrote a small code, it's just a window where you should see the 
date and the time.

If you hit "space" the window moves, if you hit "q" the wm will exit(ok ok it's 
a bit fulsome to call that shit a wm..).

So now my problem, I need to redraw the clock, that actualy doesn't working 
yet, since I 'm bit lost with "when" and "how" to redraw, if it's cairoor 
xlibwho has (or both) to redraw etc.

Moreover, there is something I don't understand more, when I hit "space", then 
the window moves and there is a redraw (you can see it when the minutes change).

I added as attachments, main.cand Makefileso you just have to type "make" 
(using pkg-configfor cairo).


I want to notice, I just see if I go to another console or X running and then I 
back, I see a visual glitch at the background of the window.

-Nicoo#include
#include
#include
#include
#include
#include
#include
#include
#include

#define DPYW DisplayWidth(dpy,scr)
#define DPYH DisplayHeight(dpy,scr)

// hit "space" -> move the clock
// hit "q" -> exit the wm

typedef struct clockStruc{
cairo_t *c;
cairo_surface_t *s;
Window  w;

}CLOCKSTRUC;

int keyRelease(XEvent *_e, Display *_dpy, Window *_w){
	XWindowAttributes wa;

	XGetWindowAttributes(_dpy,*_w,&wa);
	if(XLookupKeysym(&_e->xkey,0) == XK_q) return 1;
	if(XLookupKeysym(&_e->xkey,0) == XK_space) XMoveWindow(_dpy, *_w, wa.x+3,wa.y+1);

	return 0;
}

void updateClock(CLOCKSTRUC *_mc ){
time_t  curtime;
charbuffer[16];
struct tm *loctime;
time(&curtime);
loctime = localtime(&curtime);

cairo_set_source_rgba(_mc->c,1,1,1,1);
cairo_select_font_face(_mc->c,"Sans",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(_mc->c,10);
cairo_move_to(_mc->c, 0, 10);
strftime(buffer, 16, "%a, %d %b", loctime);
cairo_show_text(_mc->c, buffer);
cairo_set_font_size(_mc->c,24);
cairo_move_to(_mc->c, 0, 34);
strftime(buffer, 16, "%H:%M", loctime);
cairo_show_text(_mc->c, buffer);
}

void cairoClock(CLOCKSTRUC *_mc, Display *_dpy, int _scr, Window _prnt, int _x, int _y, int _sizex, int _sizey){ // attention ne detruit pas la surface à la fermeture 
XSetWindowAttributessetwbtnattr;
unsigned long   valuemask;

_mc->w=XCreateSimpleWindow(_dpy,_prnt,_x,_y,_sizex,_sizey,0,0,0);
valuemask = CWBackPixmap; //p94 vol. one
setwbtnattr.background_pixmap = None;
XChangeWindowAttributes(_dpy,_mc->w,valuemask, &setwbtnattr);
XStoreName(_dpy, _mc->w, "clock");
XSelectInput(_dpy, _mc->w, ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask);
XMapWindow(_dpy, _mc->w);


_mc->s=cairo_xlib_surface_create(_dpy, _mc->w, DefaultVisual(_dpy, 0), _sizex, _sizey); // nicoo : demander avis
_mc->c=cairo_create(_mc->s);
cairo_rectangle(_mc->c,0,0,_sizex,_sizey);
cairo_set_source_rgba(_mc->c, 0.5, 0., 0., 1.); // nicoo : rouge, temporaire
cairo_fill(_mc->c);
}

int main(int argc, char *argv[]){
Display *dpy;
	int x=100, y=200;
	Window rootwin, wbg, testwin;
int scr, stop=0;
XEvent e;
	Cursor theCursor;
	CLOCKSTRUC myClock;

	dpy = XOpenDisplay(NULL);
scr=DefaultScreen(dpy);
	theCursor = XCreateFontCursor(dpy, XC_left_ptr);
	rootwin=RootWindow(dpy, scr);
XSelectInput(dpy, rootwin, ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|PointerMotionHintMask);
	XDefineCursor(dpy,rootwin,theCursor);

// creation of the background
wbg=XCreateSimpleWindow(dpy,rootwin,0,0,DPYW,DPYH,0,BlackPixel(dpy, scr), BlackPixel(dpy, scr));
XSelectInput(dpy, wbg, ExposureMask);
	XSetWindowBackground(dpy,wbg,128);
XMapWindow(dpy, wbg);


// creation of the clock
	cairoClock(&myClock, dpy, scr, wbg,x,y,200,200);


while(stop==0) {
	updateClock(&myClock);

XNextEvent(dpy, &e);
		switch(e.type){
			case Expose		: XFlush(dpy); break;
			case KeyRelease 	: stop = keyRelease(&e,dpy,&(myClock.w)); break;
			default			: break;
		}		

}

// DEATHSTRUCTION
	cairo_surface_destroy(myClock.s);
	cairo_destroy(myClock.c);
	XFreeCursor(dpy,theCursor);
XCloseDisplay(dpy);
return 0;
}


Makefile
Description: Binary data
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

problem with my uses of the gradient.

2013-05-26 Thread First Last
Hi cairomailing list,
I got a problem, when I use this code :
    s=cairo_xlib_surface_create(dpy, wndw.frame, DefaultVisual(dpy, 0), 
640, 480);
    c=cairo_create(s);
    p=cairo_pattern_create_linear(10.10,0.10,0.0,450.0);
    cairo_pattern_add_color_stop_rgba(p,0,1,0,0,1);
    cairo_pattern_add_color_stop_rgba(p,1,0,1,0,1);
    cairo_rectangle(c,0,0,640,480);
    cairo_set_source(c,p);
    cairo_fill(c);
no rectangle is drawn. If I use this one :
    s=cairo_xlib_surface_create(dpy, wndw.frame, DefaultVisual(dpy, 0), 
640, 480);
    c=cairo_create(s);
    p=cairo_pattern_create_linear(10.10,0.10,0.0,450.0);
    cairo_pattern_add_color_stop_rgba(p,0,1,0,0,1);
    cairo_pattern_add_color_stop_rgba(p,1,1,0,0,1);
    cairo_rectangle(c,0,0,640,480);
    cairo_set_source(c,p);
    cairo_fill(c);I got a red rectangle.My code is almost the same that one 
here : http://cairographics.org/samples/gradient/ , I tried this :
    // added by me
     s=cairo_xlib_surface_create(dpy, wndw.frame, DefaultVisual(dpy, 0), 
640, 480);
    c=cairo_create(s);
    // from the link
    pat = cairo_pattern_create_linear (0.0, 0.0,  0.0, 256.0);
    cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
    cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
    cairo_rectangle (c, 0, 0, 256, 256);
    cairo_set_source (c, pat);
    cairo_fill (c);
    cairo_pattern_destroy (pat);
no rectangle is drawn. And like before, if I use the code just above with two 
times the same RGBA as patern ,I got a rectangle.
So can somebody explains to me what's going on ?

-Nicoo___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: redraw, who (xlib/cairo), when...

2013-05-26 Thread First Last
Hi Glynn,
first thanks. 

>You should redraw the window (or at least the rectangle specified in
>the XExposeEvent structure) in response to an Expose event. Ideally,
>you should collect any pending Expose events and perform the minimum
>amount of work necessary to redraw the specified rectangles (i.e. if
>there are multiple pending Expose events covering the entire window,
>you should only redraw it once, not once per event).
ok I'll take care of that, for now I flush the display because it's fast to 
code.

>Your main loop calls XNextEvent(), which will block until an event is
>available. If there are no events to report, it will block
>indefinitely.
I suspected that, but when I did a test (writting a char in a file every time 
the main loop started a new loop) I detected some loops completed, without 
interacting by myself. Now I think I will first write a loop which will be more 
chatty...>Beyond that, I suggest looking at the source code for the main loop of
>an existing GUI toolkit for clues as to how to implement input, timer
>and/or idle
 events.
I already do this, I'm looking in twm and jwm, I use two books also and I 
bother people like you, I need to have different sources in the aim to 
understand, since almost everything isn't in my mothertongue.

so now, about the rest of your email, I won't say everything is clear and 
obvious just by reading it, but you gave me enough information to lead my 
searches.

-Nicoo___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: redraw, who (xlib/cairo), when...

2013-05-27 Thread First Last
Hi Glynn and other guys,
after some reads and looking at the event.c from jwm, my clock works!
I'm using a structure like this :
    while(stop==0) {

    while(XPending(dpy)==0){
    usleep(100);
    updateClock(&myClock);

    }

    XNextEvent(dpy, &e);
    switch(e.type){
    case Expose   : XFlush(dpy); break;
    case KeyRelease : stop = 
keyRelease(&e,dpy,&(myClock.w)); break;
    default             : break;
    }
    }

notes : 

XPending() == XEventsQueued() with mode Queued-AfterFlush.

I did some change in updateClock() too, but is not the most important.

thx again for your help.

-Nicoo
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: redraw, who (xlib/cairo), when...

2013-05-28 Thread First Last
Hi Glynn and other guys,
>>     while(XPending(dpy)==0){
>>     usleep(100);
>>     updateClock(&myClock);
>> 
>
>Ugh. This causes the process to be scheduled up to 10,000 times per
>second, which is almost a busy wait. I would expect this process to
>consume far more CPU than is necessary.
do you mix up with nanosleep()(http://linux.die.net/man/3/usleep)? so, if I 
right, I have settled the sleep time at 0.1s (jwm uses the frequency of the 
microprocessor to set the sleep time). When I wrote this I expected to get 
something who works.I will try with select()or poll()as you suggested, it sound 
better.

thx,
-Nicoo___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: redraw, who (xlib/cairo), when...

2013-05-29 Thread First Last
Hi Glynn,
Oh god... you right... I really need to take a brake...

thx Glynn!

-Nicoo___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

need help with freetype + xlib.

2013-06-17 Thread First Last
Hi, I try to use freetype with xlib, I , I need to pass a char type array 
(RGBA/pixel) to a xlib function.

from freetype I got :

  face->glyph->bitmap.pixel_mode = 2
so if I understood corectly in face->glyph->bitmap.buffer datas are stored in 
gray level.
  face->glyph->bitmap.rows=16
  face->glyph->bitmap.width=8
  face->glyph->bitmap.pitch=8

so I guess,  length of face->glyph->bitmap.buffer = 1(gray 
lvl)*16(width)*8(rows)=128 unsigned chars, right ?

then I create an array of char for xlib from face->glyph->bitmap.buffer

  for(i=0;i<128;i++){    
    Xdata[4*i] = face->glyph->bitmap.buffer[i];
    Xdata[4*i+1] = face->glyph->bitmap.buffer[i];
    Xdata[4*i+2] = face->glyph->bitmap.buffer[i];
    Xdata[4*i+3] = 255;    
   }   
and I try to create a XImage :
  ximage = XCreateImage(display, DefaultVisual(display,0), 24, ZPixmap, 0,      
                     

    &Xdata[0], 8/*rows*/, 16/*width*/, 
32/*RGBA*/, 8/*pitch??*/);
  XPutImage(display,XP,gc,ximage,0,0,0,0,8/*rows*/,16/*width*/);
   

unfornatly I got a segmentation fault at XPutImage, I'm stuck with this for two 
days now... I join the full code, to compile :
g++ testFT.cpp -lX11 -I/usr/include/freetype2 -lfreetype


-Nicoo#include
#include
#include
#include
#include
#include FT_FREETYPE_H

using namespace std;

int main()
{
  FT_Library library;
  FT_Faceface;
  Display *display;
  int error;
  int glyph_index;
  GC gc;
  XImage *ximage;

  error = FT_Init_FreeType(&library);
  if(error){
cout << "error 1\n";
exit(1);
  }

  error = FT_New_Face(library, "/usr/share/fonts/TTF/comic.ttf",0,&face);

  if(error==FT_Err_Unknown_File_Format){
cout << "error 2\n";
exit(1);
  }else if (error){
cout << "error 3\n";
exit(1);
  }

  error = FT_Set_Pixel_Sizes(face,0,16);
  if(error){
cout << "error 4\n";
exit(1);
  }

  glyph_index = FT_Get_Char_Index(face,0x00028);
  if(glyph_index==0){
cout << "error 5\n";
exit(1);
  }

  error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
  if(error){
cout << "error 6\n";
exit(1);
  }

  error= FT_Render_Glyph(face->glyph,FT_RENDER_MODE_NORMAL);
  if(error){
cout << "error 7\n";
exit(1);
  }

  cout << "rows=" << face->glyph->bitmap.rows << endl;
  cout << "width=" << face->glyph->bitmap.width << endl;
  cout << "pitch=" << face->glyph->bitmap.pitch << endl;
  cout << "pixel_mode=" << size_t(face->glyph->bitmap.pixel_mode) << endl;

  char Xdata[4*128];
  int i;
  for(i=0;i<128;i++){
Xdata[4*i]   = face->glyph->bitmap.buffer[i];
Xdata[4*i+1] = face->glyph->bitmap.buffer[i];
Xdata[4*i+2] = face->glyph->bitmap.buffer[i];
Xdata[4*i+3] = 0;
  }



  display = XOpenDisplay(0);
  Window XP = XCreateSimpleWindow(display,DefaultRootWindow(display),0,0,360,90,0,0,0);
  gc = XCreateGC(display,XP,0,0);
  ximage = XCreateImage(display,DefaultVisual(display,0),24,ZPixmap,0,&Xdata[0],8,16,32,8);
  XPutImage(display,XP,gc,ximage,0,0,0,0,8,16);


  XMapWindow(display,XP);

  XFlush(display);
  XFreeGC(display,gc);

  sleep(2);

  return 0;
}
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: need help with freetype + xlib.

2013-06-17 Thread First Last


Hi Alan,
yes I know, I opened a question on stackoverflow about xft.

- Nicoo___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: [ft] need help with freetype + xlib.

2013-06-18 Thread First Last
thank you Werner, it's working fine now. So this issue was (again) from my 
english skill, I wasn't sure of scanline and pitch means...

-Nicoo
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com

Re: need help with freetype + xlib.

2013-06-18 Thread First Last
Hi Glynn,
 

>> so I guess,  length of face->glyph->bitmap.buffer = 
>> 1(gray lvl)*16(width)*8(rows)=128 unsigned chars, right ?
>
>Right answer, wrong reasoning; width should be replaced by pitch. The
>two values may differ if there is padding between lines.

thx for this.

-Nicoo
___
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: arch...@mail-archive.com