/* * render_cairo_common.c * * Copyright © 2019 Thomas White * * This file is part of Colloquium. * * Colloquium is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "storycode.h" int runs_to_pangolayout(PangoLayout *layout, struct text_run *runs, int n_runs) { size_t total_len = 0; int i; char *text; PangoAttrList *attrs; attrs = pango_layout_get_attributes(layout); /* Work out length of all text in item (paragraph) */ for ( i=0; istart_index = pos; attr->end_index = pos + run_len; pango_attr_list_insert(attrs, attr); } /* FIXME: Should check that each bit of text finishes on a character boundary */ pos += run_len; strcat(text, runs[i].text); } pango_layout_set_text(layout, text, -1); return 0; } PangoAlignment to_pangoalignment(enum alignment align) { switch ( align ) { case ALIGN_LEFT : return PANGO_ALIGN_LEFT; case ALIGN_RIGHT : return PANGO_ALIGN_RIGHT; case ALIGN_CENTER : return PANGO_ALIGN_CENTER; default: return PANGO_ALIGN_LEFT; } }