summaryrefslogtreecommitdiffstats
path: root/libass/ass_coretext.c
Commit message (Collapse)AuthorAgeFilesLines
* coretext: move meta var into loop and zero-initializeRodger Combs2019-11-071-4/+1
| | | | | This makes it a bit clearer that the struct's contents won't be reused across multiple iterations
* coretext: fix error handling in get_font_fileMarvin Scholz2019-11-071-1/+7
| | | | | | | | Fixes a crash in case a font does not has kCTFontURLAttribute, which is the case for example on macOS 10.15.1 for the ".AppleSymbolsFB" font. Fix #358
* coretext: replace CT attr reads with freetype lookupsRodger Combs2019-09-261-112/+24
| | | | | This makes results much more consistent with other platforms, particularly around cases where fonts have multiple conflicting names.
* coretext: use weight steps from macOS SDKRodger Combs2019-09-261-6/+26
|
* coretext: fix reading weights of some fontsRodger Combs2019-09-261-4/+4
| | | | | | | Some fonts have weights that can be expressed more precisely as doubles than as floats. In these cases, when writing to a float, CFNumberGetValue will set the value to the closest approximation, but return false (so we'd just clobber whatever it set with 0). Easy fix: just store to a double instead.
* Support Core Text on earlier versions of Mac OS XOleg Oshmyan2017-10-311-0/+5
| | | | | | | | | | | | | | | | | | | Loosely based on behdad/harfbuzz@b96af03c20e46105982b3608b608614403540661. Prefer to link against ApplicationServices to maximize the portability of binaries built on newer versions of macOS. The symbol kCTFontURLAttribute, which is checked in this commit, was introduced in Mac OS X 10.6, the latest of any Core Text symbols that we use. It is essential to our Core Text font provider, so this is the earliest version of Mac OS X where we can support this font provider. The TARGET_OS_IPHONE conditional that this commit adds is necessary to continue supporting iOS in addition to supporting old Mac OS X. On iOS, CoreText.h *must* be included to use Core Text, whereas on old Mac OS X, CoreText.h is not directly accessible and ApplicationServices.h must be used. On modern macOS, either header works. This conditional is also used in HarfBuzz.
* coretext: don't use a variable-length arrayOleg Oshmyan2017-10-311-1/+1
| | | | | This fixes compilation with GCC, which complains that a variable-length array declaration must not have an initializer.
* coretext: fix NULL CFStringRef dereferencewm42015-12-091-0/+2
|
* coretext: don't fetch character set when it isn't neededOleg Oshmyan2015-12-011-3/+3
| | | | | This avoids unnecessary work and fixes a memory leak: the character set wasn't released when code == 0.
* coretext: don't forget to release font format attributeOleg Oshmyan2015-11-071-0/+2
|
* fontselect: replace is_postscript flag with check_postscript functionOleg Oshmyan2015-11-041-22/+25
| | | | | | | | | | | | | | | | | | | | | | | 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.
* fontselect: use stdbool.h wherever appropriateOleg Oshmyan2015-10-231-3/+3
|
* fontselect: find fonts with PostScript outlines by PostScript nameOleg Oshmyan2015-10-231-0/+15
| | | | | | | 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, 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.
* coretext: use SAFE_CFRelease() for robustnesswm42015-09-011-17/+18
| | | | | | CFRelease(NULL) can crash. While we're still not sure which CoreText API calls can fail etc. (thanks Apple), this should fix a couple of theoretically possible crashes.
* coretext: fix sizeof vs. strlenwm42015-09-011-2/+1
|
* coretext: always use lazy loadingwm42015-09-011-29/+1
| | | | | We already decided that eager loading is too slow. No need to keep multiple code paths around.
* fontselect: simplify get_fallback signaturewm42015-09-011-5/+4
| | | | | 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-10/+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.
* coretext: implement GetFallbackFuncStefano Pigozzi2015-09-011-1/+25
|
* configure: proper configure switches for DirectWrite and CoreTextwm42015-08-281-4/+0
| | | | | Also, remove the ass_coretext.c conditional compilation hack, and fix Makefile.am instead.
* fontselect: add fallback and substitution callbacksGrigori Goronzy2015-07-101-2/+4
| | | | | Add callbacks to introduce more sane fallback handling and font alias substitutions.
* fontselect: expose a fontprovider selection APIStefano Pigozzi2015-07-101-1/+2
| | | | | | | | | 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.
* 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-101-3/+58
| | | | | | | | | | | | | | | | | | | | | | 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-101-5/+10
| | | | | | | | | | | 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-101-0/+217
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.