LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Takeshi Abe Date: Wed Jun 18 10:31:42 2008 Subject: cvs: gd /gd-pango gd_pango.c gd_pango.h
tabe Wed Jun 18 16:31:42 2008 UTC
Modified files:
/gd/gd-pango gd_pango.c gd_pango.h
Log:
pango_layout_iter_get_line_readonly() will speed you.
fix gdPangoInit() according to the comment of gdPangoIsInitialized().
prefer g_strdup_printf() to GD_PANGO_MAX_NAME_LENGTH magic number.
more cosmetic fixes.
http://cvs.php.net/viewvc.cgi/gd/gd-pango/gd_pango.c?r1=1.4&r2=1.5&diff_format=u
Index: gd/gd-pango/gd_pango.c
diff -u gd/gd-pango/gd_pango.c:1.4 gd/gd-pango/gd_pango.c:1.5
--- gd/gd-pango/gd_pango.c:1.4 Sat Jun 14 15:07:15 2008
+++ gd/gd-pango/gd_pango.c Wed Jun 18 16:31:42 2008
@@ -15,7 +15,7 @@
| Authors: Pierre-A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: gd_pango.c,v 1.4 2008/06/14 15:07:15 tabe Exp $ */
+/* $Id: gd_pango.c,v 1.5 2008/06/18 16:31:42 tabe Exp $ */
/**
* @file
* @brief Pango support for GD
@@ -24,7 +24,7 @@
*
* @author Pierre-Alain Joye
* @date 2006/12/19
- * $Id: gd_pango.c,v 1.4 2008/06/14 15:07:15 tabe Exp $
+ * $Id: gd_pango.c,v 1.5 2008/06/18 16:31:42 tabe Exp $
*/
/**
* \mainpage
@@ -326,7 +326,7 @@
static void gdPangoRenderLine(
gdPangoContext *context,
gdImagePtr surface,
- PangoLayoutLine *line,
+ const PangoLayoutLine *line,
gint x,
gint y,
gint height,
@@ -454,7 +454,7 @@
/* Public API */
/**
- * Initialize the Glib and Pango API.
+ * Initialize the GLib and Pango API.
* This function must be called before using any other functions
* in this library besides gdPangoIsInitialized.
*
@@ -462,15 +462,15 @@
*/
int gdPangoInit() {
g_type_init();
- GD_PANGO_IS_INITIALIZED = -1;
+ GD_PANGO_IS_INITIALIZED = 1;
return GD_SUCCESS;
}
/**
- * Return the intialization status
+ * Return the intialization status.
* Tells whether gdPango has been already initialized or not.
*
- * @return non-zero if it was not initialized, positive value if init.
+ * @return positive if it was initialized, otherwise zero.
*/
int gdPangoIsInitialized()
{
@@ -493,7 +493,7 @@
g_get_charset(&charset);
pango_context_set_language(context->context, pango_language_from_string(charset));
- //pango_context_set_base_dir(context->context, PANGO_DIRECTION_LTR);
+ /*pango_context_set_base_dir(context->context, PANGO_DIRECTION_LTR);*/
/*pango_context_set_base_gravity(context->context, PANGO_GRAVITY_SOUTH);*/
context->font_desc = pango_font_description_from_string(
@@ -522,12 +522,12 @@
/**
* Free a context.
*
- * @param *context Context to be free
+ * @param *context Context to be freed
*/
void gdPangoFreeContext(gdPangoContext *context)
{
gdPangofreeFTBitmap(context->ft2bmp);
- g_object_unref (context->layout);
+ g_object_unref(context->layout);
pango_font_description_free(context->font_desc);
g_object_unref(context->context);
g_object_unref(context->font_map);
@@ -550,7 +550,7 @@
}
/**
- * Render the text to the given image
+ * Render the text to the given image.
*
* Render the text to the given image. The (x,y) coordinate set the top
* left corner of the text rectangle.
@@ -619,7 +619,7 @@
PangoLayoutLine *line;
int baseline;
- line = pango_layout_iter_get_line (iter);
+ line = pango_layout_iter_get_line_readonly(iter);
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
baseline = pango_layout_iter_get_baseline (iter);
@@ -690,7 +690,7 @@
/**
* Specify default color.
*
- * Define the default foreground, background and alpha component
+ * Define the default foreground, background and alpha component.
*
* @param *context gdPangoContext context
* @param *colors a gdPangoColors ptr, defines fg, bgd or alpha default
@@ -791,7 +791,8 @@
}
/**
- * set font description from a ttf file
+ * Set font description from a ttf file
+ *
* @param *context Context
* @param *fontlist path to ttf file
*/
@@ -802,14 +803,15 @@
FcBlanks *fcBlanks;
FcValue fcFamilyName;
int numFonts;
- char font_desc[GD_PANGO_MAX_NAME_LENGTH];
+ char *font_desc;
fcBlanks = FcBlanksCreate();
fcPattern = FcFreeTypeQuery(fontlist, 0, fcBlanks, &numFonts);
FcPatternGet(fcPattern, FC_FAMILY, 0, &fcFamilyName);
- sprintf(font_desc, "%s %d", fcFamilyName.u.s, (int) ptsize);
+ font_desc = g_strdup_printf("%s %d", fcFamilyName.u.s, (int) ptsize);
context->font_desc = pango_font_description_from_string(font_desc);
+ g_free(font_desc);
gdPangoSetDpi(context, ptsize, ptsize);
}
@@ -824,7 +826,7 @@
}
/**
- * Returns the internal pango_context pointer
+ * Returns the internal pango_context pointer.
*
* This pointer can then be used directly with Pango. There is no need for
* GD to duplicate the pango API.
@@ -837,7 +839,7 @@
}
/**
- * Returns the internal pango_layout pointer
+ * Returns the internal pango_layout pointer.
*
* This pointer can then be used directly with Pango. There is no need for
* GD to duplicate the pango API.
@@ -850,7 +852,7 @@
}
/**
- * pango enabled replacement for gdImageStringFT
+ * Pango enabled replacement for gdImageStringFT.
*
* @param *im gdImagePtr
* @param brect int array of layout bounds
@@ -861,6 +863,7 @@
* @param x top left corner
* @param y top left corner
* @param *string the text to draw
+ * @return A null char* on success, or an error string on failure
*/
char *gdImageStringPangoFT(gdImagePtr im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string)
http://cvs.php.net/viewvc.cgi/gd/gd-pango/gd_pango.h?r1=1.5&r2=1.6&diff_format=u
Index: gd/gd-pango/gd_pango.h
diff -u gd/gd-pango/gd_pango.h:1.5 gd/gd-pango/gd_pango.h:1.6
--- gd/gd-pango/gd_pango.h:1.5 Tue Jun 17 03:18:12 2008
+++ gd/gd-pango/gd_pango.h Wed Jun 18 16:31:42 2008
@@ -15,14 +15,14 @@
| Authors: Pierre-A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: gd_pango.h,v 1.5 2008/06/17 03:18:12 tabe Exp $ */
+/* $Id: gd_pango.h,v 1.6 2008/06/18 16:31:42 tabe Exp $ */
/**
* @file
* @brief Header file of gd-pango
*
* @author Pierre-Alain Joye
* @date 2006/12/19
- * $Id: gd_pango.h,v 1.5 2008/06/17 03:18:12 tabe Exp $
+ * $Id: gd_pango.h,v 1.6 2008/06/18 16:31:42 tabe Exp $
*/
#ifndef GD_PANGO_H
@@ -42,8 +42,6 @@
#define GD_PANGO_DEFAULT_DPI 96
#define _MAKE_FONT_NAME(family, size) #family " " #size
#define GD_PANGO_MAKE_FONT_NAME(family, size) _MAKE_FONT_NAME(family, size)
-#define GD_PANGO_MAX_NAME_LENGTH 100
-
#define gdPangoColorToRGBA7888(pc) \
gdTrueColorAlpha(pc.red >> 8, \
@@ -67,7 +65,7 @@
* Context object. Different functions are provided to access its
* values, do not access it directly.
*/
-typedef struct gdPangoContext { /*GD Pango Context */
+typedef struct gdPangoContext { /* GD Pango Context */
PangoContext *context;
PangoFontMap *font_map;
PangoFontDescription *font_desc;
| Navigate in group php.gd.cvs at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by Zareef Ahmed
Powered By PHP Consultants |