| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
This also involves a substantial refactor of string handling in ass.c
and in the parse functions in ass_utils.c:
- Most strings are now passed around internally via ASS_StringView
- Our own read_digits routine is now used in several cases where we previously used atoi/strtoll
- This is more vsfilter-compatible; vsfilter uses the same int parsing for all integer fields, color or not
- A number of cases where we were case-sensitive are now case-insensitive, matching vsfilter
- ass_process_data now buffers incomplete lines
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The preceding commit 729e48a1eb90bd56b4bb670ee9c8c3821ef12c45
introduced the possibility of UB, when one of the following is true:
- the namelen calculation of the first path overflows to exactly zero
resulting in a NULL namebuf being passed to ass_msg and read_file
- size_t gets promoted to int and the namelen calculation
results in a signed integer overflow
To fix the former we check the namelen calculation for
wrap-arounds and skip such overly long paths.
To fix the latter we specify the constant as an unsigned integer
ensuring type promotion will be done to the larger type between
size_t and unsigned, but never to signed int.
Thanks to Oleg Oshmyan for noticing and helping to fix this.
|
| |
|
|
|
|
|
|
|
|
| |
Bug in commit a7f67df5f96f03fab6661d90d716c16e0fab4a21, which introduced
the alloc check. Before that, alloc failure would result in illegal
memory access, so at least this was an improvement.
Fixes CID 350862 found by Coverity Scan.
|
|
|
|
| |
Reuse the desktop build for this, as UCRT32 doesn't exist.
|
| |
|
| |
|
| |
|
|
|
|
| |
This avoids an extra trip to FreeType.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We use %zu format specifiers to log size_t values.
However, __attribute__((format(printf, ...))) in modern GCC means
"system's default" printf, which on MinGW means MSVCRT.DLL printf,
which does not support the z length modifier (even on Windows 10),
so GCC warns that our format strings are invalid.
Older GCC is unable to check Microsoft's format strings at all and
has only format(printf), which is equivalent to the newer gnu_printf.
Clang also lacks gnu_printf, but it is covered by the same macro
check because its __GNUC...__ macros always report version 4.2.1.
On non-Microsoft platforms, printf and gnu_printf are currently
aliases, so the __MINGW32__ check is redundant. However, with some
luck, GCC may start to check other platforms' printf formats more
carefully in the future; and we would like to receive warnings
if our format strings don't work on some platform, although we
intend to stick to standard C99 format strings. Indeed, if we use
an extension by accident, this might help us catch it. And even if
we make no mistake but there is another platform that fails to
support C99 format strings, this might warn some poor soul building
on that platform that their system printf doesn't understand our
log format strings, so they will know they need to work around it
in their log callback or to patch libass.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
CreateFontFromLOGFONT does not actually use GDI's font lookup logic
and fails to emulate it faithfully. In particular: it fails to find
CFF-outline fonts by PostScript name; it fails to find TrueType fonts
by full name on older versions of Windows; it fails to find at least
some fonts installed on demand by font managers.
When GDI is available, invoke GDI directly. This commit uses
EnumFontFamilies, which is almost perfect, except that if the user has
two different fonts such that one font's family name equals another's
full/PostScript name, this will find only the family name match.
To fix this case as well, we'd need to invoke CreateFontIndirect
separately for each font request, complete with its weight and slant.
This requires larger changes in our fontselect, which this commit
does not attempt yet.
GDI is not available in WinRT/UWP. On UWP (Windows 10), use the new
IDWriteFontSet API to emulate GDI's font lookup as well as we can.
In WinRT (Windows 8), we have no choice but to keep using
CreateFontFromLOGFONT (unless we go back to loading all fonts
eagerly, which we stopped doing for performance reasons).
It is the builder's responsibility to avoid linking in Gdi32.lib
in WinRT/UWP builds, just as it is to link in Dwrite.lib.
|
|
|
|
|
| |
There's no point. We originally had extra code here that
adjusted linker flags before the test, but that's long gone.
|
| |
|
| |
|
|
|
|
| |
This will be needed for the next commit.
|
|
|
|
| |
...instead of passing them as arguments everywhere.
|
| |
|
| |
|
| |
|
|
|
|
| |
This allowed writes to one past the end of `families` and `fullnames`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Normally, we delay loading Dwrite.dll until runtime to allow building
and running DirectWrite-enabled libass binaries on old Windows versions
that lack DirectWrite. However, this is forbidden in WinRT/UWP.
DirectWrite is present in all versions of Windows that support WinRT/UWP,
so we lose nothing by requiring it.
Older Windows SDKs (Microsoft and MinGW alike) lack <winapifamily.h>,
so include it only if we really need it.
Based on VLC patch for libass:
https://github.com/videolan/vlc/commit/eedb57aa96d2bc0046a6da2e081c75ae9edf8fd5
and on this autoconf code:
https://github.com/lu-zero/mfx_dispatch/commit/c51a54c15f51579804030c70592c0a26065f1242
Note: the VLC patch retained an unconditional call to FreeLibrary
in destroy_provider. However, FreeLibrary does not actually expect
NULL as argument, so this commit adds a guard to that call.
Perhaps FreeLibrary(NULL) simply fails cleanly and that's why
this has not caused VLC problems, but we should not rely on this.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
To use Microsoft's _mkdir one must include direct.h, not sys/stat.h as
for POSIX's mkdir. This is still true with modern MinGW headers used.
The sys/stat.h include remains required for stat.
|
|
|
|
|
|
|
|
|
|
|
| |
Since GHA only has native support for glibc-linux use Alpine via Docker.
Even though GHA does have native Docker support, its
`job.<name>.container` option cannot be used here, as there appears to
be no way to set a noop image name atm (empty string causes an error).
Using `tail -f /dev/null` to keep the image running (while ignoring
zombie processes) was taken from GHA's native Docker setup procedure.
Relies on /home/runner/work being the default for checked out repos.
|
|
|
|
| |
travis-ci.org ceased building on the 15th June 2021
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
We ask Core Text to match multiple name fields, and a single font may
match several at once. In this case, by default, Core Text duly returns
the font multiple times, and we add it to fontselect multiple times.
This does not break anything, but it is a waste, so ask Core Text
to deduplicate the returned list.
This is supposedly available since Mac OS X 10.5.
We support Core Text on 10.6+.
|
|
|
|
| |
Allows compilers to print warnings when the args we pass don't match the string
|
|
|
|
|
| |
- ass_drawing was logging size_t as %d
- ass_font was logging ASS_StringView as %s (could crash!)
|
| |
|
|
|
|
|
|
|
| |
match_fonts is supposed to add all the fonts with the same family name
for fontselect. Commit d325c633f4ac32fcb4c76a3fb5926737a45c38d0 adds
only one font, which leads to inability to select (using family name)
correct fonts from families with multiple styles.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Update SubtitlesOctopus' link and clarify Crunchyroll's relation to
SubtitlesOctopus/libass.
Perian is considered abandoned by the Maintainer, see
https://github.com/MaddTheSane/perian/issues/16#issuecomment-752262482
Add AssRender AviSynth(+) filter. AviSynth-wiki contains link to a
somewhat active repo by pinterf.
closes https://github.com/libass/libass/issues/482
|
| |
|
|
|
|
|
| |
Replace missing strndup() with its standard C equivalent
and circumvent unimplemented second argument of mkdir().
|
|
|
|
| |
It's technically more correct.
|
| |
|
|
|
|
|
|
|
|
| |
get_bitmap_glyph copies this struct via assignment. But to allow
safe assignment-copy, it seems the whole struct must be initialized,
rather than merely each of its members.
Fixes CID 314186 found by Coverity Scan.
|
|
|
|
|
|
|
|
|
|
|
|
| |
scan_fonts can be very slow when many fonts were installed in
the system. Use IDWriteGdiInterop to create a font by its name
when needed instead of scanning all installed fonts during the
initializing stage to get better performance. In case of a
non-existent font, the fallback mechanism should do its work.
Fixes https://github.com/libass/libass/issues/334.
Signed-off-by: Oleg Oshmyan <chortos@inbox.lv>
|
|
|
|
|
| |
GCC and MSVC (at least) warn about this cast as the function types
appear to be incompatible. This is correct with GetProcAddress.
|
|
|
|
|
|
|
|
| |
Second argument of cglobal macro for fill_halfplane in 64-bit mode
should always be 6 to preload all function arguments into registers.
It doesn't matter under *nix as the first 6 arguments are already
in registers according to calling conventions, but under WIN64
it's only the first 4.
|
|
|
|
|
|
| |
All Create and Copy functions create new objects, so all of them may fail.
Keep using SAFE_CFRelease only in shared cleanup clauses.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These glyphs are effectively invisible.
VSFilter draws no border around them, either (because for BorderStyle 1
it finds no pixels to draw a border around, while BorderStyle 3 gets
scaled a second time by the same \fscx or \fscy), except current MPC-HC
(which doesn't double-scale BorderStyle 3).
Since nothing is to be seen on screen, skip the rest of the pipeline
altogether. They still affect the layout of other glyphs that may
have nonzero scales, so we can only do this after text layout is done.
This avoids subsequent divisions by zero when sheared pre-scale coordinates
are computed from post-scale coordinates at scale zero. (We eagerly scale
all coordinates before shearing because it makes text layout easier.)
In apply_baseline_shear itself, the shear displacement for an \fscy0
glyph is always zero, so skipping its calculation is safe. For an
\fscx0 glyph, we currently divide 0 by 0, which we want to avoid.
Logically, this is supposed to take the cluster's pre-\fscx advance
and compute shear from that, but this commit does not do this. When
in VSFilter-compatible mode, we're actually supposed to reset the
baseline when \fscx becomes nonzero, so this won't matter. Meanwhile,
when we're trying to do a "sensible" thing, it's not clear whether
shear-before-scale makes sense in the first place. At any rate, this
improves upon the current behavior by avoiding the zero division,
and at least on x86 this actually happens to match our current layouts
in situations where the current code produces visible output at all.
Fixes https://github.com/libass/libass/issues/185.
Fixes https://github.com/libass/libass/issues/413.
Fixes https://github.com/libass/libass/issues/428.
Fixes https://github.com/libass/libass/issues/443.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current code calculates the effect of \fay on advances
early in retrieve_glyph, only to ignore it until reorder_text,
which then partially undoes these calculations.
Instead, just calculate it once, when all the necessary
properties have been fully determined.
The earliest point to do this would be within reorder_text,
but to simplify future logic changes, delay this until all
other text layout steps are done. This matches VSFilter, which
applies shear after alignment. This would also have neutralized
the bug that the previous commit fixed, because glyphs[0].pos.y
really is always 0 until shear is applied. This also opens
the door for another commit to skip glyphs that are invisible
but affect layout.
In addition to simplifying code and calculations, this commit fixes
a bug: the current code for undoing shear assumes constant scale_x/y
from the last \fay change or line break point to the next such point,
producing strange, wrong positions when scale_x/y do change.
This fixes https://github.com/libass/libass/issues/465.
|
|
|
|
|
| |
Put continue on its own line.
Don't mutate & reset info.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In most cases, text_info->glyphs[0].pos.y is 0. This makes the bbox
in compute_string_bbox have bbox.y_min = -text_info->lines[0].asc.
Thus, during event positioning, we refer to the text's top and
bottom edge coordinates in two equivalent ways: \an4-6, \pos, \move
and Scroll effects use bbox.y_min and bbox.y_max, while \an1-3
and \an7-9 use -text_info->lines[0].asc and text_info->height -
text_info->lines[0].asc.
However, text->glyphs[0].pos.y is not *actually always* 0.
Specifically, it is nonzero for events that begin with right-to-left
text with nonzero \fay (at least two visible glyphs with the same \fay).
In this case, the anchoring point we use for vertical positioning
is different between \an1-3,7-9 and the other cases. For \an1-3,7-9,
it is the middle point of the text's left edge, which makes sense.
But for \an4-6, \pos, \move and Scroll effects, it is shifted up.
It is easiest to describe for a single-line event: the anchor is
the middle point of the *left edge of the rightmost glyph*. That is,
the anchor point is not the middle of *either* edge of the full text,
and it is hard to understand intuitively, more so in a multiline event.
VSFilter in the same situation places the anchor in the middle of the
whole event's left edge, just as we do for \an1-3 and \an7-9.
This also affects the position of rotation origin,
which is likewise unintuitive and VSFilter-incompatible.
Fix this by making compute_string_bbox ignore text->glyphs[0].pos.y
even in the rare case that it is nonzero. This makes our behavior
obvious and VSFilter-compatible, and our code easier to understand
(as the reader no longer has to wonder whether there is a difference
between the various alignments, wonder *why* there seems to be no
difference after testing common cases, and make the wrong conclusion
that glyphs[0].pos.y is always 0).
|
|
|
|
|
|
|
|
|
|
|
| |
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
|