Mercurial > mplayer.hg
annotate TOOLS/subfont-c/subfont.c @ 5334:2cb0e0e83e95
dump stuff
author | arpi |
---|---|
date | Mon, 25 Mar 2002 13:35:23 +0000 |
parents | 958bcb3b5725 |
children | 48e91dc9534b |
rev | line source |
---|---|
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
1 /* |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
2 * Renders antialiased fonts for mplayer using freetype library. |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
3 * Should work with TrueType, Type1 and any other font supported by libfreetype. |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
4 * Can generate font.desc for any encoding. |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
5 * |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
6 * |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
7 * Artur Zaprzala <zybi@fanthom.irc.pl> |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
8 * |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
9 */ |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
10 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
11 #include <stdio.h> |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
12 #include <stdlib.h> |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
13 #include <iconv.h> |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
14 #include <math.h> |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
15 #include <string.h> |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
16 #include <libgen.h> |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
17 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
18 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
19 #ifndef OLD_FREETYPE2 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
20 #include <ft2build.h> |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
21 #include FT_FREETYPE_H |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
22 #include FT_GLYPH_H |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
23 #else /* freetype 2.0.1 */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
24 #include <freetype/freetype.h> |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
25 #include <freetype/ftglyph.h> |
1677 | 26 #endif |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
27 |
1677 | 28 |
29 #include "../../bswap.h" | |
30 | |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
31 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
32 #ifndef DEBUG |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
33 #define DEBUG 0 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
34 #endif |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
35 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
36 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
37 //// default values |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
38 char *encoding = "iso-8859-1"; /* target encoding */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
39 char *charmap = "ucs-4"; /* font charmap encoding, I hope ucs-4 is always big endian */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
40 /* gcc 2.1.3 doesn't support ucs-4le, but supports ucs-4 (==ucs-4be) */ |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
41 float ppem = 22; /* font size in pixels */ |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
42 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
43 double radius = 2; /* blur radius */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
44 double thickness = 1.5; /* outline thickness */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
45 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
46 char* font_desc = "font.desc"; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
47 //char* font_desc = "/dev/stdout"; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
48 |
4935 | 49 char *outdir = "."; |
50 | |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
51 //// constants |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
52 int const colors = 256; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
53 int const maxcolor = 255; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
54 unsigned const base = 256; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
55 unsigned const first_char = 33; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
56 #define max_charset_size 60000 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
57 //int const max_charset_size = 256; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
58 unsigned charset_size = 0; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
59 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
60 //// |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
61 char *command; |
1506
94d929f91b06
return value of iconv fixed for glibc 2.1.3, using strrchr instead of basename, as basename is buggy
arpi
parents:
1505
diff
changeset
|
62 char *encoding_name; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
63 char *font_path; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
64 //char *font_metrics; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
65 int append_mode = 0; |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
66 int unicode_desc = 0; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
67 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
68 unsigned char *bbuffer, *abuffer; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
69 int width, height; |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
70 int padding; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
71 static FT_ULong charset[max_charset_size]; /* characters we want to render; Unicode */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
72 static FT_ULong charcodes[max_charset_size]; /* character codes in 'encoding' */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
73 iconv_t cd; // iconv conversion descriptor |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
74 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
75 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
76 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
77 #define eprintf(...) fprintf(stderr, __VA_ARGS__) |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
78 #define ERROR_(msg, ...) (eprintf("%s: error: " msg "\n", command, __VA_ARGS__), exit(1)) |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
79 #define WARNING_(msg, ...) eprintf("%s: warning: " msg "\n", command, __VA_ARGS__) |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
80 #define ERROR(...) ERROR_(__VA_ARGS__, NULL) |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
81 #define WARNING(...) WARNING_(__VA_ARGS__, NULL) |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
82 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
83 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
84 #define f266ToInt(x) (((x)+32)>>6) // round fractional fixed point number to integer |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
85 // coordinates are in 26.6 pixels (i.e. 1/64th of pixels) |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
86 #define f266CeilToInt(x) (((x)+63)>>6) // ceiling |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
87 #define f266FloorToInt(x) ((x)>>6) // floor |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
88 #define f1616ToInt(x) (((x)+0x8000)>>16) // 16.16 |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
89 #define floatTof266(x) ((int)((x)*(1<<6)+0.5)) |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
90 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
91 #define ALIGN(x) (((x)+7)&~7) // 8 byte align |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
92 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
93 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
94 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
95 void paste_bitmap(FT_Bitmap *bitmap, int x, int y) { |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
96 int drow = x+y*width; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
97 int srow = 0; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
98 int sp, dp, w, h; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
99 if (bitmap->pixel_mode==ft_pixel_mode_mono) |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
100 for (h = bitmap->rows; h>0; --h, drow+=width, srow+=bitmap->pitch) |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
101 for (w = bitmap->width, sp=dp=0; w>0; --w, ++dp, ++sp) |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
102 bbuffer[drow+dp] = (bitmap->buffer[srow+sp/8] & (0x80>>(sp%8))) ? 255:0; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
103 else |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
104 for (h = bitmap->rows; h>0; --h, drow+=width, srow+=bitmap->pitch) |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
105 for (w = bitmap->width, sp=dp=0; w>0; --w, ++dp, ++sp) |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
106 bbuffer[drow+dp] = bitmap->buffer[srow+sp]; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
107 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
108 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
109 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
110 void write_header(FILE *f) { |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
111 static unsigned char header[800] = "mhwanh"; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
112 int i; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
113 header[7] = 4; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
114 header[8] = width>>8; header[9] = (unsigned char)width; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
115 header[10] = height>>8; header[11] = (unsigned char)height; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
116 header[12] = colors>>8; header[13] = (unsigned char)colors; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
117 for (i = 32; i<800; ++i) header[i] = (i-32)/3; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
118 fwrite(header, 1, 800, f); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
119 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
120 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
121 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
122 void write_bitmap(void *buffer, char type) { |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
123 FILE *f; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
124 int const max_name = 128; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
125 char name[max_name]; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
126 |
4935 | 127 snprintf(name, max_name, "%s/%s-%c.raw", outdir, encoding_name, type); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
128 f = fopen(name, "wb"); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
129 if (f==NULL) ERROR("fopen failed."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
130 write_header(f); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
131 fwrite(buffer, 1, width*height, f); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
132 fclose(f); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
133 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
134 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
135 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
136 void render() { |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
137 FT_Library library; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
138 FT_Face face; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
139 FT_Error error; |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
140 FT_Glyph *glyphs; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
141 FT_BitmapGlyph glyph; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
142 FILE *f; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
143 int const load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING; |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
144 int pen_x = 0, pen_xa; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
145 int ymin = INT_MAX, ymax = INT_MIN; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
146 int i, uni_charmap = 1; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
147 int baseline, space_advance = 20; |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
148 int glyphs_count = 0; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
149 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
150 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
151 /* initialize freetype */ |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
152 error = FT_Init_FreeType(&library); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
153 if (error) ERROR("Init_FreeType failed."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
154 error = FT_New_Face(library, font_path, 0, &face); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
155 if (error) ERROR("New_Face failed. Maybe the font path `%s' is wrong.", font_path); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
156 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
157 /* |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
158 if (font_metrics) { |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
159 error = FT_Attach_File(face, font_metrics); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
160 if (error) WARNING("FT_Attach_File failed."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
161 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
162 */ |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
163 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
164 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
165 #if 0 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
166 /************************************************************/ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
167 eprintf("Font encodings:\n"); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
168 for (i = 0; i<face->num_charmaps; ++i) |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
169 eprintf("'%.4s'\n", (char*)&face->charmaps[i]->encoding); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
170 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
171 //error = FT_Select_Charmap(face, ft_encoding_unicode); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
172 //error = FT_Select_Charmap(face, ft_encoding_adobe_standard); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
173 //error = FT_Select_Charmap(face, ft_encoding_adobe_custom); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
174 //error = FT_Set_Charmap(face, face->charmaps[1]); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
175 //if (error) WARNING("FT_Select_Charmap failed."); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
176 #endif |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
177 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
178 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
179 #if 0 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
180 /************************************************************/ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
181 if (FT_HAS_GLYPH_NAMES(face)) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
182 int const max_gname = 128; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
183 char gname[max_gname]; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
184 for (i = 0; i<face->num_glyphs; ++i) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
185 FT_Get_Glyph_Name(face, i, gname, max_gname); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
186 eprintf("%02x `%s'\n", i, gname); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
187 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
188 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
189 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
190 #endif |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
191 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
192 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
193 if (face->charmap==NULL || face->charmap->encoding!=ft_encoding_unicode) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
194 WARNING("Unicode charmap not available for this font. Very bad!"); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
195 uni_charmap = 0; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
196 error = FT_Set_Charmap(face, face->charmaps[0]); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
197 if (error) WARNING("No charmaps! Strange."); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
198 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
199 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
200 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
201 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
202 /* set size */ |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
203 if (FT_IS_SCALABLE(face)) { |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
204 error = FT_Set_Char_Size(face, floatTof266(ppem), 0, 0, 0); |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
205 if (error) WARNING("FT_Set_Char_Size failed."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
206 } else { |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
207 int j = 0; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
208 int jppem = face->available_sizes[0].height; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
209 /* find closest size */ |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
210 for (i = 0; i<face->num_fixed_sizes; ++i) { |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
211 if (fabs(face->available_sizes[i].height - ppem) < abs(face->available_sizes[i].height - jppem)) { |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
212 j = i; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
213 jppem = face->available_sizes[i].height; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
214 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
215 } |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
216 WARNING("Selected font is not scalable. Using ppem=%i.", face->available_sizes[j].height); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
217 error = FT_Set_Pixel_Sizes(face, face->available_sizes[j].width, face->available_sizes[j].height); |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
218 if (error) WARNING("FT_Set_Pixel_Sizes failed."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
219 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
220 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
221 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
222 if (FT_IS_FIXED_WIDTH(face)) |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
223 WARNING("Selected font is fixed-width."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
224 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
225 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
226 /* compute space advance */ |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
227 error = FT_Load_Char(face, ' ', load_flags); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
228 if (error) WARNING("spacewidth set to default."); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
229 else space_advance = f266ToInt(face->glyph->advance.x); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
230 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
231 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
232 /* create font.desc */ |
4935 | 233 { |
234 int const max_name = 128; | |
235 char name[max_name]; | |
236 | |
237 snprintf(name, max_name, "%s/%s", outdir, font_desc); | |
238 f = fopen(name, append_mode ? "a":"w"); | |
239 } | |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
240 if (f==NULL) ERROR("fopen failed."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
241 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
242 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
243 /* print font.desc header */ |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
244 if (append_mode) { |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
245 fprintf(f, "\n\n# "); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
246 } else { |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
247 fprintf(f, "# This file was generated with subfont for Mplayer.\n" |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
248 "# Subfont by Artur Zaprzala <zybi@fanthom.irc.pl>.\n\n"); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
249 fprintf(f, "[info]\n"); |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
250 } |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
251 |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
252 fprintf(f, "name 'Subtitle font for %s %s, \"%s%s%s\" face, size: %.1f pixels.'\n", |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
253 encoding_name, |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
254 unicode_desc ? "charset, Unicode encoding":"encoding", |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
255 face->family_name, |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
256 face->style_name ? " ":"", face->style_name ? face->style_name:"", |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
257 ppem); |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
258 |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
259 if (!append_mode) { |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
260 #ifdef NEW_DESC |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
261 fprintf(f, "descversion 2\n"); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
262 #else |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
263 fprintf(f, "descversion 1\n"); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
264 #endif |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
265 fprintf(f, "spacewidth %i\n", 2*padding + space_advance); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
266 #ifndef NEW_DESC |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
267 fprintf(f, "charspace %i\n", -2*padding); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
268 #endif |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
269 fprintf(f, "height %i\n", f266ToInt(face->size->metrics.height)); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
270 #ifdef NEW_DESC |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
271 fprintf(f, "ascender %i\n", f266CeilToInt(face->size->metrics.ascender)); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
272 fprintf(f, "descender %i\n", f266FloorToInt(face->size->metrics.descender)); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
273 #endif |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
274 } |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
275 fprintf(f, "\n[files]\n"); |
1506
94d929f91b06
return value of iconv fixed for glibc 2.1.3, using strrchr instead of basename, as basename is buggy
arpi
parents:
1505
diff
changeset
|
276 fprintf(f, "alpha %s-a.raw\n", encoding_name); |
94d929f91b06
return value of iconv fixed for glibc 2.1.3, using strrchr instead of basename, as basename is buggy
arpi
parents:
1505
diff
changeset
|
277 fprintf(f, "bitmap %s-b.raw\n", encoding_name); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
278 fprintf(f, "\n[characters]\n"); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
279 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
280 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
281 // render glyphs, compute bitmap size and [characters] section |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
282 glyphs = (FT_Glyph*)malloc(charset_size*sizeof(FT_Glyph*)); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
283 for (i= 0; i<charset_size; ++i) { |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
284 FT_GlyphSlot slot; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
285 FT_ULong character, code; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
286 FT_UInt glyph_index; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
287 FT_BBox bbox; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
288 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
289 character = charset[i]; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
290 code = charcodes[i]; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
291 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
292 // get glyph index |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
293 if (character==0) |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
294 glyph_index = 0; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
295 else { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
296 glyph_index = FT_Get_Char_Index(face, uni_charmap ? character:code); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
297 if (glyph_index==0) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
298 WARNING("Glyph for char 0x%02x|U+%04X|%c not found.", code, character, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
299 code<' '||code>255 ? '.':code); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
300 continue; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
301 } |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
302 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
303 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
304 // load glyph |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
305 error = FT_Load_Glyph(face, glyph_index, load_flags); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
306 if (error) { |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
307 WARNING("FT_Load_Glyph 0x%02x (char 0x%02x|U+%04X) failed.", glyph_index, code, character); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
308 continue; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
309 } |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
310 slot = face->glyph; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
311 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
312 // render glyph |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
313 if (slot->format != ft_glyph_format_bitmap) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
314 error = FT_Render_Glyph(slot, ft_render_mode_normal); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
315 if (error) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
316 WARNING("FT_Render_Glyph 0x%04x (char 0x%02x|U+%04X) failed.", glyph_index, code, character); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
317 continue; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
318 } |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
319 } |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
320 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
321 // extract glyph image |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
322 error = FT_Get_Glyph(slot, (FT_Glyph*)&glyph); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
323 if (error) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
324 WARNING("FT_Get_Glyph 0x%04x (char 0x%02x|U+%04X) failed.", glyph_index, code, character); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
325 continue; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
326 } |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
327 glyphs[glyphs_count++] = (FT_Glyph)glyph; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
328 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
329 #ifdef NEW_DESC |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
330 // max height |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
331 if (glyph->bitmap.rows > height) height = glyph->bitmap.rows; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
332 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
333 // advance pen |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
334 pen_xa = pen_x + glyph->bitmap.width + 2*padding; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
335 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
336 // font.desc |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
337 fprintf(f, "0x%04x %i %i %i %i %i %i;\tU+%04X|%c\n", unicode_desc ? character:code, |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
338 pen_x, // bitmap start |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
339 glyph->bitmap.width + 2*padding, // bitmap width |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
340 glyph->bitmap.rows + 2*padding, // bitmap height |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
341 glyph->left - padding, // left bearing |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
342 glyph->top + padding, // top bearing |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
343 f266ToInt(slot->advance.x), // advance |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
344 character, code<' '||code>255 ? '.':code); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
345 #else |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
346 // max height |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
347 if (glyph->top > ymax) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
348 ymax = glyph->top; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
349 //eprintf("%3i: ymax %i (%c)\n", code, ymax, code); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
350 } |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
351 if (glyph->top - glyph->bitmap.rows < ymin) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
352 ymin = glyph->top - glyph->bitmap.rows; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
353 //eprintf("%3i: ymin %i (%c)\n", code, ymin, code); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
354 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
355 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
356 /* advance pen */ |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
357 pen_xa = pen_x + f266ToInt(slot->advance.x) + 2*padding; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
358 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
359 /* font.desc */ |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
360 fprintf(f, "0x%04x %i %i;\tU+%04X|%c\n", unicode_desc ? character:code, |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
361 pen_x, // bitmap start |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
362 pen_xa-1, // bitmap end |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
363 character, code<' '||code>255 ? '.':code); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
364 #endif |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
365 pen_x = ALIGN(pen_xa); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
366 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
367 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
368 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
369 width = pen_x; |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
370 pen_x = 0; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
371 #ifdef NEW_DESC |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
372 if (height<=0) ERROR("Something went wrong. Use the source!"); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
373 height += 2*padding; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
374 #else |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
375 if (ymax<=ymin) ERROR("Something went wrong. Use the source!"); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
376 height = ymax - ymin + 2*padding; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
377 baseline = ymax + padding; |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
378 #endif |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
379 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
380 // end of font.desc |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
381 if (DEBUG) eprintf("bitmap size: %ix%i\n", width, height); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
382 fprintf(f, "# bitmap size: %ix%i\n", width, height); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
383 fclose(f); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
384 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
385 bbuffer = (unsigned char*)malloc(width*height); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
386 if (bbuffer==NULL) ERROR("malloc failed."); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
387 memset(bbuffer, 0, width*height); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
388 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
389 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
390 /* paste glyphs */ |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
391 for (i= 0; i<glyphs_count; ++i) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
392 glyph = (FT_BitmapGlyph)glyphs[i]; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
393 #ifdef NEW_DESC |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
394 paste_bitmap(&glyph->bitmap, |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
395 pen_x + padding, |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
396 padding); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
397 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
398 /* advance pen */ |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
399 pen_x += glyph->bitmap.width + 2*padding; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
400 #else |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
401 paste_bitmap(&glyph->bitmap, |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
402 pen_x + padding + glyph->left, |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
403 baseline - glyph->top); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
404 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
405 /* advance pen */ |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
406 pen_x += f1616ToInt(glyph->root.advance.x) + 2*padding; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
407 #endif |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
408 pen_x = ALIGN(pen_x); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
409 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
410 FT_Done_Glyph((FT_Glyph)glyph); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
411 } |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
412 free(glyphs); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
413 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
414 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
415 error = FT_Done_FreeType(library); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
416 if (error) ERROR("FT_Done_FreeType failed."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
417 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
418 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
419 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
420 /* decode from 'encoding' to unicode */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
421 FT_ULong decode_char(char c) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
422 FT_ULong o; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
423 char *inbuf = &c; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
424 char *outbuf = (char*)&o; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
425 int inbytesleft = 1; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
426 int outbytesleft = sizeof(FT_ULong); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
427 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
428 size_t count = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
429 |
1677 | 430 /* convert unicode BigEndian -> MachineEndian */ |
431 o = be2me_32(o); | |
432 | |
433 // if (count==-1) o = 0; // not OK, at least my iconv() returns E2BIG for all | |
434 if (outbytesleft!=0) o = 0; | |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
435 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
436 /* we don't want control characters */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
437 if (o>=0x7f && o<0xa0) o = 0; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
438 return o; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
439 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
440 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
441 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
442 void prepare_charset() { |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
443 FILE *f; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
444 FT_ULong i; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
445 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
446 f = fopen(encoding, "r"); // try to read custom encoding |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
447 if (f==NULL) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
448 int count = 0; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
449 // check if ucs-4 is available |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
450 cd = iconv_open(charmap, charmap); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
451 if (cd==(iconv_t)-1) ERROR("iconv doesn't know %s encoding. Use the source!", charmap); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
452 iconv_close(cd); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
453 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
454 cd = iconv_open(charmap, encoding); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
455 if (cd==(iconv_t)-1) ERROR("Unsupported encoding `%s', use iconv --list to list character sets known on your system.", encoding); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
456 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
457 charset_size = 256 - first_char; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
458 for (i = 0; i<charset_size; ++i) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
459 charcodes[count] = i+first_char; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
460 charset[count] = decode_char(i+first_char); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
461 //eprintf("%04X U%04X\n", charcodes[count], charset[count]); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
462 if (charset[count]!=0) ++count; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
463 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
464 charcodes[count] = charset[count] = 0; ++count; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
465 charset_size = count; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
466 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
467 iconv_close(cd); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
468 } else { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
469 unsigned int character, code; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
470 int count; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
471 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
472 eprintf("Reading custom encoding from file '%s'.\n", encoding); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
473 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
474 while ((count = fscanf(f, "%x%*[ \t]%x", &character, &code)) != EOF) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
475 if (charset_size==max_charset_size) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
476 WARNING("There is no place for more than %i characters. Use the source!", max_charset_size); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
477 break; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
478 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
479 if (count==0) ERROR("Unable to parse custom encoding file."); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
480 if (character<32) continue; // skip control characters |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
481 charset[charset_size] = character; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
482 charcodes[charset_size] = count==2 ? code : character; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
483 ++charset_size; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
484 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
485 fclose(f); |
1506
94d929f91b06
return value of iconv fixed for glibc 2.1.3, using strrchr instead of basename, as basename is buggy
arpi
parents:
1505
diff
changeset
|
486 // encoding = basename(encoding); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
487 } |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
488 if (charset_size==0) ERROR("No characters to render!"); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
489 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
490 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
491 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
492 // general outline |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
493 void outline( |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
494 unsigned char *s, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
495 unsigned char *t, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
496 int width, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
497 int height, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
498 int *m, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
499 int r, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
500 int mwidth) { |
1471
00a1f4b77803
dirty fix to get it work with glibc 2.1.x, and changed blur algorithm
arpi
parents:
1470
diff
changeset
|
501 |
1507 | 502 int x, y; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
503 for (y = 0; y<height; ++y) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
504 for (x = 0; x<width; ++x, ++s, ++t) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
505 unsigned max = 0; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
506 unsigned *mrow = m + r; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
507 unsigned char *srow = s -r*width; |
1507 | 508 int x1=(x<r)?-x:-r; |
509 int x2=(x+r>=width)?(width-x-1):r; | |
510 int my; | |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
511 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
512 for (my = -r; my<=r; ++my, srow+= width, mrow+= mwidth) { |
1507 | 513 int mx; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
514 if (y+my < 0) continue; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
515 if (y+my >= height) break; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
516 |
1507 | 517 for (mx = x1; mx<=x2; ++mx) { |
518 unsigned v = srow[mx] * mrow[mx]; | |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
519 if (v>max) max = v; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
520 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
521 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
522 *t = (max + base/2) / base; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
523 } |
1471
00a1f4b77803
dirty fix to get it work with glibc 2.1.x, and changed blur algorithm
arpi
parents:
1470
diff
changeset
|
524 } |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
525 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
526 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
527 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
528 // 1 pixel outline |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
529 void outline1( |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
530 unsigned char *s, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
531 unsigned char *t, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
532 int width, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
533 int height) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
534 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
535 int x, y, mx, my; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
536 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
537 for (x = 0; x<width; ++x, ++s, ++t) *t = *s; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
538 for (y = 1; y<height-1; ++y) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
539 *t++ = *s++; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
540 for (x = 1; x<width-1; ++x, ++s, ++t) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
541 unsigned v = ( |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
542 s[-1-width]+ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
543 s[-1+width]+ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
544 s[+1-width]+ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
545 s[+1+width] |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
546 )/2 + ( |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
547 s[-1]+ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
548 s[+1]+ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
549 s[-width]+ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
550 s[+width]+ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
551 s[0] |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
552 ); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
553 *t = v>maxcolor ? maxcolor : v; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
554 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
555 *t++ = *s++; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
556 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
557 for (x = 0; x<width; ++x, ++s, ++t) *t = *s; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
558 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
559 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
560 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
561 // gaussian blur |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
562 void blur( |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
563 unsigned char *buffer, |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
564 unsigned char *tmp, |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
565 int width, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
566 int height, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
567 int *m, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
568 int r, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
569 int mwidth, |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
570 unsigned volume) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
571 |
1507 | 572 int x, y; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
573 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
574 unsigned char *s = buffer - r; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
575 unsigned char *t = tmp; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
576 for (y = 0; y<height; ++y) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
577 for (x = 0; x<width; ++x, ++s, ++t) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
578 unsigned sum = 0; |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
579 int x1 = (x<r) ? r-x:0; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
580 int x2 = (x+r>=width) ? (r+width-x):mwidth; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
581 int mx; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
582 for (mx = x1; mx<x2; ++mx) |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
583 sum+= s[mx] * m[mx]; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
584 *t = (sum + volume/2) / volume; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
585 //*t = sum; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
586 } |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
587 } |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
588 tmp -= r*width; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
589 for (x = 0; x<width; ++x, ++tmp, ++buffer) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
590 s = tmp; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
591 t = buffer; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
592 for (y = 0; y<height; ++y, s+= width, t+= width) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
593 unsigned sum = 0; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
594 int y1 = (y<r) ? r-y:0; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
595 int y2 = (y+r>=height) ? (r+height-y):mwidth; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
596 unsigned char *smy = s + y1*width; |
1507 | 597 int my; |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
598 for (my = y1; my<y2; ++my, smy+= width) |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
599 sum+= *smy * m[my]; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
600 *t = (sum + volume/2) / volume; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
601 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
602 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
603 } |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
604 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
605 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
606 // Gaussian matrix |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
607 // Maybe for future use. |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
608 unsigned gmatrix(unsigned *m, int r, int w, double const A) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
609 unsigned volume = 0; // volume under Gaussian area is exactly -pi*base/A |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
610 int mx, my; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
611 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
612 for (my = 0; my<w; ++my) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
613 for (mx = 0; mx<w; ++mx) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
614 m[mx+my*w] = (unsigned)(exp(A * ((mx-r)*(mx-r)+(my-r)*(my-r))) * base + .5); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
615 volume+= m[mx+my*w]; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
616 if (DEBUG) eprintf("%3i ", m[mx+my*w]); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
617 } |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
618 if (DEBUG) eprintf("\n"); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
619 } |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
620 if (DEBUG) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
621 eprintf("A= %f\n", A); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
622 eprintf("volume: %i; exact: %.0f; volume/exact: %.6f\n\n", volume, -M_PI*base/A, volume/(-M_PI*base/A)); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
623 } |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
624 return volume; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
625 } |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
626 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
627 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
628 void alpha() { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
629 int const g_r = ceil(radius); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
630 int const o_r = ceil(thickness); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
631 int const g_w = 2*g_r+1; // matrix size |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
632 int const o_w = 2*o_r+1; // matrix size |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
633 double const A = log(1.0/base)/(radius*radius*2); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
634 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
635 int mx, my, i; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
636 unsigned volume = 0; // volume under Gaussian area is exactly -pi*base/A |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
637 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
638 unsigned *g = (unsigned*)malloc(g_w * sizeof(unsigned)); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
639 unsigned *om = (unsigned*)malloc(o_w*o_w * sizeof(unsigned)); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
640 if (g==NULL || om==NULL) ERROR("malloc failed."); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
641 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
642 // gaussian curve |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
643 for (i = 0; i<g_w; ++i) { |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
644 g[i] = (unsigned)(exp(A * (i-g_r)*(i-g_r)) * base + .5); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
645 volume+= g[i]; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
646 if (DEBUG) eprintf("%3i ", g[i]); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
647 } |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
648 //volume *= volume; |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
649 if (DEBUG) eprintf("\n"); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
650 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
651 /* outline matrix */ |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
652 for (my = 0; my<o_w; ++my) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
653 for (mx = 0; mx<o_w; ++mx) { |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
654 // antialiased circle would be perfect here, but this one is good enough |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
655 double d = thickness + 1 - sqrt((mx-o_r)*(mx-o_r)+(my-o_r)*(my-o_r)); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
656 om[mx+my*o_w] = d>=1 ? base : d<=0 ? 0 : (d*base + .5); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
657 if (DEBUG) eprintf("%3i ", om[mx+my*o_w]); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
658 } |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
659 if (DEBUG) eprintf("\n"); |
1471
00a1f4b77803
dirty fix to get it work with glibc 2.1.x, and changed blur algorithm
arpi
parents:
1470
diff
changeset
|
660 } |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
661 if (DEBUG) eprintf("\n"); |
1474 | 662 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
663 |
1507 | 664 if(thickness==1.0) |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
665 outline1(bbuffer, abuffer, width, height); // FAST solid 1 pixel outline |
1507 | 666 else |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
667 outline(bbuffer, abuffer, width, height, om, o_r, o_w); // solid outline |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
668 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
669 //outline(bbuffer, abuffer, width, height, gm, g_r, g_w); // Gaussian outline |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
670 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
671 blur(abuffer, bbuffer, width, height, g, g_r, g_w, volume); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
672 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
673 free(g); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
674 free(om); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
675 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
676 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
677 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
678 void usage() { |
4935 | 679 printf("Usage: %s [--outdir dir] [--append] [--unicode] [--blur b] [--outline o] encoding ppem font\n", command); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
680 printf("\n" |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
681 " Program creates 3 files: font.desc, <encoding>-a.raw, <encoding>-b.raw.\n" |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
682 "\n" |
4935 | 683 " --outdir output directory to place files.\n" |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
684 " --append append results to existing font.desc, suppress info header.\n" |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
685 " --unicode use Unicode in font.desc. This will work with -utf8 option of mplayer.\n" |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
686 " --blur b specify blur radius, float.\n" |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
687 " --outline o specify outline thickness, float.\n" |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
688 " encoding must be an 8 bit encoding, like iso-8859-2, or path to custom encoding file (see README).\n" |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
689 " To list encodings available on your system use iconv --list.\n" |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
690 " ppem Font size in pixels (default 24), float.\n" |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
691 " font Font file path. Any format supported by the freetype library (*.ttf, *.pfb, ...).\n" |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
692 ); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
693 exit(1); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
694 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
695 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
696 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
697 void parse_args(int argc, char **argv) { |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
698 int i, a = 0; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
699 double d; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
700 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
701 command = strrchr(argv[a], '/'); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
702 if (command==NULL) command = argv[a]; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
703 else ++command; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
704 ++a; --argc; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
705 |
4935 | 706 if (argc>=1 && strcmp(argv[a], "--outdir")==0) { |
707 ++a; --argc; | |
708 if (argc==0) usage(); | |
709 | |
710 outdir = strdup(argv[a]); | |
711 ++a; --argc; | |
712 } | |
713 | |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
714 if (argc>=1 && strcmp(argv[a], "--append")==0) { |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
715 append_mode = 1; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
716 ++a; --argc; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
717 } |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
718 |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
719 if (argc>=1 && strcmp(argv[a], "--unicode")==0) { |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
720 unicode_desc = 1; |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
721 ++a; --argc; |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
722 } |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
723 |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
724 if (argc>=1 && strcmp(argv[a], "--blur")==0) { |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
725 ++a; --argc; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
726 if (argc==0) usage(); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
727 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
728 d = atof(argv[a]); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
729 if (d>=0 && d<20) radius = d; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
730 else WARNING("using default blur radius."); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
731 ++a; --argc; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
732 } |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
733 |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
734 if (argc>=1 && strcmp(argv[a], "--outline")==0) { |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
735 ++a; --argc; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
736 if (argc==0) usage(); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
737 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
738 d = atof(argv[a]); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
739 if (d>=0 && d<20) thickness = d; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
740 else WARNING("using default outline thickness."); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
741 ++a; --argc; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
742 } |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
743 |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
744 if (argc<3) usage(); |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
745 |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
746 // encoding |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
747 if (argv[a][0]!=0) |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
748 encoding = argv[a]; |
1506
94d929f91b06
return value of iconv fixed for glibc 2.1.3, using strrchr instead of basename, as basename is buggy
arpi
parents:
1505
diff
changeset
|
749 encoding_name = strrchr(encoding, '/'); |
94d929f91b06
return value of iconv fixed for glibc 2.1.3, using strrchr instead of basename, as basename is buggy
arpi
parents:
1505
diff
changeset
|
750 if (!encoding_name) encoding_name=encoding; |
94d929f91b06
return value of iconv fixed for glibc 2.1.3, using strrchr instead of basename, as basename is buggy
arpi
parents:
1505
diff
changeset
|
751 else ++encoding_name; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
752 ++a; --argc; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
753 |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
754 // ppem |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
755 d = atof(argv[a]); |
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
756 if (d>2.) ppem = d; |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
757 ++a; --argc; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
758 |
1675
8ccac62ddfb7
Added --unicode switch. This is for UTF-8 encoded subtitles.
zybi
parents:
1607
diff
changeset
|
759 // font |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
760 font_path = argv[a]; |
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
761 ++a; --argc; |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
762 } |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
763 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
764 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
765 int main(int argc, char **argv) { |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
766 parse_args(argc, argv); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
767 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
768 padding = ceil(radius) + ceil(thickness); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
769 |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
770 prepare_charset(); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
771 |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
772 render(); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
773 write_bitmap(bbuffer, 'b'); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
774 |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
775 abuffer = (unsigned char*)malloc(width*height); |
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
776 if (abuffer==NULL) ERROR("malloc failed."); |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
777 alpha(); |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
778 write_bitmap(abuffer, 'a'); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
779 |
1607
7336606415f2
Implemented new Gaussian blur algorithm, extended font.desc format, optimized for speed and memory usage.
zybi
parents:
1507
diff
changeset
|
780 free(bbuffer); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
781 free(abuffer); |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
782 |
1505
842c29861e25
upgraded to 1.0b version by Artur Zaprzala <artur.zaprzala@talex.com.pl>
arpi
parents:
1474
diff
changeset
|
783 // fflush(stderr); |
1470
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
784 return 0; |
2c7b0478db0c
mplayer font-generator using FreeType 2.x by Artur Zaprzala <zybi@fanthom.irc.pl>
arpi
parents:
diff
changeset
|
785 } |