]> granicus.if.org Git - libass/log
libass
8 years agoRelease 0.13.1 0.13.1
Oleg Oshmyan [Tue, 1 Dec 2015 17:33:46 +0000 (19:33 +0200)]
Release 0.13.1

8 years agocoretext: don't fetch character set when it isn't needed
Oleg Oshmyan [Tue, 1 Dec 2015 16:31:33 +0000 (18:31 +0200)]
coretext: don't fetch character set when it isn't needed

This avoids unnecessary work and fixes a memory leak:
the character set wasn't released when code == 0.

8 years agofontselect: destroy private data of fonts that fail to be added
Oleg Oshmyan [Tue, 1 Dec 2015 15:40:45 +0000 (17:40 +0200)]
fontselect: destroy private data of fonts that fail to be added

8 years agofontselect: fix bool return values
Oleg Oshmyan [Tue, 1 Dec 2015 15:18:43 +0000 (17:18 +0200)]
fontselect: fix bool return values

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.

9 years agocoretext: don't forget to release font format attribute
Oleg Oshmyan [Sat, 7 Nov 2015 13:23:17 +0000 (15:23 +0200)]
coretext: don't forget to release font format attribute

9 years agofontselect: replace is_postscript flag with check_postscript function
Oleg Oshmyan [Wed, 4 Nov 2015 13:25:47 +0000 (15:25 +0200)]
fontselect: replace is_postscript flag with check_postscript function

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.

9 years agodirectwrite: improve error handling
Oleg Oshmyan [Thu, 29 Oct 2015 23:33:30 +0000 (01:33 +0200)]
directwrite: improve error handling

  * Check malloc and calloc return values.
  * Abort if a name can't be fetched, rather than supply a NULL
    string to fontselect causing it to crash.
  * Make sure to free all allocated memory.
  * Always check FAILED(hr) before using the value of any output
    argument returned by DirectWrite, because it is not clear whether
    they are guaranteed to have correct values in case of error.

9 years agodirectwrite: slightly clean up the code
Oleg Oshmyan [Thu, 29 Oct 2015 23:33:30 +0000 (01:33 +0200)]
directwrite: slightly clean up the code

  * Metrics are not used, so don't fetch them.
  * All variables except meta are always explicitly set before use,
    so don't initialize them.
  * Declare variables where they are used.
  * Use int loop variables when the loop bound is int.
  * Prefer post-increment to pre-increment.

9 years agodirectwrite: split out the inner loop of scan_fonts as a separate function
Oleg Oshmyan [Thu, 29 Oct 2015 23:13:59 +0000 (01:13 +0200)]
directwrite: split out the inner loop of scan_fonts as a separate function

This has the side effect that the ASS_FontProviderMetaData instance is now
cleared for every font rather than only once at the start of the search,
which fixes some use-after-free scenarios and prevents the creation of
chimeric fonts using names left over from other fonts processed earlier.

This lays the groundwork for further code simplification and error handling
improvements within this function, which will come in a separate commit.

This commit is transparent to `git blame -w` except for return statements.

9 years agoInterpret timestamps with negative components more obviously
Oleg Oshmyan [Thu, 29 Oct 2015 00:56:14 +0000 (02:56 +0200)]
Interpret timestamps with negative components more obviously

Keep all components signed, allowing for timestamps like 00:01:-05.00
to denote 55 seconds. This matches the behavior of VSFilter.

9 years agoFix several signedness bugs
Oleg Oshmyan [Thu, 29 Oct 2015 00:34:42 +0000 (02:34 +0200)]
Fix several signedness bugs

Reported by gcc -Wall -Wextra.

9 years agoFix Windows build
Grigori Goronzy [Wed, 28 Oct 2015 23:49:41 +0000 (00:49 +0100)]
Fix Windows build

Some parts used in fontselect weren't properly defined.

v2: RAW_CFF face type was added later, so it's at the end of the
enum list.

9 years agofontselect: silence warnings about discarding const
Oleg Oshmyan [Wed, 28 Oct 2015 22:19:20 +0000 (00:19 +0200)]
fontselect: silence warnings about discarding const

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.

9 years agoFix the Linux build on Travis CI
Oleg Oshmyan [Thu, 22 Oct 2015 23:38:59 +0000 (02:38 +0300)]
Fix the Linux build on Travis CI

We need a newer Fontconfig than the default Ubuntu
environment provides, so switch to a newer Ubuntu.

9 years agofontselect: don't trim font names
Oleg Oshmyan [Thu, 22 Oct 2015 23:20:19 +0000 (02:20 +0300)]
fontselect: don't trim font names

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.

9 years agofontselect: don't find fonts with PostScript outlines by full name
Oleg Oshmyan [Thu, 22 Oct 2015 22:55:06 +0000 (01:55 +0300)]
fontselect: don't find fonts with PostScript outlines by full name

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.

9 years agofont: check FT_Get_Postscript_Name return value for NULL
Oleg Oshmyan [Wed, 21 Oct 2015 23:43:03 +0000 (02:43 +0300)]
font: check FT_Get_Postscript_Name return value for NULL

9 years agofontselect: use stdbool.h wherever appropriate
Oleg Oshmyan [Tue, 20 Oct 2015 22:14:13 +0000 (01:14 +0300)]
fontselect: use stdbool.h wherever appropriate

9 years agodirectwrite: fix broken return value check
Oleg Oshmyan [Tue, 20 Oct 2015 22:04:10 +0000 (01:04 +0300)]
directwrite: fix broken return value check

9 years agofontselect: find fonts with PostScript outlines by PostScript name
Oleg Oshmyan [Tue, 20 Oct 2015 21:51:34 +0000 (00:51 +0300)]
fontselect: find fonts with PostScript outlines by PostScript 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.

9 years agofontconfig: read PostScript names
Oleg Oshmyan [Mon, 19 Oct 2015 13:52:34 +0000 (16:52 +0300)]
fontconfig: read PostScript names

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.

9 years agofontselect: read PostScript names for memory fonts
Oleg Oshmyan [Mon, 19 Oct 2015 13:28:33 +0000 (16:28 +0300)]
fontselect: read PostScript names for memory fonts

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.

9 years agofontselect: move PostScript name into ASS_FontProviderMetaData
Oleg Oshmyan [Mon, 19 Oct 2015 13:11:27 +0000 (16:11 +0300)]
fontselect: move PostScript name into ASS_FontProviderMetaData

9 years agofontselect: fix ass_font_provider_add_font signature and doxygen
Oleg Oshmyan [Mon, 19 Oct 2015 11:35:24 +0000 (14:35 +0300)]
fontselect: fix ass_font_provider_add_font signature and doxygen

index is signed, and psname only overrides it iff index < 0.

9 years agodrawing: remove unused field
wm4 [Wed, 14 Oct 2015 19:03:21 +0000 (21:03 +0200)]
drawing: remove unused field

9 years agoconfigure: don't add unnecessary libraries to PKG_LIBS_PRIVATE
Oleg Oshmyan [Wed, 14 Oct 2015 18:45:31 +0000 (21:45 +0300)]
configure: don't add unnecessary libraries to PKG_LIBS_PRIVATE

Library checks can succeed if the needed functions exist in libc
and don't need any extra linker flags. Avoid adding unnecessary
flags (which break static linking against libass) in this case.

9 years agoconfigure: include -liconv if that is found
wm4 [Tue, 13 Oct 2015 20:18:30 +0000 (22:18 +0200)]
configure: include -liconv if that is found

9 years agoass: use a bitmap for checking duplicate events
wm4 [Mon, 12 Oct 2015 19:56:44 +0000 (21:56 +0200)]
ass: use a bitmap for checking duplicate events

The loop in check_duplicate_event() essentially makes event processing
with ass_process_chunk() O(n^2). Using a bitmap instead of a loop brings
it back to O(n).

This could be interpreted as an API change: since the event list is
freely modifieable by the API user through ASS_Track public fields,
libass can't know if the internal bitmap went out of sync with the
public event list. We just redefine it so that calling
ass_process_chunk() means the API user agrees not to manipulate the
event list otherwise.

9 years agoconfigure: Set the correct x32 machine option for yasm
Luke Dashjr [Sat, 10 Oct 2015 08:11:38 +0000 (08:11 +0000)]
configure: Set the correct x32 machine option for yasm

9 years agoUse proper include statement for HarfBuzz
wm4 [Wed, 7 Oct 2015 16:24:33 +0000 (18:24 +0200)]
Use proper include statement for HarfBuzz

9 years agocache: remove unused BINSTRING field type
wm4 [Tue, 6 Oct 2015 12:56:50 +0000 (14:56 +0200)]
cache: remove unused BINSTRING field type

Its only use was removed in commit b63d8931.

9 years agoUpdate last release date in README
Oleg Oshmyan [Sat, 3 Oct 2015 19:28:55 +0000 (22:28 +0300)]
Update last release date in README

9 years agoRelease 0.13.0 0.13.0
wm4 [Sat, 3 Oct 2015 11:08:24 +0000 (13:08 +0200)]
Release 0.13.0

9 years agobuild: add missing new source files
wm4 [Sat, 3 Oct 2015 18:13:04 +0000 (20:13 +0200)]
build: add missing new source files

The ass_func_template.h entry was removed with commit c22a4ff9.
utils.asm is really new.

9 years agoconfigure: do not add -ldwrite to libass.pc
wm4 [Thu, 24 Sep 2015 13:55:04 +0000 (15:55 +0200)]
configure: do not add -ldwrite to libass.pc

This was forgotten. We always load dwrite.dll at runtime, so this isn't
needed.

9 years agoass_font: fix broken loop condition
wm4 [Thu, 24 Sep 2015 08:34:19 +0000 (10:34 +0200)]
ass_font: fix broken loop condition

As pointed out in #198. This is certainly just a typo.

Fixes #198.

9 years agoMerge pull request #197 from grigorig/remove-enca
Grigori Goronzy [Wed, 23 Sep 2015 10:28:46 +0000 (12:28 +0200)]
Merge pull request #197 from grigorig/remove-enca

Remove ENCA support

9 years agoRemove ENCA support
Grigori Goronzy [Wed, 23 Sep 2015 08:34:55 +0000 (10:34 +0200)]
Remove ENCA support

There is no real value in it. ENCA only works in some cases and I
can't find any information about software that integrates libass
which relies on it or users that rely on ENCA support in case the
interface is exposed directly (e.g. in MPlayer).

If there is still a wish to have charset detection integrated into
libass (it is out of scope, IMHO), a better library like uchardet
should be used for that.

9 years agoMerge pull request #84 from astiob/msvc
Grigori Goronzy [Tue, 22 Sep 2015 21:07:02 +0000 (23:07 +0200)]
Merge pull request #84 from astiob/msvc

MSVC/ICL and general header fixes

9 years agofontselect: make iconv optional again
wm4 [Sun, 20 Sep 2015 17:21:37 +0000 (19:21 +0200)]
fontselect: make iconv optional again

It was needed for UTF16BE -> UTF8 only, which is trivial to implement.

9 years agoFully fix compilation with MSVC/ICL
Oleg Oshmyan [Sun, 27 Apr 2014 05:55:42 +0000 (06:55 +0100)]
Fully fix compilation with MSVC/ICL

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>
9 years agoInclude config.h in all source files and in no headers
Oleg Oshmyan [Tue, 15 Sep 2015 14:10:58 +0000 (17:10 +0300)]
Include config.h in all source files and in no headers

This way, #include "config.h" is consistently the very
first thing the compiler sees when compiling any file.

Some source files currently don't use anything defined in config.h,
but it's easier and less error-prone to include it now to anticipate
possible future changes in those files, config.h or other headers.

9 years agoMove ASS_Shaper declaration to ass_shaper.h
Oleg Oshmyan [Sun, 27 Apr 2014 05:48:47 +0000 (06:48 +0100)]
Move ASS_Shaper declaration to ass_shaper.h

9 years agounistd.h is not needed
Oleg Oshmyan [Sun, 27 Apr 2014 04:06:05 +0000 (05:06 +0100)]
unistd.h is not needed

9 years agodirectwrite: change WINBOOL to BOOL.
torque [Sun, 13 Sep 2015 19:19:47 +0000 (12:19 -0700)]
directwrite: change WINBOOL to BOOL.

WINBOOL is MingW-specific.

9 years agodirectwrite: fix syntax error with MSVC.
torque [Sun, 13 Sep 2015 19:13:40 +0000 (12:13 -0700)]
directwrite: fix syntax error with MSVC.

MSVC requires the calling convention to be grouped with the identifier when
defining a callback type.

9 years agofont: ignore bearing for strikes
Grigori Goronzy [Tue, 15 Sep 2015 01:00:05 +0000 (03:00 +0200)]
font: ignore bearing for strikes

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.

9 years agoass_fontselect: do not use PATH_MAX
wm4 [Sun, 13 Sep 2015 20:49:04 +0000 (22:49 +0200)]
ass_fontselect: do not use PATH_MAX

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.

9 years agoMerge pull request #192 from grigorig/stringfuncs
Grigori Goronzy [Thu, 10 Sep 2015 23:15:34 +0000 (01:15 +0200)]
Merge pull request #192 from grigorig/stringfuncs

NIH: add locale-independent string functions

9 years agoNIH: add locale-independent string functions
Grigori Goronzy [Mon, 7 Sep 2015 21:44:41 +0000 (23:44 +0200)]
NIH: add locale-independent string functions

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

9 years agofontselect: avoid undefined behavior
wm4 [Wed, 9 Sep 2015 10:06:47 +0000 (12:06 +0200)]
fontselect: avoid undefined behavior

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.

9 years agofontselect: raise font selection log message
wm4 [Wed, 9 Sep 2015 10:04:51 +0000 (12:04 +0200)]
fontselect: raise font selection log message

9 years agoass_fontselect: ignore ./.. and hidden files
wm4 [Tue, 8 Sep 2015 17:45:07 +0000 (19:45 +0200)]
ass_fontselect: ignore ./.. and hidden files

9 years agofontselect: handle additional malloc errors
Grigori Goronzy [Mon, 7 Sep 2015 23:38:44 +0000 (01:38 +0200)]
fontselect: handle additional malloc errors

9 years agoass_fontselect: uninline ass_map_font()
wm4 [Mon, 7 Sep 2015 14:06:24 +0000 (16:06 +0200)]
ass_fontselect: uninline ass_map_font()

Also fixes the build on OSX under some circumstances (weird and
inconsistent rules for the inline keyword in C).

9 years agoconfigure: make fontconfig optional
wm4 [Mon, 7 Sep 2015 12:54:33 +0000 (14:54 +0200)]
configure: make fontconfig optional

9 years agoass_fontselect: log the selected font provider
wm4 [Mon, 7 Sep 2015 11:55:07 +0000 (13:55 +0200)]
ass_fontselect: log the selected font provider

9 years agoass_shaper: raise shaper info log level
wm4 [Mon, 7 Sep 2015 11:51:52 +0000 (13:51 +0200)]
ass_shaper: raise shaper info log level

MSGL_V is usually for far noisier messages, such as those printed per
subtitle event.

9 years agoass_bitmap: fix potential NULL deref
wm4 [Mon, 7 Sep 2015 11:43:00 +0000 (13:43 +0200)]
ass_bitmap: fix potential NULL deref

Another consequence of the trickiness in this code. This codepath for
opaque_box=1 assumes both bm_o and bm_g are set, but if memory
allocation fails somewhere, bm_o could be non-NULL, but bm_g NULL, which
then would result in a crash when accessing bm_g.

Possibly this code could be cleaned up to look much nicer (and not have
dozens of hidden, obscure bugs), but for now this fixes the potential
crash found by Coverity.

Fixes CID 146125.

9 years agoass_render: fix potential NULL deref
wm4 [Mon, 7 Sep 2015 11:36:23 +0000 (13:36 +0200)]
ass_render: fix potential NULL deref

Fixes CID 146421.

9 years agotravis: run on OSX too
wm4 [Mon, 7 Sep 2015 10:50:38 +0000 (12:50 +0200)]
travis: run on OSX too

9 years agoass_drawing: make ass_drawing_new() fail properly on OOM
wm4 [Mon, 7 Sep 2015 10:48:34 +0000 (12:48 +0200)]
ass_drawing: make ass_drawing_new() fail properly on OOM

Fixes CID 146124.

9 years agoass_parse: add check against ass_drawing_new() failure
wm4 [Mon, 7 Sep 2015 10:45:51 +0000 (12:45 +0200)]
ass_parse: add check against ass_drawing_new() failure

Also move the argument parsing part to the top of the function. IT's
easier to read this way.

9 years agoass_render: fix potential NULL deref
wm4 [Mon, 7 Sep 2015 10:43:40 +0000 (12:43 +0200)]
ass_render: fix potential NULL deref

The logic here is pretty complicated. The caller of this function guards
it with "if(info->bm || info->bm_o){", and generally indeed only one of
them is set. But in some cases, both are needed. fix_outline()
definitely dereferences both. This is not necessarily guaranteed, e.g.
on out of memory errors. Add the missing checks.

Fixes CID 146125.

9 years agofontselect: initialize postscript name
Grigori Goronzy [Mon, 7 Sep 2015 10:13:33 +0000 (12:13 +0200)]
fontselect: initialize postscript name

Bad things can happen otherwise. Found by coverity scan.

9 years agofontselect: fix memory leak
Grigori Goronzy [Mon, 7 Sep 2015 10:08:08 +0000 (12:08 +0200)]
fontselect: fix memory leak

Introduced by commit d6bb9af6. Found by coverity scan.

9 years agoMerge branch 'fonts'
Grigori Goronzy [Mon, 7 Sep 2015 09:40:54 +0000 (11:40 +0200)]
Merge branch 'fonts'

9 years agoMerge pull request #190 from grigorig/fonts
Grigori Goronzy [Mon, 7 Sep 2015 09:32:49 +0000 (11:32 +0200)]
Merge pull request #190 from grigorig/fonts

Substitutions and some fixes

9 years agofontselect: get rid of strdup for display name
Grigori Goronzy [Mon, 7 Sep 2015 09:06:17 +0000 (11:06 +0200)]
fontselect: get rid of strdup for display name

The name is always pulled from the font info, which is static, so
there is no need to strdup.

9 years agofontselect: improve font display name choice
Grigori Goronzy [Mon, 7 Sep 2015 09:03:28 +0000 (11:03 +0200)]
fontselect: improve font display name choice

9 years agofontselect: remove outdated remark
Grigori Goronzy [Mon, 7 Sep 2015 08:56:59 +0000 (10:56 +0200)]
fontselect: remove outdated remark

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.

9 years agofontconfig: fix memory leak in error path
Grigori Goronzy [Mon, 7 Sep 2015 08:48:17 +0000 (10:48 +0200)]
fontconfig: fix memory leak in error path

Found by clang static analysis.

9 years agofontselect: call match_fonts for each alias
Grigori Goronzy [Mon, 7 Sep 2015 08:27:26 +0000 (10:27 +0200)]
fontselect: call match_fonts for each alias

In case a font provider actually uses more than one substitution.

9 years agotest: use proper fallback name
Grigori Goronzy [Mon, 7 Sep 2015 00:12:43 +0000 (02:12 +0200)]
test: use proper fallback name

The correct generic family name is "sans-serif", the short form "Sans"
is specific to fontconfig only.

9 years agofontselect: fix fallback family fallback
Grigori Goronzy [Sun, 6 Sep 2015 23:34:48 +0000 (01:34 +0200)]
fontselect: fix fallback family fallback

9 years agofontconfig: handle fallback corner cases
Grigori Goronzy [Sun, 6 Sep 2015 23:29:27 +0000 (01:29 +0200)]
fontconfig: handle fallback corner cases

If no particular codepoint is requested (codepoint == 0), just return
the first font family. Additionally, handle fontconfig errors, albeit
they're unlikely to happen.

9 years agofontselect: fix match_fonts semantics
Grigori Goronzy [Wed, 2 Sep 2015 22:04:59 +0000 (00:04 +0200)]
fontselect: fix match_fonts semantics

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.

9 years agodirectwrite, coretext: implement substitutions
Grigori Goronzy [Tue, 1 Sep 2015 13:47:40 +0000 (15:47 +0200)]
directwrite, coretext: implement substitutions

This adds simple and sensible substitutions for generic font family
names. A helper function is introduced to reduce code duplication.

9 years agodirectwrite: fix fallback for codepoint 0
Grigori Goronzy [Tue, 1 Sep 2015 14:33:33 +0000 (16:33 +0200)]
directwrite: fix fallback for codepoint 0

9 years agodirectwrite: fix compilation
Grigori Goronzy [Tue, 1 Sep 2015 14:29:49 +0000 (16:29 +0200)]
directwrite: fix compilation

A name clash was introduced by commit ab08d079.

9 years agocoretext: use SAFE_CFRelease() for robustness
wm4 [Tue, 1 Sep 2015 12:50:36 +0000 (14:50 +0200)]
coretext: use SAFE_CFRelease() for robustness

CFRelease(NULL) can crash. While we're still not sure which CoreText API
calls can fail etc. (thanks Apple), this should fix a couple of
theoretically possible crashes.

9 years agofontselect: fix yet another memory leak
Grigori Goronzy [Tue, 1 Sep 2015 12:37:57 +0000 (14:37 +0200)]
fontselect: fix yet another memory leak

9 years agofontselect: stop font selection after first match
Grigori Goronzy [Tue, 1 Sep 2015 00:12:19 +0000 (02:12 +0200)]
fontselect: stop font selection after first match

9 years agofontselect: remove static fallback font list
Grigori Goronzy [Mon, 31 Aug 2015 23:17:53 +0000 (01:17 +0200)]
fontselect: remove static fallback font list

The default font provider needs to provide a GetFallbackFunc callback
instead.

9 years agofontselect: add const
wm4 [Tue, 1 Sep 2015 12:33:51 +0000 (14:33 +0200)]
fontselect: add const

9 years agofontselect: never pass family=NULL to get_fallback()
wm4 [Tue, 1 Sep 2015 12:33:08 +0000 (14:33 +0200)]
fontselect: never pass family=NULL to get_fallback()

The CoreText backend doesn't like this, and in fact there's no reason to
pass NULL.

9 years agocoretext: fix sizeof vs. strlen
wm4 [Tue, 1 Sep 2015 12:31:21 +0000 (14:31 +0200)]
coretext: fix sizeof vs. strlen

9 years agocoretext: always use lazy loading
wm4 [Tue, 1 Sep 2015 12:21:31 +0000 (14:21 +0200)]
coretext: always use lazy loading

We already decided that eager loading is too slow. No need to keep
multiple code paths around.

9 years agofontselect: simplify get_fallback signature
wm4 [Tue, 1 Sep 2015 12:18:51 +0000 (14:18 +0200)]
fontselect: simplify get_fallback signature

Apparently we only need the font family (and even that isn't used in all
font providers). Drop the others.

9 years agofontselect: use designated initializers
wm4 [Tue, 1 Sep 2015 12:08:47 +0000 (14:08 +0200)]
fontselect: use designated initializers

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.

9 years agocoretext: implement GetFallbackFunc
Stefano Pigozzi [Mon, 31 Aug 2015 22:18:03 +0000 (00:18 +0200)]
coretext: implement GetFallbackFunc

9 years agofontselect: add bounds checking for memory font stream reads
wm4 [Mon, 31 Aug 2015 10:15:01 +0000 (12:15 +0200)]
fontselect: add bounds checking for memory font stream reads

9 years agofont: fix double frees if opening memory font fails
wm4 [Mon, 31 Aug 2015 10:03:37 +0000 (12:03 +0200)]
font: fix double frees if opening memory font fails

Apparently, libfreetype calls close_stream_font through the
FT_Stream.close callback.

9 years agofontselect: fix a memory leak
wm4 [Mon, 31 Aug 2015 09:56:15 +0000 (11:56 +0200)]
fontselect: fix a memory leak

The result of the subst_font callback was not freed.

9 years agofontselect: reimplement ass_set_fonts_dir() functionality
wm4 [Fri, 28 Aug 2015 17:32:46 +0000 (19:32 +0200)]
fontselect: reimplement ass_set_fonts_dir() functionality

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.

9 years agorender_api: fix crash when calling ass_set_fonts() after rendering
wm4 [Fri, 28 Aug 2015 16:34:36 +0000 (18:34 +0200)]
render_api: fix crash when calling ass_set_fonts() after rendering

The caches may reference data which belongs to the font provider. If the
font selector and the font provider are destroyed, it can leave dangling
pointers in the renderer cache. (At least that's what it looks like.)

For some reason, this didn't even trigger valgrind warnings with the
fontconfig font provider. Possibly the dangling pointers were FT_Face
pointers, and fontconfig might cache these process-wide.

9 years agofont: fix broken charmap fallback handling
wm4 [Fri, 28 Aug 2015 15:39:08 +0000 (17:39 +0200)]
font: fix broken charmap fallback handling

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.

9 years agofontselect: fix fallbacks
wm4 [Fri, 28 Aug 2015 14:29:06 +0000 (16:29 +0200)]
fontselect: fix fallbacks

I broke it.

9 years agoconfigure: proper configure switches for DirectWrite and CoreText
wm4 [Fri, 28 Aug 2015 13:39:32 +0000 (15:39 +0200)]
configure: proper configure switches for DirectWrite and CoreText

Also, remove the ass_coretext.c conditional compilation hack, and fix
Makefile.am instead.

9 years agoass: make font_provider API private
wm4 [Fri, 28 Aug 2015 12:51:09 +0000 (14:51 +0200)]
ass: make font_provider API private

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.