[ZT] XFT programming document

zhaozj2021-02-16  100

Http://www.linuxfans.org/nuke/modules.php?name=news&file=article&op=view&file=Article&op=View&file=1981

CJACKER Write 'XFT Programming Technology 1. First, there are a few points to explain: 1, the font technology has become transparent. The two major UIs and their derivatives have been completely completely packaged. For example, GTK2 uses the PANGO font engine. QT is also very good to encapsulate XFT and X core font implementations. Therefore, the user performs GTK2 or QT or higher level There is no need to consider any font implementation when developing. That is, if you want to use XFT to develop application, you must ensure that the UI suite you use supports XFT unless you use XLIB programming, complete your font. 2, XFT is responsible for user interface, shoulders the interface task of Freetype and X rendering, not responsible for any font rendering, we can understand XFT is a new font management tool and program interface, Fontconfig is responsible for the XFT configuration, you can understand It is a XFT configuration tool, and the font rendering and font implementation are Freetype and X; general applications, including the development of XLIB programs, do not need to consider any font rendering issues. The XFT will be liberated from XFontSet, -Misc-Song ------------------------------------ 技 is concentrated. Second, data types and functions: Before starting, complete a few assumptions: Display * DIS and complete the initialization of DIS. INT iscreen = defaultscreen (dish); Window Win = .... Defines a window. Define style Xftpattern: As the name, XFT style, he is a set of key value pairs, each key defines a property of a font, XFTPattern is used to define a font. The more commonly used is the Family String model, which is the Helvetiva, Dongwen-Song, which is often said, such as bold, italic, bold italicpixelsize double font size Antialias bool type AA, that is Whether it is smooth. Constructing an empty Xftpattern method: xftpattern * pattern; pattern = xftpatterncreate (); setting the properties for the pattern: Because the attribute of Xftpattern is a variety of key value pairs, there is a different attribute add function: handling the String type, using XftpatternAddstring Pattern, "Family", "Dongwen-Song"); define Family as dongwen-song processing int / double, using XftpatternAddinteger (Pattern, "Pixelsize", 48); define size 48, or use xftpatternaddouble (); process Bool type, use XftpatternAddBool (Pattern, "Antialias", 1); use AA smooth. This will basically complete the definition of the font.

Match fonts XftfontMatch: XftResult Result; Xftpattern * XftfontMatch (Display * DIS, ISCREEN, XFTPATTERN * PATTERN, XFTRESULT * Result); Returns the style of the closest user-defined style, the user may be willing to define the font style definition, for example, clearly Some fonts do not have a bold, but the user uses xftpatteraddstring (Pattern, "Style", "Bold") defines a bold, and the font styles can be tested and filtered through XftFontMatch, and the closest user-defined legitimate style is obtained. Generating Font XftFont: the above example is directed font pointer XftFont * XftFontOpenPattern (Display * dis, XftPattern * pattern), we can use XftResult result; XftFont * xftFont; xftFont = XftFontOpenPattern (dis, XftFontMatch (dis, iscreen, pattern, & result ); Where is it? XFTDRAW: XFT needs to know what you should use as an output, XFTDRAW is packaged for X-related features, XFTDRAW * XFTDRAWCREATE (Display * DIS, Drawable Drawable, Visual * Visual, ColorMap ColorMap; This example, our XFTDRAW can create .xftdraw * xftdraw; xftdraw = Xftddrawcreate ((Dislocene, Defaultvisual (DIS, Defaultscreen (DIS)), DefaultColormap (DIS, Defaultscreen (DIS)); very clear, we have to draw On the window created above. Change the target Void XFTDrawChange (XFTDRAW * DRAW, DRAWABLE DRAWABLE); if there is still a Win2, we can use XFTDRAWCHANGE (XFTDRAW, WIN2) to determine . win2 to configure what color output XftColor color is below a defined structure: typedef struct {unsigned short red; unsigned short green; unsigned short blue; unsigned short alpha;} XRenderColor; typedef struct _XftColor {unsigned long pixel; XrenderColor color XftColor; completes through the XFTCOLORALLOCVALUE function. For example: XRenderColor Rendercolor; Rendercolor.Red = 0xeeeeee; rendercolor.green = 0xAAAA; renderColor.blue = 0xDDDD; renderColor.alpha = 0xFFFF; XftColorAllocValue (dis, DefaultVisual (dis, DefaultScreen (dis)), DefaultColormap (dis, DefaultScreen (dis)), & renderColor, & xftColor); output XftDrawString ??? XftDrawRect : XFT has a total of four functions of 4 output text, which is different from the type of String.

转载请注明原文地址:https://www.9cbs.com/read-10494.html

New Post(0)