| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
| |
Fixes: https://github.com/libass/libass/issues/634
Fixes: https://github.com/mpv-player/mpv/issues/13322
|
|
|
|
| |
GDI uses this same matrix.
|
|
|
|
| |
GDI uses this lookup table to convert these values to the usual scale.
|
|
|
|
|
|
|
|
| |
This kind of check is used internally in FreeType to distinguish a real
OS/2 table from a placeholder that is always present in every FT_Face.
However, the public FT_Get_Sfnt_Table API already performs this check and
returns NULL if a real table is absent: we do not need to recheck this,
and indeed we do not do this anywhere else.
|
|
|
|
|
|
|
| |
As a reminder, we require FreeType >= 2.3.6
since commit d7544850775344879dd3049046c5b7ce2d52d3b3,
as explained in commit 6d4d51db96858f37570d169b18abc68f875c657e,
which last updated the corresponding configure check.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
\h is often used in typesetting purely for horizontal padding.
We already correctly expand \h to NBSP (0xA0) during parsing, but then
later replace it with a space (0x20) for shaping run detection. Actual
shaping though again uses NBSP, but still uses the font face indices
from shaping run detection. This can lead to problems if the font
detected for a regular space doesn’t also provide a NBSP character.
HarfBuzz automatically substiutes a missing NBSP character with the
font’s space character, hiding the issue. With FriBidi doing shaping,
\h will end up as a TOFU box.
Stop replacing NBSP with a regular space,
so font substitution can take place properly.
Note: some subs rely on GDI picking Arial for a NBSP fallback.
This commit makes no attempt to nudge fallback selection
to any particular font.
This reverts 33a3ab2c8777241b73ad85024158e19fb1f9c699. We no longer know
what problems the original commit tried to solve, but know for sure the
current replacing causes issues (and that VSFilter too uses a different
font for fallback NBSP).
Fixes: https://github.com/libass/libass/issues/2
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If static libass is linked into a binary defining functions
of the same name there will be issues. To avoid this use an
ass_ prefix for namespacing.
Before this commit we already did this for most but not yet
all internal API.
read_file is renamed to ass_load_file as ass_read_file
already exists as a public API function. All other functions
are simply prefixed with ass_.
Fixes: https://github.com/libass/libass/issues/222
Fixes: https://github.com/libass/libass/issues/654
|
|
|
|
|
| |
If a conversion fails for a non-Unicode font, let
font fallback happen instead of displaying bogus glyphs.
|
|
|
|
|
|
|
|
|
| |
Use Windows native API to convert Unicode to MBCS on Windows,
then use iconv if not on Windows and iconv is available.
Do nothing if neither is available.
fix: `ass_font_index_magic` now doesn't mangle codepoint if
charmap isn't Microsoft's.
|
| |
|
|
|
|
|
|
| |
Processing of DECO_ROTATE has moved after ASS_Outline conversion too.
All relevant outline processing functions have moved into ass_outline.c.
outline_convert() now expects preallocated outline to reduce reallocations.
|
|
|
|
|
|
|
|
|
|
|
| |
At worst, even if this face isn't actually the desired one,
this will just waste memory but won't break font selection.
At best, this enables use of some broken TrueType fonts that lack valid
PostScript names, as in https://github.com/libass/libass/issues/554.
Core Text synthesizes a PostScript name, but FreeType doesn't,
so every face has a NULL face_psname. Potentially, a font might
also have a non-NULL face_psname that differs from Core Text's.
|
|
|
|
| |
Fixes https://github.com/libass/libass/issues/554.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ass_strike_outline_glyph was realloc()ing memory that was
allocated by FreeType, not us. This isn't generally safe.
Indeed, FreeType recently switched to a different allocator
on Windows, so this code started crashing.
To avoid this, move the ass_strike_outline_glyph call
after the FT_Outline -> ASS_Outline conversion.
It's safer (less chance to exceed outline size limits)
and easier to work with ASS_Outline, anyway.
Fixes the crash in https://github.com/mpv-player/mpv/issues/9227.
|
|
|
|
|
|
| |
ass_font_get_index is _always_ called with *face_index == 0,
and even then it's only a fallback default rather than a request:
it should be treated as an output-only parameter.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
...instead of passing them as arguments everywhere.
|
| |
|
|
|
|
|
| |
- ass_drawing was logging size_t as %d
- ass_font was logging ASS_StringView as %s (could crash!)
|
|
|
|
| |
That eliminates most uses of strdup() in the rendering process.
|
|
|
|
|
|
| |
ass_font_clear() can now free family string even in a failure case.
Fixes https://github.com/libass/libass/issues/414.
|
|
|
|
|
|
|
| |
- Convert tabs to spaces
- Ensure one space between keywords and parenthesis
- Ensure space between ')' and '{'
- Trim trailing whitespace
|
| |
|
|
|
|
|
| |
We used to do a lot of work to get freetype to imitate VSFilter's font-metrics
handling. Instead, we now just duplicate its behavior directly early on.
|
|
|
|
|
|
| |
And conversely, do faux-bold fonts that are too thin
The offset of 150 matches VSFilter's behavior
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit forces construction of cache values using only data
available in its companion keys. That ensures logical correctness:
keys are guaranteed to have all the necessary data, and prevents
accidental collisions.
Most fixes of cache logic correspond to minor problem
when rendering is done with double parameter but cache key stores
its approximate fixed-point representation. The only serious problem
is missing scale of clip drawing. Also this commit removes unused
scale parameters from glyph metrics cache key.
Due to missing scale clip shapes that differed only in scale
treated by cache system as identical. That can lead to incorrect reuse
of cached bitmap of different scale instead of correct one.
The only hack left is in glyph metrics cache with its
unicode >= VERTICAL_LOWER_BOUND check.
|
|
|
|
|
| |
Leading newlines are now rendered, but still incorrectly:
at full height rather than at half-height as required.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Advantages over the old algorithm consist of the following.
* There are no glitches due to full cache clearing.
Items are arranged into linked list ordered by time of last use.
Only the oldest items get deleted at the clearing event.
* Each item now keeps track of number of references.
Referenced cache values are immune to clearing.
* Reduced amount of total cache memory for the same performance.
* Reduced number of memory allocations per cache item.
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
As pointed out in #198. This is certainly just a typo.
Fixes #198.
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
| |
This is more robust and simpler. The bearing calculations initially
were bugged, but getting rid of them completely seems better. It is
consistent with other text renderers as well. To simplify things, also
move striking before the additional scale is applied and get rid of the
half-pixel overlapping thing; it is not needed with additive blending.
Fixes #193.
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Bad things can happen otherwise. Found by coverity scan.
|
|
|
|
|
| |
The name is always pulled from the font info, which is static, so
there is no need to strdup.
|
|
|
|
|
| |
Apparently, libfreetype calls close_stream_font through the
FT_Stream.close callback.
|
|
|
|
|
|
|
|
|
| |
An earlier commit added this code to avoid adding font faces multiple
times. In this form, it breaks the "Trying all charmaps" fallback case,
which can lead to text being rendered as boxes.
Return the font that is going to contain the missing glyph instead. The
calling code will check again, and run the fallback if necessary.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
This is faster in many cases, and more suitable for Windows' GetFontData
function.
|
|
|
|
|
| |
This is a bit nicer because we can actually see which physical font
has been selected for a certain logical font.
|
|
|
|
|
| |
Allow memory fonts with the get_face_data callback. This feature is
used for embedded fonts, but can be used by any font provider.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Introduce a simple glyph coverage map (created when the font is added)
and use it for checking glyph coverage in font selection. This uses a
simple linear search at the moment.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
HarfBuzz faces reference the FreeType faces. Destroying FT faces first can cause crash in HB destruction code:
https://bugs.freedesktop.org/show_bug.cgi?id=86300
|
| |
|
| |
|
|
|
|
| |
These were missing in several places. Fixes #50.
|
|
|
|
| |
Fixes libass#8.
|
|
|
|
|
|
|
|
|
|
|
| |
For whatever reason FT_Vector points[4] = { ... }; needs to come at the
beginning of a scope. Since that block was duplicated, just extract it
to a function.
This does not include buildsystem support, so actually compiling with
VC++ requires creating a project and supplying a config.h file.
Signed-off-by: wm4 <wm4@nowhere>
|
| |
|
|
|
|
|
|
|
|
| |
Some fonts stuff a signed, negative value into this unsigned
field. This usually causes very small and wrongly positioned
rendering. Also handle usWinAscent similarly, just in case.
Fixes issue #106.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The first point in a countour is not allowed to be a cubic control
point, which is sometimes violated by blindly reversing a countour,
producing the following errors:
[ass] FT_Stroker_ParseOutline failed, error: 20
[ass] Failed to rasterize glyph: 1
To avoid this, let the first point remain the first
and only reverse the order of the remaining points.
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is a bit crazy, but for vertical layout the sTypoAscender and
sTypoDescender fields of the OS/2 table are supposed to be used for
determining the size of the ideographic EM box [1], so that glyphs
can be centered on the baseline more neatly.
With this change, vertical layout should be completely equal to
VSFilter.
[1] http://www.microsoft.com/typography/otspec150/os2.htm#sta
|
|
|
|
|
| |
Make sure to use vertical advance under the right conditions -
vertical font selected, requested glyph is non-latin.
|
|
|
|
|
| |
Temporary fix for a crash when a font face doesn't actually contain
the glyph that fontconfig reports. Needs a real solution.
|
|
|
|
|
|
| |
The new revision of the stroker in FreeType doesn't like the way
contours are zero-filled to disable them. It's not particularly clean
anyway, so rewrite the whole outline instead.
|
| |
|
|