Grigori Goronzy [Sun, 10 Jul 2011 02:08:55 +0000 (04:08 +0200)]
Separate glyph font face matching and glyph loading
Split up ass_font_get_glyph into two functions: one function matches
checks the fonts for support of the requested codepoint and returns
a face_index and glyph_index to later load the glyph, with a second
function.
This approach is very useful for shaping, which needs to be done
on runs with the same font face and font size and changes the
glyph_index.
Grigori Goronzy [Sat, 9 Jul 2011 23:53:09 +0000 (01:53 +0200)]
Fix bitmap cache
Pass the *complete* hash key to the cache handling functions, not
only the outline-specific subkey. This mistake completely stopped
the cache from actually working and resulted in great slowdown!
Grigori Goronzy [Sat, 9 Jul 2011 22:38:12 +0000 (00:38 +0200)]
Reorder positions for "Banner" effect text
Events that use the "Banner" effect have different wrapping/breaking
handling (none at all, to be exact) and need special treatment to
make reordering work.
Grigori Goronzy [Sat, 9 Jul 2011 20:04:01 +0000 (22:04 +0200)]
Redesign horizontal alignment calculations for bidi
The line alignment code determined the first and last glyph in a
line and calculated the distance from that. This is rather arcane
and doesn't easily work with bidi. Redesign the algorithm to simply
add together all individual character widths instead.
Grigori Goronzy [Wed, 6 Jul 2011 21:19:54 +0000 (23:19 +0200)]
Provisional bidi and shaping support
Adds fully working bidirectional text and simple shaping support.
The following works:
- bidirectional text according to the Unicode Bidirectional Algorithm
- simple shaper for mirrored forms (brackets, etc.) according to
rule L4 of the Unicode Bidirectional Algorithm
- reordering into visual order with correct line wrapping
However, the implementation certainly needs efficiency improvements
(caching, less malloc'ing), a proper shaper (HarfBuzz) needs to be
hooked up and various bugs with karaoke and positioning need to be
fixed.
Grigori Goronzy [Mon, 4 Jul 2011 10:59:11 +0000 (12:59 +0200)]
Introduce bitmap runs
Prepare for run-based rendering. In the parser, increment a run id
according to relevant style changes (color, border, shadow, etc.) to
mark the points where a new bitmap needs to be started. Modify the line
wrapper to increment the run ids of each glyph after a break.
Add functions to calculate the render size of runs for rasterization.
Grigori Goronzy [Fri, 1 Jul 2011 01:13:22 +0000 (03:13 +0200)]
Cache ascender/descender
Cache ascender/descender so they don't have to be queried every frame
for every glyph. This also makes it possible to more uniformly handle
drawings and glyphs.
Grigori Goronzy [Mon, 27 Jun 2011 19:04:12 +0000 (21:04 +0200)]
cache: unified bitmap cache
Similarly to the glyph cache, subclass the bitmap cache to allow both
outline bitmaps and clipping mask bitmaps to coexist in the same cache
in a much cleaner way.
Grigori Goronzy [Mon, 27 Jun 2011 18:10:45 +0000 (20:10 +0200)]
cache: use outline-bitmap hierarchy to slim down bitmap hash key
The bitmap hash key duplicated a lot of information the glyph hash
key already saves. The subclassing introduced recently complicates
this even more. Modify the hash key to utilize a pointer to the glyph
hash value instead, which is faster and more flexible. Make sure to
always empty the bitmap cache when the glyph cache is emptied.
Grigori Goronzy [Mon, 27 Jun 2011 00:17:10 +0000 (02:17 +0200)]
cache: unified outline cache for glyphs/drawings
Glyphs and drawings have wildly different hash keys. Subclass the hash
keys of glyphs and drawings in a new, unified outline cache. This also
fixes some issues with drawings in the glyph cache. Now, the textual
description of the drawing is included in the key (the hash value isn't
really good enough, especially not fnv32) and the baseline offset is
saved as well.
Grigori Goronzy [Mon, 20 Jun 2011 21:12:22 +0000 (23:12 +0200)]
Use bare outlines for drawings
This finally gets rid of the nasty hack that manipulated a glyph
we somehow got from FreeType. Simplifies drawing handling a bit and
decouples drawing code from all font handling and related (fontconfig,
etc.) code.
Grigori Goronzy [Mon, 20 Jun 2011 20:50:34 +0000 (22:50 +0200)]
Convert outline processing and caching from glyphs to bare outlines
This introduces functions to use and copy pointered outline objects
easily and uses these instead of glyphs everywhere.
Previously the glyph cache was abused for caching vector clipping masks,
but this isn't possible anymore (nor desirable), thus vector clipping
cache has been disabled for the moment.
Grigori Goronzy [Mon, 13 Jun 2011 20:39:26 +0000 (22:39 +0200)]
Render outlines, not glyphs
libass can render both regular glyphs (extracted from a font) and
drawings, which are inserted into an existing glyph so far. This is a
rather crude hack. However, it is necessary, as the renderer only works
with FT_Glyphs. The obvious solution is to work on the underlying
outlines directly instead.
This is the first step to make this possible: change the basic
rasterizer to use the outline-specific rasterization functions. There
are more advantages:
- It's more efficient. The bitmap can be directly rendered into the
bordered target bitmap.
- This should make it easier to adapt the renderer to run-based
rendering later on (the pixels are ORed into the target)
The higher-level rendering code still needs to be adjusted.
Grigori Goronzy [Sat, 9 Apr 2011 19:48:08 +0000 (21:48 +0200)]
Improved "last resort" charmap matching
After font reselection, loop through all charmaps if no glyph can't be
found until we hopefully find one that works. If we get here at all, the
font is seriously broken, so this is unlikely to harm anything.
This improves the last resort charmap fallback introduced in 96057d.
Grigori Goronzy [Sat, 9 Apr 2011 02:06:39 +0000 (04:06 +0200)]
Much improved "Default" style
Make the "Default" style, useful as a fallback and required by few
scripts for proper rendering, actually do something sensible. Font,
sizes, et cetera are set up mostly like VSFilter.
Grigori Goronzy [Wed, 16 Feb 2011 19:31:15 +0000 (20:31 +0100)]
Fix fontconfig disabled at runtime
MPlayer is able to use this configuration with the -nofontconfig flag;
this fixes crashes in case no font is available. Fixes a crash at uninit
as well.
Grigori Goronzy [Wed, 16 Feb 2011 18:58:15 +0000 (19:58 +0100)]
test: fix compilation with libpng 1.5, rename configure switch
libpng 1.5 renamed the jmpbuf variable to jmp_buf. Since direct access
to this variable is deprecated, it makes more sense to use the function
png_jmpbuf() instead.
Also, rename the --enable-png switch to --enable-test to make clear this
is a debugging option.
Initial patch by Alexis Ballier, aballier AT gentoo DOT org.
Grigori Goronzy [Wed, 16 Feb 2011 18:39:54 +0000 (19:39 +0100)]
Require fontconfig by default
Enable configure to require fontconfig by default; libass is quite
useless for most purposes without it anyway. If you want to build
without fontconfig, explicitly disable it with --disable-fontconfig.
Grigori Goronzy [Wed, 9 Feb 2011 00:27:22 +0000 (01:27 +0100)]
Simplify word wrapping and fix possible endless loop
wrap_lines_smart() got stuck if there was a long line without spaces
followed by a hard linebreak. When the loop got to the '\n' character
the hard linebreak was not handled because the line was already over
wrap length and soft linebreak handling had precedence. Then at the
end of the loop body the code noted that the hard linebreak hadn't yet
been handled, and the same glyph needed to be reprocessed for that.
However, the soft linebreak code hadn't actually done anything because
there was no space to break at, and thus the loop repeated from the
exact same state forever.
Handle this by removing the check for an additional hard linebreak
after a soft linebreak, which stepped back by one char. This is a
very marginal case and shouldn't really matter in practice.
Grigori Goronzy [Tue, 28 Sep 2010 14:10:31 +0000 (16:10 +0200)]
Relicense to ISC
In hope to make libass as useful as possible, relicense libass to ISC, a
simplified 2-clause BSD license. All contributors who provided
non-trivial changes have granted their permission for this.
Grigori Goronzy [Thu, 12 Aug 2010 20:15:10 +0000 (22:15 +0200)]
Add support for \fs+ and \fs- syntax
These forms can be used to add or subtract a value from the
current font size instead of setting a new font size. Animations
are supported, but not recommended, as they won't be fluid due to
grid-fitting/hinting.
Grigori Goronzy [Thu, 12 Aug 2010 19:47:24 +0000 (21:47 +0200)]
Only word wrap on spaces
It looks like VSFilter only ever wraps on spaces, even if the line
length is going to overflow. We should do that as well.
Fixes a pretty confusing problem with scrolling vertical text.
Grigori Goronzy [Mon, 9 Aug 2010 00:55:30 +0000 (02:55 +0200)]
Fix drawing leakage: delay glyph allocation
Delay allocation of the "faux" glyph until a drawing is parsed.
This helps with fixing a (pretty bad) memory leak and also reduces frame
overhead a little.
Grigori Goronzy [Sun, 1 Aug 2010 21:52:30 +0000 (23:52 +0200)]
Fall back to first charmap as last resort
If we're already after the font reselection stage and a glyph cannot be
found in a font, try again with the first charmap as a last resort.
This is needed for old "symbol" fonts, for example.
Grigori Goronzy [Sun, 1 Aug 2010 01:30:59 +0000 (03:30 +0200)]
Limit (bitmap) glyph cache size
Now that bitmap glyphs (for vector clip masks) are stored in the glyph
cache, make sure it cannot grow indefinitely easily. Similar to the
bitmap cache, track approximate size of the cached elements and reset
if the cache exceeds a certain limit.
Also, reduce default bitmap cache size to 30 MB as we have essentially
two bitmap caches now. That's still plenty in all use cases where
caching matters.
Grigori Goronzy [Thu, 29 Jul 2010 00:38:29 +0000 (02:38 +0200)]
Fix drawing cbox calculation
Use extremes of all points fed to the parser, instead of only points
that are added to the outline.
Fixes a rendering problem reported on IRC and should fix Issue #7.
Grigori Goronzy [Thu, 22 Jul 2010 17:02:12 +0000 (19:02 +0200)]
Better PAR correction
PAR correction so far merely applied a horizontal scaling factor to
glyphs right after loading. This screws up transformed text,
unfortunately.
It's a much better approach to typeset text without correction and scale
everything at the very end. In MPlayer, an EOSD rendering now looks
exactly the same as a video filter rendering (except for more sharpness
in the EOSD case).
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.