4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 static void copy_int(int &a, int &b);
34 static void copy_double(double *a, double b);
35 static double divide_double(double a, double b);
36 static void clamp(int32_t &x, int32_t y, int32_t z);
37 static void clamp(int64_t &x, int64_t y, int64_t z);
38 static void clamp(float &x, float y, float z);
39 static void clamp(double &x, double y, double z);
40 static float pow(float x, float y);
46 #include <X11/Xft/Xft.h>
52 #include <fontconfig/fontconfig.h>
53 #include <fontconfig/fcfreetype.h>
55 Bool xftInit(const char *config);
56 FcBool xftInitFtLibrary(void);
57 Bool xftDefaultHasRender(Display *dpy);
58 Bool xftDefaultSet(Display *dpy, FcPattern *defaults);
59 FcBool xftCharExists(Display *dpy, XftFont *pub, FcChar32 ucs4);
60 void xftTextExtents8(Display *dpy, XftFont *pub,
61 _Xconst FcChar8 *string, int len, XGlyphInfo *extents);
62 void xftTextExtentsUtf8(Display *dpy, XftFont *pub,
63 _Xconst FcChar8 *string, int len, XGlyphInfo *extents);
64 void xftTextExtents32(Display *dpy, XftFont *pub,
65 _Xconst FcChar32 *string, int len, XGlyphInfo *extents);
66 XftDraw *xftDrawCreate(Display *dpy, Drawable drawable, Visual *visual,
68 XftDraw *xftDrawCreateBitmap(Display *dpy, Pixmap bitmap);
69 void xftDrawDestroy(XftDraw *draw);
70 void xftDrawString32(XftDraw *draw, _Xconst XftColor *color, XftFont *pub,
71 int x, int y, _Xconst FcChar32 *string, int len);
72 Bool xftColorAllocValue(Display *dpy, Visual *visual,
73 Colormap cmap, _Xconst XRenderColor *color, XftColor *result);
74 void xftColorFree(Display *dpy, Visual *visual, Colormap cmap, XftColor *color);
75 XftFont *xftFontOpenName(Display *dpy, int screen, _Xconst char *name);
76 XftFont *xftFontOpenXlfd(Display *dpy, int screen, _Xconst char *xlfd);
77 XftFont *xftFontOpenPattern(Display *dpy, FcPattern *pattern);
78 void xftFontClose(Display *dpy, XftFont *pub);
80 FT_Error ft_Done_Face(FT_Face face);
81 FT_Error ft_Done_FreeType(FT_Library library);
82 void ft_Done_Glyph(FT_Glyph glyph);
83 FT_UInt ft_Get_Char_Index(FT_Face face, FT_ULong charcode);
84 FT_Error ft_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph);
85 FT_Error ft_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph,
86 FT_UInt kern_mode, FT_Vector *akerning);
87 FT_Error ft_Init_FreeType(FT_Library *alibrary);
88 FT_Error ft_Load_Char(FT_Face face, FT_ULong char_code, FT_Int32 load_flags);
89 FT_Error ft_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags);
90 FT_Error ft_New_Face(FT_Library library, const char *filepathname, FT_Long face_index,
92 FT_Error ft_Outline_Done(FT_Library library, FT_Outline *outline);
93 FT_Error ft_Outline_Get_BBox(FT_Outline *outline, FT_BBox *abbox);
94 FT_Error ft_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline,
95 const FT_Bitmap *abitmap);
96 FT_Error ft_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours,
97 FT_Outline *anoutline);
98 void ft_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset);
99 FT_Error ft_Select_Charmap(FT_Face face, FT_Encoding encoding);
100 FT_Error ft_Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width, FT_UInt pixel_height);
101 void ft_Stroker_Done(FT_Stroker stroker);
102 void ft_Stroker_Export(FT_Stroker stroker, FT_Outline *outline);
103 FT_Error ft_Stroker_GetCounts(FT_Stroker stroker, FT_UInt *anum_points,
104 FT_UInt *anum_contours);
105 FT_Error ft_Stroker_New(FT_Library library, FT_Stroker *astroker);
106 FT_Error ft_Stroker_ParseOutline(FT_Stroker stroker, FT_Outline *outline,
108 void ft_Stroker_Set(FT_Stroker stroker, FT_Fixed radius, FT_Stroker_LineCap line_cap,
109 FT_Stroker_LineJoin line_join, FT_Fixed miter_limit);
111 FcBool fcCharSetAddChar(FcCharSet *fcs, FcChar32 ucs4);
112 FcCharSet *fcCharSetCreate(void);
113 void fcCharSetDestroy(FcCharSet *fcs);
114 FcBool fcCharSetHasChar(const FcCharSet *fcs, FcChar32 ucs4);
115 FcBool fcConfigAppFontAddDir(FcConfig *config, const FcChar8 *dir);
116 FcConfig *fcConfigGetCurrent();
117 FcBool fcConfigSetRescanInterval(FcConfig *config, int rescanInterval);
118 FcFontSet *fcFontList(FcConfig *config, FcPattern *p, FcObjectSet *os);
119 void fcFontSetDestroy(FcFontSet *s);
120 FcPattern *fcFreeTypeQueryFace(const FT_Face face, const FcChar8 *file, unsigned int id,
123 FcBool fcLangSetAdd(FcLangSet *ls, const FcChar8 *lang);
124 FcLangSet *fcLangSetCreate(void);
125 void fcLangSetDestroy(FcLangSet *ls);
126 FcObjectSet *fcObjectSetBuild(const char *first, ...);
127 void fcObjectSetDestroy(FcObjectSet *os);
128 FcBool fcPatternAddBool(FcPattern *p, const char *object, FcBool b);
129 FcBool fcPatternAddCharSet(FcPattern *p, const char *object, const FcCharSet *c);
130 FcBool fcPatternAddDouble(FcPattern *p, const char *object, double d);
131 FcBool fcPatternAddInteger(FcPattern *p, const char *object, int i);
132 FcBool fcPatternAddLangSet(FcPattern *p, const char *object, const FcLangSet *ls);
133 FcResult fcPatternGetInteger(const FcPattern *p, const char *object, int n, int *i);
134 FcResult fcPatternGetDouble(const FcPattern *p, const char *object, int n, double *d);
135 FcResult fcPatternGetString(const FcPattern *p, const char *object, int n, FcChar8 **s);
136 FcPattern *fcPatternCreate(void);
137 FcBool fcPatternDel(FcPattern *p, const char *object);
138 void fcPatternDestroy(FcPattern *p);
139 FcPattern *fcPatternDuplicate(const FcPattern *p);
140 FcResult fcPatternGetCharSet(const FcPattern *p, const char *object, int n,