Grigori Goronzy [Sat, 26 Jun 2010 23:25:56 +0000 (01:25 +0200)]
Reduce number of glyph copies
Do not copy glyphs when it isn't really needed.
Profiling with valgrind's callgrind showed that FT_Glyph_Copy takes a
big fraction of the rendering time (~40%) for "simple styled softsubs"
cases. It turned out that glyphs are duplicated much more often than
is necessary. Reducing the number of copies cuts down the rendering
time for the "simple styled softsubs" case by about 70%!
Grigori Goronzy [Sat, 26 Jun 2010 03:15:18 +0000 (05:15 +0200)]
Add fixups for various font defects
Reverse "outside" contours with wrong winding correction, require
that a contour is "inside" for considering its removal; Move this
hack into ass_font.c, where it belongs.
Grigori Goronzy [Sat, 26 Jun 2010 00:17:03 +0000 (02:17 +0200)]
Improve fullname matching
Only match outline fonts and take slant and weight into consideration.
This matches all font faces which have at least the slant/weight that is
requested. This fixes issue 23; however, corner cases can be constructed
in which wrong fonts will be matched, if multiple slant/weight variants
of the same font exist, but that is very unlikely in practice.
Grigori Goronzy [Sun, 30 May 2010 23:38:11 +0000 (01:38 +0200)]
Add API function to flush all events
Add a function to flush all events in a track and increment
LIBASS_VERSION to indicate the addition.
Initial patch by Aurelien Jacobs (aurel AT gnuage DOT org).
Grigori Goronzy [Sat, 17 Apr 2010 23:28:25 +0000 (01:28 +0200)]
Use first Windows charmap as fallback
Extend the charmap selection heuristics to select the first Windows
charmap if no Unicode charmap is found.
Fixes one particular font, FGP楷書体NT-M, and possibly others.
Grigori Goronzy [Sat, 17 Apr 2010 20:59:47 +0000 (22:59 +0200)]
Support multiple faces per attachment correctly
Store the real font face id instead of using 0 all the time and use the
real font face id for font lookup as well. This makes font attachments
with multiple faces work correctly.
Grigori Goronzy [Thu, 18 Feb 2010 04:27:16 +0000 (05:27 +0100)]
Basic @font support
Do not skip '@' at the start of a font name in styles; detect '@' at
font name start and set a new attribute in ASS_Font accordingly.
Rotate affected glyphs after loading and calculate a suitable advance.
Grigori Goronzy [Sat, 10 Apr 2010 02:02:36 +0000 (04:02 +0200)]
Ignore global advance width unconditionally
Some (arguably) broken CJK fonts claim to have a fixed advance width,
but they actually use two different widths for half-width and full-width
characters. Even worse, some use proportional width.
This can cause problems under certain circumstances. A big project
(Cairo) uses a FreeType load flag to ignore the global advance width
for such fonts, so I assume it can be used safely. Let's do it just
like them.
Grigori Goronzy [Wed, 10 Feb 2010 22:51:11 +0000 (23:51 +0100)]
fontconfig: consider fullname for matching fonts
Additionally match fonts via the fullname (or name for humans) and
prefer these matches. Previously, libass matched against the family name
only and this name can be completely different from the fullname (which
is used by VSFilter!).
Grigori Goronzy [Thu, 21 Jan 2010 05:31:45 +0000 (06:31 +0100)]
Skip border generation if glyph is collapsed
If a character is completely collapsed in x or y direction (\fscx0,
\fscy0), the rasterizer will not generate any visible pixels. This also
means vsfilter will never draw any border in this case, since it works
on the pixel data. FreeType's stroker OTOH happily draws a border around
a character, no matter how collapsed it is. Emulate vsfilter's behavior
by skipping border generation if the glyph is collapsed.
Grigori Goronzy [Mon, 18 Jan 2010 23:42:22 +0000 (00:42 +0100)]
Up size limit for script files
Change size limit from 10MB to 50MB and clean up code a bit. A limit
still might be handy if one selects a very big file for subtitles by
accident. 50MB should be enough for even the biggest karaoke files.
Grigori Goronzy [Wed, 6 Jan 2010 22:51:01 +0000 (23:51 +0100)]
Improve rotation cache accuracy
In some cases 16.16 precision is not good enough. Instead use 10.22 and
use modulo 360.0 on the angles to make overflows impossible and improve
cache hit ratio sometimes.
Grigori Goronzy [Mon, 4 Jan 2010 18:54:19 +0000 (19:54 +0100)]
Reset clip_mode on new events
Make sure that the clip mode is reset to regular on new events.
Otherwise events after an event that used inverse clip will also use
inverse clip. Ouch! Usually the symptom is that subtitles become
invisible as the whole screen is clipped.
Grigori Goronzy [Sun, 3 Jan 2010 13:54:02 +0000 (14:54 +0100)]
Replace strtod with locale-independent strtod
strtod respects the locale and in some locales, the decimal separator is
not a point, leading to parsing errors in tags like \pos(23.4,5), which
are perfectly valid.
As there isn't a really portable way to use a particular locale just for
one call to strtod, reimplement it. The implementation was taken from
the 1.8 branch of Ruby.
Grigori Goronzy [Sun, 11 Oct 2009 07:07:26 +0000 (09:07 +0200)]
Fix libass w/o fontconfig
Make sure that libass does not crash even if no default font is
provided. Additionally, fix crashes related to drawings in this and
possibly other unusual cases.
Document the default_path and default_family parameters of
ass_set_fonts.
Grigori Goronzy [Thu, 10 Sep 2009 02:47:21 +0000 (04:47 +0200)]
Render NBSP (\h) as normal space
Many fonts don't have a non-breaking space (NBSP) character and this
can cause problems when these glyphs are substituted. Render them
like a regular space.
Grigori Goronzy [Tue, 8 Sep 2009 20:21:43 +0000 (22:21 +0200)]
Disable kerning by default and make it configurable
Kerning causes problems with many (broken) fonts. VSFilter doesn't use
kerning so these problems won't be apparant, while libass uses kerning
by default.
For compatibility reasons, disable kerning by default. In addition,
make it configurable through style overrides and the Script Info
header.
I.e. put "Kerning: yes" into the Script Info header to enable kerning.
With MPlayer, using "-ass-force-style Kerning=yes" will always
enable kerning.
This also includes a minor ABI change for tracking the kerning boolean.
As this only affects code that creates or modifies ASS_Tracks manually,
and I'm not aware of anyone doing that, the SONAME will not be bumped.
Grigori Goronzy [Tue, 1 Sep 2009 00:22:44 +0000 (02:22 +0200)]
Revert "Merge glyph and outline bitmap better"
This reverts commit d3cd5b0148d64ae0f6e288e69b09acfe639fdcce.
This hack improved blending in few situations, but at the same time
broke it in lots o others; get rid of it.
Grigori Goronzy [Mon, 31 Aug 2009 00:52:03 +0000 (02:52 +0200)]
Calculate glyph slant width correctly
If a glyph is wider than its advance width for italic to non-italic
style changes, assume it was obliqued by FreeType's FT_GlyphSlot_Oblique
function and offset the next glyph accordingly.
Grigori Goronzy [Sat, 29 Aug 2009 18:26:20 +0000 (20:26 +0200)]
Do not close empty drawings
If there are no points (i.e. illegal drawing), do not close the drawing
by incrementing the contour counter. Under certain circumstances, this
can crash the FreeType stroker.
Grigori Goronzy [Sun, 23 Aug 2009 14:33:38 +0000 (16:33 +0200)]
Fix opaque box sizing again
Another try to get it to work like in VSFilter. Hopefully it's
behaving the same now (except in some cases, since VSFilter layouts
word-based, but libass is glyph-based).
Additionally, make sure horizontal letter spacing (\fsp) is scaled
according to ScaleX.
Grigori Goronzy [Sun, 23 Aug 2009 01:49:22 +0000 (03:49 +0200)]
Fix glyph overlap blending
Use the bitmap pointer for the cache hash key. This preserves the
blending history, which fixes occasional corruptions due to previous
replacements not being dealt with correctly. It also simplifies the
hash key a lot and thus speeds up cache lookups.
Additionally, change the blending equation from max(a, b) to min(a + b,
0xff), i.e. a saturating addition. Usually this looks a lot better.
Grigori Goronzy [Thu, 20 Aug 2009 14:41:11 +0000 (16:41 +0200)]
Clip vector blending: do not copy last row padding
Do not copy the padding on the last row into the new buffer since we
cannot rely on the padding actually existing; might fix a segfault in
some obscure cases.
Grigori Goronzy [Thu, 20 Aug 2009 02:36:47 +0000 (04:36 +0200)]
Adjust shearing behavior to match VSFilter
Make horizontal shearing (\fax) shear from top to bottom of a glyph;
scale shearing factors with horizontal and vertical scaling factors.
This makes the shearing operations similar to VSFilter, except for
\fay in some cases, but this is not unexpected. Vertical shearing
is implemented different on purpose.
Grigori Goronzy [Wed, 19 Aug 2009 21:10:24 +0000 (23:10 +0200)]
VSFilter quirk: double-scale widths of opaque boxes
VSFilter double-scales the widths of the opaque box in X direction,
which gives much wider boxes than expected (or much less wider boxes)
if ScaleX != 100. Emulate this behavior, even if it is unbelievably
stupid and no doubt a bug in VSFilter.
Grigori Goronzy [Sat, 15 Aug 2009 01:31:52 +0000 (03:31 +0200)]
Improve and fix outline striker
Exit early if no striking is needed; make sure to strike in reverse
direction for non-truetype font and use the usual return value
convention (0 == no errors).
Grigori Goronzy [Wed, 12 Aug 2009 23:08:22 +0000 (01:08 +0200)]
Use event bbox for collision detection
Consider the bounding box of an event for collision detection instead
of only its vertical position and height. This allows multiple events
per line if they don't overlap.
Grigori Goronzy [Wed, 12 Aug 2009 04:20:26 +0000 (06:20 +0200)]
Always parse colors as hex for ASS tracks
According to the ASS specification, colors can only be specified in hex.
Modify the color parsing accordingly; this especially means that colors
where the hex sigil (the "H") is missing can now be parsed.
Grigori Goronzy [Wed, 12 Aug 2009 03:26:55 +0000 (05:26 +0200)]
Add glyph emboldening fallback
Fallback to embolden manually with FreeType in case a bold face was
requested, but no bold variant is available. The glyphs are slightly
emboldened (much less than FT_GlyphSlot_Embolden would do) and the
metrics are not touched at all.
Grigori Goronzy [Wed, 12 Aug 2009 03:07:13 +0000 (05:07 +0200)]
Fix italic to non-italic space handling
Scan backwards in the glyph array for a glyph with some actual points
when correctin glyph spacing after italic to non-italic style changes.
This is mostly useful in case a space ends italicized text.
Grigori Goronzy [Wed, 12 Aug 2009 01:43:46 +0000 (03:43 +0200)]
Support \q override tag
Parse \q override tag and set a new state variable to its value.
The line wrapping code still needs improvements; wrap style 0/3 are not
entirely correctly implemented and style 1 is not implemented.
Grigori Goronzy [Wed, 12 Aug 2009 00:59:00 +0000 (02:59 +0200)]
Implement BorderStyle 3
The "opaque box" border style renders an opaque box in the glyph area
instead of rendering a regular stroked border. This implementation
replaces the glyph outline by an outline that contains only one
rectangle with the size of the glyph, plus optional extra border.
Grigori Goronzy [Tue, 11 Aug 2009 23:45:39 +0000 (01:45 +0200)]
Fix advance for italic to non-italic style changes
After a italic to non-italic style change the space between the glyphs
is sometimes wrongly calculated, especially if the font doesn't have
an italic version and FreeType falls back to oblique glyphs.
In such cases, add additional space to the glyph's advance to make up
for the slant of the glyph; the amount is calculated from the glyph's
bbox.
Grigori Goronzy [Thu, 6 Aug 2009 11:04:20 +0000 (13:04 +0200)]
Rename typedefs (breaks API)
Rename all typedefs from the convention foo_bar_t, which can possibly
conflict with POSIX types, to FooBar (and ASS_FooBar for public
API typedefs). Fix formatting and stray comments while at it.