Mercurial > mplayer.hg
annotate libvo/font_load_ft.c @ 22696:3eba30a92c20
Remove empty directory.
author | diego |
---|---|
date | Sun, 18 Mar 2007 13:08:10 +0000 |
parents | ee21c7dff35f |
children | 2a66d95355f0 |
rev | line source |
---|---|
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1 /* |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
2 * Renders antialiased fonts for mplayer using freetype library. |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
3 * Should work with TrueType, Type1 and any other font supported by libfreetype. |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
4 * |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
5 * Artur Zaprzala <zybi@fanthom.irc.pl> |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
6 * |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
7 * ported inside mplayer by Jindrich Makovicka |
20646 | 8 * <makovick@gmail.com> |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
9 * |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
10 */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
11 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
12 #include "config.h" |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
13 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
14 #include <stdio.h> |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
15 #include <stdlib.h> |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
16 #include <math.h> |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
17 #include <string.h> |
7147
0541f7fb59bf
libgen.h is glibc specific, and not used at all -> removed
arpi
parents:
7140
diff
changeset
|
18 |
17931
ed9950b8200d
The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other
albeu
parents:
17566
diff
changeset
|
19 #ifdef USE_ICONV |
7147
0541f7fb59bf
libgen.h is glibc specific, and not used at all -> removed
arpi
parents:
7140
diff
changeset
|
20 #include <iconv.h> |
17931
ed9950b8200d
The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other
albeu
parents:
17566
diff
changeset
|
21 #endif |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
22 |
11500 | 23 #include <ft2build.h> |
24 #include FT_FREETYPE_H | |
25 #include FT_GLYPH_H | |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
26 |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
27 #ifdef HAVE_FONTCONFIG |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
28 #include <fontconfig/fontconfig.h> |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
29 #endif |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
30 |
21372 | 31 #include "libavutil/common.h" |
21507
fa99b3d31d13
Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents:
21501
diff
changeset
|
32 #include "mpbswap.h" |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
33 #include "font_load.h" |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
34 #include "mp_msg.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13632
diff
changeset
|
35 #include "mplayer.h" |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
36 #include "osd_font.h" |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
37 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
38 #if (FREETYPE_MAJOR > 2) || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 1) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
39 #define HAVE_FREETYPE21 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
40 #endif |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
41 |
18889
e60c8c7399d2
get_path as const, patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18878
diff
changeset
|
42 char *get_path(const char *filename); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
43 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
44 char *subtitle_font_encoding = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
45 float text_font_scale_factor = 5.0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
46 float osd_font_scale_factor = 6.0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
47 float subtitle_font_radius = 2.0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
48 float subtitle_font_thickness = 2.0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
49 // 0 = no autoscale |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
50 // 1 = video height |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
51 // 2 = video width |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
52 // 3 = diagonal |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
53 int subtitle_autoscale = 3; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
54 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
55 int vo_image_width = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
56 int vo_image_height = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
57 int force_load_font; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
58 |
8635
81dbd28ef7c0
these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents:
8123
diff
changeset
|
59 int using_freetype = 0; |
11584 | 60 int font_fontconfig = 0; |
8635
81dbd28ef7c0
these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents:
8123
diff
changeset
|
61 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
62 //// constants |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
63 static unsigned int const colors = 256; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
64 static unsigned int const maxcolor = 255; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
65 static unsigned const base = 256; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
66 static unsigned const first_char = 33; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
67 #define MAX_CHARSET_SIZE 60000 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
68 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
69 static FT_Library library; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
70 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
71 #define OSD_CHARSET_SIZE 15 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
72 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
73 static FT_ULong osd_charset[OSD_CHARSET_SIZE] = |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
74 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
75 0xe001, 0xe002, 0xe003, 0xe004, 0xe005, 0xe006, 0xe007, 0xe008, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
76 0xe009, 0xe00a, 0xe00b, 0xe010, 0xe011, 0xe012, 0xe013 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
77 }; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
78 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
79 static FT_ULong osd_charcodes[OSD_CHARSET_SIZE] = |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
80 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
81 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
82 0x09,0x0a,0x0b,0x10,0x11,0x12,0x13 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
83 }; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
84 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
85 #define f266ToInt(x) (((x)+32)>>6) // round fractional fixed point number to integer |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
86 // coordinates are in 26.6 pixels (i.e. 1/64th of pixels) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
87 #define f266CeilToInt(x) (((x)+63)>>6) // ceiling |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
88 #define f266FloorToInt(x) ((x)>>6) // floor |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
89 #define f1616ToInt(x) (((x)+0x8000)>>16) // 16.16 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
90 #define floatTof266(x) ((int)((x)*(1<<6)+0.5)) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
91 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
92 #define ALIGN(x) (((x)+7)&~7) // 8 byte align |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
93 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
94 #define WARNING(msg, args...) mp_msg(MSGT_OSD, MSGL_WARN, msg "\n", ## args) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
95 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
96 #define DEBUG 0 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
97 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
98 //static double ttime; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
99 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
100 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
101 static void paste_bitmap(unsigned char *bbuffer, FT_Bitmap *bitmap, int x, int y, int width, int height, int bwidth) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
102 int drow = x+y*width; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
103 int srow = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
104 int sp, dp, w, h; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
105 if (bitmap->pixel_mode==ft_pixel_mode_mono) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
106 for (h = bitmap->rows; h>0 && height > 0; --h, height--, drow+=width, srow+=bitmap->pitch) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
107 for (w = bwidth, sp=dp=0; w>0; --w, ++dp, ++sp) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
108 bbuffer[drow+dp] = (bitmap->buffer[srow+sp/8] & (0x80>>(sp%8))) ? 255:0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
109 else |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
110 for (h = bitmap->rows; h>0 && height > 0; --h, height--, drow+=width, srow+=bitmap->pitch) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
111 for (w = bwidth, sp=dp=0; w>0; --w, ++dp, ++sp) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
112 bbuffer[drow+dp] = bitmap->buffer[srow+sp]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
113 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
114 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
115 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
116 static int check_font(font_desc_t *desc, float ppem, int padding, int pic_idx, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
117 int charset_size, FT_ULong *charset, FT_ULong *charcodes, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
118 int unicode) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
119 FT_Error error; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
120 FT_Face face = desc->faces[pic_idx]; |
15440 | 121 int const load_flags = FT_LOAD_DEFAULT; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
122 int ymin = INT_MAX, ymax = INT_MIN; |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
123 int space_advance = 20; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
124 int width, height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
125 unsigned char *bbuffer; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
126 int i, uni_charmap = 1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
127 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
128 error = FT_Select_Charmap(face, ft_encoding_unicode); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
129 // fprintf(stderr, "select unicode charmap: %d\n", error); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
130 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
131 if (face->charmap==NULL || face->charmap->encoding!=ft_encoding_unicode) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
132 WARNING("Unicode charmap not available for this font. Very bad!"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
133 uni_charmap = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
134 error = FT_Set_Charmap(face, face->charmaps[0]); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
135 if (error) WARNING("No charmaps! Strange."); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
136 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
137 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
138 /* set size */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
139 if (FT_IS_SCALABLE(face)) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
140 error = FT_Set_Char_Size(face, 0, floatTof266(ppem), 0, 0); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
141 if (error) WARNING("FT_Set_Char_Size failed."); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
142 } else { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
143 int j = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
144 int jppem = face->available_sizes[0].height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
145 /* find closest size */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
146 for (i = 0; i<face->num_fixed_sizes; ++i) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
147 if (fabs(face->available_sizes[i].height - ppem) < abs(face->available_sizes[i].height - jppem)) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
148 j = i; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
149 jppem = face->available_sizes[i].height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
150 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
151 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
152 WARNING("Selected font is not scalable. Using ppem=%i.", face->available_sizes[j].height); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
153 error = FT_Set_Pixel_Sizes(face, face->available_sizes[j].width, face->available_sizes[j].height); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
154 if (error) WARNING("FT_Set_Pixel_Sizes failed."); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
155 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
156 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
157 if (FT_IS_FIXED_WIDTH(face)) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
158 WARNING("Selected font is fixed-width."); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
159 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
160 /* compute space advance */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
161 error = FT_Load_Char(face, ' ', load_flags); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
162 if (error) WARNING("spacewidth set to default."); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
163 else space_advance = f266ToInt(face->glyph->advance.x); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
164 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
165 if (!desc->spacewidth) desc->spacewidth = 2*padding + space_advance; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
166 if (!desc->charspace) desc->charspace = -2*padding; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
167 if (!desc->height) desc->height = f266ToInt(face->size->metrics.height); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
168 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
169 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
170 for (i= 0; i<charset_size; ++i) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
171 FT_ULong character, code; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
172 FT_UInt glyph_index; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
173 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
174 character = charset[i]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
175 code = charcodes[i]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
176 desc->font[unicode?character:code] = pic_idx; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
177 // get glyph index |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
178 if (character==0) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
179 glyph_index = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
180 else { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
181 glyph_index = FT_Get_Char_Index(face, uni_charmap ? character:code); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
182 if (glyph_index==0) { |
19204
17acc0a995e2
Fixes the format string for the warning message on line 182 (%x
diego
parents:
18980
diff
changeset
|
183 WARNING("Glyph for char 0x%02lx|U+%04lX|%c not found.", code, character, |
17acc0a995e2
Fixes the format string for the warning message on line 182 (%x
diego
parents:
18980
diff
changeset
|
184 code<' '||code>255 ? '.':(char)code); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
185 desc->font[unicode?character:code] = -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
186 continue; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
187 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
188 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
189 desc->glyph_index[unicode?character:code] = glyph_index; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
190 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
191 // fprintf(stderr, "font height: %lf\n", (double)(face->bbox.yMax-face->bbox.yMin)/(double)face->units_per_EM*ppem); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
192 // fprintf(stderr, "font width: %lf\n", (double)(face->bbox.xMax-face->bbox.xMin)/(double)face->units_per_EM*ppem); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
193 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
194 ymax = (double)(face->bbox.yMax)/(double)face->units_per_EM*ppem+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
195 ymin = (double)(face->bbox.yMin)/(double)face->units_per_EM*ppem-1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
196 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
197 width = ppem*(face->bbox.xMax-face->bbox.xMin)/face->units_per_EM+3+2*padding; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
198 if (desc->max_width < width) desc->max_width = width; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
199 width = ALIGN(width); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
200 desc->pic_b[pic_idx]->charwidth = width; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
201 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
202 if (width <= 0) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
203 mp_msg(MSGT_OSD, MSGL_ERR, "Wrong bounding box, width <= 0 !\n"); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
204 return -1; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
205 } |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
206 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
207 if (ymax<=ymin) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
208 mp_msg(MSGT_OSD, MSGL_ERR, "Something went wrong. Use the source!\n"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
209 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
210 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
211 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
212 height = ymax - ymin + 2*padding; |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
213 if (height <= 0) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
214 mp_msg(MSGT_OSD, MSGL_ERR, "Wrong bounding box, height <= 0 !\n"); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
215 return -1; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
216 } |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
217 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
218 if (desc->max_height < height) desc->max_height = height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
219 desc->pic_b[pic_idx]->charheight = height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
220 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
221 // fprintf(stderr, "font height2: %d\n", height); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
222 desc->pic_b[pic_idx]->baseline = ymax + padding; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
223 desc->pic_b[pic_idx]->padding = padding; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
224 desc->pic_b[pic_idx]->current_alloc = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
225 desc->pic_b[pic_idx]->current_count = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
226 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
227 bbuffer = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
228 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
229 desc->pic_b[pic_idx]->w = width; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
230 desc->pic_b[pic_idx]->h = height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
231 desc->pic_b[pic_idx]->c = colors; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
232 desc->pic_b[pic_idx]->bmp = bbuffer; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
233 desc->pic_b[pic_idx]->pen = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
234 return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
235 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
236 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
237 // general outline |
18950 | 238 static void outline( |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
239 unsigned char *s, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
240 unsigned char *t, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
241 int width, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
242 int height, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
243 int stride, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
244 unsigned char *m, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
245 int r, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
246 int mwidth, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
247 int msize) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
248 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
249 int x, y; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
250 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
251 for (y = 0; y<height; y++) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
252 for (x = 0; x<width; x++) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
253 const int src= s[x]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
254 if(src==0) continue; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
255 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
256 const int x1=(x<r) ? r-x : 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
257 const int y1=(y<r) ? r-y : 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
258 const int x2=(x+r>=width ) ? r+width -x : 2*r+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
259 const int y2=(y+r>=height) ? r+height-y : 2*r+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
260 register unsigned char *dstp= t + (y1+y-r)* stride + x-r; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
261 //register int *mp = m + y1 *mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
262 register unsigned char *mp= m + msize*src + y1*mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
263 int my; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
264 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
265 for(my= y1; my<y2; my++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
266 register int mx; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
267 for(mx= x1; mx<x2; mx++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
268 if(dstp[mx] < mp[mx]) dstp[mx]= mp[mx]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
269 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
270 dstp+=stride; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
271 mp+=mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
272 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
273 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
274 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
275 s+= stride; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
276 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
277 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
278 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
279 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
280 // 1 pixel outline |
18950 | 281 static void outline1( |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
282 unsigned char *s, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
283 unsigned char *t, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
284 int width, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
285 int height, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
286 int stride) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
287 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
288 int x, y; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
289 int skip = stride-width; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
290 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
291 for (x = 0; x<width; ++x, ++s, ++t) *t = *s; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
292 s += skip; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
293 t += skip; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
294 for (y = 1; y<height-1; ++y) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
295 *t++ = *s++; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
296 for (x = 1; x<width-1; ++x, ++s, ++t) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
297 unsigned v = ( |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
298 s[-1-stride]+ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
299 s[-1+stride]+ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
300 s[+1-stride]+ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
301 s[+1+stride] |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
302 )/2 + ( |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
303 s[-1]+ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
304 s[+1]+ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
305 s[-stride]+ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
306 s[+stride]+ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
307 s[0] |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
308 ); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
309 *t = v>maxcolor ? maxcolor : v; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
310 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
311 *t++ = *s++; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
312 s += skip; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
313 t += skip; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
314 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
315 for (x = 0; x<width; ++x, ++s, ++t) *t = *s; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
316 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
317 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
318 // "0 pixel outline" |
18950 | 319 static void outline0( |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
320 unsigned char *s, |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
321 unsigned char *t, |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
322 int width, |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
323 int height, |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
324 int stride) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
325 int y; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
326 for (y = 0; y<height; ++y) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
327 memcpy(t, s, width); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
328 s += stride; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
329 t += stride; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
330 } |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
331 } |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
332 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
333 // gaussian blur |
19847 | 334 void blur( |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
335 unsigned char *buffer, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
336 unsigned short *tmp2, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
337 int width, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
338 int height, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
339 int stride, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
340 int *m2, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
341 int r, |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
342 int mwidth) { |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
343 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
344 int x, y; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
345 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
346 unsigned char *s = buffer; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
347 unsigned short *t = tmp2+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
348 for(y=0; y<height; y++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
349 memset(t-1, 0, (width+1)*sizeof(short)); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
350 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
351 for(x=0; x<r; x++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
352 const int src= s[x]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
353 if(src){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
354 register unsigned short *dstp= t + x-r; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
355 int mx; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
356 unsigned *m3= m2 + src*mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
357 for(mx=r-x; mx<mwidth; mx++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
358 dstp[mx]+= m3[mx]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
359 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
360 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
361 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
362 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
363 for(; x<width-r; x++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
364 const int src= s[x]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
365 if(src){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
366 register unsigned short *dstp= t + x-r; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
367 int mx; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
368 unsigned *m3= m2 + src*mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
369 for(mx=0; mx<mwidth; mx++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
370 dstp[mx]+= m3[mx]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
371 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
372 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
373 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
374 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
375 for(; x<width; x++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
376 const int src= s[x]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
377 if(src){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
378 register unsigned short *dstp= t + x-r; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
379 int mx; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
380 const int x2= r+width -x; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
381 unsigned *m3= m2 + src*mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
382 for(mx=0; mx<x2; mx++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
383 dstp[mx]+= m3[mx]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
384 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
385 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
386 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
387 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
388 s+= stride; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
389 t+= width + 1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
390 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
391 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
392 t = tmp2; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
393 for(x=0; x<width; x++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
394 for(y=0; y<r; y++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
395 unsigned short *srcp= t + y*(width+1) + 1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
396 int src= *srcp; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
397 if(src){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
398 register unsigned short *dstp= srcp - 1 + width+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
399 const int src2= (src + 128)>>8; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
400 unsigned *m3= m2 + src2*mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
401 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
402 int mx; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
403 *srcp= 128; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
404 for(mx=r-1; mx<mwidth; mx++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
405 *dstp += m3[mx]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
406 dstp+= width+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
407 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
408 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
409 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
410 for(; y<height-r; y++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
411 unsigned short *srcp= t + y*(width+1) + 1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
412 int src= *srcp; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
413 if(src){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
414 register unsigned short *dstp= srcp - 1 - r*(width+1); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
415 const int src2= (src + 128)>>8; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
416 unsigned *m3= m2 + src2*mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
417 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
418 int mx; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
419 *srcp= 128; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
420 for(mx=0; mx<mwidth; mx++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
421 *dstp += m3[mx]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
422 dstp+= width+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
423 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
424 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
425 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
426 for(; y<height; y++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
427 unsigned short *srcp= t + y*(width+1) + 1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
428 int src= *srcp; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
429 if(src){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
430 const int y2=r+height-y; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
431 register unsigned short *dstp= srcp - 1 - r*(width+1); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
432 const int src2= (src + 128)>>8; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
433 unsigned *m3= m2 + src2*mwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
434 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
435 int mx; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
436 *srcp= 128; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
437 for(mx=0; mx<y2; mx++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
438 *dstp += m3[mx]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
439 dstp+= width+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
440 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
441 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
442 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
443 t++; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
444 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
445 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
446 t = tmp2; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
447 s = buffer; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
448 for(y=0; y<height; y++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
449 for(x=0; x<width; x++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
450 s[x]= t[x]>>8; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
451 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
452 s+= stride; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
453 t+= width + 1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
454 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
455 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
456 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
457 // Gaussian matrix |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
458 static unsigned gmatrix(unsigned char *m, int r, int w, double const A) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
459 unsigned volume = 0; // volume under Gaussian area is exactly -pi*base/A |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
460 int mx, my; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
461 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
462 for (my = 0; my<w; ++my) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
463 for (mx = 0; mx<w; ++mx) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
464 m[mx+my*w] = (exp(A * ((mx-r)*(mx-r)+(my-r)*(my-r))) * base + .5); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
465 volume+= m[mx+my*w]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
466 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
467 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
468 mp_msg(MSGT_OSD, MSGL_DBG2, "A= %f\n", A); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
469 mp_msg(MSGT_OSD, MSGL_DBG2, "volume: %i; exact: %.0f; volume/exact: %.6f\n\n", volume, -M_PI*base/A, volume/(-M_PI*base/A)); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
470 return volume; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
471 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
472 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
473 static void resample_alpha(unsigned char *abuf, unsigned char *bbuf, int width, int height, int stride, float factor) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
474 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
475 int f=factor*256.0f; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
476 int i,j; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
477 for (i = 0; i < height; i++) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
478 unsigned char *a = abuf+i*stride; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
479 unsigned char *b = bbuf+i*stride; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
480 for(j=0;j<width;j++,a++,b++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
481 int x=*a; // alpha |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
482 int y=*b; // bitmap |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
483 x=255-((x*f)>>8); // scale |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
484 if (x+y>255) x=255-y; // to avoid overflows |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
485 if (x<1) x=1; else if (x>=252) x=0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
486 *a=x; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
487 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
488 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
489 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
490 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
491 #define ALLOC_INCR 32 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
492 void render_one_glyph(font_desc_t *desc, int c) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
493 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
494 FT_GlyphSlot slot; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
495 FT_UInt glyph_index; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
496 FT_BitmapGlyph glyph; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
497 int width, height, stride, maxw, off; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
498 unsigned char *abuffer, *bbuffer; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
499 |
15440 | 500 int const load_flags = FT_LOAD_DEFAULT; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
501 int pen_xa; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
502 int font = desc->font[c]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
503 int error; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
504 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
505 // fprintf(stderr, "render_one_glyph %d\n", c); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
506 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
507 if (!desc->dynamic) return; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
508 if (desc->width[c] != -1) return; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
509 if (desc->font[c] == -1) return; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
510 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
511 glyph_index = desc->glyph_index[c]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
512 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
513 // load glyph |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
514 error = FT_Load_Glyph(desc->faces[font], glyph_index, load_flags); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
515 if (error) { |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
516 WARNING("FT_Load_Glyph 0x%02x (char 0x%04x) failed.", glyph_index, c); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
517 desc->font[c] = -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
518 return; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
519 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
520 slot = desc->faces[font]->glyph; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
521 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
522 // render glyph |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
523 if (slot->format != ft_glyph_format_bitmap) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
524 error = FT_Render_Glyph(slot, ft_render_mode_normal); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
525 if (error) { |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
526 WARNING("FT_Render_Glyph 0x%04x (char 0x%04x) failed.", glyph_index, c); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
527 desc->font[c] = -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
528 return; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
529 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
530 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
531 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
532 // extract glyph image |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
533 error = FT_Get_Glyph(slot, (FT_Glyph*)&glyph); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
534 if (error) { |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
535 WARNING("FT_Get_Glyph 0x%04x (char 0x%04x) failed.", glyph_index, c); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
536 desc->font[c] = -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
537 return; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
538 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
539 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
540 // fprintf(stderr, "glyph generated\n"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
541 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
542 maxw = desc->pic_b[font]->charwidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
543 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
544 if (glyph->bitmap.width > maxw) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
545 fprintf(stderr, "glyph too wide!\n"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
546 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
547 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
548 // allocate new memory, if needed |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
549 // fprintf(stderr, "\n%d %d %d\n", desc->pic_b[font]->charwidth, desc->pic_b[font]->charheight, desc->pic_b[font]->current_alloc); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
550 if (desc->pic_b[font]->current_count >= desc->pic_b[font]->current_alloc) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
551 int newsize = desc->pic_b[font]->charwidth*desc->pic_b[font]->charheight*(desc->pic_b[font]->current_alloc+ALLOC_INCR); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
552 int increment = desc->pic_b[font]->charwidth*desc->pic_b[font]->charheight*ALLOC_INCR; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
553 desc->pic_b[font]->current_alloc += ALLOC_INCR; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
554 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
555 // fprintf(stderr, "\nns = %d inc = %d\n", newsize, increment); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
556 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
557 desc->pic_b[font]->bmp = realloc(desc->pic_b[font]->bmp, newsize); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
558 desc->pic_a[font]->bmp = realloc(desc->pic_a[font]->bmp, newsize); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
559 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
560 off = desc->pic_b[font]->current_count*desc->pic_b[font]->charwidth*desc->pic_b[font]->charheight; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
561 memset(desc->pic_b[font]->bmp+off, 0, increment); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
562 memset(desc->pic_a[font]->bmp+off, 0, increment); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
563 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
564 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
565 abuffer = desc->pic_a[font]->bmp; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
566 bbuffer = desc->pic_b[font]->bmp; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
567 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
568 off = desc->pic_b[font]->current_count*desc->pic_b[font]->charwidth*desc->pic_b[font]->charheight; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
569 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
570 paste_bitmap(bbuffer+off, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
571 &glyph->bitmap, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
572 desc->pic_b[font]->padding + glyph->left, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
573 desc->pic_b[font]->baseline - glyph->top, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
574 desc->pic_b[font]->charwidth, desc->pic_b[font]->charheight, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
575 glyph->bitmap.width <= maxw ? glyph->bitmap.width : maxw); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
576 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
577 // fprintf(stderr, "glyph pasted\n"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
578 FT_Done_Glyph((FT_Glyph)glyph); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
579 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
580 /* advance pen */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
581 pen_xa = f266ToInt(slot->advance.x) + 2*desc->pic_b[font]->padding; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
582 if (pen_xa > maxw) pen_xa = maxw; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
583 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
584 desc->start[c] = off; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
585 width = desc->width[c] = pen_xa; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
586 height = desc->pic_b[font]->charheight; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
587 stride = desc->pic_b[font]->w; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
588 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
589 if (desc->tables.o_r == 0) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
590 outline0(bbuffer+off, abuffer+off, width, height, stride); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
591 } else if (desc->tables.o_r == 1) { |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
592 outline1(bbuffer+off, abuffer+off, width, height, stride); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
593 } else { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
594 outline(bbuffer+off, abuffer+off, width, height, stride, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
595 desc->tables.omt, desc->tables.o_r, desc->tables.o_w, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
596 desc->tables.o_size); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
597 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
598 // fprintf(stderr, "fg: outline t = %lf\n", GetTimer()-t); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
599 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
600 if (desc->tables.g_r) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
601 blur(abuffer+off, desc->tables.tmp, width, height, stride, |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
602 desc->tables.gt2, desc->tables.g_r, |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
603 desc->tables.g_w); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
604 // fprintf(stderr, "fg: blur t = %lf\n", GetTimer()-t); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
605 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
606 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
607 resample_alpha(abuffer+off, bbuffer+off, width, height, stride, font_factor); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
608 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
609 desc->pic_b[font]->current_count++; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
610 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
611 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
612 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
613 static int prepare_font(font_desc_t *desc, FT_Face face, float ppem, int pic_idx, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
614 int charset_size, FT_ULong *charset, FT_ULong *charcodes, int unicode, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
615 double thickness, double radius) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
616 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
617 int i, err; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
618 int padding = ceil(radius) + ceil(thickness); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
619 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
620 desc->faces[pic_idx] = face; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
621 |
18878 | 622 desc->pic_a[pic_idx] = malloc(sizeof(raw_file)); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
623 if (!desc->pic_a[pic_idx]) return -1; |
18878 | 624 desc->pic_b[pic_idx] = malloc(sizeof(raw_file)); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
625 if (!desc->pic_b[pic_idx]) return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
626 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
627 desc->pic_a[pic_idx]->bmp = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
628 desc->pic_a[pic_idx]->pal = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
629 desc->pic_b[pic_idx]->bmp = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
630 desc->pic_b[pic_idx]->pal = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
631 |
18878 | 632 desc->pic_a[pic_idx]->pal = malloc(sizeof(unsigned char)*256*3); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
633 if (!desc->pic_a[pic_idx]->pal) return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
634 for (i = 0; i<768; ++i) desc->pic_a[pic_idx]->pal[i] = i/3; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
635 |
18878 | 636 desc->pic_b[pic_idx]->pal = malloc(sizeof(unsigned char)*256*3); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
637 if (!desc->pic_b[pic_idx]->pal) return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
638 for (i = 0; i<768; ++i) desc->pic_b[pic_idx]->pal[i] = i/3; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
639 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
640 // ttime = GetTimer(); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
641 err = check_font(desc, ppem, padding, pic_idx, charset_size, charset, charcodes, unicode); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
642 // ttime=GetTimer()-ttime; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
643 // printf("render: %7lf us\n",ttime); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
644 if (err) return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
645 // fprintf(stderr, "fg: render t = %lf\n", GetTimer()-t); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
646 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
647 desc->pic_a[pic_idx]->w = desc->pic_b[pic_idx]->w; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
648 desc->pic_a[pic_idx]->h = desc->pic_b[pic_idx]->h; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
649 desc->pic_a[pic_idx]->c = colors; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
650 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
651 desc->pic_a[pic_idx]->bmp = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
652 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
653 // fprintf(stderr, "fg: w = %d, h = %d\n", desc->pic_a[pic_idx]->w, desc->pic_a[pic_idx]->h); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
654 return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
655 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
656 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
657 |
18950 | 658 static int generate_tables(font_desc_t *desc, double thickness, double radius) |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
659 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
660 int width = desc->max_height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
661 int height = desc->max_width; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
662 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
663 double A = log(1.0/base)/(radius*radius*2); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
664 int mx, my, i; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
665 double volume_diff, volume_factor = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
666 unsigned char *omtp; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
667 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
668 desc->tables.g_r = ceil(radius); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
669 desc->tables.o_r = ceil(thickness); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
670 desc->tables.g_w = 2*desc->tables.g_r+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
671 desc->tables.o_w = 2*desc->tables.o_r+1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
672 desc->tables.o_size = desc->tables.o_w * desc->tables.o_w; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
673 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
674 // fprintf(stderr, "o_r = %d\n", desc->tables.o_r); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
675 |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
676 if (desc->tables.g_r) { |
18878 | 677 desc->tables.g = malloc(desc->tables.g_w * sizeof(unsigned)); |
678 desc->tables.gt2 = malloc(256 * desc->tables.g_w * sizeof(unsigned)); | |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
679 if (desc->tables.g==NULL || desc->tables.gt2==NULL) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
680 return -1; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
681 } |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
682 } |
18878 | 683 desc->tables.om = malloc(desc->tables.o_w*desc->tables.o_w * sizeof(unsigned)); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
684 desc->tables.omt = malloc(desc->tables.o_size*256); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
685 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
686 omtp = desc->tables.omt; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
687 desc->tables.tmp = malloc((width+1)*height*sizeof(short)); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
688 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
689 if (desc->tables.om==NULL || desc->tables.omt==NULL || desc->tables.tmp==NULL) { |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
690 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
691 }; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
692 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
693 if (desc->tables.g_r) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
694 // gaussian curve with volume = 256 |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
695 for (volume_diff=10000000; volume_diff>0.0000001; volume_diff*=0.5){ |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
696 volume_factor+= volume_diff; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
697 desc->tables.volume=0; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
698 for (i = 0; i<desc->tables.g_w; ++i) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
699 desc->tables.g[i] = (unsigned)(exp(A * (i-desc->tables.g_r)*(i-desc->tables.g_r)) * volume_factor + .5); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
700 desc->tables.volume+= desc->tables.g[i]; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
701 } |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
702 if(desc->tables.volume>256) volume_factor-= volume_diff; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
703 } |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
704 desc->tables.volume=0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
705 for (i = 0; i<desc->tables.g_w; ++i) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
706 desc->tables.g[i] = (unsigned)(exp(A * (i-desc->tables.g_r)*(i-desc->tables.g_r)) * volume_factor + .5); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
707 desc->tables.volume+= desc->tables.g[i]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
708 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
709 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
710 // gauss table: |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
711 for(mx=0;mx<desc->tables.g_w;mx++){ |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
712 for(i=0;i<256;i++){ |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
713 desc->tables.gt2[mx+i*desc->tables.g_w] = i*desc->tables.g[mx]; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
714 } |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
715 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
716 } |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
717 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
718 /* outline matrix */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
719 for (my = 0; my<desc->tables.o_w; ++my) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
720 for (mx = 0; mx<desc->tables.o_w; ++mx) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
721 // antialiased circle would be perfect here, but this one is good enough |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
722 double d = thickness + 1 - sqrt((mx-desc->tables.o_r)*(mx-desc->tables.o_r)+(my-desc->tables.o_r)*(my-desc->tables.o_r)); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
723 desc->tables.om[mx+my*desc->tables.o_w] = d>=1 ? base : d<=0 ? 0 : (d*base + .5); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
724 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
725 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
726 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
727 // outline table: |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
728 for(i=0;i<256;i++){ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
729 for(mx=0;mx<desc->tables.o_size;mx++) *(omtp++) = (i*desc->tables.om[mx] + (base/2))/base; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
730 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
731 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
732 return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
733 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
734 |
17931
ed9950b8200d
The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other
albeu
parents:
17566
diff
changeset
|
735 #ifdef USE_ICONV |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
736 /* decode from 'encoding' to unicode */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
737 static FT_ULong decode_char(iconv_t *cd, char c) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
738 FT_ULong o; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
739 char *inbuf = &c; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
740 char *outbuf = (char*)&o; |
19204
17acc0a995e2
Fixes the format string for the warning message on line 182 (%x
diego
parents:
18980
diff
changeset
|
741 size_t inbytesleft = 1; |
17acc0a995e2
Fixes the format string for the warning message on line 182 (%x
diego
parents:
18980
diff
changeset
|
742 size_t outbytesleft = sizeof(FT_ULong); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
743 |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7147
diff
changeset
|
744 iconv(*cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
745 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
746 /* convert unicode BigEndian -> MachineEndian */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
747 o = be2me_32(o); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
748 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
749 // if (count==-1) o = 0; // not OK, at least my iconv() returns E2BIG for all |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
750 if (outbytesleft!=0) o = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
751 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
752 /* we don't want control characters */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
753 if (o>=0x7f && o<0xa0) o = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
754 return o; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
755 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
756 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
757 static int prepare_charset(char *charmap, char *encoding, FT_ULong *charset, FT_ULong *charcodes) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
758 FT_ULong i; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
759 int count = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
760 int charset_size; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
761 iconv_t cd; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
762 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
763 // check if ucs-4 is available |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
764 cd = iconv_open(charmap, charmap); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
765 if (cd==(iconv_t)-1) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
766 mp_msg(MSGT_OSD, MSGL_ERR, "iconv doesn't know %s encoding. Use the source!\n", charmap); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
767 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
768 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
769 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
770 iconv_close(cd); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
771 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
772 cd = iconv_open(charmap, encoding); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
773 if (cd==(iconv_t)-1) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
774 mp_msg(MSGT_OSD, MSGL_ERR, "Unsupported encoding `%s', use iconv --list to list character sets known on your system.\n", encoding); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
775 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
776 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
777 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
778 charset_size = 256 - first_char; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
779 for (i = 0; i<charset_size; ++i) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
780 charcodes[count] = i+first_char; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
781 charset[count] = decode_char(&cd, i+first_char); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
782 if (charset[count]!=0) ++count; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
783 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
784 charcodes[count] = charset[count] = 0; ++count; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
785 charset_size = count; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
786 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
787 iconv_close(cd); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
788 if (charset_size==0) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
789 mp_msg(MSGT_OSD, MSGL_ERR, "No characters to render!\n"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
790 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
791 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
792 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
793 return charset_size; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
794 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
795 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
796 static int prepare_charset_unicode(FT_Face face, FT_ULong *charset, FT_ULong *charcodes) { |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7147
diff
changeset
|
797 #ifdef HAVE_FREETYPE21 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
798 FT_ULong charcode; |
21606 | 799 #else |
800 int j; | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7147
diff
changeset
|
801 #endif |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
802 FT_UInt gindex; |
19205 | 803 int i; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
804 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
805 if (face->charmap==NULL || face->charmap->encoding!=ft_encoding_unicode) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
806 WARNING("Unicode charmap not available for this font. Very bad!"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
807 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
808 } |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
809 #ifdef HAVE_FREETYPE21 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
810 i = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
811 charcode = FT_Get_First_Char( face, &gindex ); |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
812 while (gindex != 0) { |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
813 if (charcode < 65536 && charcode >= 33) { // sanity check |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
814 charset[i] = charcode; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
815 charcodes[i] = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
816 i++; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
817 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
818 charcode = FT_Get_Next_Char( face, charcode, &gindex ); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
819 } |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
820 #else |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
821 // for FT < 2.1 we have to use brute force enumeration |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
822 i = 0; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
823 for (j = 33; j < 65536; j++) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
824 gindex = FT_Get_Char_Index(face, j); |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
825 if (gindex > 0) { |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
826 charset[i] = j; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
827 charcodes[i] = 0; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
828 i++; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
829 } |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
830 } |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
831 #endif |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
832 mp_msg(MSGT_OSD, MSGL_V, "Unicode font: %d glyphs.\n", i); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
833 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
834 return i; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
835 } |
17931
ed9950b8200d
The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other
albeu
parents:
17566
diff
changeset
|
836 #endif |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
837 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
15440
diff
changeset
|
838 static font_desc_t* init_font_desc(void) |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
839 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
840 font_desc_t *desc; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
841 int i; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
842 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
843 desc = malloc(sizeof(font_desc_t)); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
844 if(!desc) return NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
845 memset(desc,0,sizeof(font_desc_t)); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
846 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
847 desc->dynamic = 1; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
848 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
849 /* setup sane defaults */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
850 desc->name = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
851 desc->fpath = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
852 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
853 desc->face_cnt = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
854 desc->charspace = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
855 desc->spacewidth = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
856 desc->height = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
857 desc->max_width = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
858 desc->max_height = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
859 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
860 desc->tables.g = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
861 desc->tables.gt2 = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
862 desc->tables.om = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
863 desc->tables.omt = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
864 desc->tables.tmp = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
865 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
866 for(i = 0; i < 65536; i++) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
867 desc->start[i] = desc->width[i] = desc->font[i] = -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
868 for(i = 0; i < 16; i++) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
869 desc->pic_a[i] = desc->pic_b[i] = NULL; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
870 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
871 return desc; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
872 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
873 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
874 void free_font_desc(font_desc_t *desc) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
875 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
876 int i; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
877 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
878 if (!desc) return; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
879 |
9176 | 880 // if (!desc->dynamic) return; // some vo_aa crap, better leaking than crashing |
9172 | 881 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
882 if (desc->name) free(desc->name); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
883 if (desc->fpath) free(desc->fpath); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
884 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
885 for(i = 0; i < 16; i++) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
886 if (desc->pic_a[i]) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
887 if (desc->pic_a[i]->bmp) free(desc->pic_a[i]->bmp); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
888 if (desc->pic_a[i]->pal) free(desc->pic_a[i]->pal); |
13632 | 889 free (desc->pic_a[i]); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
890 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
891 if (desc->pic_b[i]) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
892 if (desc->pic_b[i]->bmp) free(desc->pic_b[i]->bmp); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
893 if (desc->pic_b[i]->pal) free(desc->pic_b[i]->pal); |
13632 | 894 free (desc->pic_b[i]); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
895 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
896 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
897 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
898 if (desc->tables.g) free(desc->tables.g); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
899 if (desc->tables.gt2) free(desc->tables.gt2); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
900 if (desc->tables.om) free(desc->tables.om); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
901 if (desc->tables.omt) free(desc->tables.omt); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
902 if (desc->tables.tmp) free(desc->tables.tmp); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
903 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
904 for(i = 0; i < desc->face_cnt; i++) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
905 FT_Done_Face(desc->faces[i]); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
906 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
907 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
908 free(desc); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
909 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
910 |
18980
ed69754aa58d
Marks several string parameters as const when they are not modified in the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18950
diff
changeset
|
911 static int load_sub_face(const char *name, FT_Face *face) |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
912 { |
7139 | 913 int err = -1; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
914 |
7139 | 915 if (name) err = FT_New_Face(library, name, 0, face); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
916 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
917 if (err) { |
13632 | 918 char *font_file = get_path("subfont.ttf"); |
919 err = FT_New_Face(library, font_file, 0, face); | |
920 free(font_file); | |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
921 if (err) { |
10272
7b0bc557987b
renames: DATADIR->MPLAYER_DATADIR, CONFDIR->MPLAYER_CONFDIR, LIBDIR->MPLAYER_LIBDIR
arpi
parents:
9176
diff
changeset
|
922 err = FT_New_Face(library, MPLAYER_DATADIR "/subfont.ttf", 0, face); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
923 if (err) { |
7139 | 924 mp_msg(MSGT_OSD, MSGL_ERR, "New_Face failed. Maybe the font path is wrong.\nPlease supply the text font file (~/.mplayer/subfont.ttf).\n" ); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
925 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
926 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
927 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
928 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
929 return err; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
930 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
931 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
932 static int load_osd_face(FT_Face *face) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
933 { |
7139 | 934 if ( FT_New_Memory_Face(library, osd_font_pfb, sizeof(osd_font_pfb), 0, face) ) { |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
935 mp_msg(MSGT_OSD, MSGL_ERR, "New_Memory_Face failed..\n"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
936 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
937 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
938 return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
939 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
940 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
941 int kerning(font_desc_t *desc, int prevc, int c) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
942 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
943 FT_Vector kern; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
944 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
945 if (!vo_font->dynamic) return 0; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
946 if (prevc < 0 || c < 0) return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
947 if (desc->font[prevc] != desc->font[c]) return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
948 if (desc->font[prevc] == -1 || desc->font[c] == -1) return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
949 FT_Get_Kerning(desc->faces[desc->font[c]], |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
950 desc->glyph_index[prevc], desc->glyph_index[c], |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
951 ft_kerning_default, &kern); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
952 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
953 // fprintf(stderr, "kern: %c %c %d\n", prevc, c, f266ToInt(kern.x)); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
954 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
955 return f266ToInt(kern.x); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
956 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
957 |
18980
ed69754aa58d
Marks several string parameters as const when they are not modified in the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18950
diff
changeset
|
958 font_desc_t* read_font_desc_ft(const char *fname, int movie_width, int movie_height) |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
959 { |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
960 font_desc_t *desc = NULL; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
961 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
962 FT_Face face; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
963 |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
964 FT_ULong *my_charset = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* characters we want to render; Unicode */ |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
965 FT_ULong *my_charcodes = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* character codes in 'encoding' */ |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
966 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
967 char *charmap = "ucs-4"; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
968 int err; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
969 int charset_size; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
970 int i, j; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
971 int unicode; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
972 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
973 float movie_size; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
974 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
975 float subtitle_font_ppem; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
976 float osd_font_ppem; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
977 |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
978 if (my_charset == NULL || my_charcodes == NULL) { |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
979 mp_msg(MSGT_OSD, MSGL_ERR, "subtitle font: malloc failed.\n"); |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
980 goto err_out; |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
981 } |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
982 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
983 switch (subtitle_autoscale) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
984 case 1: |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
985 movie_size = movie_height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
986 break; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
987 case 2: |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
988 movie_size = movie_width; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
989 break; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
990 case 3: |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
991 movie_size = sqrt(movie_height*movie_height+movie_width*movie_width); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
992 break; |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
993 default: |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
994 movie_size = 100; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
995 break; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
996 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
997 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
998 subtitle_font_ppem = movie_size*text_font_scale_factor/100.0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
999 osd_font_ppem = movie_size*osd_font_scale_factor/100.0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1000 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1001 if (subtitle_font_ppem < 5) subtitle_font_ppem = 5; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1002 if (osd_font_ppem < 5) osd_font_ppem = 5; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1003 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1004 if (subtitle_font_ppem > 128) subtitle_font_ppem = 128; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1005 if (osd_font_ppem > 128) osd_font_ppem = 128; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1006 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1007 if ((subtitle_font_encoding == NULL) |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1008 || (strcasecmp(subtitle_font_encoding, "unicode") == 0)) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1009 unicode = 1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1010 } else { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1011 unicode = 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1012 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1013 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1014 desc = init_font_desc(); |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1015 if(!desc) goto err_out; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1016 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1017 // t=GetTimer(); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1018 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1019 /* generate the subtitle font */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1020 err = load_sub_face(fname, &face); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1021 if (err) { |
7139 | 1022 mp_msg(MSGT_OSD, MSGL_WARN, "subtitle font: load_sub_face failed.\n"); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1023 goto gen_osd; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1024 } |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1025 desc->face_cnt++; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1026 |
17931
ed9950b8200d
The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other
albeu
parents:
17566
diff
changeset
|
1027 #ifdef USE_ICONV |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1028 if (unicode) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1029 charset_size = prepare_charset_unicode(face, my_charset, my_charcodes); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1030 } else { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1031 if (subtitle_font_encoding) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1032 charset_size = prepare_charset(charmap, subtitle_font_encoding, my_charset, my_charcodes); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1033 } else { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1034 charset_size = prepare_charset(charmap, "iso-8859-1", my_charset, my_charcodes); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1035 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1036 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1037 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1038 if (charset_size < 0) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1039 mp_msg(MSGT_OSD, MSGL_ERR, "subtitle font: prepare_charset failed.\n"); |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1040 goto err_out; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1041 } |
17931
ed9950b8200d
The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other
albeu
parents:
17566
diff
changeset
|
1042 #else |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1043 goto err_out; |
17931
ed9950b8200d
The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other
albeu
parents:
17566
diff
changeset
|
1044 #endif |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1045 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1046 // fprintf(stderr, "fg: prepare t = %lf\n", GetTimer()-t); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1047 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1048 err = prepare_font(desc, face, subtitle_font_ppem, desc->face_cnt-1, |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1049 charset_size, my_charset, my_charcodes, unicode, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1050 subtitle_font_thickness, subtitle_font_radius); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1051 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1052 if (err) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1053 mp_msg(MSGT_OSD, MSGL_ERR, "Cannot prepare subtitle font.\n"); |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1054 goto err_out; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1055 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1056 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1057 gen_osd: |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1058 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1059 /* generate the OSD font */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1060 err = load_osd_face(&face); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1061 if (err) { |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1062 goto err_out; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1063 } |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1064 desc->face_cnt++; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1065 |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1066 err = prepare_font(desc, face, osd_font_ppem, desc->face_cnt-1, |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1067 OSD_CHARSET_SIZE, osd_charset, osd_charcodes, 0, |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1068 subtitle_font_thickness, subtitle_font_radius); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1069 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1070 if (err) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1071 mp_msg(MSGT_OSD, MSGL_ERR, "Cannot prepare OSD font.\n"); |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1072 goto err_out; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1073 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1074 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1075 err = generate_tables(desc, subtitle_font_thickness, subtitle_font_radius); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1076 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1077 if (err) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1078 mp_msg(MSGT_OSD, MSGL_ERR, "Cannot generate tables.\n"); |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1079 goto err_out; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1080 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1081 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1082 // final cleanup |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1083 desc->font[' ']=-1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1084 desc->width[' ']=desc->spacewidth; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1085 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1086 j = '_'; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1087 if (desc->font[j] < 0) j = '?'; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1088 if (desc->font[j] < 0) j = ' '; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1089 render_one_glyph(desc, j); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1090 for(i = 0; i < 65536; i++) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1091 if (desc->font[i] < 0 && i != ' ') { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1092 desc->start[i] = desc->start[j]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1093 desc->width[i] = desc->width[j]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1094 desc->font[i] = desc->font[j]; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1095 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1096 } |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1097 free(my_charset); |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1098 free(my_charcodes); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1099 return desc; |
19208
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1100 |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1101 err_out: |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1102 if (desc) |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1103 free_font_desc(desc); |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1104 free(my_charset); |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1105 free(my_charcodes); |
99d6ca895c46
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
reimar
parents:
19205
diff
changeset
|
1106 return NULL; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1107 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1108 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
15440
diff
changeset
|
1109 int init_freetype(void) |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1110 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1111 int err; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1112 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1113 /* initialize freetype */ |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1114 err = FT_Init_FreeType(&library); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1115 if (err) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1116 mp_msg(MSGT_OSD, MSGL_ERR, "Init_FreeType failed.\n"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1117 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1118 } |
8818 | 1119 mp_msg(MSGT_OSD, MSGL_V, "init_freetype\n"); |
8635
81dbd28ef7c0
these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents:
8123
diff
changeset
|
1120 using_freetype = 1; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1121 return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1122 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1123 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
15440
diff
changeset
|
1124 int done_freetype(void) |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1125 { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1126 int err; |
8635
81dbd28ef7c0
these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents:
8123
diff
changeset
|
1127 |
81dbd28ef7c0
these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents:
8123
diff
changeset
|
1128 if (!using_freetype) |
81dbd28ef7c0
these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents:
8123
diff
changeset
|
1129 return 0; |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1130 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1131 err = FT_Done_FreeType(library); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1132 if (err) { |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1133 mp_msg(MSGT_OSD, MSGL_ERR, "FT_Done_FreeType failed.\n"); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1134 return -1; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1135 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1136 |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1137 return 0; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1138 } |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1139 |
8635
81dbd28ef7c0
these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents:
8123
diff
changeset
|
1140 void load_font_ft(int width, int height) |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1141 { |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1142 #ifdef HAVE_FONTCONFIG |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1143 FcPattern *fc_pattern; |
21501 | 1144 FcPattern *fc_pattern2; |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1145 FcChar8 *s; |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1146 FcBool scalable; |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1147 #endif |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1148 vo_image_width = width; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1149 vo_image_height = height; |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1150 |
7140
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1151 // protection against vo_aa font hacks |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1152 if (vo_font && !vo_font->dynamic) return; |
b9ce54c7f30f
add Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz> freetype patch
pontscho
parents:
7139
diff
changeset
|
1153 |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1154 if (vo_font) free_font_desc(vo_font); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1155 |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1156 #ifdef HAVE_FONTCONFIG |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1157 if (font_fontconfig) |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1158 { |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1159 if (!font_name) |
17962
f35cfd56c800
NEVER assign static strings to string command line options.
albeu
parents:
17931
diff
changeset
|
1160 font_name = strdup("sans-serif"); |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1161 FcInit(); |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1162 fc_pattern = FcNameParse(font_name); |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1163 FcConfigSubstitute(0, fc_pattern, FcMatchPattern); |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1164 FcDefaultSubstitute(fc_pattern); |
21501 | 1165 fc_pattern2 = fc_pattern; |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1166 fc_pattern = FcFontMatch(0, fc_pattern, 0); |
21501 | 1167 FcPatternDestroy(fc_pattern2); |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1168 FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable); |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1169 if (scalable != FcTrue) { |
21501 | 1170 FcPatternDestroy(fc_pattern); |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1171 fc_pattern = FcNameParse("sans-serif"); |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1172 FcConfigSubstitute(0, fc_pattern, FcMatchPattern); |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1173 FcDefaultSubstitute(fc_pattern); |
21501 | 1174 fc_pattern2 = fc_pattern; |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1175 fc_pattern = FcFontMatch(0, fc_pattern, 0); |
21501 | 1176 FcPatternDestroy(fc_pattern2); |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1177 } |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1178 // s doesn't need to be freed according to fontconfig docs |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1179 FcPatternGetString(fc_pattern, FC_FILE, 0, &s); |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1180 vo_font=read_font_desc_ft(s, width, height); |
21501 | 1181 FcPatternDestroy(fc_pattern); |
11580
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1182 } |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1183 else |
90953d955165
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
alex
parents:
11500
diff
changeset
|
1184 #endif |
8635
81dbd28ef7c0
these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents:
8123
diff
changeset
|
1185 vo_font=read_font_desc_ft(font_name, width, height); |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
diff
changeset
|
1186 } |