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
25 #include "workarounds.h"
27 void Workarounds::copy_int(int &a, int &b)
32 double Workarounds::divide_double(double a, double b)
37 void Workarounds::copy_double(double *a, double b)
43 void Workarounds::clamp(int32_t &x, int32_t y, int32_t z)
50 void Workarounds::clamp(int64_t &x, int64_t y, int64_t z)
57 void Workarounds::clamp(float &x, float y, float z)
64 void Workarounds::clamp(double &x, double y, double z)
71 float Workarounds::pow(float x, float y)
78 static Mutex xft_lock("xft_lock");
80 Bool xftInit(const char *config)
82 xft_lock.lock("XftInit");
83 Bool ret = XftInit(config);
88 FcBool xftInitFtLibrary(void)
90 xft_lock.lock("xftInitFtLibrary");
91 FcBool ret = XftInitFtLibrary();
96 Bool xftDefaultHasRender(Display *dpy)
98 xft_lock.lock("xftDefaultHasRender");
99 Bool ret = XftDefaultHasRender(dpy);
104 Bool xftDefaultSet(Display *dpy, FcPattern *defaults)
106 xft_lock.lock("xftDefaultHasRender");
107 Bool ret = XftDefaultSet(dpy, defaults);
112 FcBool xftCharExists(Display *dpy, XftFont *pub, FcChar32 ucs4)
114 xft_lock.lock("xftCharExists");
115 FcBool ret = XftCharExists(dpy, pub, ucs4);
120 void xftTextExtents8(Display *dpy, XftFont *pub,
121 _Xconst FcChar8 *string, int len, XGlyphInfo *extents)
123 xft_lock.lock("xftTextExtents8");
124 XftTextExtents8(dpy, pub, string, len, extents);
128 void xftTextExtentsUtf8(Display *dpy, XftFont *pub,
129 _Xconst FcChar8 *string, int len, XGlyphInfo *extents)
131 xft_lock.lock("xftTextExtentsUtf8");
132 XftTextExtentsUtf8(dpy, pub, string, len, extents);
136 void xftTextExtents32(Display *dpy, XftFont *pub,
137 _Xconst FcChar32 *string, int len, XGlyphInfo *extents)
139 xft_lock.lock("xftTextExtents32");
140 XftTextExtents32(dpy, pub, string, len, extents);
144 XftDraw *xftDrawCreate(Display *dpy, Drawable drawable, Visual *visual, Colormap colormap)
146 xft_lock.lock("xftDrawCreate");
147 XftDraw *ret = XftDrawCreate(dpy, drawable, visual, colormap);
152 XftDraw *xftDrawCreateBitmap(Display *dpy, Pixmap bitmap)
154 xft_lock.lock("xftDrawCreateBitmap");
155 XftDraw *ret = XftDrawCreateBitmap(dpy, bitmap);
160 void xftDrawDestroy(XftDraw *draw)
162 xft_lock.lock("xftDrawDestroy");
163 XftDrawDestroy(draw);
167 void xftDrawString32(XftDraw *draw, _Xconst XftColor *color, XftFont *pub,
168 int x, int y, _Xconst FcChar32 *string, int len)
170 xft_lock.lock("xftDrawString32");
171 XftDrawString32(draw, color, pub, x, y, string, len);
175 Bool xftColorAllocValue(Display *dpy, Visual *visual,
176 Colormap cmap, _Xconst XRenderColor *color, XftColor *result)
178 xft_lock.lock("xftColorAllocValue");
179 Bool ret = XftColorAllocValue(dpy, visual, cmap, color, result);
184 void xftColorFree(Display *dpy, Visual *visual, Colormap cmap, XftColor *color)
186 xft_lock.lock("xftColorFree");
187 XftColorFree(dpy, visual, cmap, color);
191 XftFont *xftFontOpenName(Display *dpy, int screen, _Xconst char *name)
193 xft_lock.lock("xftFontOpenName");
194 XftFont *ret = XftFontOpenName(dpy, screen, name);
199 XftFont *xftFontOpenXlfd(Display *dpy, int screen, _Xconst char *xlfd)
201 xft_lock.lock("xftFontOpenXlfd");
202 XftFont *ret = XftFontOpenXlfd(dpy, screen, xlfd);
207 XftFont *xftFontOpenPattern(Display *dpy, FcPattern *pattern)
209 xft_lock.lock("xftFontOpenPattern");
210 XftFont *ret = XftFontOpenPattern(dpy, pattern);
215 void xftFontClose(Display *dpy, XftFont *pub)
217 xft_lock.lock("xftFontClose");
218 XftFontClose(dpy, pub);
223 static Mutex &ft_lock = xft_lock;
225 FT_Error ft_Done_Face(FT_Face face)
227 ft_lock.lock("ft_Done_Face");
228 FT_Error ret = FT_Done_Face(face);
233 FT_Error ft_Done_FreeType(FT_Library library)
235 ft_lock.lock("ft_Done_FreeType");
236 FT_Error ret = FT_Done_FreeType(library);
241 void ft_Done_Glyph(FT_Glyph glyph)
243 ft_lock.lock("ft_Done_Glyph");
244 FT_Done_Glyph(glyph);
248 FT_UInt ft_Get_Char_Index(FT_Face face, FT_ULong charcode)
250 ft_lock.lock("ft_Get_Char_Index");
251 FT_UInt ret = FT_Get_Char_Index(face, charcode);
256 FT_Error ft_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph)
258 ft_lock.lock("ft_Get_Glyph");
259 FT_Error ret = FT_Get_Glyph(slot, aglyph);
264 FT_Error ft_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning)
266 ft_lock.lock("ft_Get_Kerning");
267 FT_Error ret = FT_Get_Kerning(face, left_glyph, right_glyph, kern_mode, akerning);
272 FT_Error ft_Init_FreeType(FT_Library *alibrary)
274 ft_lock.lock("ft_Init_FreeType");
275 FT_Error ret = FT_Init_FreeType(alibrary);
280 FT_Error ft_Load_Char(FT_Face face, FT_ULong char_code, FT_Int32 load_flags)
282 ft_lock.lock("ft_Load_Char");
283 FT_Error ret = FT_Load_Char(face, char_code, load_flags);
288 FT_Error ft_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
290 ft_lock.lock("ft_Load_Glyph");
291 FT_Error ret = FT_Load_Glyph(face, glyph_index, load_flags);
296 FT_Error ft_New_Face(FT_Library library, const char *filepathname, FT_Long face_index, FT_Face *aface)
298 ft_lock.lock("ft_New_Face");
299 FT_Error ret = FT_New_Face(library, filepathname, face_index, aface);
304 FT_Error ft_Outline_Done(FT_Library library, FT_Outline *outline)
306 ft_lock.lock("ft_Outline_Done");
307 FT_Error ret = FT_Outline_Done(library, outline);
312 FT_Error ft_Outline_Get_BBox(FT_Outline *outline, FT_BBox *abbox)
314 ft_lock.lock("ft_Outline_Get_BBox");
315 FT_Error ret = FT_Outline_Get_BBox(outline, abbox);
320 FT_Error ft_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap *abitmap)
322 ft_lock.lock("ft_Outline_Get_Bitmap");
323 FT_Error ret = FT_Outline_Get_Bitmap(library, outline, abitmap);
328 FT_Error ft_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline)
330 ft_lock.lock("ft_Outline_New");
331 FT_Error ret = FT_Outline_New(library, numPoints, numContours, anoutline);
336 void ft_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
338 ft_lock.lock("ft_Outline_Translate");
339 FT_Outline_Translate(outline, xOffset, yOffset);
343 FT_Error ft_Select_Charmap(FT_Face face, FT_Encoding encoding)
345 ft_lock.lock("ft_Select_Charmap");
346 FT_Error ret = FT_Select_Charmap(face, encoding);
350 FT_Error ft_Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width, FT_UInt pixel_height)
352 ft_lock.lock("ft_Set_Pixel_Sizes");
353 FT_Error ret = FT_Set_Pixel_Sizes(face, pixel_width, pixel_height);
358 void ft_Stroker_Done(FT_Stroker stroker)
360 ft_lock.lock("ft_Stroker_Done");
361 FT_Stroker_Done(stroker);
365 void ft_Stroker_Export(FT_Stroker stroker, FT_Outline *outline)
367 ft_lock.lock("ft_Stroker_Export");
368 FT_Stroker_Export(stroker, outline);
372 FT_Error ft_Stroker_GetCounts(FT_Stroker stroker, FT_UInt *anum_points, FT_UInt *anum_contours)
374 ft_lock.lock("ft_Stroker_GetCounts");
375 FT_Error ret = FT_Stroker_GetCounts(stroker, anum_points, anum_contours);
380 FT_Error ft_Stroker_New(FT_Library library, FT_Stroker *astroker)
382 ft_lock.lock("ft_Stroker_New");
383 FT_Error ret = FT_Stroker_New(library, astroker);
388 FT_Error ft_Stroker_ParseOutline(FT_Stroker stroker, FT_Outline *outline, FT_Bool opened)
390 ft_lock.lock("ft_Stroker_ParseOutline");
391 FT_Error ret = FT_Stroker_ParseOutline(stroker, outline, opened);
396 void ft_Stroker_Set(FT_Stroker stroker, FT_Fixed radius, FT_Stroker_LineCap line_cap, FT_Stroker_LineJoin line_join, FT_Fixed miter_limit)
398 ft_lock.lock("ft_Stroker_Set");
399 FT_Stroker_Set(stroker, radius, line_cap, line_join, miter_limit);
404 static Mutex &fc_lock = xft_lock;
406 FcBool fcCharSetAddChar(FcCharSet *fcs, FcChar32 ucs4)
408 fc_lock.lock("fcCharSetAddChar");
409 FcBool ret = FcCharSetAddChar(fcs, ucs4);
414 FcCharSet *fcCharSetCreate(void)
416 fc_lock.lock("fcCharSetCreate");
417 FcCharSet *ret = FcCharSetCreate();
421 void fcCharSetDestroy(FcCharSet *fcs)
423 fc_lock.lock("fcCharSetDestroy");
424 FcCharSetDestroy(fcs);
428 FcBool fcCharSetHasChar(const FcCharSet *fcs, FcChar32 ucs4)
430 fc_lock.lock("fcCharSetHasChar");
431 FcBool ret = FcCharSetHasChar(fcs, ucs4);
436 FcBool fcConfigAppFontAddDir(FcConfig *config, const FcChar8 *dir)
438 fc_lock.lock("fcConfigAppFontAddDir");
439 FcBool ret = FcConfigAppFontAddDir(config, dir);
444 FcConfig *fcConfigGetCurrent()
446 fc_lock.lock("fcConfigGetCurrent");
447 FcConfig *ret = FcConfigGetCurrent();
452 FcBool fcConfigSetRescanInterval(FcConfig *config, int rescanInterval)
454 fc_lock.lock("fcConfigSetRescanInterval");
455 FcBool ret = FcConfigSetRescanInterval(config, rescanInterval);
460 FcFontSet *fcFontList(FcConfig *config, FcPattern *p, FcObjectSet *os)
462 fc_lock.lock("fcFontList");
463 FcFontSet *ret = FcFontList(config, p, os);
468 void fcFontSetDestroy(FcFontSet *s)
470 fc_lock.lock("fcFontSetDestroy");
475 FcPattern *fcFreeTypeQueryFace(const FT_Face face, const FcChar8 *file, unsigned int id, FcBlanks *blanks)
477 fc_lock.lock("fcFreeTypeQueryFace");
478 FcPattern *ret = FcFreeTypeQueryFace(face, file, id, blanks);
485 fc_lock.lock("fcInit");
486 FcBool ret = FcInit();
491 FcBool fcLangSetAdd(FcLangSet *ls, const FcChar8 *lang)
493 fc_lock.lock("fcLangSetAdd");
494 FcBool ret = FcLangSetAdd(ls, lang);
499 FcLangSet *fcLangSetCreate(void)
501 fc_lock.lock("fcLangSetCreate");
502 FcLangSet *ret = FcLangSetCreate();
507 void fcLangSetDestroy(FcLangSet *ls)
509 fc_lock.lock("fcLangSetDestroy");
510 FcLangSetDestroy(ls);
514 FcObjectSet *fcObjectSetBuild(const char *first, ...)
516 fc_lock.lock("fcObjectSetBuild");
517 va_list va; va_start(va, first);
518 FcObjectSet *ret = FcObjectSetVaBuild(first, va);
524 void fcObjectSetDestroy(FcObjectSet *os)
526 fc_lock.lock("fcObjectSetDestroy");
527 FcObjectSetDestroy(os);
531 FcBool fcPatternAddBool(FcPattern *p, const char *object, FcBool b)
533 fc_lock.lock("fcPatternAddBool");
534 FcBool ret = FcPatternAddBool(p, object, b);
539 FcBool fcPatternAddCharSet(FcPattern *p, const char *object, const FcCharSet *c)
541 fc_lock.lock("fcPatternAddCharSet");
542 FcBool ret = FcPatternAddCharSet(p, object, c);
547 FcBool fcPatternAddDouble(FcPattern *p, const char *object, double d)
549 fc_lock.lock("fcPatternAddDouble");
550 FcBool ret = FcPatternAddDouble(p, object, d);
555 FcBool fcPatternAddInteger(FcPattern *p, const char *object, int i)
557 fc_lock.lock("fcPatternAddInteger");
558 FcBool ret = FcPatternAddInteger(p, object, i);
563 FcBool fcPatternAddLangSet(FcPattern *p, const char *object, const FcLangSet *ls)
565 fc_lock.lock("fcPatternAddLangSet");
566 FcBool ret = FcPatternAddLangSet(p, object, ls);
571 FcResult fcPatternGetInteger(const FcPattern *p, const char *object, int n, int *i)
573 fc_lock.lock("fcPatternGetInteger");
574 FcResult ret = FcPatternGetInteger(p, object, n, i);
579 FcResult fcPatternGetDouble (const FcPattern *p, const char *object, int n, double *d)
581 fc_lock.lock("fcPatternGetDouble");
582 FcResult ret = FcPatternGetDouble(p, object, n, d);
587 FcResult fcPatternGetString(const FcPattern *p, const char *object, int n, FcChar8 **s)
589 fc_lock.lock("fcPatternGetString");
590 FcResult ret = FcPatternGetString(p, object, n, s);
595 FcPattern *fcPatternCreate(void)
597 fc_lock.lock("fcPatternCreate");
598 FcPattern *ret = FcPatternCreate();
603 FcBool fcPatternDel(FcPattern *p, const char *object)
605 fc_lock.lock("fcPatternDel");
606 FcBool ret = FcPatternDel(p, object);
611 void fcPatternDestroy(FcPattern *p)
613 fc_lock.lock("fcPatternDestroy ");
618 FcPattern *fcPatternDuplicate(const FcPattern *p)
620 fc_lock.lock("fcPatternDuplicate");
621 FcPattern *ret = FcPatternDuplicate(p);
626 FcResult fcPatternGetCharSet(const FcPattern *p, const char *object, int n, FcCharSet **c)
628 fc_lock.lock("fcPatternGetCharSet");
629 FcResult ret = FcPatternGetCharSet(p, object, n, c);