shaper: add hack to workaround grid-fitting
[libass.git] / libass / ass_drawing.h
blobb17d7e3beadaee57aae2bd7c244549678016d651
1 /*
2 * Copyright (C) 2009 Grigori Goronzy <greg@geekmind.org>
4 * This file is part of libass.
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.
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.
19 #ifndef LIBASS_DRAWING_H
20 #define LIBASS_DRAWING_H
22 #include <ft2build.h>
23 #include FT_OUTLINE_H
25 #include "ass.h"
27 #define DRAWING_INITIAL_SIZE 256
29 typedef enum {
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 } ASS_TokenType;
40 typedef struct ass_drawing_token {
41 ASS_TokenType type;
42 FT_Vector point;
43 struct ass_drawing_token *next;
44 struct ass_drawing_token *prev;
45 } ASS_DrawingToken;
47 typedef struct {
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_Outline outline; // target outline
57 FT_Vector advance; // advance (from cbox)
58 int hash; // hash value (for caching)
60 // private
61 FT_Library ftlibrary; // needed for font ops
62 ASS_Library *library;
63 int size; // current buffer size
64 ASS_DrawingToken *tokens; // tokenized drawing
65 int max_points; // current maximum size
66 int max_contours;
67 double point_scale_x;
68 double point_scale_y;
69 FT_BBox cbox; // bounding box, or let's say... VSFilter's idea of it
70 } ASS_Drawing;
72 ASS_Drawing *ass_drawing_new(ASS_Library *lib, FT_Library ftlib);
73 void ass_drawing_free(ASS_Drawing* drawing);
74 void ass_drawing_add_char(ASS_Drawing* drawing, char symbol);
75 void ass_drawing_hash(ASS_Drawing* drawing);
76 FT_Outline *ass_drawing_parse(ASS_Drawing *drawing, int raw_mode);
78 #endif /* LIBASS_DRAWING_H */