1 // pangotext.h
2 // text handling code
3 // (c) A. Penkov 2010
4 // pieces of code taken and modified from scribbler.c
5 // released under the GNU GPL 3 or later
6 // see file COPYING or www.gnu.org for details
7 
8 // (c) G. Finch 2002 - 2015
9 
10 #ifndef LIVES_PANGOTEXT_H
11 #define LIVES_PANGOTEXT_H
12 
13 #define SUB_OPACITY 20480 // TODO
14 
15 typedef enum {
16   SUBTITLE_TYPE_NONE = 0,
17   SUBTITLE_TYPE_SRT,
18   SUBTITLE_TYPE_SUB
19 } lives_subtitle_type_t;
20 
21 // for future use
22 typedef struct {
23   lives_colRGB48_t fg;
24   lives_colRGB48_t bg;
25 } lives_subtitle_style_t;
26 
27 typedef struct _lives_subtitle_t xlives_subtitle_t;
28 
29 typedef struct _lives_subtitle_t {
30   double start_time;
31   double end_time;
32   lives_subtitle_style_t *style; ///< for future use
33   long textpos;
34   xlives_subtitle_t *prev; ///< for future use
35   xlives_subtitle_t *next;
36 } lives_subtitle_t;
37 
38 typedef struct {
39   lives_subtitle_type_t type;
40   int tfile;
41   char *text;
42   lives_subtitle_t *current; ///< pointer to current entry in index
43   lives_subtitle_t *first;
44   lives_subtitle_t *last;
45   int offset; ///< offset in frames (default 0)
46   double last_time;
47 } lives_subtitles_t;
48 
49 typedef enum {
50   LIVES_TEXT_MODE_FOREGROUND_ONLY,
51   LIVES_TEXT_MODE_FOREGROUND_AND_BACKGROUND,
52   LIVES_TEXT_MODE_BACKGROUND_ONLY,
53   LIVES_TEXT_MODE_PRECALCULATE
54 } lives_text_mode_t;
55 
56 char **get_font_list(void);
57 
58 weed_plant_t *render_text_overlay(weed_layer_t *layer, const char *text);
59 
60 weed_plant_t *render_text_to_layer(weed_layer_t *layer, const char *text, const char *fontname,
61                                    double size, lives_text_mode_t mode, lives_colRGBA64_t *fg_col,
62                                    lives_colRGBA64_t *bg_col, boolean center, boolean rising, double top);
63 
64 LingoLayout *render_text_to_cr(LiVESWidget *widget, lives_painter_t *, const char *text, const char *fontname,
65                                double size, lives_text_mode_t mode, lives_colRGBA64_t *fg_col, lives_colRGBA64_t *bg_col,
66                                boolean center, boolean rising, double *top, int *start, int dwidth, int *dheight);
67 
68 void layout_to_lives_painter(LingoLayout *layout, lives_painter_t *cr, lives_text_mode_t mode, lives_colRGBA64_t *fg,
69                              lives_colRGBA64_t *bg, int dwidth, int dheight, double x_bg, double y_bg, double x_text, double y_text);
70 
71 LingoLayout *layout_nth_message_at_bottom(int n, int width, int height, LiVESWidget *widget, int *linecount);
72 
73 /// subtitles
74 
75 #define SRT_DEF_CHARSET "Windows-1252"
76 #define LIVES_CHARSET_UTF8 "UTF-8"
77 
78 typedef struct _lives_clip_t lives_clip_t;
79 
80 boolean subtitles_init(lives_clip_t *sfile, char *fname, lives_subtitle_type_t);
81 void subtitles_free(lives_clip_t *sfile);
82 boolean get_subt_text(lives_clip_t *sfile, double xtime);
83 boolean save_sub_subtitles(lives_clip_t *sfile, double start_time, double end_time, double offset_time, const char *filename);
84 boolean save_srt_subtitles(lives_clip_t *sfile, double start_time, double end_time, double offset_time, const char *filename);
85 
86 boolean lives_parse_font_string(const char *string, char **font, int *size, char **stretch,
87                                 char **style, char **weight);
88 
89 #endif
90 
91