+ int title_offset_x;
+ switch (config.title_align) {
+ case ALIGN_LEFT:
+ /* (pad)[text ](pad)[mark + its pad) */
+ title_offset_x = title_padding;
+ break;
+ case ALIGN_CENTER:
+ /* (pad)[ text ](pad)[mark + its pad)
+ * To center the text inside its allocated space, the surface
+ * between the brackets, we use the formula
+ * (surface_width - predict_text_width) / 2
+ * where surface_width = deco_width - 2 * pad - mark_width
+ * so, offset = pad + (surface_width - predict_text_width) / 2 =
+ * = … = (deco_width - mark_width - predict_text_width) / 2 */
+ title_offset_x = max(title_padding, (deco_width - mark_width - predict_text_width(title)) / 2);
+ break;
+ case ALIGN_RIGHT:
+ /* [mark + its pad](pad)[ text](pad) */
+ title_offset_x = max(title_padding + mark_width, deco_width - title_padding - predict_text_width(title));
+ break;
+ }
+