summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontselect.h
Commit message (Collapse)AuthorAgeFilesLines
* ass_shaper: create hb_font_t eagerly during add_faceHEADmasterrcombs4 days1-1/+0
|
* fontselect: eagerly compute is_postscript in get_font_infoOleg Oshmyan2023-08-061-1/+7
| | | | | | | | | | | | | | | | | | | This lets us get rid of the font format check in ass_coretext, which is not available on Mac OS X 10.5 and prerelease 10.6. This fixes https://github.com/libass/libass/issues/595, which is about 10.6 prerelease build 10A190, the last Mac OS X build available for PowerPC CPUs. A separate commit will expand on this and make us compatible with 10.5 on all CPUs. This partly reverts commit d0566318ee5035ca3a4d2d65d46a80a4e3d8244c, where eager is_postscript was replaced by lazy check_postscript because back then ass_directwrite eagerly loaded all of the system's fonts and reading is_postscript from each font slowed it down significantly. But eventually (in particular but not only because even without this it was still slow for huge font collections) ass_directwrite learnt to load fonts lazily, so there's a decent chance that this lazy check_postscript (as well as the lazy get_font_index) isn't necessary at all any more and can be removed in the future.
* ass_fontselect: take const ASS_Font*rcombs2022-11-151-1/+1
|
* fontselect: automatically read metadata from font file if neededOleg Oshmyan2021-07-101-16/+3
|
* fontselect: save library and ftlibrary in ASS_FontSelectorOleg Oshmyan2021-07-101-3/+2
| | | | ...instead of passing them as arguments everywhere.
* Pass last-resort-fallback family name directly to get_font_infoOleg Oshmyan2021-07-101-2/+2
|
* font, fontselect: factor out common code for creating FT_FaceOleg Oshmyan2021-07-101-2/+1
|
* fontselect, coretext: match whole extended family on fallbackOleg Oshmyan2021-06-071-5/+16
| | | | | | | | | | | | | | 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-0/+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: ask Core Text for family name as last resortOleg Oshmyan2021-04-291-0/+2
| | | | | | | | If a font contains no recognized Microsoft-platform family names, use the family name reported by Core Text. Skip FreeType's face->family_name because it is an ASCII bastardization of a family name and may not exist at all.
* fontselect: coretext: reuse main FT_LibraryOleg Oshmyan2021-04-291-1/+3
|
* Fix embedded and memory fontsOneric2021-04-221-3/+8
| | | | | | | | | | | Previously only both only worked when ass_set_fonts was called after all embedded and memory fonts were already added. Especially for embedded fonts this meant it won't work for most users, except mpv, including our own utilities, even if extract_fonts was set. Now that it works, enable extract_fonts in our utilities. GitHub: fixes #266
* fontselect: provide a way to use freetype to get font infoRodger Combs2019-09-261-0/+14
|
* Update ass_fontselect.hC.W. Betts2019-09-261-3/+3
| | | | Fix documentation misspellings/texts. As reported by Clang.
* fontselect: fix include guard macro nameOleg Oshmyan2017-10-271-3/+3
|
* directwrite: fix font collectionsGrigori Goronzy2017-06-011-0/+11
| | | | | | | | | | | | | | | | 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.
* fontselect: replace is_postscript flag with check_postscript functionOleg Oshmyan2015-11-041-2/+9
| | | | | | | | | | | | | | | | | | | | | | | 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/+3
| | | | | | | 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-3/+7
|
* fontselect: fix ass_font_provider_add_font signature and doxygenOleg Oshmyan2015-10-211-2/+3
| | | | index is signed, and psname only overrides it iff index < 0.
* ass_fontselect: uninline ass_map_font()wm42015-09-071-12/+2
| | | | | Also fixes the build on OSX under some circumstances (weird and inconsistent rules for the inline keyword in C).
* directwrite, coretext: implement substitutionsGrigori Goronzy2015-09-021-0/+31
| | | | | This adds simple and sensible substitutions for generic font family names. A helper function is introduced to reduce code duplication.
* fontselect: never pass family=NULL to get_fallback()wm42015-09-011-1/+1
| | | | | The CoreText backend doesn't like this, and in fact there's no reason to pass NULL.
* fontselect: simplify get_fallback signaturewm42015-09-011-1/+2
| | | | | 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-9/+9
| | | | | | 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.
* ass: make font_provider API privatewm42015-08-281-0/+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.
* 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.
* fontselect: coretext: allow selection based on PostScript nameStefano Pigozzi2015-07-101-2/+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.
* Use streamed access for memory fontsGrigori Goronzy2015-07-101-2/+2
| | | | | This is faster in many cases, and more suitable for Windows' GetFontData function.
* Export font provider interfaceGrigori Goronzy2015-07-101-37/+0
| | | | | | | 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-101-2/+3
| | | | | Allow memory fonts with the get_face_data callback. This feature is used for embedded fonts, but can be used by any font provider.
* 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.
* Use TrueType font weight scaleGrigori Goronzy2015-07-101-0/+4
| | | | | | | | | | 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.
* Restore fontconfig runtime configurationGrigori Goronzy2015-07-101-1/+1
| | | | | | | | | | | 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.
* Never add a face twice to an ASS_FontGrigori Goronzy2015-07-101-5/+7
| | | | | | 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.
* Custom font matching and font sourcesGrigori Goronzy2015-07-101-0/+74
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.