for ( zstring = render->strings; zstring != NULL; zstring = zstring->next )
{
bstring = gl_barcode_shape_string_new();
- bstring->x = (double) zstring->x - (((6.0 / 9.0) * zstring->length * zstring->fsize) / 2);
+ bstring->x = (double) zstring->x;
bstring->y = (double) zstring->y;
bstring->fsize = (double) zstring->fsize;
bstring->str = g_strndup (zstring->text, zstring->length);
* / / \ \ | |_) | | (__ |
* /__/ \__\ |_.___/ \____| |
* v
- * @ --------------------------------------
+ * @ ------------------
+ * x = horizontal center
*/
typedef struct {
glBarcodeShapeAlpha *bchar;
glBarcodeShapeString *bstring;
GList *p;
- gdouble y_offset;
+ gdouble x_offset, y_offset;
PangoLayout *layout;
PangoFontDescription *desc;
gchar *text, *cstring;
glColorNode *color_node;
guint format_digits;
gdouble w, h;
+ gint iw, ih;
+ gdouble layout_width;
gl_debug (DEBUG_LABEL, "START");
pango_layout_set_text (layout, bstring->str, -1);
+ pango_layout_get_size (layout, &iw, &ih);
+ layout_width = (gdouble)iw / (gdouble)PANGO_SCALE;
+
+ x_offset = layout_width / 2.0;
y_offset = 0.2 * bstring->fsize;
- cairo_move_to (cr, bstring->x, bstring->y-y_offset);
+ cairo_move_to (cr, (bstring->x - x_offset), (bstring->y - y_offset));
pango_cairo_show_layout (cr, layout);
g_object_unref (layout);