| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
This fixes a double-free in be0d1613f79a95073d18d96a60e1394abf9316a2
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Fixes a possible NULL pointer dereference, reported by Coverity.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
This is a normal course of action and should not generate a warning,
especially for applications which use libass and might notify the user
on such "warnings", while in fact it should be info or even verbose.
Fixes #231
|
| |
|
|
|
|
|
|
|
| |
Return true on success and false on failure.
get_font_info was actually inconsistent, returning false both
on success and on failure due to the face not being scalable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
Fixing this properly involves constifying ASS_FontProviderMetaData
and refactoring code that allocates and frees strings stored in it.
This seems easy on the surface but turns out to be nontrivial when
you actually try to do it. This may still be done at a later date,
but for now, just add explicit casts.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This matches the behavior of GDI and hence VSFilter.
Note that \fn arguments are trimmed during parsing.
However, none of the names inside fonts should be trimmed,
and @-prefixed fonts should keep whitespace following the @,
both of which this commit addresses.
Remove strdup_trimmed because it is no longer used. Also remove
the declaration of a function that was deleted a few months ago.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Related to commit e00691e8096cc69e5651480155ebc61d9e079290:
it turns out that GDI (and hence VSFilter) does not check full names of
fonts that have PostScript outlines when searching for a font by name.
To summarize the resulting behavior:
* Fonts with PostScript outlines can be found by family name
and by PostScript name.
* Fonts without PostScript outlines can be found by family name
and by full name.
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Currently this affects only the verbose output in
ass_font_select, but it will become more useful when we
start matching against PostScript names in the future.
|
| |
|
|
|
|
| |
index is signed, and psname only overrides it iff index < 0.
|
|\
| |
| | |
MSVC/ICL and general header fixes
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|/
|
|
| |
It was needed for UTF16BE -> UTF8 only, which is trivial to implement.
|
|
|
|
|
| |
This seems to cause issues on MSVC. Considering that even most Unix OSes
hate PATH_MAX and don't really honour it, using 4096 is just as good.
|
|
|
|
|
|
|
|
| |
OS or platform-specific locale independent functions are painful to
use and/or not available, so roll our own. Not great but the least
painful and least intrusive.
v2: fix indexing, use static inline
|
|
|
|
|
|
| |
Passing NULL as argument to %s format specifiers when using the printf
fasmily of functions is not allowed. While some libcs handle it, other
libcs will simply crash.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Also fixes the build on OSX under some circumstances (weird and
inconsistent rules for the inline keyword in C).
|
| |
|
|
|
|
| |
Introduced by commit d6bb9af6. Found by coverity scan.
|
|
|
|
|
| |
The name is always pulled from the font info, which is static, so
there is no need to strdup.
|
| |
|
|
|
|
|
| |
fontselect is an internal only API for now. That said, it also seems
much more sane to let library users deal with this resource management.
|
|
|
|
| |
In case a font provider actually uses more than one substitution.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
We don't want to add fonts multiple times, so call match_fonts lazily,
i.e. only after selecting a font with a certain name failed. Since
font matching interacts with glyph coverage checks, add a simple
mechanism to determine whether matching failed because of name or
glyph coverage. Additionally make sure to handle substitutions before
any calls to match_fonts; this only correctly deals with single-name
substitutions, though.
|
| |
|
| |
|
|
|
|
|
| |
The default font provider needs to provide a GetFallbackFunc callback
instead.
|
| |
|
|
|
|
|
| |
The CoreText backend doesn't like this, and in fact there's no reason to
pass NULL.
|
|
|
|
|
| |
Apparently we only need the font family (and even that isn't used in all
font providers). Drop the others.
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
The result of the subst_font callback was not freed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
I broke it.
|
|
|
|
|
| |
Use a pointer to the selected font info, instead of an index. Makes the
code a bit more readable.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Don't assume it sets all fields. If it doesn't return any font names at
all, go with the default.
|
|
|
|
| |
Signed-off-by: wm4 <wm4@nowhere>
|
|
|
|
| |
Should fix the DirectWrite to Fontconfig fallback.
|
|
|
|
|
| |
Prefer DirectWrite before the cross-platform fontconfig, so that
DirectWrite is used by default if both are compiled into libass.
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
We want the best variant, but if it doesn't have the glyph coverage,
we may also use another variant from the same family.
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
This is just a cleaner and safer interface for string trimming.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
FreeType can do it for us and is probably more efficient. Also fixes
deinitialization order of ASS_Renderer to make this work.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Add callbacks to introduce more sane fallback handling and font
alias substitutions.
|
|
|
|
| |
Incomplete, leaks memory, but capable of rendering something.
|
|
|
|
|
| |
Apparently on some broken fonts, FreeType can return a NULL family name. Avoid
to crash in these cases.
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 do |