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_OUTLINE_H
24 
25 #include "ass.h"
26 #include "ass_bitmap.h"
27 
28 typedef enum {
29     TOKEN_MOVE,
30     TOKEN_MOVE_NC,
31     TOKEN_LINE,
32     TOKEN_CUBIC_BEZIER,
33     TOKEN_CONIC_BEZIER,
34     TOKEN_B_SPLINE,
35     TOKEN_EXTEND_SPLINE,
36     TOKEN_CLOSE
37 } ASS_TokenType;
38 
39 typedef struct ass_drawing_token {
40     ASS_TokenType type;
41     FT_Vector point;
42     struct ass_drawing_token *next;
43     struct ass_drawing_token *prev;
44 } ASS_DrawingToken;
45 
46 typedef struct {
47     char *text; // drawing string
48     int scale;  // scale (1-64) for subpixel accuracy
49     double pbo; // drawing will be shifted in y direction by this amount
50     double scale_x;     // FontScaleX
51     double scale_y;     // FontScaleY
52     int asc;            // ascender
53     int desc;           // descender
54     ASS_Outline outline; // target outline
55     FT_Vector advance;  // advance (from cbox)
56     int hash;           // hash value (for caching)
57 
58     // private
59     FT_Library ftlibrary;   // needed for font ops
60     ASS_Library *library;
61     ASS_DrawingToken *tokens;    // tokenized drawing
62     double point_scale_x;
63     double point_scale_y;
64     FT_BBox cbox;   // bounding box, or let's say... VSFilter's idea of it
65 } ASS_Drawing;
66 
67 ASS_Drawing *ass_drawing_new(ASS_Library *lib, FT_Library ftlib);
68 void ass_drawing_free(ASS_Drawing* drawing);
69 void ass_drawing_set_text(ASS_Drawing* drawing, char *str, size_t n);
70 void ass_drawing_hash(ASS_Drawing* drawing);
71 ASS_Outline *ass_drawing_parse(ASS_Drawing *drawing, int raw_mode);
72 
73 #endif /* LIBASS_DRAWING_H */
74