summaryrefslogtreecommitdiffstats
path: root/libass
Commit message (Collapse)AuthorAgeFilesLines
* fontselect: expose a fontprovider listing APIStefano Pigozzi2015-07-103-0/+24
| | | | | | This allows client code to query libass for the font providers it was compiled with. It can be useful for clients so that they can show selection interfaces to their users.
* fontselect: expose a fontprovider selection APIStefano Pigozzi2015-07-106-20/+59
| | | | | | | | | Allow the user of libass to select the font provider from ass_set_fonts. This API change actually doesn't break client code which was passing `fc=1`; now the same value will autodetect a usable font provider. Also add an api to list available font providers as that is useful for client code to show drop down menus with a font provider to choose from.
* fontselect: use fallback fonts when querying font providersStefano Pigozzi2015-07-101-18/+11
| | | | | | | | | 51f9e80b added a MatchFontsFunc callback which allows to lookup font names directly on the font provider. This approach broke support for font fallback which worked only with lookups from libass in-memory font database. This commit moves the font fallback code in the font lookup function, so that it is available for all font providers.
* coretext: fix conversion from CFStringRef to utf8 bufferStefano Pigozzi2015-07-101-3/+5
| | | | | | The code incorrectly assumed that the utf8 characters could always be represented with only one byte. This commit queries CFStringRef instances for the actual amount of bytes needed.
* coretext: also lazy load fonts based on Family and PostScript namesStefano Pigozzi2015-07-101-8/+21
| | | | | Previously, the lazy load of fonts was only using display name. Also use the other names available through the CoreText API (FamilyName and PostScriptName).
* fontselect: coretext: allow to match fontname using the providerStefano Pigozzi2015-07-103-5/+70
| | | | | | | | | | | | | | | | | | | | | | Not all APIs cache everything the same way that fontconfig does. This allows to first perform a match based on the font name and then score the matched fonts using the common code using and in memory database approach. The benefit is the application doesn't have to load all of the fonts and query for weight, slant, width, path and fullnames. I left both code paths inside ass_coretext.c. This allows to test matching problems and have a term of comparison with the slower implementation. To activate it one just has to flip the CT_FONTS_EAGER_LOAD define to 1. Here are some benchmarks with a pretty typical OS X font library of ~600 fonts and using Libass's test program to load a script with 'Helvetica Neue': CT_FONTS_EAGER_LOAD=0 0.04s user 0.02s system 79% cpu 0.081 total CT_FONTS_EAGER_LOAD=1 0.12s user 0.06s system 44% cpu 0.420 total
* fontselect: coretext: allow selection based on PostScript nameStefano Pigozzi2015-07-106-31/+68
| | | | | | | | | | | Up until now fontselect used the face index to identify which font to load from a font collection. While this pretty convenient when using something freetype based like fontconfig, it seems to be somewhat freetype specific. CoreText uses the PostScript name as the unique identifier of a font. This commit allows to use that instead of the index to decide which face to open with FT_New_Face. To use the PostScript name the provider must return a -1 index and the PostScript name.
* fontselect: implement a coretext font providerStefano Pigozzi2015-07-104-1/+262
| | | | | | | | | | | | | | | Fontconfig is known to be very slow on OS X and Windows, this has to do with the extremely prohibitive cache times (which are getting even longer with latest versions of Fontconfig). This commits starts to address the problem by using CoreText on OS X to load the font data. The commit uses the simplest possible approach to load all of the data in memory and then use it to match. This causes a somewhat slow startup time (around ~400ms on my i7) but it is already better than waiting *minutes* for Fontconfig to cache the fonts data. A later commit will improve the speed of the match by using a hybrid approach that lazy loads in the libass database only the necessary fonts.
* Add todo commentsGrigori Goronzy2015-07-102-0/+5
|
* Support multiple font family namesGrigori Goronzy2015-07-103-42/+67
| | | | | | Some fonts use localized family names, especially CJK fonts, which often have English and Japanese or Chinese names. Handle these cases just like full names.
* nit: add width to font_info_dumpGrigori Goronzy2015-07-101-0/+1
|
* Add support for font width propertyGrigori Goronzy2015-07-103-7/+19
| | | | | | Add a width field to metadata. This is used for sorting fonts as well. Fixes wrong matches with different width variants in the same font family.
* Use streamed access for memory fontsGrigori Goronzy2015-07-105-30/+70
| | | | | This is faster in many cases, and more suitable for Windows' GetFontData function.
* Pass family name as path for memory fontsGrigori Goronzy2015-07-102-5/+5
| | | | | This is a bit nicer because we can actually see which physical font has been selected for a certain logical font.
* Export font provider interfaceGrigori Goronzy2015-07-105-37/+83
| | | | | | | Add wrapper to the ASS_Renderer to create a font provider from its internal font selector and shuffle some code around to export everything that's needed for font providers to the public. Document font provider functions.
* Memory font supportGrigori Goronzy2015-07-104-51/+98
| | | | | Allow memory fonts with the get_face_data callback. This feature is used for embedded fonts, but can be used by any font provider.
* Make sure font path is validGrigori Goronzy2015-07-101-1/+3
| | | | We do not support memory-based fonts yet, so a path is mandatory.
* Fix weight validity checkGrigori Goronzy2015-07-101-1/+1
|
* Free a provider's fonts when it is freedGrigori Goronzy2015-07-101-25/+65
| | | | | When a provider is freed, iterate the font database, free all fonts that belong to that provider and compact the database afterwards.
* Add convenience defines for slant valuesGrigori Goronzy2015-07-101-0/+3
| | | | | | | | There is no standard scale for slant. This is almost a boolean attribute. However, a font can have a real italic variant, and/or a simple oblique variant. fontconfig's notation supports both of these, so it makes sense to reuse that notation for the sake of flexibility; we might need to differentiate between them.
* oops: remove debug outputGrigori Goronzy2015-07-101-2/+0
|
* Check weight and slant validity in font providerGrigori Goronzy2015-07-101-3/+13
| | | | | When adding a new font, check that weight and slant are valid. If they're not, use reasonable defaults.
* Use TrueType font weight scaleGrigori Goronzy2015-07-105-7/+23
| | | | | | | | | | fontconfig uses an unusual scale from 0-215 for the font weight. It looks like it is somewhat derived from the typographic scale some font families use, but is still rather nonstandard. Nowadays the TrueType scale from 100-900 seems to be standard. CSS uses it, for example. However, most importantly, VSFilter also uses the TrueType scale. So let's use it in libass, too.
* Fix similarity calculationsGrigori Goronzy2015-07-101-2/+2
|
* Add a fixed set of fallback fontsGrigori Goronzy2015-07-101-11/+22
| | | | | Add a small set of fixed fallback fonts, some of them with very wide glyph coverage.
* Don't match any font if there's no glyph coverageGrigori Goronzy2015-07-101-1/+3
| | | | | Do not return a font face at all instead of using the last one. Fixes fallback to the default font path.
* Restore fontconfig runtime configurationGrigori Goronzy2015-07-103-9/+8
| | | | | | | | | | | Pass the fontconfig configuration file option and enable switch through into the font selector. This restores some of the old functionality related to fontconfig. However, the functionality to delay the fontconfig database update will not come back. This is not a big problem. Later it will be possible to manually add the fontconfig provider, which will delay the update in a comparable way.
* Fix compilation without fontconfigGrigori Goronzy2015-07-101-0/+4
| | | | | | Conditionally add the fontconfig provider. We can actually run without fontconfig now! That is, if embedded fonts or fallbacks are good enough.
* Fix off-by-one bug in font matchingGrigori Goronzy2015-07-101-1/+1
|
* Add reference to font provider in font databaseGrigori Goronzy2015-07-101-13/+20
| | | | | | This provides more flexibility than just referencing the callbacks: we can identify the font provider (useful for removing fonts when a provider is freed) and possibly access the font provider private data.
* Improve font selector/provider documentationGrigori Goronzy2015-07-101-5/+41
|
* Convert embedded font handling to a real font providerGrigori Goronzy2015-07-101-33/+55
|
* Add glyph coverage map for embedded fontsGrigori Goronzy2015-07-103-5/+83
| | | | | | Introduce a simple glyph coverage map (created when the font is added) and use it for checking glyph coverage in font selection. This uses a simple linear search at the moment.
* Never add a face twice to an ASS_FontGrigori Goronzy2015-07-104-27/+52
| | | | | | Introduce a unique ID per font face and check it in add_face to make sure we never add a font face twice. This is useful in case the glyph coverage report is unreliable.
* Fix trimming functionGrigori Goronzy2015-07-101-1/+1
| | | | Did not correctly handle empty strings (only whitespace). Whoops.
* Trim spaces of font family stringsGrigori Goronzy2015-07-103-3/+23
| | | | | This adds a trimming utility function that is used for trimming strings of font requests in the font sorter.
* Custom font matching and font sourcesGrigori Goronzy2015-07-1013-563/+733
| | | | | | | Implement a simple font sorter (FontSelector) and an interface to deal with multiple font sources (FontProvider). Unfinished business, but works for the most part. Currently the only implemented FontProvider uses fontconfig.
* Implement cascade gaussian blurDr.Smile2015-07-0410-351/+2525
| | | | | | | | | | That's complete version with SSE2/AVX2 assembly. Should be much faster than old algorithm even in pure C. Algorithm description can be found in this article (PDF): https://github.com/MrSmile/CascadeBlur/releases Close #9
* Fix code path of rasterization through FreeTypeDr.Smile2015-07-011-2/+2
|
* Release 0.12.30.12.3wm42015-06-302-2/+2
|
* Makefile.am: add missing ass_func_template.h to list of sourceswm42015-06-301-1/+1
|
* Switch to virtual function tableDr.Smile2015-06-2611-392/+297
| | | | | | | | | | Use one pointer to table of functions instead of scattered bunch of function pointers. Different versions of these tables can be constructed in compile time. Also, bitmap memory alignment now depends only on SSE2/AVX2 support and is constant for every width. That simplifies code without noticeable performance penalty.
* Improve rasterizer commentsDr.Smile2015-06-263-26/+48
|
* Merge pull request #160 from astiob/beGrigori Goronzy2015-06-233-57/+133
|\ | | | | \be fixes including clipping and value range
| * Make sure the synth tmp buffer is large enough for be_blurOleg Oshmyan2015-02-101-1/+2
| |
| * Use correct types in be_blur_cOleg Oshmyan2015-02-101-6/+5
| | | | | | | | | | | | | | | | Also fix a related sort-of-bug: a multiple of sizeof(uint16_t) was being added to a pointer that already pointed to uint16_t. This was not causing any harm given enough space in the buffer. Fixing the above also lets us combine the two memsets.
| * Add enough padding for \be to avoid clippingOleg Oshmyan2015-02-103-1/+31
| | | | | | | | | | To avoid making bitmaps unnecessarily large, use just the necessary amount of padding for the given \be value.
| * Calculate \be using [0..64] value range (like VSFilter)Oleg Oshmyan2015-02-102-9/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | To avoid banding in the output, the full [0..255] value range is restored before the last \be pass, which then uses the full range and hides the bands by virtue of being a blur. With this, our \be finally closely matches VSFilter's. The only visible difference (other than the lack of banding) is in clipping: we add proper padding and output the whole blurred image, while VSFilter does not add any padding and hence clips the blurred image too early.
| * Apply \be after \blur (like VSFilter)Oleg Oshmyan2015-02-101-14/+14
| |
| * Don't forget to apply \be to the first/last row/column (again)Oleg Oshmyan2015-02-101-29/+26
| | | | | | | | | | The implementation of \be was changed to xy-VSFilter's, which (like VSFilter's) reads but does not write out the first/last row/column.
* | Fix crash when stroked outline overflows SHRT_MAXDr.Smile2015-06-141-1/+1
| |
* | Do not apply ass_set_line_position() to positioned eventswm42015-06-111-3/+4
| | | | | | | | | | Even if we wanted this, the result would be inconsistent if e.g. \clip is used.
* | string2timecode: don't truncate to intOleg Oshmyan2015-06-091-1/+1
| | | | | | | | | | | | | | | | | | The timecode is a long long, but it is computed as a product whose all multiplicands are (unsigned) ints and so effectively has the value of an (unsigned) int. Fix this, and use the full long long range, by explicitly making one of the first two multiplicands a long long. Found by Coverity Scan.
* | Remove several dead storesGrigori Goronzy2015-06-072-7/+4
| | | | | | | | Reported by clang scan-build static analysis.
* | Check possible NULL dereferenceGrigori Goronzy2015-06-071-1/+1
| | | | | | | | | | | | Reported by clang scan-build static analysis. This cannot happen with the current code, but the check might make this more robust in case anything changes.
* | Fix minor memory leak in ass_read_stylesGrigori Goronzy2015-06-071-1/+2
| | | | | | | | | | Reported by clang scan-build static analysis. Also fix incorrect return value in case of error.
* | Strictly clip non-dialog events against the video rectanglewm42015-05-251-0/+13
| | | | | | | | | | | | Only normal dialog lines are allowed to appear outside. Fixes #177.
* | Simplify change_alpha and change_colorOleg Oshmyan2015-05-251-6/+4
| |
* | Apply fade only when the fade alpha is positive (like VSFilter)Oleg Oshmyan2015-05-253-6/+8
| |
* | parse_tag: split \[1-4][ac]Oleg Oshmyan2015-05-251-47/+49
| |
* | Parse and animate all colors and alpha values like VSFilterOleg Oshmyan2015-05-255-61/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Allow exactly one of these prefixes in header values: 0x, 0X, &h, &H. Note that "0x0xFFFFFF" is a correct value, as the first 0x is consumed by the parser and the second by the string-to-number conversion following strtol semantics. * Allow arbitrary numbers of leading & and H (and not h) in any order in override tag values. * Reduce header values modulo 2**32 instead of saturating them to LLONG_MIN/MAX. * Saturate override tag values to INT32_MIN/MAX rather than to LLONG_MIN/MAX. * Don't fiddle with bytes in alpha override tag values. (They can be outside of the 0..255 range.) Also change the byte swapping code to be more sensible. Fixes #80. Fixes #145. Fixes #178. Also fixes our behavior in the case described in https://code.google.com/p/xy-vsfilter/issues/detail?id=80.
* | shaper: purge outdated commentGrigori Goronzy2015-05-241-2/+2
| | | | | | | | | | HarfBuzz has been able to disable fallback kerning since commit 038c98f6. Add some more useful docstrings instead.
* | Fix a wrong commentOleg Oshmyan2015-05-231-1/+1
| |
* | Fix memory leak with drawingswm42015-05-101-1/+6
| | | | | | | | | | | | What. Closes #175.
* | Remove RenderContext.drawingwm42015-05-102-20/+19
| | | | | | | | | | This really didn't make a lot of sense. This is a simplification, and should not affect actual program behavior.
* | Release 0.12.20.12.2wm42015-05-072-2/+2
| |
* | Don't use margins for events that should not be overriddenwm42015-03-162-0/+14
| | | | | | | | | | | | | | libass already does not use the margins for events using \pos. This is not quite complete: there are other tags that we consider as "not dialogue", and which should not be overridden. These tags do not use EVENT_POSITIONED, and thus use the margins, which can mess up rendering.
* | Reorder functionswm42015-03-161-12/+12
| | | | | | | | Just move the *_pos ones about the variants without this postfix.
* | Fix range in rot_keyRodger Combs2015-03-121-1/+1
| | | | | | | | Oops, trig is hard. We output from -pi to +pi now.
* | Fix degrees/radians cache confusion; avoid a fixed-point overflowRodger Combs2015-03-122-5/+5