FreeBSD Bugzilla – Attachment 239150 Details for
Bug 268668
x11-themes/classiclooks unduly force fontconfig antialias settings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test program used to produce the two screenshots
xftest.c (text/plain), 3.87 KB, created by
Bertrand Petit
on 2022-12-31 11:28:43 UTC
(
hide
)
Description:
Test program used to produce the two screenshots
Filename:
MIME Type:
Creator:
Bertrand Petit
Created:
2022-12-31 11:28:43 UTC
Size:
3.87 KB
patch
obsolete
>/* Inspired by the following documents: > * https://keithp.com/~keithp/render/Xft.tutorial > * https://www.geeks3d.com/20120102/programming-tutorial-simple-x11-x-window-code-sample-for-linux-and-mac-os-x/ > * https://github.com/jsynacek/xft-example/blob/master/main.c > */ > >#include <stdbool.h> >#include <stdio.h> >#include <stdlib.h> >#include <string.h> > >#include <X11/Xlib.h> >#include <X11/Xos.h> >#include <X11/Xutil.h> >#include <X11/Xft/Xft.h> > >int main(int argc, char **argv) >{ > const char *TextSample="minimum"; > size_t TextSampleSize=strlen(TextSample); > const char *FontName=argc>1 ? argv[1] : "Sans Serif-48"; > > const int LineHeight=12; > const int LineSkip=4; > const int Ystart=LineHeight+5; > > char StrBuf[1024]; /* Unparsed font names can be quite large. */ > > Display *Dpy = XOpenDisplay(NULL); > if(Dpy==NULL) > { > perror("Cannot open display"); > exit(1); > } > if(!XftDefaultHasRender(Dpy)) > { > perror("Display does not support the X Render extension"); > exit(1); > } > > int Scr=DefaultScreen(Dpy); > Visual *Vis=DefaultVisual(Dpy, Scr); > Colormap Cmap=DefaultColormap(Dpy, Scr); > > Window Win=XCreateSimpleWindow(Dpy, RootWindow(Dpy, Scr), > 10, 10, 325, 148, > 1, > BlackPixel(Dpy, Scr), WhitePixel(Dpy, Scr)); > XSelectInput(Dpy, Win, ExposureMask | KeyPressMask); > XStoreName(Dpy, Win, "Xft test"); > > Atom WM_DELETE_WINDOW = XInternAtom(Dpy, "WM_DELETE_WINDOW", False); > XSetWMProtocols(Dpy, Win, &WM_DELETE_WINDOW, 1); > > XMapWindow(Dpy, Win); > > // Used to clear the window on expose events > GC PaperGC=XCreateGC(Dpy, Win, 0, NULL); > XSetForeground(Dpy, PaperGC, WhitePixel(Dpy, Scr)); > > // Used for ancillary text > GC InkGC=XCreateGC(Dpy, Win, 0, NULL); > XSetForeground(Dpy, InkGC, BlackPixel(Dpy, Scr)); > > // Used for Xft text sample > XftDraw *Draw=XftDrawCreate(Dpy, Win, Vis, Cmap); > XftColor DrawColor; > memset(&DrawColor, 0, sizeof(DrawColor)); > bool ColorAllocated=XftColorAllocName(Dpy, Vis, Cmap, "black", &DrawColor); > if(!ColorAllocated) > perror("can't allocate the black color for Xft drawing"); > > XftFont *Font=XftFontOpenName(Dpy, Scr, FontName); > XGlyphInfo Extents; > if(Font==NULL) > perror("can't load font"); > else > { > *StrBuf=0; > XftNameUnparse(Font->pattern, StrBuf, sizeof(StrBuf)-1); > printf("loaded font: \"%s\"\n", StrBuf); > > memset(&Extents, 0, sizeof(Extents)); > XftTextExtents8(Dpy, Font, (const FcChar8 *)TextSample, TextSampleSize, > &Extents); > } > > while(ColorAllocated && Font!=NULL) > { > XEvent Evt; > memset(&Evt, 0, sizeof(Evt)); > XNextEvent(Dpy, &Evt); > > if(Evt.type==Expose) > { > XWindowAttributes WinAttrs; > memset(&WinAttrs, 0, sizeof(WinAttrs)); > XGetWindowAttributes(Dpy, Win, &WinAttrs); > XFillRectangle(Dpy, Win, PaperGC, > 0, 0, WinAttrs.width, WinAttrs.height); > > int Ypos=Ystart; > snprintf(StrBuf, sizeof(StrBuf)-1, "Xft v%d.%d.%d", > XFT_MAJOR, XFT_MINOR, XFT_REVISION); > XDrawString(Dpy, Win, InkGC, > 10, Ypos, > StrBuf, strlen(StrBuf)); > > Ypos+=LineHeight+LineSkip; > snprintf(StrBuf, sizeof(StrBuf)-1, "fontconfig v%d.%d.%d", > FC_MAJOR, FC_MINOR, FC_REVISION); > XDrawString(Dpy, Win, InkGC, > 10, Ypos, > StrBuf, strlen(StrBuf)); > > Ypos+=Extents.height+LineSkip*3; > XftDrawString8(Draw, &DrawColor, Font, 10, Ypos, > (const FcChar8 *)TextSample, TextSampleSize); > } > else if(Evt.type==KeyPress) > { > *StrBuf=0; > KeySym Keysym; > int len=XLookupString(&Evt.xkey, StrBuf, sizeof(StrBuf), > &Keysym, NULL); > if (Keysym==XK_Escape) > break; > } > else if(Evt.type==ClientMessage && > Evt.xclient.data.l[0]==WM_DELETE_WINDOW) > break; > } > > if(Font!=NULL) > XftFontClose(Dpy, Font); > if(ColorAllocated) > XftColorFree(Dpy, Vis, Cmap, &DrawColor); > XftDrawDestroy(Draw); > XFreeGC(Dpy, InkGC); > XFreeGC(Dpy, PaperGC); > XDestroyWindow(Dpy, Win); > XCloseDisplay(Dpy); > return 0; >} > >/* > * Local Variables: > * mode: c > * c-basic-offset: 4 > * tab-width: 4 > * End: > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 268668
:
239148
|
239149
| 239150 |
239151
|
239265
|
239266