Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
5935dc9c
Commit
5935dc9c
authored
Sep 09, 2003
by
Derk-Jan Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
We no longer need this.
parent
86bc7bb8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
356 deletions
+0
-356
doc/subtitles/readme
doc/subtitles/readme
+0
-19
doc/subtitles/vlc-font.pl
doc/subtitles/vlc-font.pl
+0
-205
doc/subtitles/vlc-gimp.pl
doc/subtitles/vlc-gimp.pl
+0
-132
No files found.
doc/subtitles/readme
deleted
100644 → 0
View file @
86bc7bb8
How to create new subtitles fonts
---------------------------------
VLC uses run-length encoded fonts. We already provide 2 of these fonts
(share/font-eutopiabold21.rle and share/font-eutopiabold36.rle) but you might
also want to generate your own.
Two (very basic) perl scripts are provided to generate these fonts files,
vlc-gimp.pl and vlc-font.pl. vlc-gimp.pl is perl-fu, and uses gimp's font
plotting routines to create an image, which should be saved as an RAW PNM.
Installing vlc-gimp.pl with "gimptool --install-bin vlc-gimp.pl" will add a new
entry in the Xtns/Perl-Fu menu in gimp.
vlc-font.pl extracts the characters from the raw PNM, and creates a run-length
encoded font file which VLC can use. As already stated these scripts are quite
basic so you will have to hack them to your liking.
Also note that the subtitler engine in VLC is currently being replaced to use
the freetype library which will allow the use of fonts already available on
your system and some other new powerful features.
\ No newline at end of file
doc/subtitles/vlc-font.pl
deleted
100755 → 0
View file @
86bc7bb8
#! /usr/bin/perl
$file_input
=
"
font.pnm
";
$file_output
=
"
eutopiabold36.rle
";
$border
=-
1
;
$spaceborder
=
4
;
$|
=
1
;
open
(
INPUT
,
$file_input
)
||
die
"
Couldn't open font: $!
\n
";
$tag
=<
INPUT
>
;
chop
(
$tag
);
if
(
$tag
ne
"
P6
")
{
die
"
Couldn't process image: not a pnm file (
$tag
)
";
}
$comment
=<
INPUT
>
;
$dimensions
=<
INPUT
>
;
chop
(
$dimensions
);
if
(
$dimensions
=~
/(\d+) (\d+)/
)
{
$width
=
$1
;
$height
=
$2
;
}
else
{
die
"
Couldn't process image: couldn't get dimensions
";
}
$bits
=<
INPUT
>
;
print
"
width
$width
height
$height
\n
";
for
(
$j
=
0
;
$j
<
$height
;
$j
++
)
{
for
(
$i
=
0
;
$i
<
$width
;
$i
++
)
{
$red
[
$i
][
$j
]
=
ord
(
getc
(
INPUT
));
$green
[
$i
][
$j
]
=
ord
(
getc
(
INPUT
));
$blue
[
$i
][
$j
]
=
ord
(
getc
(
INPUT
));
}
print
"
.
";
}
print
"
\n
";
close
(
INPUT
);
open
(
OUTPUT
,"
>
"
.
$file_output
)
||
die
"
Couldn't open output: $!
\n
";
# Put header
print
OUTPUT
pack
("
C2
",
0x36
,
0x05
);
# Put font height
print
OUTPUT
pack
("
C
",
$height
);
$xstart
=
0
;
# Search for space
$xstart
=
2
;
$x
=
$xstart
;
$blank
=
0
;
while
(
$x
<
$width
&&
!
$blank
)
{
$blank
=
1
;
for
(
$y
=
0
;
$y
<
$height
;
$y
++
)
{
if
(
$blue
[
$x
][
$y
]
!=
255
)
{
$blank
=
0
;
}
}
if
(
!
$blank
)
{
$x
++
;
}
}
$xstart
=
$x
;
$x
=
$xstart
;
$blank
=
1
;
while
(
$x
<
$width
&&
$blank
)
{
$blank
=
1
;
for
(
$y
=
0
;
$y
<
$height
;
$y
++
)
{
if
(
$blue
[
$x
][
$y
]
!=
255
)
{
$blank
=
0
;
}
}
if
(
$blank
)
{
$x
++
;
}
}
$xend
=
$x
;
$spacewidth
=
$xend
-
$xstart
+
$spaceborder
;
$spacewidth
=
$spacewidth
/
2
;
if
(
$spacewidth
==
0
)
{
$spacewidth
=
1
;
}
print
"
space start=
$xstart
end=
$xend
-> width=
$spacewidth
\n\n
";
# Put space character code
print
OUTPUT
pack
("
C
",
32
);
# Put space width
print
OUTPUT
pack
("
C
",
$spacewidth
);
# Put space RLE data
for
(
$y
=
0
;
$y
<
$height
;
$y
++
)
{
print
OUTPUT
pack
("
C
",
1
);
print
OUTPUT
pack
("
C
",
0
);
print
OUTPUT
pack
("
C
",
$spacewidth
);
}
$char
=
33
;
while
(
$xstart
<
$width
)
{
print
"
looking for character
$char
\"
"
.
chr
(
$char
)
.
"
\"\n
";
$x
=
$xstart
;
$blank
=
1
;
while
(
$x
<
$width
&&
$blank
)
{
$blank
=
1
;
for
(
$y
=
0
;
$y
<
$height
;
$y
++
)
{
if
(
$blue
[
$x
][
$y
]
!=
255
)
{
$blank
=
0
;
}
}
if
(
$blank
)
{
$x
++
;
}
}
$xstart
=
$x
;
$x
=
$xstart
;
$blank
=
0
;
while
(
$x
<
$width
&&
!
$blank
)
{
$blank
=
1
;
for
(
$y
=
0
;
$y
<
$height
;
$y
++
)
{
if
(
$blue
[
$x
][
$y
]
!=
255
)
{
$blank
=
0
;
}
}
if
(
!
$blank
)
{
$x
++
;
}
}
$xend
=
$x
;
print
"
start=
$xstart
end=
$xend
\n
";
$dstart
=
$xstart
-
$border
;
if
(
$dstart
<
0
)
{
$dstart
=
0
;
}
$dend
=
$xend
+
$border
;
if
(
$dend
>
$width
)
{
$dend
=
$width
;
}
# Put character
print
OUTPUT
pack
("
C
",
$char
);
# Put character width
print
OUTPUT
pack
("
C
",
$dend
-
$dstart
);
for
(
$y
=
0
;
$y
<
$height
;
$y
++
)
{
$linecode
=
"";
$bytecode
=
"";
$lastcolour
=-
1
;
$count
=
0
;
for
(
$x
=
$dstart
;
$x
<
$dend
;
$x
++
)
{
# Transparent background
$c
=
"
:
";
$colour
=
0
;
# Anti-aliased foreground
if
(
$blue
[
$x
][
$y
]
<
255
&&
$red
[
$x
][
$y
]
>
0
)
{
$c
=
"
+
";
$colour
=
1
;
}
# Solid foreground
if
(
$blue
[
$x
][
$y
]
==
255
&&
$red
[
$x
][
$y
]
==
255
)
{
$c
=
"
#
";
$colour
=
2
;
}
# Anti-aliased shadow (same as shadow)
if
(
$blue
[
$x
][
$y
]
<
255
&&
$red
[
$x
][
$y
]
==
0
)
{
$c
=
"
.
";
$colour
=
3
;
}
# Solid shadow
if
(
$blue
[
$x
][
$y
]
==
0
&&
$red
[
$x
][
$y
]
==
0
)
{
$c
=
"
";
$colour
=
3
;
}
print
$c
;
if
(
$colour
!=
$lastcolour
)
{
if
(
$lastcolour
!=-
1
)
{
$linecode
.=
"
$lastcolour
,
$count
";
$bytecode
.=
pack
("
C2
",
$lastcolour
,
$count
);
}
$lastcolour
=
$colour
;
$count
=
1
;
}
else
{
$count
++
;
}
}
if
(
$lastcolour
!=-
1
)
{
$linecode
.=
"
$lastcolour
,
$count
";
$bytecode
.=
pack
("
C2
",
$lastcolour
,
$count
);
}
print
"
[
$linecode
]
\n
";
# Put length of RLE line
print
OUTPUT
pack
("
C*
",
length
(
$bytecode
)
/
2
);
# Put RLE line
print
OUTPUT
$bytecode
;
}
print
"
\n
";
$xstart
=
$xend
+
1
;
$char
++
;
}
print
OUTPUT
pack
("
C
",
255
);
print
"
Done!
\n
";
close
(
OUTPUT
);
doc/subtitles/vlc-gimp.pl
deleted
100755 → 0
View file @
86bc7bb8
#!/usr/bin/perl
use
Gimp
"
:auto
";
use
Gimp::
Fu
;
sub
vlc_subtitler_font
{
$shadowcolour
=
[
0
,
0
,
0
];
$textcolour
=
[
255
,
255
,
255
];
$backcolour
=
[
0
,
0
,
255
];
$font
=
"
-*-utopia-bold-r-*-*-21-*-*-*-*-*-*-*
";
$border
=
3
;
$alias
=
1
;
$text
=
"
_
";
for
(
$i
=
33
;
$i
<
127
;
$i
++
)
{
$text
.=
chr
(
$i
);
$text
.=
"
";
}
# Create a new image of an arbitrary size with
$img
=
gimp_image_new
(
100
,
100
,
RGB
);
# Create a new layer for the background of arbitrary size, and
# add it to the image
my
$background
=
gimp_layer_new
(
$img
,
100
,
100
,
RGB
,
"
Background
",
100
,
NORMAL_MODE
);
gimp_image_add_layer
(
$background
,
1
);
# Choose color of text
gimp_palette_set_foreground
(
$textcolour
);
# Create the text layer. Using -1 as the drawable creates a new layer.
my
$text_layer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
# Get size of the text drawable and resize the image and the
# background layer to this size.
my
(
$width
,
$height
)
=
(
$text_layer
->
width
,
$text_layer
->
height
);
gimp_image_resize
(
$img
,
$width
,
$height
,
0
,
0
);
gimp_layer_resize
(
$background
,
$width
,
$height
,
0
,
0
);
gimp_layer_delete
(
$text_layer
);
# Fill the background layer now when it has the right size.
gimp_palette_set_background
(
$backcolour
);
gimp_edit_fill
(
$background
,
BG_IMAGE_FILL
);
my
$shadowlayer
,
$textlayer
;
# Plot eight shadow copies of the text
gimp_palette_set_foreground
(
$shadowcolour
);
$shadowlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_layer_translate
(
$shadowlayer
,
-
2
,
0
);
gimp_image_flatten
(
$img
);
gimp_palette_set_foreground
(
$shadowcolour
);
$shadowlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_layer_translate
(
$shadowlayer
,
2
,
0
);
gimp_image_flatten
(
$img
);
gimp_palette_set_foreground
(
$shadowcolour
);
$shadowlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_layer_translate
(
$shadowlayer
,
0
,
-
2
);
gimp_image_flatten
(
$img
);
gimp_palette_set_foreground
(
$shadowcolour
);
$shadowlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_layer_translate
(
$shadowlayer
,
0
,
2
);
gimp_image_flatten
(
$img
);
gimp_palette_set_foreground
(
$shadowcolour
);
$shadowlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_layer_translate
(
$shadowlayer
,
-
1
,
-
1
);
gimp_image_flatten
(
$img
);
gimp_palette_set_foreground
(
$shadowcolour
);
$shadowlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_layer_translate
(
$shadowlayer
,
-
1
,
1
);
gimp_image_flatten
(
$img
);
gimp_palette_set_foreground
(
$shadowcolour
);
$shadowlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_layer_translate
(
$shadowlayer
,
1
,
-
1
);
gimp_image_flatten
(
$img
);
gimp_palette_set_foreground
(
$shadowcolour
);
$shadowlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_layer_translate
(
$shadowlayer
,
1
,
1
);
gimp_image_flatten
(
$img
);
# Plot the text itself
gimp_palette_set_foreground
(
$textcolour
);
$textlayer
=
gimp_text_fontname
(
$img
,
-
1
,
0
,
0
,
$text
,
$border
,
$alias
,
xlfd_size
(
$font
),
$font
);
gimp_image_flatten
(
$img
);
return
$img
;
}
# register the script
register
"
vlc_subtitler_font
",
"
vlc subtitler font
",
"
vlc subtitler font
",
"
Andrew Flintham
",
"
Andrew Flintham
",
"
2002-06-18
",
"
<Toolbox>/Xtns/Perl-Fu/VLC Subtitles Font
",
"
*
",
[]
,
\&
vlc_subtitler_font
;
# Handle over control to gimp
exit
main
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment