aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frame.c171
-rw-r--r--src/render.c8
-rw-r--r--src/sc_interp.c326
-rw-r--r--src/sc_interp.h24
-rw-r--r--src/sc_parse.c14
-rw-r--r--src/sc_parse.h3
-rw-r--r--src/shape.c30
-rw-r--r--src/shape.h2
8 files changed, 299 insertions, 279 deletions
diff --git a/src/frame.c b/src/frame.c
index eb0ce7a..40daa86 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -84,187 +84,18 @@ struct frame *add_subframe(struct frame *fr)
}
-#if 0
-static LengthUnits get_units(const char *t)
-{
- size_t len = strlen(t);
-
- if ( t[len-1] == 'f' ) return UNITS_FRAC;
- if ( t[len-1] == 'u' ) return UNITS_SLIDE;
-
- fprintf(stderr, "Invalid units in '%s'\n", t);
- return UNITS_SLIDE;
-}
-
-
-static void parse_option(struct frame *fr, const char *opt)
-{
- if ( (index(opt, 'x') != NULL) && (index(opt, '+') != NULL)
- && (index(opt, '+') != rindex(opt, '+')) )
- {
- char *w;
- char *h;
- char *x;
- char *y;
- char *check;
-
- /* Looks like a dimension/position thing */
- w = strdup(opt);
- h = index(w, 'x');
- h[0] = '\0'; h++;
-
- x = index(h, '+');
- if ( x == NULL ) {
- fprintf(stderr, "Invalid option '%s'\n", opt);
- return;
- }
- x[0] = '\0'; x++;
-
- y = index(x, '+');
- if ( x == NULL ) {
- fprintf(stderr, "Invalid option '%s'\n", opt);
- return;
- }
- y[0] = '\0'; y++;
-
- fr->lop.w = strtod(w, &check);
- if ( check == w ) {
- fprintf(stderr, "Invalid option '%s'\n", opt);
- return;
- }
- fr->lop.w_units = get_units(w);
-
- fr->lop.h = strtod(h, &check);
- if ( check == h ) {
- fprintf(stderr, "Invalid option '%s'\n", opt);
- return;
- }
- fr->lop.h_units = get_units(h);
-
- fr->lop.x = strtod(x, &check);
- if ( check == x ) {
- fprintf(stderr, "Invalid option '%s'\n", opt);
- return;
- }
- fr->lop.y = strtod(y, &check);
- if ( check == y ) {
- fprintf(stderr, "Invalid option '%s'\n", opt);
- return;
- }
-
- }
-}
-
-
-static void parse_options(struct frame *fr, const char *opth, StyleSheet *ss)
-{
- int i;
- size_t len;
- size_t start;
- char *opt;
-
- if ( opth == NULL ) return;
-
- opt = strdup(opth);
-
- len = strlen(opt);
- start = 0;
-
- for ( i=0; i<len; i++ ) {
-
- /* FIXME: comma might be escaped or quoted */
- if ( opt[i] == ',' ) {
- opt[i] = '\0';
- parse_option(fr, opt+start, ss);
- start = i+1;
- }
-
- }
-
- if ( start != len ) {
- parse_option(fr, opt+start, ss);
- }
-
- free(opt);
-}
-
-
-static int recursive_unpack(struct frame *fr, const char *sc, StyleSheet *ss)
-{
- SCBlockList *bl;
- SCBlockListIterator *iter;
- struct scblock *b;
-
- bl = sc_find_blocks(sc, "f");
- if ( bl == NULL ) return 1;
-
- for ( b = sc_block_list_first(bl, &iter);
- b != NULL;
- b = sc_block_list_next(bl, iter) )
- {
- struct frame *sfr;
-
- sfr = add_subframe(fr);
- sfr->empty = 0;
- parse_options(sfr, b->options, ss);
-
- if ( sfr->lop.w < 0.0 ) {
- sfr->lop.x += sfr->lop.w;
- sfr->lop.w = -sfr->lop.w;
- }
-
- if ( sfr->lop.h < 0.0 ) {
- sfr->lop.y += sfr->lop.h;
- sfr->lop.h = -sfr->lop.h;
- }
-
- sfr->sc = remove_blocks(b->contents, "f");
- sfr->sc_len = strlen(sfr->sc)+1;
- if ( recursive_unpack(sfr, b->contents, ss) ) {
- sc_block_list_free(bl);
- return 1;
- }
- }
- sc_block_list_free(bl);
-
- return 0;
-}
-
-
-/* Unpack level 2 StoryCode (content + subframes) into frames */
-struct frame *sc_unpack(const char *sc, StyleSheet *ss)
-{
- struct frame *fr;
-
- fr = frame_new();
- if ( fr == NULL ) return NULL;
-
- fr->empty = 0;
- fr->sc = remove_blocks(sc, "f");
- if ( recursive_unpack(fr, sc, ss) ) {
- return NULL;
- }
-
- return fr;
-}
-
-
void show_hierarchy(struct frame *fr, const char *t)
{
int i;
char tn[1024];
- char *sc;
strcpy(tn, t);
strcat(tn, " ");
- sc = escape_text(fr->sc);
- printf("%s%p %s (%.2f x %.2f)\n", t, fr, sc, fr->w, fr->h);
- free(sc);
+ printf("%s%p (%.2f x %.2f)\n", t, fr, fr->w, fr->h);
for ( i=0; i<fr->num_children; i++ ) {
show_hierarchy(fr->children[i], tn);
}
}
-#endif
diff --git a/src/render.c b/src/render.c
index a4fbd51..65d1601 100644
--- a/src/render.c
+++ b/src/render.c
@@ -293,7 +293,7 @@ static int render_frame(cairo_t *cr, struct frame *fr, ImageStore *is,
int i;
SCBlock *bl = fr->scblocks;
- scin = sc_interp_new(pc);
+ scin = sc_interp_new(pc, fr);
if ( scin == NULL ) {
fprintf(stderr, "Failed to set up interpreter.\n");
return 1;
@@ -316,6 +316,12 @@ static int render_frame(cairo_t *cr, struct frame *fr, ImageStore *is,
/* Actually draw the lines */
draw_frame(cr, fr, is, isz);
+ for ( i=0; i<fr->num_children; i++ ) {
+ cairo_translate(cr, fr->children[i]->x, fr->children[i]->y);
+ render_frame(cr, fr->children[i], is, isz, scc, pcc, pc);
+ cairo_restore(cr);
+ }
+
sc_interp_destroy(scin);
return 0;
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 4b74fef..dcafd36 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -36,6 +36,19 @@
#include "shape.h"
#include "wrap.h"
+
+struct sc_state
+{
+ PangoFontDescription *fontdesc;
+ PangoFont *font;
+ double col[4];
+ int ascent;
+ int height;
+
+ struct frame *fr; /* The current frame */
+};
+
+
struct _scinterp
{
PangoContext *pc;
@@ -44,40 +57,71 @@ struct _scinterp
struct slide_constants *s_constants;
struct presentation_constants *p_constants;
- struct sc_font *fontstack;
- int n_fonts;
- int max_fonts;
+ struct sc_state *state;
+ int j; /* Index of the current state */
+ int max_state;
struct wrap_line *boxes;
};
+PangoFont *sc_interp_get_font(SCInterpreter *scin)
+{
+ struct sc_state *st = &scin->state[scin->j];
+ return st->font;
+}
+
+
+PangoFontDescription *sc_interp_get_fontdesc(SCInterpreter *scin)
+{
+ struct sc_state *st = &scin->state[scin->j];
+ return st->fontdesc;
+}
+
+
+double *sc_interp_get_fgcol(SCInterpreter *scin)
+{
+ struct sc_state *st = &scin->state[scin->j];
+ return st->col;
+}
+
+
+int sc_interp_get_ascent(SCInterpreter *scin)
+{
+ struct sc_state *st = &scin->state[scin->j];
+ return st->ascent;
+}
+
+
+int sc_interp_get_height(SCInterpreter *scin)
+{
+ struct sc_state *st = &scin->state[scin->j];
+ return st->height;
+}
+
+
static void set_font(SCInterpreter *scin, const char *font_name)
{
PangoFontMetrics *metrics;
- struct sc_font *scf;
-
- scf = &scin->fontstack[scin->n_fonts-1];
+ struct sc_state *st = &scin->state[scin->j];
- scf->fontdesc = pango_font_description_from_string(font_name);
- if ( scf->fontdesc == NULL ) {
+ st->fontdesc = pango_font_description_from_string(font_name);
+ if ( st->fontdesc == NULL ) {
fprintf(stderr, "Couldn't describe font.\n");
return;
}
- scf->font = pango_font_map_load_font(pango_context_get_font_map(scin->pc),
- scin->pc, scf->fontdesc);
- if ( scf->font == NULL ) {
+ st->font = pango_font_map_load_font(pango_context_get_font_map(scin->pc),
+ scin->pc, st->fontdesc);
+ if ( st->font == NULL ) {
fprintf(stderr, "Couldn't load font.\n");
return;
}
/* FIXME: Language for box */
- metrics = pango_font_get_metrics(scf->font, NULL);
- scf->ascent = pango_font_metrics_get_ascent(metrics);
- scf->height = scf->ascent + pango_font_metrics_get_descent(metrics);
+ metrics = pango_font_get_metrics(st->font, NULL);
+ st->ascent = pango_font_metrics_get_ascent(metrics);
+ st->height = st->ascent + pango_font_metrics_get_descent(metrics);
pango_font_metrics_unref(metrics);
-
- scf->free_font_on_pop = 1;
}
@@ -85,94 +129,96 @@ static void set_font(SCInterpreter *scin, const char *font_name)
static void set_colour(SCInterpreter *scin, const char *colour)
{
GdkRGBA col;
- struct sc_font *scf = &scin->fontstack[scin->n_fonts-1];
+ struct sc_state *st = &scin->state[scin->j];
if ( colour == NULL ) {
printf("Invalid colour\n");
- scf->col[0] = 0.0;
- scf->col[1] = 0.0;
- scf->col[2] = 0.0;
- scf->col[3] = 1.0;
+ st->col[0] = 0.0;
+ st->col[1] = 0.0;
+ st->col[2] = 0.0;
+ st->col[3] = 1.0;
return;
}
gdk_rgba_parse(&col, colour);
- scf->col[0] = col.red;
- scf->col[1] = col.green;
- scf->col[2] = col.blue;
- scf->col[3] = col.alpha;
+ st->col[0] = col.red;
+ st->col[1] = col.green;
+ st->col[2] = col.blue;
+ st->col[3] = col.alpha;
}
-static void copy_top_font(SCInterpreter *scin)
+void sc_interp_save(SCInterpreter *scin)
{
- if ( scin->n_fonts == scin->max_fonts ) {
+ if ( scin->j+1 == scin->max_state ) {
- struct sc_font *stack_new;
+ struct sc_state *stack_new;
- stack_new = realloc(scin->fontstack, sizeof(struct sc_font)
- * ((scin->max_fonts)+8));
+ stack_new = realloc(scin->state, sizeof(struct sc_state)
+ * (scin->max_state+8));
if ( stack_new == NULL ) {
- fprintf(stderr, "Failed to push font or colour.\n");
+ fprintf(stderr, "Failed to add to stack.\n");
return;
}
- scin->fontstack = stack_new;
- scin->max_fonts += 8;
+ scin->state = stack_new;
+ scin->max_state += 8;
}
/* When n_fonts=0, we leave the first font uninitialised. This allows
* the stack to be "bootstrapped", but requires the first caller to do
* set_font and set_colour straight away. */
- if ( scin->n_fonts > 0 ) {
- scin->fontstack[scin->n_fonts] = scin->fontstack[scin->n_fonts-1];
- }
-
- /* This is a copy, so don't free it later */
- scin->fontstack[scin->n_fonts].free_font_on_pop = 0;
-
- scin->n_fonts++;
+ scin->state[scin->j+1] = scin->state[scin->j];
+ scin->j++;
}
-static void push_font(SCInterpreter *scin, const char *font_name)
+void sc_interp_restore(SCInterpreter *scin)
{
- copy_top_font(scin);
- set_font(scin, font_name);
+ struct sc_state *st = &scin->state[scin->j];
+
+ if ( scin->j > 0 ) {
+ if ( st->fontdesc != scin->state[scin->j-1].fontdesc )
+ {
+ pango_font_description_free(st->fontdesc);
+ } /* else the font is the same as the previous one, and we
+ * don't need to free it just yet */
+ }
+
+ scin->j--;
}
-static void push_colour(SCInterpreter *scin, const char *colour)
+struct frame *sc_interp_get_frame(SCInterpreter *scin)
{
- copy_top_font(scin);
- set_colour(scin, colour);
+ struct sc_state *st = &scin->state[scin->j];
+ return st->fr;
}
-static void pop_font_or_colour(SCInterpreter *scin)
+static void set_frame(SCInterpreter *scin, struct frame *fr)
{
- struct sc_font *scf = &scin->fontstack[scin->n_fonts-1];
-
- if ( scf->free_font_on_pop ) {
- pango_font_description_free(scf->fontdesc);
- }
-
- scin->n_fonts--;
+ struct sc_state *st = &scin->state[scin->j];
+ st->fr = fr;
}
-SCInterpreter *sc_interp_new(PangoContext *pc)
+SCInterpreter *sc_interp_new(PangoContext *pc, struct frame *top)
{
SCInterpreter *scin;
scin = malloc(sizeof(SCInterpreter));
if ( scin == NULL ) return NULL;
- scin->fontstack = NULL;
- scin->n_fonts = 0;
- scin->max_fonts = 0;
+ scin->state = malloc(8*sizeof(struct sc_state));
+ if ( scin->state == NULL ) {
+ free(scin);
+ return NULL;
+ }
+ scin->j = 0;
+ scin->max_state = 8;
scin->pc = pc;
scin->s_constants = NULL;
@@ -189,8 +235,9 @@ SCInterpreter *sc_interp_new(PangoContext *pc)
initialise_line(scin->boxes);
/* The "ultimate" default font */
- push_font(scin, "Sans 12");
+ set_font(scin, "Sans 12");
set_colour(scin, "#000000");
+ set_frame(scin, top);
return scin;
}
@@ -199,15 +246,123 @@ SCInterpreter *sc_interp_new(PangoContext *pc)
void sc_interp_destroy(SCInterpreter *scin)
{
/* Empty the stack */
- while ( scin->n_fonts > 0 ) {
- pop_font_or_colour(scin);
+ while ( scin->j > 0 ) {
+ sc_interp_restore(scin);
}
+ pango_font_description_free(scin->state[0].fontdesc);
+
free(scin);
}
-int sc_interp_add_blocks(SCInterpreter *scin, const SCBlock *bl)
+static LengthUnits get_units(const char *t)
+{
+ size_t len = strlen(t);
+
+ if ( t[len-1] == 'f' ) return UNITS_FRAC;
+ if ( t[len-1] == 'u' ) return UNITS_SLIDE;
+
+ fprintf(stderr, "Invalid units in '%s'\n", t);
+ return UNITS_SLIDE;
+}
+
+
+static void parse_frame_option(struct frame *fr, const char *opt)
+{
+ if ( (index(opt, 'x') != NULL) && (index(opt, '+') != NULL)
+ && (index(opt, '+') != rindex(opt, '+')) )
+ {
+ char *w;
+ char *h;
+ char *x;
+ char *y;
+ char *check;
+ LengthUnits h_units, w_units;
+
+ /* Looks like a dimension/position thing */
+ w = strdup(opt);
+ h = index(w, 'x');
+ h[0] = '\0'; h++;
+
+ x = index(h, '+');
+ if ( x == NULL ) {
+ fprintf(stderr, "Invalid option '%s'\n", opt);
+ return;
+ }
+ x[0] = '\0'; x++;
+
+ y = index(x, '+');
+ if ( x == NULL ) {
+ fprintf(stderr, "Invalid option '%s'\n", opt);
+ return;
+ }
+ y[0] = '\0'; y++;
+
+ fr->w = strtod(w, &check);
+ if ( check == w ) {
+ fprintf(stderr, "Invalid option '%s'\n", opt);
+ return;
+ }
+ w_units = get_units(w);
+
+ fr->h = strtod(h, &check);
+ if ( check == h ) {
+ fprintf(stderr, "Invalid option '%s'\n", opt);
+ return;
+ }
+ h_units = get_units(h);
+ /* FIXME: Handle units */
+
+ fr->x = strtod(x, &check);
+ if ( check == x ) {
+ fprintf(stderr, "Invalid option '%s'\n", opt);
+ return;
+ }
+ fr->y = strtod(y, &check);
+ if ( check == y ) {
+ fprintf(stderr, "Invalid option '%s'\n", opt);
+ return;
+ }
+
+ }
+}
+
+
+static void parse_frame_options(struct frame *fr, const char *opth)
+{
+ int i;
+ size_t len;
+ size_t start;
+ char *opt;
+
+ if ( opth == NULL ) return;
+
+ opt = strdup(opth);
+
+ len = strlen(opt);
+ start = 0;
+
+ for ( i=0; i<len; i++ ) {
+
+ /* FIXME: comma might be escaped or quoted */
+ if ( opt[i] == ',' ) {
+ opt[i] = '\0';
+ parse_frame_option(fr, opt+start);
+ start = i+1;
+ }
+
+ }
+
+ if ( start != len ) {
+ parse_frame_option(fr, opt+start);
+ }
+
+ free(opt);
+}
+
+
+int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl)
{
while ( bl != NULL ) {
@@ -216,32 +371,24 @@ int sc_interp_add_blocks(SCInterpreter *scin, const SCBlock *bl)
const char *contents = sc_block_contents(bl);
SCBlock *child = sc_block_child(bl);
+ if ( child != NULL ) {
+ sc_interp_save(scin);
+ }
+
if ( name == NULL ) {
split_words(scin->boxes, scin->pc, contents,
- scin->lang, 1,
- &scin->fontstack[scin->n_fonts-1]);
+ scin->lang, 1, scin);
- } else if ( (strcmp(name, "font")==0) && (child == NULL) ) {
+ } else if ( strcmp(name, "font") == 0 ) {
set_font(scin, options);
- } else if ( (strcmp(name, "font")==0) && (child != NULL) ) {
- push_font(scin, options);
- sc_interp_add_blocks(scin, child);
- pop_font_or_colour(scin);
-
- } else if ( (strcmp(name, "fgcol")==0) && (child == NULL) ) {
+ } else if ( strcmp(name, "fgcol") == 0 ) {
set_colour(scin, options);
- } else if ( (strcmp(name, "fgcol")==0) && (child != NULL) ) {
- push_colour(scin, options);
- sc_interp_add_blocks(scin, child);
- pop_font_or_colour(scin);
-
#if 0
- } else if ( (strcmp(name, "image")==0)
- && (contents != NULL) && (b->options != NULL) ) {
+ } else if ( strcmp(name, "image")==0 ) {
int w, h;
- if ( get_size(b->options, fr, &w, &h) == 0 ) {
+ if ( get_size(options, fr, &w, &h) == 0 ) {
add_image_box(boxes, b->contents, offset, w, h,
editable);
}
@@ -258,6 +405,20 @@ int sc_interp_add_blocks(SCInterpreter *scin, const SCBlock *bl)
} /* else go away and sulk about it */
#endif
+ } else if ( strcmp(name, "f")==0 ) {
+ struct frame *fr = sc_block_frame(bl);
+ if ( fr == NULL ) {
+ fr = add_subframe(sc_interp_get_frame(scin));
+ sc_block_set_frame(bl, fr);
+ fr->scblocks = child;
+ }
+ if ( fr == NULL ) {
+ fprintf(stderr, "Failed to add frame.\n");
+ goto next;
+ }
+ parse_frame_options(fr, options);
+ set_frame(scin, fr);
+
} else {
fprintf(stderr, "Don't know what to do with this:\n");
@@ -265,6 +426,11 @@ int sc_interp_add_blocks(SCInterpreter *scin, const SCBlock *bl)
}
+next:
+ if ( child != NULL ) {
+ sc_interp_add_blocks(scin, child);
+ sc_interp_restore(scin);
+ }
bl = sc_block_next(bl);
}
diff --git a/src/sc_interp.h b/src/sc_interp.h
index 05504f0..78f32d9 100644
--- a/src/sc_interp.h
+++ b/src/sc_interp.h
@@ -29,26 +29,24 @@
#include <pango/pangocairo.h>
-
-struct sc_font
-{
- PangoFontDescription *fontdesc;
- PangoFont *font;
- double col[4];
- int ascent;
- int height;
- int free_font_on_pop;
-};
-
typedef struct _scinterp SCInterpreter;
-extern SCInterpreter *sc_interp_new(PangoContext *pc);
+extern SCInterpreter *sc_interp_new(PangoContext *pc, struct frame *top);
extern void sc_interp_destroy(SCInterpreter *scin);
extern void sc_interp_save(SCInterpreter *scin);
extern void sc_interp_restore(SCInterpreter *scin);
-extern int sc_interp_add_blocks(SCInterpreter *scin, const SCBlock *bl);
+extern int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl);
+
extern struct wrap_line *sc_interp_get_boxes(SCInterpreter *scin);
+/* Get the current state of the interpreter */
+extern struct frame *sc_interp_get_frame(SCInterpreter *scin);
+extern PangoFont *sc_interp_get_font(SCInterpreter *scin);
+extern PangoFontDescription *sc_interp_get_fontdesc(SCInterpreter *scin);
+extern double *sc_interp_get_fgcol(SCInterpreter *scin);
+extern int sc_interp_get_ascent(SCInterpreter *scin);
+extern int sc_interp_get_height(SCInterpreter *scin);
+
#endif /* SC_INTERP_H */
diff --git a/src/sc_parse.c b/src/sc_parse.c
index b94f548..aeb9ea9 100644
--- a/src/sc_parse.c
+++ b/src/sc_parse.c
@@ -42,6 +42,8 @@ struct _scblock
SCBlock *next;
SCBlock *prev;
SCBlock *child;
+
+ struct frame *fr;
};
@@ -86,6 +88,18 @@ const char *sc_block_contents(const SCBlock *bl)
}
+struct frame *sc_block_frame(const SCBlock *bl)
+{
+ return bl->fr;
+}
+
+
+void sc_block_set_frame(SCBlock *bl, struct frame *fr)
+{
+ bl->fr = fr;
+}
+
+
/* Insert a new block after "bl". "name", "options" and "contents"
* will not be copied. Returns the block just created, or NULL on error.
* If *blfp points to NULL, it will updated to point at the new block. */
diff --git a/src/sc_parse.h b/src/sc_parse.h
index fd3e221..b5d2c5c 100644
--- a/src/sc_parse.h
+++ b/src/sc_parse.h
@@ -39,6 +39,9 @@ extern const char *sc_block_name(const SCBlock *bl);
extern const char *sc_block_options(const SCBlock *bl);
extern const char *sc_block_contents(const SCBlock *bl);
+extern struct frame *sc_block_frame(const SCBlock *bl);
+extern void sc_block_set_frame(SCBlock *bl, struct frame *fr);
+
extern void show_sc_blocks(const SCBlock *bl);
extern void show_sc_block(const SCBlock *bl, const char *prefix);
diff --git a/src/shape.c b/src/shape.c
index 93625e0..a3f2292 100644
--- a/src/shape.c
+++ b/src/shape.c
@@ -63,12 +63,13 @@ static void shape_and_measure(gpointer data, gpointer user_data)
/* Add "text", followed by a space of type "space", to "line" */
static int add_wrap_box(struct wrap_line *line, char *text, size_t offset,
enum wrap_box_space space, PangoContext *pc,
- struct sc_font *font, int editable)
+ SCInterpreter *scin, int editable)
{
GList *pango_items;
struct wrap_box *box;
PangoAttrList *attrs;
PangoAttribute *attr;
+ double *col;
if ( line->n_boxes == line->max_boxes ) {
line->max_boxes += 32;
@@ -82,15 +83,16 @@ static int add_wrap_box(struct wrap_line *line, char *text, size_t offset,
box->type = WRAP_BOX_PANGO;
box->text = text;
box->space = space;
- box->font = font->font;
+ box->font = sc_interp_get_font(scin);
box->width = 0;
box->editable = editable;
- box->ascent = font->ascent;
- box->height = font->height;
- box->col[0] = font->col[0]; /* Red */
- box->col[1] = font->col[1]; /* Green */
- box->col[2] = font->col[2]; /* Blue */
- box->col[3] = font->col[3]; /* Alpha */
+ box->ascent = sc_interp_get_ascent(scin);
+ box->height = sc_interp_get_height(scin);
+ col = sc_interp_get_fgcol(scin);
+ box->col[0] = col[0]; /* Red */
+ box->col[1] = col[1]; /* Green */
+ box->col[2] = col[2]; /* Blue */
+ box->col[3] = col[3]; /* Alpha */
line->n_boxes++;
if ( strlen(text) == 0 ) {
@@ -99,7 +101,7 @@ static int add_wrap_box(struct wrap_line *line, char *text, size_t offset,
}
attrs = pango_attr_list_new();
- attr = pango_attr_font_desc_new(font->fontdesc);
+ attr = pango_attr_font_desc_new(sc_interp_get_fontdesc(scin));
pango_attr_list_insert_before(attrs, attr);
pango_items = pango_itemize(pc, text, 0, strlen(text), attrs, NULL);
g_list_foreach(pango_items, shape_and_measure, box);
@@ -131,7 +133,7 @@ static void add_image_box(struct wrap_line *line, const char *filename,
int split_words(struct wrap_line *boxes, PangoContext *pc, const char *text,
- PangoLanguage *lang, int editable, struct sc_font *font)
+ PangoLanguage *lang, int editable, SCInterpreter *scin)
{
PangoLogAttr *log_attrs;
glong len_chars, i;
@@ -188,7 +190,7 @@ int split_words(struct wrap_line *boxes, PangoContext *pc, const char *text,
}
if ( add_wrap_box(boxes, word, start, type,
- pc, font, editable) ) {
+ pc, scin, editable) ) {
fprintf(stderr, "Failed to add wrap box.\n");
}
start = offs;
@@ -216,14 +218,14 @@ int split_words(struct wrap_line *boxes, PangoContext *pc, const char *text,
word2 = strndup(word, l-1);
add_wrap_box(boxes, word2, start,
- WRAP_SPACE_EOP, pc, font, editable);
+ WRAP_SPACE_EOP, pc, scin, editable);
add_wrap_box(boxes, strdup(""), len_bytes,
- WRAP_SPACE_NONE, pc, font, editable);
+ WRAP_SPACE_NONE, pc, scin, editable);
} else {
add_wrap_box(boxes, word, start,
- WRAP_SPACE_NONE, pc, font, editable);
+ WRAP_SPACE_NONE, pc, scin, editable);
}
diff --git a/src/shape.h b/src/shape.h
index 3e218f4..77d9c3f 100644
--- a/src/shape.h
+++ b/src/shape.h
@@ -33,6 +33,6 @@
extern int split_words(struct wrap_line *boxes, PangoContext *pc,
const char *text, PangoLanguage *lang, int editable,
- struct sc_font *font);
+ SCInterpreter *scin);
#endif /* SHAPE_H */