]> granicus.if.org Git - libass/blob - libass/ass_drawing.h
Message callback funtionality
[libass] / libass / ass_drawing.h
1 /*
2  * Copyright (C) 2009 Grigori Goronzy <greg@geekmind.org>
3  *
4  * This file is part of libass.
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18
19 #ifndef LIBASS_DRAWING_H
20 #define LIBASS_DRAWING_H
21
22 #include <ft2build.h>
23 #include FT_GLYPH_H
24
25 #include "ass.h"
26
27 #define DRAWING_INITIAL_SIZE 256
28
29 enum ass_token_type {
30     TOKEN_MOVE,
31     TOKEN_MOVE_NC,
32     TOKEN_LINE,
33     TOKEN_CUBIC_BEZIER,
34     TOKEN_CONIC_BEZIER,
35     TOKEN_B_SPLINE,
36     TOKEN_EXTEND_SPLINE,
37     TOKEN_CLOSE
38 };
39
40 typedef struct ass_drawing_token_s {
41     enum ass_token_type type;
42     FT_Vector point;
43     struct ass_drawing_token_s *next;
44     struct ass_drawing_token_s *prev;
45 } ass_drawing_token_t;
46
47 typedef struct ass_drawing_s {
48     char *text; // drawing string
49     int i;      // text index
50     int scale;  // scale (1-64) for subpixel accuracy
51     double pbo; // drawing will be shifted in y direction by this amount
52     double scale_x;     // FontScaleX
53     double scale_y;     // FontScaleY
54     int asc;            // ascender
55     int desc;           // descender
56     FT_OutlineGlyph glyph;  // the "fake" glyph created for later rendering
57     int hash;           // hash value (for caching)
58
59     // private
60     FT_Library ftlibrary;   // FT library instance, needed for font ops
61     ass_library_t *library;
62     int size;           // current buffer size
63     ass_drawing_token_t *tokens;    // tokenized drawing
64     int max_points;     // current maximum size
65     int max_contours;
66     double point_scale_x;
67     double point_scale_y;
68 } ass_drawing_t;
69
70 ass_drawing_t *ass_drawing_new(void *fontconfig_priv, ass_font_t *font,
71                                ass_hinting_t hint, FT_Library lib);
72 void ass_drawing_free(ass_drawing_t* drawing);
73 void ass_drawing_add_char(ass_drawing_t* drawing, char symbol);
74 void ass_drawing_hash(ass_drawing_t* drawing);
75 FT_OutlineGlyph *ass_drawing_parse(ass_drawing_t *drawing);
76
77 #endif /* LIBASS_DRAWING_H */