Mercurial > mplayer.hg
annotate libass/ass_utils.h @ 36650:8b2c68d6fd89
Enable specifying a font file in the GUI preferences.
This has been broken since the introduction of Fontconfig.
Since Fontconfig is selecting fonts by font patterns and the GUI does so
by selecting a font file, it is necessary to temporarily disable
fontconfig font handling if there is a directory separator character
found in the name (or pattern) of the font to be used, i.e. assume the
font name to be a pattern if and only if it doesn't contain a directory
separator character.
Thus set option 'fontconfig' depending on font_name. Set it in guiInit()
for the font possibly given in a configuration file or on the command
line, and set it in mplayerLoadFont() whenever it is affected by GUI
preferences settings.
(Although the font selection dialog only allows files to be selected,
it is possible to simply enter a fontconfig font pattern in the
preferences' text entry field - or to enter it directly into the GUI
configuration file or to specify on the command line, both of which
always is possible.)
author | ib |
---|---|
date | Sun, 26 Jan 2014 16:40:49 +0000 (2014-01-26) |
parents | c3aaaf17c721 |
children |
rev | line source |
---|---|
20008
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
1 /* |
26723 | 2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com> |
3 * | |
26738
588ce97b44f2
Speak of libass instead of MPlayer in the libass license headers.
diego
parents:
26723
diff
changeset
|
4 * This file is part of libass. |
26723 | 5 * |
34011 | 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. | |
26723 | 9 * |
34011 | 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. | |
26723 | 17 */ |
20008
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
18 |
25897
aaebaf255b23
Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents:
25535
diff
changeset
|
19 #ifndef LIBASS_UTILS_H |
aaebaf255b23
Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents:
25535
diff
changeset
|
20 #define LIBASS_UTILS_H |
18937 | 21 |
30200 | 22 #include <stdio.h> |
23 #include <stdarg.h> | |
26138
74055622161d
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26036
diff
changeset
|
24 #include <stdint.h> |
30200 | 25 #include <stdlib.h> |
26 #include <string.h> | |
27 #include <assert.h> | |
26138
74055622161d
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
26036
diff
changeset
|
28 |
30200 | 29 #ifdef CONFIG_ENCA |
30 #include <enca.h> | |
31 #endif | |
32 | |
33 #include "ass.h" | |
34 | |
35 #define MSGL_FATAL 0 | |
36 #define MSGL_ERR 1 | |
37 #define MSGL_WARN 2 | |
38 #define MSGL_INFO 4 | |
39 #define MSGL_V 6 | |
40 #define MSGL_DBG2 7 | |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
41 |
30200 | 42 #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) |
43 #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) | |
44 #define FFMINMAX(c,a,b) FFMIN(FFMAX(c, a), b) | |
45 | |
46 int mystrtoi(char **p, int *res); | |
47 int mystrtoll(char **p, long long *res); | |
48 int mystrtou32(char **p, int base, uint32_t *res); | |
49 int mystrtod(char **p, double *res); | |
50 int strtocolor(ASS_Library *library, char **q, uint32_t *res, int hex); | |
51 char parse_bool(char *str); | |
36363 | 52 int parse_ycbcr_matrix(char *str); |
30200 | 53 unsigned ass_utf8_get_char(char **str); |
54 void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...); | |
35262 | 55 int lookup_style(ASS_Track *track, char *name); |
30200 | 56 #ifdef CONFIG_ENCA |
57 void *ass_guess_buffer_cp(ASS_Library *library, unsigned char *buffer, | |
58 int buflen, char *preferred_language, | |
59 char *fallback); | |
60 #endif | |
61 | |
62 /* defined in ass_strtod.c */ | |
63 double ass_strtod(const char *string, char **endPtr); | |
64 | |
65 static inline int d6_to_int(int x) | |
66 { | |
67 return (x + 32) >> 6; | |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
68 } |
30200 | 69 static inline int d16_to_int(int x) |
70 { | |
71 return (x + 32768) >> 16; | |
72 } | |
73 static inline int int_to_d6(int x) | |
74 { | |
75 return x << 6; | |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
76 } |
30200 | 77 static inline int int_to_d16(int x) |
78 { | |
79 return x << 16; | |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
80 } |
30200 | 81 static inline int d16_to_d6(int x) |
82 { | |
83 return (x + 512) >> 10; | |
84 } | |
85 static inline int d6_to_d16(int x) | |
86 { | |
87 return x << 10; | |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
88 } |
30200 | 89 static inline double d6_to_double(int x) |
90 { | |
91 return x / 64.; | |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
92 } |
30200 | 93 static inline int double_to_d6(double x) |
94 { | |
95 return (int) (x * 64); | |
96 } | |
97 static inline double d16_to_double(int x) | |
98 { | |
99 return ((double) x) / 0x10000; | |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
100 } |
30200 | 101 static inline int double_to_d16(double x) |
102 { | |
103 return (int) (x * 0x10000); | |
23299
0ee56ec36a40
Limit ass_font_set_transform to nonrotating transformations.
eugeni
parents:
22213
diff
changeset
|
104 } |
30200 | 105 static inline double d22_to_double(int x) |
106 { | |
107 return ((double) x) / 0x400000; | |
108 } | |
109 static inline int double_to_d22(double x) | |
110 { | |
111 return (int) (x * 0x400000); | |
23299
0ee56ec36a40
Limit ass_font_set_transform to nonrotating transformations.
eugeni
parents:
22213
diff
changeset
|
112 } |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
113 |
30200 | 114 // Calculate cache key for a rotational angle in degrees |
115 static inline int rot_key(double a) | |
116 { | |
117 const int m = double_to_d22(360.0); | |
118 return double_to_d22(a) % m; | |
119 } | |
120 | |
121 #define FNV1_32A_INIT (unsigned)0x811c9dc5 | |
122 | |
123 static inline unsigned fnv_32a_buf(void *buf, size_t len, unsigned hval) | |
124 { | |
125 unsigned char *bp = buf; | |
126 unsigned char *be = bp + len; | |
127 while (bp < be) { | |
128 hval ^= (unsigned) *bp++; | |
129 hval += | |
130 (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + | |
131 (hval << 24); | |
132 } | |
133 return hval; | |
134 } | |
135 static inline unsigned fnv_32a_str(char *str, unsigned hval) | |
136 { | |
137 unsigned char *s = (unsigned char *) str; | |
138 while (*s) { | |
139 hval ^= (unsigned) *s++; | |
140 hval += | |
141 (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + | |
142 (hval << 24); | |
143 } | |
144 return hval; | |
145 } | |
146 | |
147 #endif /* LIBASS_UTILS_H */ |