summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* fontselect: simplify get_fallback signaturewm42015-09-015-16/+9
| | | | | Apparently we only need the font family (and even that isn't used in all font providers). Drop the others.
* fontselect: use designated initializerswm42015-09-015-37/+28
| | | | | | Tired of matching the names and order of the callbacks in my head. While we're at it, also give some of the callbacks better names.
* coretext: implement GetFallbackFuncStefano Pigozzi2015-09-011-1/+25
|
* fontselect: add bounds checking for memory font stream readswm42015-08-311-0/+6
|
* font: fix double frees if opening memory font failswm42015-08-311-2/+0
| | | | | Apparently, libfreetype calls close_stream_font through the FT_Stream.close callback.
* fontselect: fix a memory leakwm42015-08-311-22/+29
| | | | The result of the subst_font callback was not freed.
* fontselect: reimplement ass_set_fonts_dir() functionalitywm42015-08-283-1/+32
| | | | | | | | | | | | | | | | | | ass_set_fonts_dir() is supposed to enable all fonts in a specific directory. The implementation for it was dropped with the commit introducing the new fontselect code. Some users were relying on it, so we need it back. It used to be implemented using a single fontconfig call. But since this has to work even if fontconfig support is not even compiled, a new implementation is needed. This commit adds very simple and low-effort support for it. It loads all files into memory, and then lets the memory font code do the rest. A more efficient implementation would be possible, for example by implementing a new font provider, which serves get_data requests from open file handles. Anyone who wants to do this is welcome to try, and this commit is just the minimum to restore the lost feature.
* render_api: fix crash when calling ass_set_fonts() after renderingwm42015-08-281-0/+2
| | | | | | | | | | The caches may reference data which belongs to the font provider. If the font selector and the font provider are destroyed, it can leave dangling pointers in the renderer cache. (At least that's what it looks like.) For some reason, this didn't even trigger valgrind warnings with the fontconfig font provider. Possibly the dangling pointers were FT_Face pointers, and fontconfig might cache these process-wide.
* font: fix broken charmap fallback handlingwm42015-08-281-1/+1
| | | | | | | | | An earlier commit added this code to avoid adding font faces multiple times. In this form, it breaks the "Trying all charmaps" fallback case, which can lead to text being rendered as boxes. Return the font that is going to contain the missing glyph instead. The calling code will check again, and run the fallback if necessary.
* fontselect: fix fallbackswm42015-08-281-1/+1
| | | | I broke it.
* configure: proper configure switches for DirectWrite and CoreTextwm42015-08-283-6/+11
| | | | | Also, remove the ass_coretext.c conditional compilation hack, and fix Makefile.am instead.
* ass: make font_provider API privatewm42015-08-285-180/+180
| | | | | | | | | | We were discussing whether this should be public or private. It could be public, because the API is potentially useful, and is relatively simple. On the other hand, the API is not necessarily final, and making it public would prevent us from improving/fixing it. Make it private for now - making it public later is much easier than having to break the public API later.
* ass: ass_fonts_update() is a stubwm42015-08-281-2/+2
|
* ass: restore ABI compatibility with older versions (more or less)wm42015-08-282-3/+8
| | | | | | | | | | | While enums normally are ints on most systems, it isn't guaranteed. This might also make C++ code fail to compile, since C++ doesn't allow implicit conversion of ints to enums. If the API user ever passed anything other than 0 or 1, compatibility will still break, but I guess we have to live with this. Also extend the doxygen.
* fontconfig: fix error checkingwm42015-08-281-3/+2
| | | | | | | FcInitLoadConfig() could faul, leaving rc=1 and fc->config=NULL, making FcConfigBuildFonts() potentially crash. Also, the FcConfigBuildFonts() return value was not checked.
* fontselect: minor cleanupwm42015-08-281-12/+11
| | | | | Use a pointer to the selected font info, instead of an index. Makes the code a bit more readable.
* fontselect: correctly match list of font substitutionswm42015-08-281-66/+72
| | | | | | | | | | | | This code prioritized fonts by scanning order, but the scanning order is essentially arbitrary. This resulted in suboptimal and indeterministic font selection by family name. Prefer the order as returned by the substitution callback. This requires some restructuring. The core algorithm is still exactly the same though; only the order of comparisons changes. If the font backend has no subtitution callback, nothing should change.
* fontselect: deal with potential ASS_FontProvider.subst_font failurewm42015-08-281-2/+3
| | | | | Don't assume it sets all fields. If it doesn't return any font names at all, go with the default.
* fontconfig: implement substitutionsGrigori Goronzy2015-08-283-21/+67
| | | | Signed-off-by: wm4 <wm4@nowhere>
* fontselect: check fontprovider constructors for failurewm42015-08-281-4/+4
| | | | Should fix the DirectWrite to Fontconfig fallback.
* Rename dwrite.h, minor cleanupswm42015-08-054-300/+8
| | | | | | | Rename dwrite.h to dwrite_c.h to make the difference between the official header and ours clearer. Also apply minor cleanups to it. Remove the patch against upstream MinGW; it's pointless now.
* Fix typedefswm42015-08-041-3/+3
|
* configure: remove some unneeded checkswm42015-07-111-10/+2
|
* directwrite: don't crash on unknown DWRITE_FONT_STRETCHwm42015-07-111-1/+1
| | | | | The existing code doesn't even handle all currently defined values for it, and nothing says no new values are ever going to be added.
* directwrite: convert to Cwm42015-07-115-195/+1205
| | | | | | | | | | | | | | | | | | | | | Unfortunately, nobody ever tested the MinGW dwrite.h header in C. There are multiple glaring mistakes, and the header doesn't even compile by itself. The main issues are overloaded functions (which doesn't work in C), and broken COBJMACROS defines. dwrite.diff contains changes to dwrite.h which make libass work. Warning: the patch lacks a required change to the DrawInlineObject method of IDWriteTextRenderer (missing THIS_). Additionally, these definitions would ideally be provided by dwrite.h: DEFINE_GUID(IID_IDWriteFactory, 0xb859ee5a,0xd838,0x4b5b,0xa2,0xe8,0x1a,0xdc,0x7d,0x93,0xdb,0x48); DEFINE_GUID(IID_IDWritePixelSnapping, 0xeaf3a2da,0xecf4,0x4d24,0xb6,0x44,0xb3,0x4f,0x68,0x42,0x02,0x4b); DEFINE_GUID(IID_IDWriteTextRenderer, 0xef8a8135,0x5cc6,0x45fe,0x88,0x25,0xc5,0xa0,0x72,0x4e,0xb8,0x19); Also, in order to make libass compile out of the box with current MinGW/msys installations, a very stripped down in-tree copy of dwrite.h is provided.
* directwrite: dynamically load dwrite.dllwm42015-07-112-15/+54
|
* directwrite: compile only on Windowswm42015-07-114-9/+8
|
* fontselect: prefer platform font providersGrigori Goronzy2015-07-101-3/+3
| | | | | Prefer DirectWrite before the cross-platform fontconfig, so that DirectWrite is used by default if both are compiled into libass.
* directwrite: add font fallback callbackGrigori Goronzy2015-07-102-1/+232
| | | | | | This uses a faux rendering with a high-level interface of DirectWrite to determine a suitable fallback. Choices are different from GDI, but reasonable.
* fontconfig: add font fallback callbackGrigori Goronzy2015-07-101-17/+98
| | | | | This creates a sorted list of fallback fonts and reuses it, for speed. Font sorting is very slow.
* fontselect: add fallback handling with callbackGrigori Goronzy2015-07-101-0/+19
| | | | | If we can't find a matching font face (with glyph coverage), ask the default font provider for a fallback family. The callback is optional.
* fontselect: improved face selection among a familyGrigori Goronzy2015-07-101-17/+27
| | | | | We want the best variant, but if it doesn't have the glyph coverage, we may also use another variant from the same family.
* Constify ass_msg format (NFC)Grigori Goronzy2015-07-102-2/+2
|
* directwrite: multiple improvements to font scanningGrigori Goronzy2015-07-101-29/+52
| | | | | | | | | | | | | | | | There were various issues with font scanning. This addresses the following: - Synthesized font faces (bold/oblique) were added to the list. Just skip those, this is handled internally by libass. - Use the win32 font family names, if available. Traditionally, Windows groups font families in a different way, so that the number of variants is small (<= 4). With this, Arial Narrow and Arial Black appear as a separate family, which is what we want. - Full names are not mandatory. Correctly handle the case that there are no full names. - Don't use the bogus LOCALE_NAME_MAX_LENGTH constant to determine the size of the name buffer. Names can be almost arbitrarily long. Handle names up to 256 characters correctly and truncate longer names.
* fontselect: fix oblique/italic mixupGrigori Goronzy2015-07-101-1/+1
| | | | The constants were swapped. In some cases this lead to incorrect matching.
* fontselect: fix undefined behavior with callocGrigori Goronzy2015-07-101-7/+23
| | | | | | | | | If allocations have the size zero, malloc/calloc implementations can return a zero-size buffer or NULL. The earlier introduced malloc checking blows up if an implementation returns NULL. Fix that by only allocating and checking when it's actually needed. Also fix a minor problem with iconv deinitialization in an error path.
* directwrite: fix linkingGrigori Goronzy2015-07-101-0/+3
|
* fontselect: replace magic numbers (NFC)Grigori Goronzy2015-07-101-3/+6
|
* fontselect: trim names of embedded fontsGrigori Goronzy2015-07-101-2/+2
| | | | | | | | Embedded fonts tend to be extra bad, so trim the names. I have encountered fonts faces with untrimmed names. Leave this at the discretion of the font provider for platform-specific font providers.
* fontselect: add and use strdup_trimmedGrigori Goronzy2015-07-103-12/+20
| | | | This is just a cleaner and safer interface for string trimming.
* fontselect: simplify lookup of embedded fontsGrigori Goronzy2015-07-101-23/+3
| | | | | | | | | Currently, it is not safe to change the embedded fonts (ass_add_font/ass_clear_fonts) while an ASS_Renderer exists. We can simplify how embedded fonts are looked up because of that. At some point, ASS_Library and ASS_Renderer should be merged and we can then implement a more flexible approach.
* fontselect: malloc and error checkingGrigori Goronzy2015-07-102-27/+127
| | | | | | | | Add malloc checks with useful semantics and error checks in some specific cases. This should hopefully make fontselect more robust. The platform-specific font providers (DirectWrite/CoreText/FontConfig) still need to be checked for proper memory management.
* fontselect: simplify cmap lookup for embedded fontsGrigori Goronzy2015-07-102-65/+13
| | | | | FreeType can do it for us and is probably more efficient. Also fixes deinitialization order of ASS_Renderer to make this work.
* fontselect: improved and simplified matchingGrigori Goronzy2015-07-101-68/+59
| | | | | | | | | | | | Sorting the font list is overkill and not very useful. We are interested in *exact* name matches only; all other font families don't matter and we'll use another fallback mechanism for glyph fallbacks (TBD). Replace the sorting and glyph fallback search with a simple linear scan. Fonts are first matched against family name first (to allow further comparison against style attributes) and if that fails, the fullname is considered.
* fontselect: add fallback and substitution callbacksGrigori Goronzy2015-07-104-9/+57
| | | | | Add callbacks to introduce more sane fallback handling and font alias substitutions.
* fontselect: add documentationGrigori Goronzy2015-07-101-17/+76
| | | | | Add some documentation to the font provider callbacks and metadata struct.
* directwrite: fix indentationStephan Vedder2015-07-101-240/+275
|
* directwrite: add missing memory release in case of failureStephan Vedder2015-07-101-4/+24
|
* directwrite: release localizedStringsStephan Vedder2015-07-101-1/+5
|
* directwrite: fix error handling in font scanningStephan Vedder2015-07-101-8/+8
| | | | Fix that a single broken font could mess up the entire font scanning.
* directwrite: use standard mallocGrigori Goronzy2015-07-101-1/+1
|
* directwrite: add 'width' attributeGrigori Goronzy2015-07-101-0/+6
| | | | This is required for proper font matching.
* directwrite: wire up destroy callbacksGrigori Goronzy2015-07-101-3/+3
|
* directwrite: cache FontFileStreamGrigori Goronzy2015-07-101-36/+85
| | | | | Extract a function to set up FontFileStream and store it in a newly introduced private struct. Fix memory management as well.
* directwrite: add initial fontselect implementationfeliwir2015-07-107-1/+309
| | | | Incomplete, leaks memory, but capable of rendering something.
* Changed configure.ac to work with c++ filesfeliwir2015-07-102-5/+4
|
* Compile the check with the g++ compiler nowStephan Vedder2015-07-101-0/+5
|
* Added directwrite checkStephan Vedder2015-07-101-0/+20
|
* fontselect: fix NULL dereferenceStefano Pigozzi2015-07-101-1/+1
| | | | | Apparently on some broken fonts, FreeType can return a NULL family name. Avoid to crash in these cases.
* Provisional support for libiconvGrigori Goronzy2015-07-101-0/+1
|
* Fix compiler compatibilityGrigori Goronzy2015-07-101-1/+2
|
* Fix warningsGrigori Goronzy2015-07-102-2/+4
|
* fontselect: expose a fontprovider listing APIStefano Pigozzi2015-07-104-0/+46
| | | | | | 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-107-21/+61
| | | | | | | | | 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-105-1/+284
| | | | | | | | | | | | | | | 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
| | | | |