summaryrefslogtreecommitdiffstats
path: root/libass/ass_directwrite.c
Commit message (Collapse)AuthorAgeFilesLines
* directwrite: fix font collectionsGrigori Goronzy2017-06-011-0/+14
| | | | | | | | | | | | | | | | DirectWrite's FontFileStream does not actually use the data of a specific font in a collection, which was an expectation of the existing code. It simply returns a stream to the underlying file, collection or not. So we need to get the index of the font. This needs to be done lazily as this information is only available in a FontFace, which is expensive to initialize. Add a new optional font provider function for lazy initialization of the index and use it. This is similar to the check_postscript callback. Fixes libass#275. v2: fix type of returned value.
* directwrite: drop SAL annotationsOleg Oshmyan2016-12-281-16/+16
| | | | | | | MinGW and old versions of mingw-w64 don't define the SAL macros. They don't serve any value to us, so just remove them from our code. See https://github.com/libass/libass/pull/251.
* directwrite: fix leaks of IDWriteFontFamily/IDWriteFontCollectionHannes Domani2016-03-271-0/+4
|
* fontselect: replace is_postscript flag with check_postscript functionOleg Oshmyan2015-11-041-34/+46
| | | | | | | | | | | | | | | | | | | | | | | DirectWrite does not provide fast access to the is_postscript flag, requiring each font to be loaded before its format can be determined. Eagerly doing this for every installed font can be quite slow, on the order of seconds. To improve performance, ask the font provider for this information only when it is actually needed, i.e. when one of the font's full names or its PostScript name matches a requested font name and we need to know whether to accept this match. The return value of check_postscript is not cached in this commit. This makes repeated calls slower than accessing is_postscript was. This should not be a problem, but if it is, the value can be cached (or precomputed) by font providers in their font private data. This commit also potentially increases the memory usage of some font providers by retaining data structures needed to implement check_postscript in their font private data. This should not be a problem either, but if it is, the value of check_postscript can be precomputed by all providers other than DirectWrite.
* directwrite: improve error handlingOleg Oshmyan2015-10-301-23/+51
| | | | | | | | | | * Check malloc and calloc return values. * Abort if a name can't be fetched, rather than supply a NULL string to fontselect causing it to crash. * Make sure to free all allocated memory. * Always check FAILED(hr) before using the value of any output argument returned by DirectWrite, because it is not clear whether they are guaranteed to have correct values in case of error.
* directwrite: slightly clean up the codeOleg Oshmyan2015-10-301-19/+17
| | | | | | | | | * Metrics are not used, so don't fetch them. * All variables except meta are always explicitly set before use, so don't initialize them. * Declare variables where they are used. * Use int loop variables when the loop bound is int. * Prefer post-increment to pre-increment.
* directwrite: split out the inner loop of scan_fonts as a separate functionOleg Oshmyan2015-10-301-109/+117
| | | | | | | | | | | | This has the side effect that the ASS_FontProviderMetaData instance is now cleared for every font rather than only once at the start of the search, which fixes some use-after-free scenarios and prevents the creation of chimeric fonts using names left over from other fonts processed earlier. This lays the groundwork for further code simplification and error handling improvements within this function, which will come in a separate commit. This commit is transparent to `git blame -w` except for return statements.
* fontselect: use stdbool.h wherever appropriateOleg Oshmyan2015-10-231-5/+4
|
* directwrite: fix broken return value checkOleg Oshmyan2015-10-231-1/+1
|
* fontselect: find fonts with PostScript outlines by PostScript nameOleg Oshmyan2015-10-231-0/+20
| | | | | | | Fonts without PostScript outlines (such as TrueType fonts) are unaffected, and their PostScript names continue to be ignored when searching for fonts. This matches the behavior of GDI and hence VSFilter.
* fontselect: move PostScript name into ASS_FontProviderMetaDataOleg Oshmyan2015-10-211-5/+6
|
* Fully fix compilation with MSVC/ICLOleg Oshmyan2015-09-171-0/+1
| | | | | | | | | As before, this does not add any build system support: a config.h file and a project must still be manually created (or the compiler can be run manually instead of using a project). Signed-off-by: Grigori Goronzy <greg@kinoho.net> Signed-off-by: Oleg Oshmyan <chortos@inbox.lv>
* directwrite: change WINBOOL to BOOL.torque2015-09-171-2/+2
| | | | WINBOOL is MingW-specific.
* directwrite: fix syntax error with MSVC.torque2015-09-171-1/+1
| | | | | MSVC requires the calling convention to be grouped with the identifier when defining a callback type.
* directwrite, coretext: implement substitutionsGrigori Goronzy2015-09-021-0/+14
| | | | | This adds simple and sensible substitutions for generic font family names. A helper function is introduced to reduce code duplication.
* directwrite: fix fallback for codepoint 0Grigori Goronzy2015-09-011-5/+7
|
* directwrite: fix compilationGrigori Goronzy2015-09-011-1/+1
| | | | A name clash was introduced by commit ab08d079.
* fontselect: simplify get_fallback signaturewm42015-09-011-2/+1
| | | | | 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-011-7/+5
| | | | | | 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.
* Rename dwrite.h, minor cleanupswm42015-08-051-5/+1
| | | | | | | 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.
* 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-111-0/+706
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.