Don't use deprecated gimp_text functions, clean up font name string
2004-06-18 Manish Singh <yosh@gimp.org> * plug-ins/common/film.c: Don't use deprecated gimp_text functions, clean up font name string handling a bit, default is now "Monospace" instead of "Courier".
This commit is contained in:

committed by
Manish Singh

parent
3720ce2ef7
commit
b93b92be2d
@ -1,3 +1,9 @@
|
|||||||
|
2004-06-18 Manish Singh <yosh@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/common/film.c: Don't use deprecated gimp_text functions,
|
||||||
|
clean up font name string handling a bit, default is now "Monospace"
|
||||||
|
instead of "Courier".
|
||||||
|
|
||||||
2004-06-19 Michael Natterer <mitch@gimp.org>
|
2004-06-19 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/widgets/gimpcontrollers.c (gimp_controllers_event_mapped):
|
* app/widgets/gimpcontrollers.c (gimp_controllers_event_mapped):
|
||||||
|
@ -43,6 +43,8 @@ static char ident[] = "@(#) GIMP Film plug-in v1.04 1999-10-08";
|
|||||||
#define COLOR_BUTTON_WIDTH 50
|
#define COLOR_BUTTON_WIDTH 50
|
||||||
#define COLOR_BUTTON_HEIGHT 20
|
#define COLOR_BUTTON_HEIGHT 20
|
||||||
|
|
||||||
|
#define FONT_LEN 256
|
||||||
|
|
||||||
/* Define how the plug-in works. Values marked (r) are with regard */
|
/* Define how the plug-in works. Values marked (r) are with regard */
|
||||||
/* to film_height (i.e. it should be a value from 0.0 to 1.0) */
|
/* to film_height (i.e. it should be a value from 0.0 to 1.0) */
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -58,7 +60,7 @@ typedef struct
|
|||||||
gdouble number_height; /* height of picture numbering (r) */
|
gdouble number_height; /* height of picture numbering (r) */
|
||||||
gint number_start; /* number for first picture */
|
gint number_start; /* number for first picture */
|
||||||
GimpRGB number_color; /* color of number */
|
GimpRGB number_color; /* color of number */
|
||||||
gchar number_fontf[256]; /* font family to use for numbering */
|
gchar number_font[FONT_LEN]; /* font family to use for numbering */
|
||||||
gint number_pos[2]; /* flags where to draw numbers (top/bottom) */
|
gint number_pos[2]; /* flags where to draw numbers (top/bottom) */
|
||||||
gint keep_height; /* flag if to keep max. image height */
|
gint keep_height; /* flag if to keep max. image height */
|
||||||
gint num_images; /* number of images */
|
gint num_images; /* number of images */
|
||||||
@ -185,7 +187,7 @@ static FilmVals filmvals =
|
|||||||
0.052, /* Image number height */
|
0.052, /* Image number height */
|
||||||
1, /* Start index of numbering */
|
1, /* Start index of numbering */
|
||||||
{ 0.93, 0.61, 0.0, 1.0 }, /* Color of number */
|
{ 0.93, 0.61, 0.0, 1.0 }, /* Color of number */
|
||||||
"Courier", /* Font family for numbering */
|
"Monospace", /* Font family for numbering */
|
||||||
{ TRUE, TRUE }, /* Numbering on top and bottom */
|
{ TRUE, TRUE }, /* Numbering on top and bottom */
|
||||||
0, /* Dont keep max. image height */
|
0, /* Dont keep max. image height */
|
||||||
0, /* Number of images */
|
0, /* Number of images */
|
||||||
@ -216,7 +218,7 @@ query (void)
|
|||||||
{ GIMP_PDB_INT32, "film_height", "Height of film (0: fit to images)" },
|
{ GIMP_PDB_INT32, "film_height", "Height of film (0: fit to images)" },
|
||||||
{ GIMP_PDB_COLOR, "film_color", "Color of the film" },
|
{ GIMP_PDB_COLOR, "film_color", "Color of the film" },
|
||||||
{ GIMP_PDB_INT32, "number_start", "Start index for numbering" },
|
{ GIMP_PDB_INT32, "number_start", "Start index for numbering" },
|
||||||
{ GIMP_PDB_STRING, "number_fontf", "Font family for drawing numbers" },
|
{ GIMP_PDB_STRING, "number_font", "Font for drawing numbers" },
|
||||||
{ GIMP_PDB_COLOR, "number_color", "Color for numbers" },
|
{ GIMP_PDB_COLOR, "number_color", "Color for numbers" },
|
||||||
{ GIMP_PDB_INT32, "at_top", "Flag for drawing numbers at top of film" },
|
{ GIMP_PDB_INT32, "at_top", "Flag for drawing numbers at top of film" },
|
||||||
{ GIMP_PDB_INT32, "at_bottom", "Flag for drawing numbers at bottom of film" },
|
{ GIMP_PDB_INT32, "at_bottom", "Flag for drawing numbers at bottom of film" },
|
||||||
@ -295,9 +297,7 @@ run (const gchar *name,
|
|||||||
128 : param[3].data.d_int32);
|
128 : param[3].data.d_int32);
|
||||||
filmvals.film_color = param[4].data.d_color;
|
filmvals.film_color = param[4].data.d_color;
|
||||||
filmvals.number_start = param[5].data.d_int32;
|
filmvals.number_start = param[5].data.d_int32;
|
||||||
k = sizeof (filmvals.number_fontf);
|
g_strlcpy (filmvals.number_font, param[6].data.d_string, FONT_LEN);
|
||||||
strncpy (filmvals.number_fontf, param[6].data.d_string, k);
|
|
||||||
filmvals.number_fontf[k-1] = '\0';
|
|
||||||
filmvals.number_color = param[7].data.d_color;
|
filmvals.number_color = param[7].data.d_color;
|
||||||
filmvals.number_pos[0] = param[8].data.d_int32;
|
filmvals.number_pos[0] = param[8].data.d_int32;
|
||||||
filmvals.number_pos[1] = param[9].data.d_int32;
|
filmvals.number_pos[1] = param[9].data.d_int32;
|
||||||
@ -567,8 +567,8 @@ check_filmvals (void)
|
|||||||
if (filmvals.number_start < 0)
|
if (filmvals.number_start < 0)
|
||||||
filmvals.number_start = 0;
|
filmvals.number_start = 0;
|
||||||
|
|
||||||
if (filmvals.number_fontf[0] == '\0')
|
if (filmvals.number_font[0] == '\0')
|
||||||
strcpy (filmvals.number_fontf, "courier");
|
strcpy (filmvals.number_font, "Monospace");
|
||||||
|
|
||||||
if (filmvals.num_images < 1)
|
if (filmvals.num_images < 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -878,7 +878,7 @@ draw_number (gint32 layer_ID,
|
|||||||
gint32 image_ID;
|
gint32 image_ID;
|
||||||
gint32 text_layer_ID;
|
gint32 text_layer_ID;
|
||||||
gint text_width, text_height, text_ascent, descent;
|
gint text_width, text_height, text_ascent, descent;
|
||||||
gchar *family = filmvals.number_fontf;
|
gchar *fontname = filmvals.number_font;
|
||||||
|
|
||||||
g_snprintf (buf, sizeof (buf), "%d", num);
|
g_snprintf (buf, sizeof (buf), "%d", num);
|
||||||
|
|
||||||
@ -890,51 +890,34 @@ draw_number (gint32 layer_ID,
|
|||||||
max_delta = 1;
|
max_delta = 1;
|
||||||
|
|
||||||
/* Numbers dont need the descent. Inquire it and move the text down */
|
/* Numbers dont need the descent. Inquire it and move the text down */
|
||||||
for (k = 0; k < max_delta*2 + 1; k++)
|
for (k = 0; k < max_delta * 2 + 1; k++)
|
||||||
{ /* Try different font sizes if inquire of extent failed */
|
{
|
||||||
|
/* Try different font sizes if inquire of extent failed */
|
||||||
|
gboolean success;
|
||||||
|
|
||||||
delta = (k+1) / 2;
|
delta = (k+1) / 2;
|
||||||
if ((k & 1) == 0) delta = -delta;
|
|
||||||
|
|
||||||
gimp_text_get_extents (buf,
|
if ((k & 1) == 0)
|
||||||
height+delta,
|
delta = -delta;
|
||||||
GIMP_PIXELS,
|
|
||||||
"*", /* foundry */
|
|
||||||
family, /* family */
|
|
||||||
"*", /* weight */
|
|
||||||
"*", /* slant */
|
|
||||||
"*", /* set_width */
|
|
||||||
"*", /* spacing */
|
|
||||||
"*",
|
|
||||||
"*",
|
|
||||||
&text_width,
|
|
||||||
&text_height,
|
|
||||||
&text_ascent,
|
|
||||||
&descent);
|
|
||||||
|
|
||||||
if (text_width) /* FIXME: use return_value of gimp_text_get_extens */
|
success = gimp_text_get_extents_fontname (buf,
|
||||||
|
height + delta, GIMP_PIXELS,
|
||||||
|
fontname,
|
||||||
|
&text_width, &text_height,
|
||||||
|
&text_ascent, &descent);
|
||||||
|
|
||||||
|
if (success)
|
||||||
{
|
{
|
||||||
height += delta;
|
height += delta;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text_layer_ID = gimp_text (image_ID,
|
text_layer_ID = gimp_text_fontname (image_ID, layer_ID,
|
||||||
layer_ID,
|
x, y + descent / 2,
|
||||||
x,
|
buf, 1, FALSE,
|
||||||
y+descent/2,
|
height, GIMP_PIXELS,
|
||||||
buf,
|
fontname);
|
||||||
1, /* border */
|
|
||||||
FALSE, /* antialias */
|
|
||||||
height,
|
|
||||||
GIMP_PIXELS,
|
|
||||||
"*", /* foundry */
|
|
||||||
family, /* family */
|
|
||||||
"*", /* weight */
|
|
||||||
"*", /* slant */
|
|
||||||
"*", /* set_width */
|
|
||||||
"*", /* spacing */
|
|
||||||
"*",
|
|
||||||
"*");
|
|
||||||
|
|
||||||
if (text_layer_ID == -1)
|
if (text_layer_ID == -1)
|
||||||
g_message ("draw_number: Error in drawing text\n");
|
g_message ("draw_number: Error in drawing text\n");
|
||||||
@ -1283,7 +1266,7 @@ create_selection_tab (GtkWidget *notebook,
|
|||||||
|
|
||||||
/* Fontfamily for numbering */
|
/* Fontfamily for numbering */
|
||||||
font_sel = gimp_font_select_widget_new (NULL,
|
font_sel = gimp_font_select_widget_new (NULL,
|
||||||
filmvals.number_fontf,
|
filmvals.number_font,
|
||||||
film_font_select_callback,
|
film_font_select_callback,
|
||||||
&filmvals);
|
&filmvals);
|
||||||
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||||
@ -1543,6 +1526,5 @@ film_font_select_callback (const gchar *name,
|
|||||||
{
|
{
|
||||||
FilmVals *vals = (FilmVals *) data;
|
FilmVals *vals = (FilmVals *) data;
|
||||||
|
|
||||||
strncpy (vals->number_fontf, name, sizeof (vals->number_fontf));
|
g_strlcpy (vals->number_font, name, FONT_LEN);
|
||||||
vals->number_fontf[sizeof (vals->number_fontf) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user