summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontconfig.c
Commit message (Collapse)AuthorAgeFilesLines
* fontconfig: fix misplaced overflow checkOleg Oshmyan2021-07-101-6/+6
| | | | This allowed writes to one past the end of `families` and `fullnames`.
* fontselect, coretext: match whole extended family on fallbackOleg Oshmyan2021-06-071-1/+1
| | | | | | | | | | | | | | Currently implemented only for coretext, but other providers may/should add this later. This improves fallback font choice by considering the whole extended family. This also fixes remaining cases of Core Text fallback failure caused by differences among the names recognized by Core Text, the name we choose to return from get_fallback, and the names we seek in find_font. This partly reverts commit 152d0484e98f118d01987138695cf40579c9e297. This fixes https://github.com/libass/libass/issues/512.
* fontselect: coretext: get fallback font family name via FreeTypeOleg Oshmyan2021-04-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit be0d1613f79a95073d18d96a60e1394abf9316a2, get_fallback can return a name from Core Text that is different from all names that match_fonts registers for the same font. This causes font fallback to fail as find_fonts fails to find any font having the name received from get_fallback. (Moreover, libass will keep retrying fallback for other glyphs, and the coretext match_fonts will keep readding the same fonts over and over again.) Commit 152d0484e98f118d01987138695cf40579c9e297 attempted to fix font fallback by getting a full name from Core Text instead of a family name when it was noticed that Core Text's family name can come from TT_NAME_ID_TYPOGRAPHIC_FAMILY in addition to TT_NAME_ID_FONT_FAMILY, which we fetch in get_font_info, but the problem goes deeper: Core Text can return Macintosh-platform names that don't match Microsoft-platform names, or the font might have no Microsoft-platform names at all. Furthermore, returning a full name breaks style matching: get_fallback does not know about weight, slant etc. and is expected to return a whole family of fonts that will be lazy-loaded in its entirety (if applicable) and searched through for the best stylistic match by find_fonts. To fix fallback while preserving maximum name portability in the spirit of be0d1613f79a95073d18d96a60e1394abf9316a2, use the same API in get_fallback as is used in match_fonts to look up a family name. Note: this could be more efficient if ass_get_font_info could be told to return just an arbitrary family name. This fixes https://github.com/libass/libass/issues/457.
* fontselect: coretext: reuse main FT_LibraryOleg Oshmyan2021-04-291-1/+1
|
* ass_fontconfig: use FcWeightToOpenTypeDoublercombs2020-09-191-6/+10
| | | | | This provides higher precision in reported weights when using the fontconfig font provider.
* fontconfig: improve weight mappingRodger Combs2019-09-261-5/+36
| | | | | Use FcWeightToOpenType when available; otherwise, use an if/elseif ladder implementing the inverse of fontconfig's behavior.
* Completely exclude ass_fontconfig.c from build when it is disabledOleg Oshmyan2017-10-271-4/+0
|
* Explicitly handle FcPatternGetString(FC_POSTSCRIPT_NAME) mismatchOleg Oshmyan2017-02-111-3/+4
| | | | | | | This does not affect functionality in any way, but it hopefully makes the logic easier to follow. Resolves CID 175691.
* fontselect: replace is_postscript flag with check_postscript functionOleg Oshmyan2015-11-041-8/+15
| | | | | | | | | | | | | | | | | | | | | | | 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-6/+6
|
* fontselect: find fonts with PostScript outlines by PostScript nameOleg Oshmyan2015-10-231-0/+8
| | | | | | | 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.
* fontconfig: read PostScript namesOleg Oshmyan2015-10-231-2/+7
| | | | | | | And fix two wrong comments. Bump the Fontconfig version requirement to 2.10.92 (2.11 RC2), released on 2013-03-29, to ensure Fontconfig caches and exposes PostScript names.
* fontselect: move PostScript name into ASS_FontProviderMetaDataOleg Oshmyan2015-10-211-2/+1
|
* 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>
* fontconfig: fix memory leak in error pathGrigori Goronzy2015-09-071-0/+1
| | | | Found by clang static analysis.
* fontconfig: handle fallback corner casesGrigori Goronzy2015-09-071-2/+16
| | | | | | If no particular codepoint is requested (codepoint == 0), just return the first font family. Additionally, handle fontconfig errors, albeit they're unlikely to happen.
* 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/+4
| | | | | | 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.
* 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.
* fontconfig: implement substitutionsGrigori Goronzy2015-08-281-1/+38
| | | | Signed-off-by: wm4 <wm4@nowhere>
* 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 and substitution callbacksGrigori Goronzy2015-07-101-0/+2
| | | | | Add callbacks to introduce more sane fallback handling and font alias substitutions.
* Fix warningsGrigori Goronzy2015-07-101-1/+2
|
* fontselect: coretext: allow selection based on PostScript nameStefano Pigozzi2015-07-101-1/+2
| | | | | | | | | | | 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.
* Support multiple font family namesGrigori Goronzy2015-07-101-9/+12
| | | | | | 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.
* Add support for font width propertyGrigori Goronzy2015-07-101-6/+5
| | | | | | 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 TrueType font weight scaleGrigori Goronzy2015-07-101-2/+12
| | | | | | | | | | 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.
* Custom font matching and font sourcesGrigori Goronzy2015-07-101-497/+96
| | | | | | | 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.
* More malloc checkingwm42014-11-201-0/+3
| | | | | | | | Don't crash if running out of memory when allocating per-glyph data during shaping. Also some fixes to initialization. The caller of ass_fontconfig.c/match_fullname() actually handles a NULL return value correctly.
* Print debug message when loading a memory fontwm42014-11-151-0/+2
|
* Check more mallocswm42014-11-091-3/+13
| | | | This is just a start and gets most easy ones.
* fontconfig: don't compact the sorted font listOleg Oshmyan2014-01-241-1/+1
| | | | Some broken fonts are dropped by Fontconfig during compacting.
* Improve font mismatch messagewm42013-06-221-5/+12
| | | | | | | | | | | | | | | | | | | | | | | Example for an old message: [ass] fontconfig: Selected font is not the requested one: 'DejaVu Sans' != 'Wingdings' it was hard to tell which was the selected and the requested font. Also, it's not really clear what's the problem at all. Why would it select a different font? Obviously, the issue is that it can't find the font in the first place. Now it prints: [ass] fontconfig: cannot find glyph U+006C in font 'Wingdings', falling back to 'DejaVu Sans' Or if the code parameter for select_font() is 0: [ass] fontconfig: cannot find font 'Wingdings', falling back to 'DejaVu Sans' I'm not sure if this message is really accurate in all cases. It's possible that there are more reasons for failure. But all things considered, this should be easier to understand.
* fontconfig: remove default "lang" setting from patternsUoti Urpala2013-05-141-0/+8
| | | | | | | | | | | | | | Fontconfig defaults set the "lang" value in patterns, and it then prefers fonts which are listed as supporting this language. The default value may not match actual script language, and even a setting of "en" for English subtitle can cause problems. Remove the "lang" setting from patterns used to find fonts. A file had a normal and an oblique version of the same font attached, with different character set coverage: the normal version lacked some non-ascii characters that fontconfig includes in its list of characters required for English support. As a result, the oblique version was picked for what was supposed to be normal text.
* Fix fontconfig disabled at runtimeGrigori Goronzy2011-02-161-1/+2
| | | | | | 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.
* Relicense to ISCGrigori Goronzy2010-09-281-12/+10
| | | | | | 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.
* Get rid of NULL checks for freeGrigori Goronzy2010-08-091-5/+4
| | | | | The useless "if (foo) free(foo)" idiom is all over the place, just get rid of it finally...
* POSIX compliance: add strings.h include where appropriateGrigori Goronzy2010-08-071-0/+1
| | | | | strcasecmp/strncasecmp needs strings.h according to POSIX, so add this include where these occur.
* Fix match_fullname loopGrigori Goronzy2010-07-111-1/+2
| | | | | Let's loop over everything and not just the outline check. *sigh* Fixes a crash reported by lachs0r on IRC.
* Improve fullname matchingGrigori Goronzy2010-06-261-5/+18
| | | | | | | | Only match outline fonts and take slant and weight into consideration. This matches all font faces which have at least the slant/weight that is requested. This fixes issue 23; however, corner cases can be constructed in which wrong fonts will be matched, if multiple slant/weight variants of the same font exist, but that is very unlikely in practice.
* Support multiple faces per attachment correctlyGrigori Goronzy2010-04-171-1/+1
| | | | | | | | Store the real font face id instead of using 0 all the time and use the real font face id for font lookup as well. This makes font attachments with multiple faces work correctly. Thanks to ubitux and uau!
* Cosmetics: remove underscore prefix from _select_font functionGrigori Goronzy2010-02-131-4/+4
|
* fontconfig: consider fullname for matching fontsGrigori Goronzy2010-02-121-3/+61
| | | | | | | Additionally match fonts via the fullname (or name for humans) and prefer these matches. Previously, libass matched against the family name only and this name can be completely different from the fullname (which is used by VSFilter!).
* Update documentation to reflect fontconfig changesGrigori Goronzy2010-02-121-2/+2
|
* Adjust a few message levels and message textsGrigori Goronzy2010-01-191-1/+1
|
* Remove support for fontconfig < 2.4.2Grigori Goronzy2010-01-081-119/+1
| | | | | Get rid of compatibility code and #ifdefs for very old fontconfig versions. libass now requires at least version 2.4.2.
* Fix libass w/o fontconfigGrigori Goronzy2009-10-111-1/+1
| | | | | | | | | Make sure that libass does not crash even if no default font is provided. Additionally, fix crashes related to drawings in this and possibly other unusual cases. Document the default_path and default_family parameters of ass_set_fonts.
* strdup() fontconfig strings freed by callerGrigori Goronzy2009-10-081-3/+5
| | | | | fontconfig_select() can return the path to the default font as fallback, but the caller frees it later. Return a copy with strdup() instead.
* Fix build without fontconfigAlexis Ballier2009-08-121-0/+2
|
* Rename typedefs (breaks API)Grigori Goronzy2009-08-061-18/+18
| | | | | | Rename all typedefs from the convention foo_bar_t, which can possibly conflict with POSIX types, to FooBar (and ASS_FooBar for public API typedefs). Fix formatting and stray comments while at it.
* Clean up typedefs/structsGrigori Goronzy2009-07-281-1/+1
| | | | | Remove useless _s suffix from struct names and remove struct name where not needed (only the typedef'd struct is used). Clean up API headers.
* Fix fontconfig memory leaksGrigori Goronzy2009-07-241-4/+2
| | | | | | | | | | | | Do not manually use FcConfigFilename; passing a NULL pointer to FcConfigParseAndLoad is just as effective and also avoids a memory leak since the string allocated by FcConfigFilename was never freed. Free FcConfig instance in fontconfig_done; since we're not using the default configuration anymore it doesn't make sense to keep the configuration around. Leaks were found by valgrind/memcheck.
* Fix compilation without fontconfigGrigori Goronzy2009-07-241-3/+5
| | | | | Adjust fontconfig_select and fontconfig_update stubs for the recent changes.
* Fallback to default fontconfig configurationGrigori Goronzy2009-07-221-1/+9
| | | | | | | | If parsing or loading the fontconfig configuration file, either using the default or a specified one, fails, try to load the default fontconfig configuration. This triggers loading a fallback configuration if no configuration file is available at all. A warning message is emitted to notify the user about this.
* Improve fontconfig setupGrigori Goronzy2009-07-171-12/+25
| | | | | | | Add an argument to ass_set_fonts for controlling whether the fontconfig font cache should be built/updated. Add a new function ass_fonts_update to make it possible to update fonts later on. Additionally, stop using FcConfigSetDefault for thread safety.
* Message callback funtionalityGrigori Goronzy2009-07-111-36/+39
| | | | | | | | | | | Introduce functionality for providing a message callback that is used for passing messages to the controlling application instead of simply printing them to standard output. The function pointer to the callback is stored in the ass_library_t instance. ass_msg needs access to it, so in many places the library instance needs to be passed around now. The default behavior is the old one: messages of MSGL_INFO or lower are printed to the standard output, prefixed with "[ass]".
* Replace string defines with real stringsGrigori Goronzy2009-07-111-35/+32
| | | | | | Instead of referencing string defines from help_mp.h, use the strings directly in ass_msg. Consequently, help_mp.h is useless and can be deleted.
* Include ass_utils.h instead of mputils.hGrigori Goronzy2009-06-271-1/+1
|
* Rename various non-static functionsGrigori Goronzy2009-06-271-1/+1
| | | | | Rename a few functions to avoid symbol clashes. Clean up mputils.h.
* Rename mp_msg to ass_msgGrigori Goronzy2009-06-271-21/+21
|
* ass_set_fonts: optionally pass fontconfig config pathgreg2009-06-201-5/+13
| | | | | | | Optionally pass a fontconfig config file to the fontconfig initialisation. This changes the public API.
* Silence warnings introduced by -Wallgreg2009-06-201-1/+1
| | | | | Silence a few warnings that should be harmless and were introduced by the -Wall option.
* Reindent all source code.greg2009-06-201-380/+408
| | | | | | | | | | | | | | | Reindent complete source code (*.c, *.h) with indent, the exact command line being: indent -kr -i4 -bap -nut -l76 *.c *.h From now on, new code should use (more or less) K&R style, only spaces and no tabs, 4 spaces indent width. Avoid long lines. Fix function declaration pointer spacing. Remove spaces that were added to many function declarations by indent, like some_func(foo_t * bar). Fix indenting of macros in ass.c
* whitespace cosmetics: Remove all trailing whitespace.diego2009-05-131-15/+15
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29305 b3059339-0415-0410-9bf9-f77b7e298cf2
* Cosmetics: reindent.eugeni2009-03-161-5/+5
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28977 b3059339-0415-0410-9bf9-f77b7e298cf2
* Fix uninitialized memory access in ass_fontconfig.eugeni2009-03-161-0/+2
| | | | | | | This fixes hangups with plaintext subtitles happening when the first subtitle is about to be displayed. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28976 b3059339-0415-0410-9bf9-f77b7e298cf2
* Cosmetics: reindent.eugeni2009-03-081-25/+25
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28896 b3059339-0415-0410-9bf9-f77b7e298cf2
* Treat -font/-subfont as Fontconfig pattern in libass.eugeni2009-03-081-11/+20
| | | | | | Patch by Adrian Stutz (adrian sttz ch). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28895 b3059339-0415-0410-9bf9-f77b7e298cf2
*