aboutsummaryrefslogtreecommitdiff
path: root/src/sc_interp.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-03-23 21:28:30 +0100
committerThomas White <taw@physics.org>2018-03-23 21:28:30 +0100
commite0204fa4ae96ec9b298b67b723afe9fb6919a0d7 (patch)
treeaf8c7b75108be798483c9c33b7bb493640ca971f /src/sc_interp.c
parent476a5210dcdddcad5eab5c5bc0e3cdee9a7efad1 (diff)
Add \ralign
Diffstat (limited to 'src/sc_interp.c')
-rw-r--r--src/sc_interp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 55d5f34..eb09063 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -56,6 +56,7 @@ struct sc_state
{
PangoFontDescription *fontdesc;
PangoFont *font;
+ PangoAlignment alignment;
double col[4];
int ascent;
int height;
@@ -408,6 +409,13 @@ static void set_italic(SCInterpreter *scin)
}
+static void set_alignment(SCInterpreter *scin, PangoAlignment align)
+{
+ struct sc_state *st = &scin->state[scin->j];
+ st->alignment = align;
+}
+
+
/* This sets the colour for the font at the top of the stack */
static void set_colour(SCInterpreter *scin, const char *colour)
{
@@ -613,6 +621,7 @@ SCInterpreter *sc_interp_new(PangoContext *pc, PangoLanguage *lang,
st->paraspace[3] = 0.0;
st->fontdesc = NULL;
st->have_size = 0;
+ st->alignment = PANGO_ALIGN_LEFT;
scin->lang = lang;
@@ -991,6 +1000,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl,
para = create_paragraph(fr, bl, rbl);
}
+ set_para_alignment(para, st->alignment);
add_run(para, bl, rbl, fontdesc, col);
set_para_spacing(para, st->paraspace);
@@ -1181,6 +1191,11 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl)
set_italic(scin);
maybe_recurse_after(scin, child);
+ } else if ( strcmp(name, "ralign") == 0 ) {
+ maybe_recurse_before(scin, child);
+ set_alignment(scin, PANGO_ALIGN_RIGHT);
+ maybe_recurse_after(scin, child);
+
} else if ( strcmp(name, "fgcol") == 0 ) {
maybe_recurse_before(scin, child);
set_colour(scin, options);