forked from mia/Aegisub
Update libass to d8a0fe5984d9bc6d7827026215d21ada3dda7b71 and update LICENSE to reflect that libass is now ISCL
Originally committed to SVN as r4839.
This commit is contained in:
parent
c0c82505c7
commit
5be8ee5c0e
25 changed files with 1188 additions and 1304 deletions
|
@ -34,7 +34,7 @@ The following directories and file are covered by their respective licenses as
|
||||||
follows:
|
follows:
|
||||||
|
|
||||||
libass/
|
libass/
|
||||||
- GPL see libass/COPYING.
|
- ISC license. See libass/COPYING.
|
||||||
|
|
||||||
libffms/
|
libffms/
|
||||||
- MIT license.
|
- MIT license.
|
||||||
|
|
|
@ -1,339 +1,11 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
Version 2, June 1991
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
of this license document, but changing it is not allowed.
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
Preamble
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
License is intended to guarantee your freedom to share and change free
|
|
||||||
software--to make sure the software is free for all its users. This
|
|
||||||
General Public License applies to most of the Free Software
|
|
||||||
Foundation's software and to any other program whose authors commit to
|
|
||||||
using it. (Some other Free Software Foundation software is covered by
|
|
||||||
the GNU Lesser General Public License instead.) You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
this service if you wish), that you receive source code or can get it
|
|
||||||
if you want it, that you can change the software or use pieces of it
|
|
||||||
in new free programs; and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
anyone to deny you these rights or to ask you to surrender the rights.
|
|
||||||
These restrictions translate to certain responsibilities for you if you
|
|
||||||
distribute copies of the software, or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must give the recipients all the rights that
|
|
||||||
you have. You must make sure that they, too, receive or can get the
|
|
||||||
source code. And you must show them these terms so they know their
|
|
||||||
rights.
|
|
||||||
|
|
||||||
We protect your rights with two steps: (1) copyright the software, and
|
|
||||||
(2) offer you this license which gives you legal permission to copy,
|
|
||||||
distribute and/or modify the software.
|
|
||||||
|
|
||||||
Also, for each author's protection and ours, we want to make certain
|
|
||||||
that everyone understands that there is no warranty for this free
|
|
||||||
software. If the software is modified by someone else and passed on, we
|
|
||||||
want its recipients to know that what they have is not the original, so
|
|
||||||
that any problems introduced by others will not reflect on the original
|
|
||||||
authors' reputations.
|
|
||||||
|
|
||||||
Finally, any free program is threatened constantly by software
|
|
||||||
patents. We wish to avoid the danger that redistributors of a free
|
|
||||||
program will individually obtain patent licenses, in effect making the
|
|
||||||
program proprietary. To prevent this, we have made it clear that any
|
|
||||||
patent must be licensed for everyone's free use or not licensed at all.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License applies to any program or other work which contains
|
|
||||||
a notice placed by the copyright holder saying it may be distributed
|
|
||||||
under the terms of this General Public License. The "Program", below,
|
|
||||||
refers to any such program or work, and a "work based on the Program"
|
|
||||||
means either the Program or any derivative work under copyright law:
|
|
||||||
that is to say, a work containing the Program or a portion of it,
|
|
||||||
either verbatim or with modifications and/or translated into another
|
|
||||||
language. (Hereinafter, translation is included without limitation in
|
|
||||||
the term "modification".) Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running the Program is not restricted, and the output from the Program
|
|
||||||
is covered only if its contents constitute a work based on the
|
|
||||||
Program (independent of having been made by running the Program).
|
|
||||||
Whether that is true depends on what the Program does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Program's
|
|
||||||
source code as you receive it, in any medium, provided that you
|
|
||||||
conspicuously and appropriately publish on each copy an appropriate
|
|
||||||
copyright notice and disclaimer of warranty; keep intact all the
|
|
||||||
notices that refer to this License and to the absence of any warranty;
|
|
||||||
and give any other recipients of the Program a copy of this License
|
|
||||||
along with the Program.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy, and
|
|
||||||
you may at your option offer warranty protection in exchange for a fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Program or any portion
|
|
||||||
of it, thus forming a work based on the Program, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) You must cause the modified files to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
b) You must cause any work that you distribute or publish, that in
|
|
||||||
whole or in part contains or is derived from the Program or any
|
|
||||||
part thereof, to be licensed as a whole at no charge to all third
|
|
||||||
parties under the terms of this License.
|
|
||||||
|
|
||||||
c) If the modified program normally reads commands interactively
|
|
||||||
when run, you must cause it, when started running for such
|
|
||||||
interactive use in the most ordinary way, to print or display an
|
|
||||||
announcement including an appropriate copyright notice and a
|
|
||||||
notice that there is no warranty (or else, saying that you provide
|
|
||||||
a warranty) and that users may redistribute the program under
|
|
||||||
these conditions, and telling the user how to view a copy of this
|
|
||||||
License. (Exception: if the Program itself is interactive but
|
|
||||||
does not normally print such an announcement, your work based on
|
|
||||||
the Program is not required to print an announcement.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Program,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Program, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Program.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Program
|
|
||||||
with the Program (or with a work based on the Program) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may copy and distribute the Program (or a work based on it,
|
|
||||||
under Section 2) in object code or executable form under the terms of
|
|
||||||
Sections 1 and 2 above provided that you also do one of the following:
|
|
||||||
|
|
||||||
a) Accompany it with the complete corresponding machine-readable
|
|
||||||
source code, which must be distributed under the terms of Sections
|
|
||||||
1 and 2 above on a medium customarily used for software interchange; or,
|
|
||||||
|
|
||||||
b) Accompany it with a written offer, valid for at least three
|
|
||||||
years, to give any third party, for a charge no more than your
|
|
||||||
cost of physically performing source distribution, a complete
|
|
||||||
machine-readable copy of the corresponding source code, to be
|
|
||||||
distributed under the terms of Sections 1 and 2 above on a medium
|
|
||||||
customarily used for software interchange; or,
|
|
||||||
|
|
||||||
c) Accompany it with the information you received as to the offer
|
|
||||||
to distribute corresponding source code. (This alternative is
|
|
||||||
allowed only for noncommercial distribution and only if you
|
|
||||||
received the program in object code or executable form with such
|
|
||||||
an offer, in accord with Subsection b above.)
|
|
||||||
|
|
||||||
The source code for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For an executable work, complete source
|
|
||||||
code means all the source code for all modules it contains, plus any
|
|
||||||
associated interface definition files, plus the scripts used to
|
|
||||||
control compilation and installation of the executable. However, as a
|
|
||||||
special exception, the source code distributed need not include
|
|
||||||
anything that is normally distributed (in either source or binary
|
|
||||||
form) with the major components (compiler, kernel, and so on) of the
|
|
||||||
operating system on which the executable runs, unless that component
|
|
||||||
itself accompanies the executable.
|
|
||||||
|
|
||||||
If distribution of executable or object code is made by offering
|
|
||||||
access to copy from a designated place, then offering equivalent
|
|
||||||
access to copy the source code from the same place counts as
|
|
||||||
distribution of the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program
|
|
||||||
except as expressly provided under this License. Any attempt
|
|
||||||
otherwise to copy, modify, sublicense or distribute the Program is
|
|
||||||
void, and will automatically terminate your rights under this License.
|
|
||||||
However, parties who have received copies, or rights, from you under
|
|
||||||
this License will not have their licenses terminated so long as such
|
|
||||||
parties remain in full compliance.
|
|
||||||
|
|
||||||
5. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Program or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Program (or any work based on the
|
|
||||||
Program), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Program or works based on it.
|
|
||||||
|
|
||||||
6. Each time you redistribute the Program (or any work based on the
|
|
||||||
Program), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute or modify the Program subject to
|
|
||||||
these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties to
|
|
||||||
this License.
|
|
||||||
|
|
||||||
7. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Program at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Program by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Program.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under
|
|
||||||
any particular circumstance, the balance of the section is intended to
|
|
||||||
apply and the section as a whole is intended to apply in other
|
|
||||||
circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system, which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
8. If the distribution and/or use of the Program is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Program under this License
|
|
||||||
may add an explicit geographical distribution limitation excluding
|
|
||||||
those countries, so that distribution is permitted only in or among
|
|
||||||
countries not thus excluded. In such case, this License incorporates
|
|
||||||
the limitation as if written in the body of this License.
|
|
||||||
|
|
||||||
9. The Free Software Foundation may publish revised and/or new versions
|
|
||||||
of the General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
|
||||||
specifies a version number of this License which applies to it and "any
|
|
||||||
later version", you have the option of following the terms and conditions
|
|
||||||
either of that version or of any later version published by the Free
|
|
||||||
Software Foundation. If the Program does not specify a version number of
|
|
||||||
this License, you may choose any version ever published by the Free Software
|
|
||||||
Foundation.
|
|
||||||
|
|
||||||
10. If you wish to incorporate parts of the Program into other free
|
|
||||||
programs whose distribution conditions are different, write to the author
|
|
||||||
to ask for permission. For software which is copyrighted by the Free
|
|
||||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
||||||
make exceptions for this. Our decision will be guided by the two goals
|
|
||||||
of preserving the free status of all derivatives of our free software and
|
|
||||||
of promoting the sharing and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
||||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
||||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
||||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
||||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
|
||||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
||||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
||||||
REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
||||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
||||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
|
||||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
|
||||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
||||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program is interactive, make it output a short notice like this
|
|
||||||
when it starts in an interactive mode:
|
|
||||||
|
|
||||||
Gnomovision version 69, Copyright (C) year name of author
|
|
||||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, the commands you use may
|
|
||||||
be called something other than `show w' and `show c'; they could even be
|
|
||||||
mouse-clicks or menu items--whatever suits your program.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
||||||
necessary. Here is a sample; alter the names:
|
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
||||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
||||||
|
|
||||||
<signature of Ty Coon>, 1 April 1989
|
|
||||||
Ty Coon, President of Vice
|
|
||||||
|
|
||||||
This General Public License does not permit incorporating your program into
|
|
||||||
proprietary programs. If your program is a subroutine library, you may
|
|
||||||
consider it more useful to permit linking proprietary applications with the
|
|
||||||
library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License.
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ libass_aegisub_a_SOURCES = \
|
||||||
ass_library.c \
|
ass_library.c \
|
||||||
ass_parse.c \
|
ass_parse.c \
|
||||||
ass_render.c \
|
ass_render.c \
|
||||||
|
ass_render_api.c \
|
||||||
ass_strtod.c \
|
ass_strtod.c \
|
||||||
ass_utils.c
|
ass_utils.c
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -23,6 +21,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -38,6 +37,8 @@
|
||||||
#include "ass_utils.h"
|
#include "ass_utils.h"
|
||||||
#include "ass_library.h"
|
#include "ass_library.h"
|
||||||
|
|
||||||
|
#define ass_atof(STR) (ass_strtod((STR),NULL))
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PST_UNKNOWN = 0,
|
PST_UNKNOWN = 0,
|
||||||
PST_INFO,
|
PST_INFO,
|
||||||
|
@ -62,26 +63,22 @@ void ass_free_track(ASS_Track *track)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (track->parser_priv) {
|
if (track->parser_priv) {
|
||||||
if (track->parser_priv->fontname)
|
|
||||||
free(track->parser_priv->fontname);
|
free(track->parser_priv->fontname);
|
||||||
if (track->parser_priv->fontdata)
|
|
||||||
free(track->parser_priv->fontdata);
|
free(track->parser_priv->fontdata);
|
||||||
free(track->parser_priv);
|
free(track->parser_priv);
|
||||||
}
|
}
|
||||||
if (track->style_format)
|
|
||||||
free(track->style_format);
|
free(track->style_format);
|
||||||
if (track->event_format)
|
|
||||||
free(track->event_format);
|
free(track->event_format);
|
||||||
if (track->styles) {
|
if (track->styles) {
|
||||||
for (i = 0; i < track->n_styles; ++i)
|
for (i = 0; i < track->n_styles; ++i)
|
||||||
ass_free_style(track, i);
|
ass_free_style(track, i);
|
||||||
free(track->styles);
|
|
||||||
}
|
}
|
||||||
|
free(track->styles);
|
||||||
if (track->events) {
|
if (track->events) {
|
||||||
for (i = 0; i < track->n_events; ++i)
|
for (i = 0; i < track->n_events; ++i)
|
||||||
ass_free_event(track, i);
|
ass_free_event(track, i);
|
||||||
free(track->events);
|
|
||||||
}
|
}
|
||||||
|
free(track->events);
|
||||||
free(track->name);
|
free(track->name);
|
||||||
free(track);
|
free(track);
|
||||||
}
|
}
|
||||||
|
@ -133,22 +130,18 @@ int ass_alloc_event(ASS_Track *track)
|
||||||
void ass_free_event(ASS_Track *track, int eid)
|
void ass_free_event(ASS_Track *track, int eid)
|
||||||
{
|
{
|
||||||
ASS_Event *event = track->events + eid;
|
ASS_Event *event = track->events + eid;
|
||||||
if (event->Name)
|
|
||||||
free(event->Name);
|
free(event->Name);
|
||||||
if (event->Effect)
|
|
||||||
free(event->Effect);
|
free(event->Effect);
|
||||||
if (event->Text)
|
|
||||||
free(event->Text);
|
free(event->Text);
|
||||||
if (event->render_priv)
|
|
||||||
free(event->render_priv);
|
free(event->render_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ass_free_style(ASS_Track *track, int sid)
|
void ass_free_style(ASS_Track *track, int sid)
|
||||||
{
|
{
|
||||||
ASS_Style *style = track->styles + sid;
|
ASS_Style *style = track->styles + sid;
|
||||||
if (style->Name)
|
|
||||||
free(style->Name);
|
free(style->Name);
|
||||||
if (style->FontName)
|
|
||||||
free(style->FontName);
|
free(style->FontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +243,7 @@ static int numpad2align(int val)
|
||||||
ass_msg(track->library, MSGL_DBG2, "%s = %s", #name, token);
|
ass_msg(track->library, MSGL_DBG2, "%s = %s", #name, token);
|
||||||
|
|
||||||
#define INTVAL(name) ANYVAL(name,atoi)
|
#define INTVAL(name) ANYVAL(name,atoi)
|
||||||
#define FPVAL(name) ANYVAL(name,atof)
|
#define FPVAL(name) ANYVAL(name,ass_atof)
|
||||||
#define TIMEVAL(name) \
|
#define TIMEVAL(name) \
|
||||||
} else if (strcasecmp(tname, #name) == 0) { \
|
} else if (strcasecmp(tname, #name) == 0) { \
|
||||||
target->name = string2timecode(track->library, token); \
|
target->name = string2timecode(track->library, token); \
|
||||||
|
@ -384,7 +377,7 @@ void ass_process_force_style(ASS_Track *track)
|
||||||
else if (!strcasecmp(*fs, "PlayResY"))
|
else if (!strcasecmp(*fs, "PlayResY"))
|
||||||
track->PlayResY = atoi(token);
|
track->PlayResY = atoi(token);
|
||||||
else if (!strcasecmp(*fs, "Timer"))
|
else if (!strcasecmp(*fs, "Timer"))
|
||||||
track->Timer = atof(token);
|
track->Timer = ass_atof(token);
|
||||||
else if (!strcasecmp(*fs, "WrapStyle"))
|
else if (!strcasecmp(*fs, "WrapStyle"))
|
||||||
track->WrapStyle = atoi(token);
|
track->WrapStyle = atoi(token);
|
||||||
else if (!strcasecmp(*fs, "ScaledBorderAndShadow"))
|
else if (!strcasecmp(*fs, "ScaledBorderAndShadow"))
|
||||||
|
@ -534,12 +527,6 @@ static int process_style(ASS_Track *track, char *str)
|
||||||
style->Name = strdup("Default");
|
style->Name = strdup("Default");
|
||||||
if (!style->FontName)
|
if (!style->FontName)
|
||||||
style->FontName = strdup("Arial");
|
style->FontName = strdup("Arial");
|
||||||
// skip '@' at the start of the font name
|
|
||||||
if (*style->FontName == '@') {
|
|
||||||
p = style->FontName;
|
|
||||||
style->FontName = strdup(p + 1);
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
free(format);
|
free(format);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -568,7 +555,7 @@ static int process_info_line(ASS_Track *track, char *str)
|
||||||
} else if (!strncmp(str, "PlayResY:", 9)) {
|
} else if (!strncmp(str, "PlayResY:", 9)) {
|
||||||
track->PlayResY = atoi(str + 9);
|
track->PlayResY = atoi(str + 9);
|
||||||
} else if (!strncmp(str, "Timer:", 6)) {
|
} else if (!strncmp(str, "Timer:", 6)) {
|
||||||
track->Timer = atof(str + 6);
|
track->Timer = ass_atof(str + 6);
|
||||||
} else if (!strncmp(str, "WrapStyle:", 10)) {
|
} else if (!strncmp(str, "WrapStyle:", 10)) {
|
||||||
track->WrapStyle = atoi(str + 10);
|
track->WrapStyle = atoi(str + 10);
|
||||||
} else if (!strncmp(str, "ScaledBorderAndShadow:", 22)) {
|
} else if (!strncmp(str, "ScaledBorderAndShadow:", 22)) {
|
||||||
|
@ -597,6 +584,7 @@ static int process_events_line(ASS_Track *track, char *str)
|
||||||
if (!strncmp(str, "Format:", 7)) {
|
if (!strncmp(str, "Format:", 7)) {
|
||||||
char *p = str + 7;
|
char *p = str + 7;
|
||||||
skip_spaces(&p);
|
skip_spaces(&p);
|
||||||
|
free(track->event_format);
|
||||||
track->event_format = strdup(p);
|
track->event_format = strdup(p);
|
||||||
ass_msg(track->library, MSGL_DBG2, "Event format: %s", track->event_format);
|
ass_msg(track->library, MSGL_DBG2, "Event format: %s", track->event_format);
|
||||||
} else if (!strncmp(str, "Dialogue:", 9)) {
|
} else if (!strncmp(str, "Dialogue:", 9)) {
|
||||||
|
@ -618,7 +606,7 @@ static int process_events_line(ASS_Track *track, char *str)
|
||||||
|
|
||||||
process_event_tail(track, event, str, 0);
|
process_event_tail(track, event, str, 0);
|
||||||
} else {
|
} else {
|
||||||
ass_msg(track->library, MSGL_V, "Not understood: '%s'", str);
|
ass_msg(track->library, MSGL_V, "Not understood: '%.30s'", str);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -677,11 +665,9 @@ static int decode_font(ASS_Track *track)
|
||||||
if (track->library->extract_fonts) {
|
if (track->library->extract_fonts) {
|
||||||
ass_add_font(track->library, track->parser_priv->fontname,
|
ass_add_font(track->library, track->parser_priv->fontname,
|
||||||
(char *) buf, dsize);
|
(char *) buf, dsize);
|
||||||
buf = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error_decode_font:
|
error_decode_font:
|
||||||
if (buf)
|
|
||||||
free(buf);
|
free(buf);
|
||||||
free(track->parser_priv->fontname);
|
free(track->parser_priv->fontname);
|
||||||
free(track->parser_priv->fontdata);
|
free(track->parser_priv->fontdata);
|
||||||
|
@ -909,6 +895,20 @@ void ass_process_chunk(ASS_Track *track, char *data, int size,
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Flush buffered events.
|
||||||
|
* \param track track
|
||||||
|
*/
|
||||||
|
void ass_flush_events(ASS_Track *track)
|
||||||
|
{
|
||||||
|
if (track->events) {
|
||||||
|
int eid;
|
||||||
|
for (eid = 0; eid < track->n_events; eid++)
|
||||||
|
ass_free_event(track, eid);
|
||||||
|
track->n_events = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ICONV
|
#ifdef CONFIG_ICONV
|
||||||
/** \brief recode buffer to utf-8
|
/** \brief recode buffer to utf-8
|
||||||
* constraint: codepage != 0
|
* constraint: codepage != 0
|
||||||
|
@ -1019,14 +1019,6 @@ static char *read_file(ASS_Library *library, char *fname, size_t *bufsize)
|
||||||
sz = ftell(fp);
|
sz = ftell(fp);
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
|
|
||||||
if (sz > 10 * 1024 * 1024) {
|
|
||||||
ass_msg(library, MSGL_INFO,
|
|
||||||
"ass_read_file(%s): Refusing to load subtitles "
|
|
||||||
"larger than 10MiB", fname);
|
|
||||||
fclose(fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ass_msg(library, MSGL_V, "File size: %ld", sz);
|
ass_msg(library, MSGL_V, "File size: %ld", sz);
|
||||||
|
|
||||||
buf = malloc(sz + 1);
|
buf = malloc(sz + 1);
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_ASS_H
|
#ifndef LIBASS_ASS_H
|
||||||
|
@ -25,7 +23,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "ass_types.h"
|
#include "ass_types.h"
|
||||||
|
|
||||||
#define LIBASS_VERSION 0x00908000
|
#define LIBASS_VERSION 0x00911000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A linked list of images produced by an ass renderer.
|
* A linked list of images produced by an ass renderer.
|
||||||
|
@ -75,11 +73,13 @@ ASS_Library *ass_library_init(void);
|
||||||
void ass_library_done(ASS_Library *priv);
|
void ass_library_done(ASS_Library *priv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set private font directory.
|
* \brief Set additional fonts directory.
|
||||||
* It is used for saving embedded fonts and also in font lookup.
|
* Optional directory that will be scanned for fonts recursively. The fonts
|
||||||
|
* found are used for font lookup.
|
||||||
|
* NOTE: A valid font directory is not needed to support embedded fonts.
|
||||||
*
|
*
|
||||||
* \param priv library handle
|
* \param priv library handle
|
||||||
* \param fonts_dir private directory for font extraction
|
* \param fonts_dir directory with additional fonts
|
||||||
*/
|
*/
|
||||||
void ass_set_fonts_dir(ASS_Library *priv, const char *fonts_dir);
|
void ass_set_fonts_dir(ASS_Library *priv, const char *fonts_dir);
|
||||||
|
|
||||||
|
@ -203,6 +203,8 @@ void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing);
|
||||||
* if fontconfig is used.
|
* if fontconfig is used.
|
||||||
* \param update whether fontconfig cache should be built/updated now. Only
|
* \param update whether fontconfig cache should be built/updated now. Only
|
||||||
* relevant if fontconfig is used.
|
* relevant if fontconfig is used.
|
||||||
|
*
|
||||||
|
* NOTE: font lookup must be configured before an ASS_Renderer can be used.
|
||||||
*/
|
*/
|
||||||
void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
|
void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
|
||||||
const char *default_family, int fc, const char *config,
|
const char *default_family, int fc, const char *config,
|
||||||
|
@ -297,7 +299,8 @@ void ass_free_event(ASS_Track *track, int eid);
|
||||||
void ass_process_data(ASS_Track *track, char *data, int size);
|
void ass_process_data(ASS_Track *track, char *data, int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Parse Codec Private section of subtitle stream.
|
* \brief Parse Codec Private section of the subtitle stream, in Matroska
|
||||||
|
* format. See the Matroska specification for details.
|
||||||
* \param track target track
|
* \param track target track
|
||||||
* \param data string to parse
|
* \param data string to parse
|
||||||
* \param size length of data
|
* \param size length of data
|
||||||
|
@ -305,8 +308,8 @@ void ass_process_data(ASS_Track *track, char *data, int size);
|
||||||
void ass_process_codec_private(ASS_Track *track, char *data, int size);
|
void ass_process_codec_private(ASS_Track *track, char *data, int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Parse a chunk of subtitle stream data. In Matroska,
|
* \brief Parse a chunk of subtitle stream data. A chunk contains exactly one
|
||||||
* this contains exactly 1 event (or a commentary).
|
* event in Matroska format. See the Matroska specification for details.
|
||||||
* \param track track
|
* \param track track
|
||||||
* \param data string to parse
|
* \param data string to parse
|
||||||
* \param size length of data
|
* \param size length of data
|
||||||
|
@ -316,6 +319,12 @@ void ass_process_codec_private(ASS_Track *track, char *data, int size);
|
||||||
void ass_process_chunk(ASS_Track *track, char *data, int size,
|
void ass_process_chunk(ASS_Track *track, char *data, int size,
|
||||||
long long timecode, long long duration);
|
long long timecode, long long duration);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Flush buffered events.
|
||||||
|
* \param track track
|
||||||
|
*/
|
||||||
|
void ass_flush_events(ASS_Track *track);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Read subtitles from file.
|
* \brief Read subtitles from file.
|
||||||
* \param library library handle
|
* \param library library handle
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -113,7 +111,6 @@ static void resize_tmp(ASS_SynthPriv *priv, int w, int h)
|
||||||
priv->tmp_w *= 2;
|
priv->tmp_w *= 2;
|
||||||
while (priv->tmp_h < h)
|
while (priv->tmp_h < h)
|
||||||
priv->tmp_h *= 2;
|
priv->tmp_h *= 2;
|
||||||
if (priv->tmp)
|
|
||||||
free(priv->tmp);
|
free(priv->tmp);
|
||||||
priv->tmp = malloc((priv->tmp_w + 1) * priv->tmp_h * sizeof(short));
|
priv->tmp = malloc((priv->tmp_w + 1) * priv->tmp_h * sizeof(short));
|
||||||
}
|
}
|
||||||
|
@ -127,11 +124,8 @@ ASS_SynthPriv *ass_synth_init(double radius)
|
||||||
|
|
||||||
void ass_synth_done(ASS_SynthPriv *priv)
|
void ass_synth_done(ASS_SynthPriv *priv)
|
||||||
{
|
{
|
||||||
if (priv->tmp)
|
|
||||||
free(priv->tmp);
|
free(priv->tmp);
|
||||||
if (priv->g)
|
|
||||||
free(priv->g);
|
free(priv->g);
|
||||||
if (priv->gt2)
|
|
||||||
free(priv->gt2);
|
free(priv->gt2);
|
||||||
free(priv);
|
free(priv);
|
||||||
}
|
}
|
||||||
|
@ -139,8 +133,8 @@ void ass_synth_done(ASS_SynthPriv *priv)
|
||||||
static Bitmap *alloc_bitmap(int w, int h)
|
static Bitmap *alloc_bitmap(int w, int h)
|
||||||
{
|
{
|
||||||
Bitmap *bm;
|
Bitmap *bm;
|
||||||
bm = calloc(1, sizeof(Bitmap));
|
bm = malloc(sizeof(Bitmap));
|
||||||
bm->buffer = malloc(w * h);
|
bm->buffer = calloc(w, h);
|
||||||
bm->w = w;
|
bm->w = w;
|
||||||
bm->h = h;
|
bm->h = h;
|
||||||
bm->left = bm->top = 0;
|
bm->left = bm->top = 0;
|
||||||
|
@ -149,11 +143,9 @@ static Bitmap *alloc_bitmap(int w, int h)
|
||||||
|
|
||||||
void ass_free_bitmap(Bitmap *bm)
|
void ass_free_bitmap(Bitmap *bm)
|
||||||
{
|
{
|
||||||
if (bm) {
|
if (bm)
|
||||||
if (bm->buffer)
|
|
||||||
free(bm->buffer);
|
free(bm->buffer);
|
||||||
free(bm);
|
free(bm);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bitmap *copy_bitmap(const Bitmap *src)
|
static Bitmap *copy_bitmap(const Bitmap *src)
|
||||||
|
@ -165,7 +157,7 @@ static Bitmap *copy_bitmap(const Bitmap *src)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_glyph_area(ASS_Library *library, FT_Glyph glyph)
|
int check_glyph_area(ASS_Library *library, FT_Glyph glyph)
|
||||||
{
|
{
|
||||||
FT_BBox bbox;
|
FT_BBox bbox;
|
||||||
long long dx, dy;
|
long long dx, dy;
|
||||||
|
@ -213,7 +205,6 @@ static Bitmap *glyph_to_bitmap_internal(ASS_Library *library,
|
||||||
w = bit->width;
|
w = bit->width;
|
||||||
h = bit->rows;
|
h = bit->rows;
|
||||||
bm = alloc_bitmap(w + 2 * bord, h + 2 * bord);
|
bm = alloc_bitmap(w + 2 * bord, h + 2 * bord);
|
||||||
memset(bm->buffer, 0, bm->w * bm->h);
|
|
||||||
bm->left = bg->left - bord;
|
bm->left = bg->left - bord;
|
||||||
bm->top = -bg->top - bord;
|
bm->top = -bg->top - bord;
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_BITMAP_H
|
#ifndef LIBASS_BITMAP_H
|
||||||
|
@ -53,5 +51,6 @@ int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur,
|
||||||
int border_style);
|
int border_style);
|
||||||
|
|
||||||
void ass_free_bitmap(Bitmap *bm);
|
void ass_free_bitmap(Bitmap *bm);
|
||||||
|
int check_glyph_area(ASS_Library *library, FT_Glyph glyph);
|
||||||
|
|
||||||
#endif /* LIBASS_BITMAP_H */
|
#endif /* LIBASS_BITMAP_H */
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -156,6 +154,8 @@ static int font_compare(void *key1, void *key2, size_t key_size)
|
||||||
return 0;
|
return 0;
|
||||||
if (a->treat_family_as_pattern != b->treat_family_as_pattern)
|
if (a->treat_family_as_pattern != b->treat_family_as_pattern)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (a->vertical != b->vertical)
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,6 +286,11 @@ static void glyph_hash_dtor(void *key, size_t key_size, void *value,
|
||||||
void *cache_add_glyph(Hashmap *glyph_cache, GlyphHashKey *key,
|
void *cache_add_glyph(Hashmap *glyph_cache, GlyphHashKey *key,
|
||||||
GlyphHashValue *val)
|
GlyphHashValue *val)
|
||||||
{
|
{
|
||||||
|
if (val->glyph && val->glyph->format == FT_GLYPH_FORMAT_BITMAP) {
|
||||||
|
FT_Bitmap *bitmap = &((FT_BitmapGlyph) val->glyph)->bitmap;
|
||||||
|
glyph_cache->cache_size += bitmap->rows * bitmap->pitch;
|
||||||
|
}
|
||||||
|
|
||||||
return hashmap_insert(glyph_cache, key, val);
|
return hashmap_insert(glyph_cache, key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_CACHE_H
|
#ifndef LIBASS_CACHE_H
|
||||||
|
|
|
@ -34,13 +34,13 @@
|
||||||
* \brief Get and prepare a FreeType glyph
|
* \brief Get and prepare a FreeType glyph
|
||||||
*/
|
*/
|
||||||
static void drawing_make_glyph(ASS_Drawing *drawing, void *fontconfig_priv,
|
static void drawing_make_glyph(ASS_Drawing *drawing, void *fontconfig_priv,
|
||||||
ASS_Font *font, ASS_Hinting hint)
|
ASS_Font *font)
|
||||||
{
|
{
|
||||||
FT_OutlineGlyph glyph;
|
FT_OutlineGlyph glyph;
|
||||||
|
|
||||||
// This is hacky...
|
// This is hacky...
|
||||||
glyph = (FT_OutlineGlyph) ass_font_get_glyph(fontconfig_priv, font,
|
glyph = (FT_OutlineGlyph) ass_font_get_glyph(fontconfig_priv, font,
|
||||||
(uint32_t) ' ', hint, 0);
|
(uint32_t) ' ', 0, 0);
|
||||||
if (glyph) {
|
if (glyph) {
|
||||||
FT_Outline_Done(drawing->ftlibrary, &glyph->outline);
|
FT_Outline_Done(drawing->ftlibrary, &glyph->outline);
|
||||||
FT_Outline_New(drawing->ftlibrary, GLYPH_INITIAL_POINTS,
|
FT_Outline_New(drawing->ftlibrary, GLYPH_INITIAL_POINTS,
|
||||||
|
@ -112,24 +112,12 @@ static void drawing_prepare(ASS_Drawing *drawing)
|
||||||
static void drawing_finish(ASS_Drawing *drawing, int raw_mode)
|
static void drawing_finish(ASS_Drawing *drawing, int raw_mode)
|
||||||
{
|
{
|
||||||
int i, offset;
|
int i, offset;
|
||||||
FT_BBox bbox;
|
FT_BBox bbox = drawing->cbox;
|
||||||
FT_Outline *ol = &drawing->glyph->outline;
|
FT_Outline *ol = &drawing->glyph->outline;
|
||||||
|
|
||||||
// Close the last contour
|
// Close the last contour
|
||||||
drawing_close_shape(drawing);
|
drawing_close_shape(drawing);
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Dump points
|
|
||||||
for (i = 0; i < ol->n_points; i++) {
|
|
||||||
printf("point (%d, %d)\n", (int) ol->points[i].x,
|
|
||||||
(int) ol->points[i].y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dump contours
|
|
||||||
for (i = 0; i < ol->n_contours; i++)
|
|
||||||
printf("contour %d\n", ol->contours[i]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ass_msg(drawing->library, MSGL_V,
|
ass_msg(drawing->library, MSGL_V,
|
||||||
"Parsed drawing with %d points and %d contours", ol->n_points,
|
"Parsed drawing with %d points and %d contours", ol->n_points,
|
||||||
ol->n_contours);
|
ol->n_contours);
|
||||||
|
@ -137,7 +125,6 @@ static void drawing_finish(ASS_Drawing *drawing, int raw_mode)
|
||||||
if (raw_mode)
|
if (raw_mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FT_Outline_Get_CBox(&drawing->glyph->outline, &bbox);
|
|
||||||
drawing->glyph->root.advance.x = d6_to_d16(bbox.xMax - bbox.xMin);
|
drawing->glyph->root.advance.x = d6_to_d16(bbox.xMax - bbox.xMin);
|
||||||
|
|
||||||
drawing->desc = double_to_d6(-drawing->pbo * drawing->scale_y);
|
drawing->desc = double_to_d6(-drawing->pbo * drawing->scale_y);
|
||||||
|
@ -231,15 +218,6 @@ static ASS_DrawingToken *drawing_tokenize(char *str)
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Check tokens
|
|
||||||
ASS_DrawingToken *t = root;
|
|
||||||
while(t) {
|
|
||||||
printf("token %d point (%d, %d)\n", t->type, t->point.x, t->point.y);
|
|
||||||
t = t->next;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,6 +233,19 @@ static void drawing_free_tokens(ASS_DrawingToken *token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Update drawing cbox
|
||||||
|
*/
|
||||||
|
static inline void update_cbox(ASS_Drawing *drawing, FT_Vector *point)
|
||||||
|
{
|
||||||
|
FT_BBox *box = &drawing->cbox;
|
||||||
|
|
||||||
|
box->xMin = FFMIN(box->xMin, point->x);
|
||||||
|
box->xMax = FFMAX(box->xMax, point->x);
|
||||||
|
box->yMin = FFMIN(box->yMin, point->y);
|
||||||
|
box->yMax = FFMAX(box->yMax, point->y);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Translate and scale a point coordinate according to baseline
|
* \brief Translate and scale a point coordinate according to baseline
|
||||||
* offset and scale.
|
* offset and scale.
|
||||||
|
@ -263,6 +254,8 @@ static inline void translate_point(ASS_Drawing *drawing, FT_Vector *point)
|
||||||
{
|
{
|
||||||
point->x = drawing->point_scale_x * point->x;
|
point->x = drawing->point_scale_x * point->x;
|
||||||
point->y = drawing->point_scale_y * -point->y;
|
point->y = drawing->point_scale_y * -point->y;
|
||||||
|
|
||||||
|
update_cbox(drawing, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -362,19 +355,19 @@ static void drawing_evaluate_curve(ASS_Drawing *drawing,
|
||||||
* \brief Create and initialize a new drawing and return it
|
* \brief Create and initialize a new drawing and return it
|
||||||
*/
|
*/
|
||||||
ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font,
|
ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font,
|
||||||
ASS_Hinting hint, FT_Library lib)
|
FT_Library lib)
|
||||||
{
|
{
|
||||||
ASS_Drawing *drawing;
|
ASS_Drawing *drawing;
|
||||||
|
|
||||||
drawing = calloc(1, sizeof(*drawing));
|
drawing = calloc(1, sizeof(*drawing));
|
||||||
drawing->text = calloc(1, DRAWING_INITIAL_SIZE);
|
drawing->text = calloc(1, DRAWING_INITIAL_SIZE);
|
||||||
drawing->size = DRAWING_INITIAL_SIZE;
|
drawing->size = DRAWING_INITIAL_SIZE;
|
||||||
|
drawing->cbox.xMin = drawing->cbox.yMin = INT_MAX;
|
||||||
|
drawing->cbox.xMax = drawing->cbox.yMax = INT_MIN;
|
||||||
|
drawing->fontconfig_priv = fontconfig_priv;
|
||||||
|
drawing->font = font;
|
||||||
drawing->ftlibrary = lib;
|
drawing->ftlibrary = lib;
|
||||||
if (font) {
|
|
||||||
drawing->library = font->library;
|
drawing->library = font->library;
|
||||||
drawing_make_glyph(drawing, fontconfig_priv, font, hint);
|
|
||||||
}
|
|
||||||
|
|
||||||
drawing->scale_x = 1.;
|
drawing->scale_x = 1.;
|
||||||
drawing->scale_y = 1.;
|
drawing->scale_y = 1.;
|
||||||
|
@ -390,8 +383,6 @@ ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font,
|
||||||
void ass_drawing_free(ASS_Drawing* drawing)
|
void ass_drawing_free(ASS_Drawing* drawing)
|
||||||
{
|
{
|
||||||
if (drawing) {
|
if (drawing) {
|
||||||
if (drawing->glyph)
|
|
||||||
FT_Done_Glyph((FT_Glyph) drawing->glyph);
|
|
||||||
free(drawing->text);
|
free(drawing->text);
|
||||||
}
|
}
|
||||||
free(drawing);
|
free(drawing);
|
||||||
|
@ -429,6 +420,8 @@ FT_OutlineGlyph *ass_drawing_parse(ASS_Drawing *drawing, int raw_mode)
|
||||||
ASS_DrawingToken *token;
|
ASS_DrawingToken *token;
|
||||||
FT_Vector pen = {0, 0};
|
FT_Vector pen = {0, 0};
|
||||||
|
|
||||||
|
if (drawing->font)
|
||||||
|
drawing_make_glyph(drawing, drawing->fontconfig_priv, drawing->font);
|
||||||
if (!drawing->glyph)
|
if (!drawing->glyph)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,9 @@ typedef struct {
|
||||||
int hash; // hash value (for caching)
|
int hash; // hash value (for caching)
|
||||||
|
|
||||||
// private
|
// private
|
||||||
FT_Library ftlibrary; // FT library instance, needed for font ops
|
FT_Library ftlibrary; // needed for font ops
|
||||||
|
ASS_Font *font; // dito
|
||||||
|
void *fontconfig_priv; // dito
|
||||||
ASS_Library *library;
|
ASS_Library *library;
|
||||||
int size; // current buffer size
|
int size; // current buffer size
|
||||||
ASS_DrawingToken *tokens; // tokenized drawing
|
ASS_DrawingToken *tokens; // tokenized drawing
|
||||||
|
@ -65,10 +67,11 @@ typedef struct {
|
||||||
int max_contours;
|
int max_contours;
|
||||||
double point_scale_x;
|
double point_scale_x;
|
||||||
double point_scale_y;
|
double point_scale_y;
|
||||||
|
FT_BBox cbox; // bounding box, or let's say... VSFilter's idea of it
|
||||||
} ASS_Drawing;
|
} ASS_Drawing;
|
||||||
|
|
||||||
ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font,
|
ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font,
|
||||||
ASS_Hinting hint, FT_Library lib);
|
FT_Library lib);
|
||||||
void ass_drawing_free(ASS_Drawing* drawing);
|
void ass_drawing_free(ASS_Drawing* drawing);
|
||||||
void ass_drawing_add_char(ASS_Drawing* drawing, char symbol);
|
void ass_drawing_add_char(ASS_Drawing* drawing, char symbol);
|
||||||
void ass_drawing_hash(ASS_Drawing* drawing);
|
void ass_drawing_hash(ASS_Drawing* drawing);
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -27,6 +25,7 @@
|
||||||
#include FT_GLYPH_H
|
#include FT_GLYPH_H
|
||||||
#include FT_TRUETYPE_TABLES_H
|
#include FT_TRUETYPE_TABLES_H
|
||||||
#include FT_OUTLINE_H
|
#include FT_OUTLINE_H
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
#include "ass.h"
|
#include "ass.h"
|
||||||
#include "ass_library.h"
|
#include "ass_library.h"
|
||||||
|
@ -36,13 +35,18 @@
|
||||||
#include "ass_fontconfig.h"
|
#include "ass_fontconfig.h"
|
||||||
#include "ass_utils.h"
|
#include "ass_utils.h"
|
||||||
|
|
||||||
|
#define VERTICAL_LOWER_BOUND 0x02f1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select Microfost Unicode CharMap, if the font has one.
|
* Select a good charmap, prefer Microsoft Unicode charmaps.
|
||||||
* Otherwise, let FreeType decide.
|
* Otherwise, let FreeType decide.
|
||||||
*/
|
*/
|
||||||
static void charmap_magic(ASS_Library *library, FT_Face face)
|
static void charmap_magic(ASS_Library *library, FT_Face face)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int ms_cmap = -1;
|
||||||
|
|
||||||
|
// Search for a Microsoft Unicode cmap
|
||||||
for (i = 0; i < face->num_charmaps; ++i) {
|
for (i = 0; i < face->num_charmaps; ++i) {
|
||||||
FT_CharMap cmap = face->charmaps[i];
|
FT_CharMap cmap = face->charmaps[i];
|
||||||
unsigned pid = cmap->platform_id;
|
unsigned pid = cmap->platform_id;
|
||||||
|
@ -52,7 +56,15 @@ static void charmap_magic(ASS_Library *library, FT_Face face)
|
||||||
|| eid == 10 /*full unicode */ )) {
|
|| eid == 10 /*full unicode */ )) {
|
||||||
FT_Set_Charmap(face, cmap);
|
FT_Set_Charmap(face, cmap);
|
||||||
return;
|
return;
|
||||||
|
} else if (pid == 3 && ms_cmap < 0)
|
||||||
|
ms_cmap = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try the first Microsoft cmap if no Microsoft Unicode cmap was found
|
||||||
|
if (ms_cmap >= 0) {
|
||||||
|
FT_CharMap cmap = face->charmaps[ms_cmap];
|
||||||
|
FT_Set_Charmap(face, cmap);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!face->charmap) {
|
if (!face->charmap) {
|
||||||
|
@ -67,17 +79,6 @@ static void charmap_magic(ASS_Library *library, FT_Face face)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_transform(ASS_Font *font)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
FT_Matrix m;
|
|
||||||
m.xx = double_to_d16(font->scale_x);
|
|
||||||
m.yy = double_to_d16(font->scale_y);
|
|
||||||
m.xy = m.yx = 0;
|
|
||||||
for (i = 0; i < font->n_faces; ++i)
|
|
||||||
FT_Set_Transform(font->faces[i], &m, &font->v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief find a memory font by name
|
* \brief find a memory font by name
|
||||||
*/
|
*/
|
||||||
|
@ -139,7 +140,7 @@ static int add_face(void *fc_priv, ASS_Font *font, uint32_t ch)
|
||||||
FT_New_Memory_Face(font->ftlibrary,
|
FT_New_Memory_Face(font->ftlibrary,
|
||||||
(unsigned char *) font->library->
|
(unsigned char *) font->library->
|
||||||
fontdata[mem_idx].data,
|
fontdata[mem_idx].data,
|
||||||
font->library->fontdata[mem_idx].size, 0,
|
font->library->fontdata[mem_idx].size, index,
|
||||||
&face);
|
&face);
|
||||||
if (error) {
|
if (error) {
|
||||||
ass_msg(font->library, MSGL_WARN,
|
ass_msg(font->library, MSGL_WARN,
|
||||||
|
@ -160,7 +161,6 @@ static int add_face(void *fc_priv, ASS_Font *font, uint32_t ch)
|
||||||
buggy_font_workaround(face);
|
buggy_font_workaround(face);
|
||||||
|
|
||||||
font->faces[font->n_faces++] = face;
|
font->faces[font->n_faces++] = face;
|
||||||
update_transform(font);
|
|
||||||
face_set_size(face, font->size);
|
face_set_size(face, font->size);
|
||||||
free(path);
|
free(path);
|
||||||
return font->n_faces - 1;
|
return font->n_faces - 1;
|
||||||
|
@ -188,6 +188,7 @@ ASS_Font *ass_font_new(void *font_cache, ASS_Library *library,
|
||||||
font.desc.treat_family_as_pattern = desc->treat_family_as_pattern;
|
font.desc.treat_family_as_pattern = desc->treat_family_as_pattern;
|
||||||
font.desc.bold = desc->bold;
|
font.desc.bold = desc->bold;
|
||||||
font.desc.italic = desc->italic;
|
font.desc.italic = desc->italic;
|
||||||
|
font.desc.vertical = desc->vertical;
|
||||||
|
|
||||||
font.scale_x = font.scale_y = 1.;
|
font.scale_x = font.scale_y = 1.;
|
||||||
font.v.x = font.v.y = 0;
|
font.v.x = font.v.y = 0;
|
||||||
|
@ -213,7 +214,6 @@ void ass_font_set_transform(ASS_Font *font, double scale_x,
|
||||||
font->v.x = v->x;
|
font->v.x = v->x;
|
||||||
font->v.y = v->y;
|
font->v.y = v->y;
|
||||||
}
|
}
|
||||||
update_transform(font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void face_set_size(FT_Face face, double size)
|
static void face_set_size(FT_Face face, double size)
|
||||||
|
@ -276,6 +276,9 @@ void ass_font_get_asc_desc(ASS_Font *font, uint32_t ch, int *asc,
|
||||||
*asc = FT_MulFix(face->ascender, y_scale);
|
*asc = FT_MulFix(face->ascender, y_scale);
|
||||||
*desc = FT_MulFix(-face->descender, y_scale);
|
*desc = FT_MulFix(-face->descender, y_scale);
|
||||||
}
|
}
|
||||||
|
if (font->desc.vertical && ch >= VERTICAL_LOWER_BOUND) {
|
||||||
|
*asc = FT_MulFix(face->max_advance_width, y_scale);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,6 +417,7 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
|
||||||
FT_Glyph glyph;
|
FT_Glyph glyph;
|
||||||
FT_Face face = 0;
|
FT_Face face = 0;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
int vertical = font->desc.vertical;
|
||||||
|
|
||||||
if (ch < 0x20)
|
if (ch < 0x20)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -441,6 +445,14 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
|
||||||
if (face_idx >= 0) {
|
if (face_idx >= 0) {
|
||||||
face = font->faces[face_idx];
|
face = font->faces[face_idx];
|
||||||
index = FT_Get_Char_Index(face, ch);
|
index = FT_Get_Char_Index(face, ch);
|
||||||
|
if (index == 0 && face->num_charmaps > 0) {
|
||||||
|
ass_msg(font->library, MSGL_WARN,
|
||||||
|
"Glyph 0x%X not found, falling back to first charmap", ch);
|
||||||
|
FT_CharMap cur = face->charmap;
|
||||||
|
FT_Set_Charmap(face, face->charmaps[0]);
|
||||||
|
index = FT_Get_Char_Index(face, ch);
|
||||||
|
FT_Set_Charmap(face, cur);
|
||||||
|
}
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
ass_msg(font->library, MSGL_ERR,
|
ass_msg(font->library, MSGL_ERR,
|
||||||
"Glyph 0x%X not found in font for (%s, %d, %d)",
|
"Glyph 0x%X not found in font for (%s, %d, %d)",
|
||||||
|
@ -451,22 +463,23 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
flags = FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
|
||||||
|
| FT_LOAD_IGNORE_TRANSFORM;
|
||||||
switch (hinting) {
|
switch (hinting) {
|
||||||
case ASS_HINTING_NONE:
|
case ASS_HINTING_NONE:
|
||||||
flags = FT_LOAD_NO_HINTING;
|
flags |= FT_LOAD_NO_HINTING;
|
||||||
break;
|
break;
|
||||||
case ASS_HINTING_LIGHT:
|
case ASS_HINTING_LIGHT:
|
||||||
flags = FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_LIGHT;
|
flags |= FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_LIGHT;
|
||||||
break;
|
break;
|
||||||
case ASS_HINTING_NORMAL:
|
case ASS_HINTING_NORMAL:
|
||||||
flags = FT_LOAD_FORCE_AUTOHINT;
|
flags |= FT_LOAD_FORCE_AUTOHINT;
|
||||||
break;
|
break;
|
||||||
case ASS_HINTING_NATIVE:
|
case ASS_HINTING_NATIVE:
|
||||||
flags = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = FT_Load_Glyph(face, index, FT_LOAD_NO_BITMAP | flags);
|
error = FT_Load_Glyph(face, index, flags);
|
||||||
if (error) {
|
if (error) {
|
||||||
ass_msg(font->library, MSGL_WARN, "Error loading glyph, index %d",
|
ass_msg(font->library, MSGL_WARN, "Error loading glyph, index %d",
|
||||||
index);
|
index);
|
||||||
|
@ -488,6 +501,24 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rotate glyph, if needed
|
||||||
|
if (vertical && ch >= VERTICAL_LOWER_BOUND) {
|
||||||
|
FT_Matrix m = { 0, double_to_d16(-1.0), double_to_d16(1.0), 0 };
|
||||||
|
FT_Outline_Transform(&((FT_OutlineGlyph) glyph)->outline, &m);
|
||||||
|
FT_Outline_Translate(&((FT_OutlineGlyph) glyph)->outline,
|
||||||
|
face->glyph->metrics.vertAdvance,
|
||||||
|
0);
|
||||||
|
glyph->advance.x = face->glyph->linearVertAdvance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply scaling and shift
|
||||||
|
FT_Matrix scale = { double_to_d16(font->scale_x), 0, 0,
|
||||||
|
double_to_d16(font->scale_y) };
|
||||||
|
FT_Outline *outl = &((FT_OutlineGlyph) glyph)->outline;
|
||||||
|
FT_Outline_Transform(outl, &scale);
|
||||||
|
FT_Outline_Translate(outl, font->v.x, font->v.y);
|
||||||
|
glyph->advance.x *= font->scale_x;
|
||||||
|
|
||||||
ass_strike_outline_glyph(face, font, glyph, deco & DECO_UNDERLINE,
|
ass_strike_outline_glyph(face, font, glyph, deco & DECO_UNDERLINE,
|
||||||
deco & DECO_STRIKETHROUGH);
|
deco & DECO_STRIKETHROUGH);
|
||||||
|
|
||||||
|
@ -502,6 +533,9 @@ FT_Vector ass_font_get_kerning(ASS_Font *font, uint32_t c1, uint32_t c2)
|
||||||
FT_Vector v = { 0, 0 };
|
FT_Vector v = { 0, 0 };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (font->desc.vertical)
|
||||||
|
return v;
|
||||||
|
|
||||||
for (i = 0; i < font->n_faces; ++i) {
|
for (i = 0; i < font->n_faces; ++i) {
|
||||||
FT_Face face = font->faces[i];
|
FT_Face face = font->faces[i];
|
||||||
int i1 = FT_Get_Char_Index(face, c1);
|
int i1 = FT_Get_Char_Index(face, c1);
|
||||||
|
@ -526,7 +560,133 @@ void ass_font_free(ASS_Font *font)
|
||||||
for (i = 0; i < font->n_faces; ++i)
|
for (i = 0; i < font->n_faces; ++i)
|
||||||
if (font->faces[i])
|
if (font->faces[i])
|
||||||
FT_Done_Face(font->faces[i]);
|
FT_Done_Face(font->faces[i]);
|
||||||
if (font->desc.family)
|
|
||||||
free(font->desc.family);
|
free(font->desc.family);
|
||||||
free(font);
|
free(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Calculate the cbox of a series of points
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
get_contour_cbox(FT_BBox *box, FT_Vector *points, int start, int end)
|
||||||
|
{
|
||||||
|
box->xMin = box->yMin = INT_MAX;
|
||||||
|
box->xMax = box->yMax = INT_MIN;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = start; i <= end; i++) {
|
||||||
|
box->xMin = (points[i].x < box->xMin) ? points[i].x : box->xMin;
|
||||||
|
box->xMax = (points[i].x > box->xMax) ? points[i].x : box->xMax;
|
||||||
|
box->yMin = (points[i].y < box->yMin) ? points[i].y : box->yMin;
|
||||||
|
box->yMax = (points[i].y > box->yMax) ? points[i].y : box->yMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Determine winding direction of a contour
|
||||||
|
* \return direction; 0 = clockwise
|
||||||
|
*/
|
||||||
|
static int get_contour_direction(FT_Vector *points, int start, int end)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
long long sum = 0;
|
||||||
|
int x = points[start].x;
|
||||||
|
int y = points[start].y;
|
||||||
|
for (i = start + 1; i <= end; i++) {
|
||||||
|
sum += x * (points[i].y - y) - y * (points[i].x - x);
|
||||||
|
x = points[i].x;
|
||||||
|
y = points[i].y;
|
||||||
|
}
|
||||||
|
sum += x * (points[start].y - y) - y * (points[start].x - x);
|
||||||
|
return sum > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Fix-up stroker result for huge borders by removing inside contours
|
||||||
|
* that would reverse in size
|
||||||
|
*/
|
||||||
|
void fix_freetype_stroker(FT_OutlineGlyph glyph, int border_x, int border_y)
|
||||||
|
{
|
||||||
|
int nc = glyph->outline.n_contours;
|
||||||
|
int begin, stop;
|
||||||
|
char modified = 0;
|
||||||
|
char *valid_cont = malloc(nc);
|
||||||
|
int start = 0;
|
||||||
|
int end = -1;
|
||||||
|
FT_BBox *boxes = malloc(nc * sizeof(FT_BBox));
|
||||||
|
int i, j;
|
||||||
|
int inside_direction;
|
||||||
|
|
||||||
|
inside_direction = FT_Outline_Get_Orientation(&glyph->outline) ==
|
||||||
|
FT_ORIENTATION_TRUETYPE;
|
||||||
|
|
||||||
|
// create a list of cboxes of the contours
|
||||||
|
for (i = 0; i < nc; i++) {
|
||||||
|
start = end + 1;
|
||||||
|
end = glyph->outline.contours[i];
|
||||||
|
get_contour_cbox(&boxes[i], glyph->outline.points, start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for each contour, check direction and whether it's "outside"
|
||||||
|
// or contained in another contour
|
||||||
|
end = -1;
|
||||||
|
for (i = 0; i < nc; i++) {
|
||||||
|
start = end + 1;
|
||||||
|
end = glyph->outline.contours[i];
|
||||||
|
int dir = get_contour_direction(glyph->outline.points, start, end);
|
||||||
|
valid_cont[i] = 1;
|
||||||
|
if (dir == inside_direction) {
|
||||||
|
for (j = 0; j < nc; j++) {
|
||||||
|
if (i == j)
|
||||||
|
continue;
|
||||||
|
if (boxes[i].xMin >= boxes[j].xMin &&
|
||||||
|
boxes[i].xMax <= boxes[j].xMax &&
|
||||||
|
boxes[i].yMin >= boxes[j].yMin &&
|
||||||
|
boxes[i].yMax <= boxes[j].yMax)
|
||||||
|
goto check_inside;
|
||||||
|
}
|
||||||
|
/* "inside" contour but we can't find anything it could be
|
||||||
|
* inside of - assume the font is buggy and it should be
|
||||||
|
* an "outside" contour, and reverse it */
|
||||||
|
for (j = 0; j < (end + 1 - start) / 2; j++) {
|
||||||
|
FT_Vector temp = glyph->outline.points[start + j];
|
||||||
|
char temp2 = glyph->outline.tags[start + j];
|
||||||
|
glyph->outline.points[start + j] = glyph->outline.points[end - j];
|
||||||
|
glyph->outline.points[end - j] = temp;
|
||||||
|
glyph->outline.tags[start + j] = glyph->outline.tags[end - j];
|
||||||
|
glyph->outline.tags[end - j] = temp2;
|
||||||
|
}
|
||||||
|
dir ^= 1;
|
||||||
|
}
|
||||||
|
check_inside:
|
||||||
|
if (dir == inside_direction) {
|
||||||
|
FT_BBox box;
|
||||||
|
get_contour_cbox(&box, glyph->outline.points, start, end);
|
||||||
|
int width = box.xMax - box.xMin;
|
||||||
|
int height = box.yMax - box.yMin;
|
||||||
|
if (width < border_x * 2 || height < border_y * 2) {
|
||||||
|
valid_cont[i] = 0;
|
||||||
|
modified = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// zero-out contours that can be removed; much simpler than copying
|
||||||
|
if (modified) {
|
||||||
|
for (i = 0; i < nc; i++) {
|
||||||
|
if (valid_cont[i])
|
||||||
|
continue;
|
||||||
|
begin = (i == 0) ? 0 : glyph->outline.contours[i - 1] + 1;
|
||||||
|
stop = glyph->outline.contours[i];
|
||||||
|
for (j = begin; j <= stop; j++) {
|
||||||
|
glyph->outline.points[j].x = 0;
|
||||||
|
glyph->outline.points[j].y = 0;
|
||||||
|
glyph->outline.tags[j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(boxes);
|
||||||
|
free(valid_cont);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_FONT_H
|
#ifndef LIBASS_FONT_H
|
||||||
|
@ -36,6 +34,7 @@ typedef struct {
|
||||||
unsigned bold;
|
unsigned bold;
|
||||||
unsigned italic;
|
unsigned italic;
|
||||||
int treat_family_as_pattern;
|
int treat_family_as_pattern;
|
||||||
|
int vertical; // @font vertical layout
|
||||||
} ASS_FontDesc;
|
} ASS_FontDesc;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -62,5 +61,6 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
|
||||||
uint32_t ch, ASS_Hinting hinting, int flags);
|
uint32_t ch, ASS_Hinting hinting, int flags);
|
||||||
FT_Vector ass_font_get_kerning(ASS_Font *font, uint32_t c1, uint32_t c2);
|
FT_Vector ass_font_get_kerning(ASS_Font *font, uint32_t c1, uint32_t c2);
|
||||||
void ass_font_free(ASS_Font *font);
|
void ass_font_free(ASS_Font *font);
|
||||||
|
void fix_freetype_stroker(FT_OutlineGlyph glyph, int border_x, int border_y);
|
||||||
|
|
||||||
#endif /* LIBASS_FONT_H */
|
#endif /* LIBASS_FONT_H */
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -24,6 +22,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -51,6 +50,61 @@ struct fc_instance {
|
||||||
|
|
||||||
#ifdef CONFIG_FONTCONFIG
|
#ifdef CONFIG_FONTCONFIG
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Case-insensitive match ASS/SSA font family against full name. (also
|
||||||
|
* known as "name for humans")
|
||||||
|
*
|
||||||
|
* \param lib library instance
|
||||||
|
* \param priv fontconfig instance
|
||||||
|
* \param family font fullname
|
||||||
|
* \param bold weight attribute
|
||||||
|
* \param italic italic attribute
|
||||||
|
* \return font set
|
||||||
|
*/
|
||||||
|
static FcFontSet *
|
||||||
|
match_fullname(ASS_Library *lib, FCInstance *priv, const char *family,
|
||||||
|
unsigned bold, unsigned italic)
|
||||||
|
{
|
||||||
|
FcFontSet *sets[2];
|
||||||
|
FcFontSet *result = FcFontSetCreate();
|
||||||
|
int nsets = 0;
|
||||||
|
int i, fi;
|
||||||
|
|
||||||
|
if ((sets[nsets] = FcConfigGetFonts(priv->config, FcSetSystem)))
|
||||||
|
nsets++;
|
||||||
|
if ((sets[nsets] = FcConfigGetFonts(priv->config, FcSetApplication)))
|
||||||
|
nsets++;
|
||||||
|
|
||||||
|
// Run over font sets and patterns and try to match against full name
|
||||||
|
for (i = 0; i < nsets; i++) {
|
||||||
|
FcFontSet *set = sets[i];
|
||||||
|
for (fi = 0; fi < set->nfont; fi++) {
|
||||||
|
FcPattern *pat = set->fonts[fi];
|
||||||
|
char *fullname;
|
||||||
|
int pi = 0, at;
|
||||||
|
FcBool ol;
|
||||||
|
while (FcPatternGetString(pat, FC_FULLNAME, pi++,
|
||||||
|
(FcChar8 **) &fullname) == FcResultMatch) {
|
||||||
|
if (FcPatternGetBool(pat, FC_OUTLINE, 0, &ol) != FcResultMatch
|
||||||
|
|| ol != FcTrue)
|
||||||
|
continue;
|
||||||
|
if (FcPatternGetInteger(pat, FC_SLANT, 0, &at) != FcResultMatch
|
||||||
|
|| at < italic)
|
||||||
|
continue;
|
||||||
|
if (FcPatternGetInteger(pat, FC_WEIGHT, 0, &at) != FcResultMatch
|
||||||
|
|| at < bold)
|
||||||
|
continue;
|
||||||
|
if (strcasecmp(fullname, family) == 0) {
|
||||||
|
FcFontSetAdd(result, FcPatternDuplicate(pat));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Low-level font selection.
|
* \brief Low-level font selection.
|
||||||
* \param priv private data
|
* \param priv private data
|
||||||
|
@ -62,7 +116,7 @@ struct fc_instance {
|
||||||
* \param code: the character that should be present in the font, can be 0
|
* \param code: the character that should be present in the font, can be 0
|
||||||
* \return font file path
|
* \return font file path
|
||||||
*/
|
*/
|
||||||
static char *_select_font(ASS_Library *library, FCInstance *priv,
|
static char *select_font(ASS_Library *library, FCInstance *priv,
|
||||||
const char *family, int treat_family_as_pattern,
|
const char *family, int treat_family_as_pattern,
|
||||||
unsigned bold, unsigned italic, int *index,
|
unsigned bold, unsigned italic, int *index,
|
||||||
uint32_t code)
|
uint32_t code)
|
||||||
|
@ -74,7 +128,7 @@ static char *_select_font(ASS_Library *library, FCInstance *priv,
|
||||||
FcChar8 *r_family, *r_style, *r_file, *r_fullname;
|
FcChar8 *r_family, *r_style, *r_file, *r_fullname;
|
||||||
FcBool r_outline, r_embolden;
|
FcBool r_outline, r_embolden;
|
||||||
FcCharSet *r_charset;
|
FcCharSet *r_charset;
|
||||||
FcFontSet *fset = NULL;
|
FcFontSet *ffullname = NULL, *fsorted = NULL, *fset = NULL;
|
||||||
int curf;
|
int curf;
|
||||||
char *retval = NULL;
|
char *retval = NULL;
|
||||||
int family_cnt = 0;
|
int family_cnt = 0;
|
||||||
|
@ -126,10 +180,23 @@ static char *_select_font(ASS_Library *library, FCInstance *priv,
|
||||||
if (!rc)
|
if (!rc)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
fset = FcFontSort(priv->config, pat, FcTrue, NULL, &result);
|
fsorted = FcFontSort(priv->config, pat, FcTrue, NULL, &result);
|
||||||
if (!fset)
|
ffullname = match_fullname(library, priv, family, bold, italic);
|
||||||
|
if (!fsorted || !ffullname)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
fset = FcFontSetCreate();
|
||||||
|
for (curf = 0; curf < ffullname->nfont; ++curf) {
|
||||||
|
FcPattern *curp = ffullname->fonts[curf];
|
||||||
|
FcPatternReference(curp);
|
||||||
|
FcFontSetAdd(fset, curp);
|
||||||
|
}
|
||||||
|
for (curf = 0; curf < fsorted->nfont; ++curf) {
|
||||||
|
FcPattern *curp = fsorted->fonts[curf];
|
||||||
|
FcPatternReference(curp);
|
||||||
|
FcFontSetAdd(fset, curp);
|
||||||
|
}
|
||||||
|
|
||||||
for (curf = 0; curf < fset->nfont; ++curf) {
|
for (curf = 0; curf < fset->nfont; ++curf) {
|
||||||
FcPattern *curp = fset->fonts[curf];
|
FcPattern *curp = fset->fonts[curf];
|
||||||
|
|
||||||
|
@ -215,6 +282,10 @@ static char *_select_font(ASS_Library *library, FCInstance *priv,
|
||||||
FcPatternDestroy(pat);
|
FcPatternDestroy(pat);
|
||||||
if (rpat)
|
if (rpat)
|
||||||
FcPatternDestroy(rpat);
|
FcPatternDestroy(rpat);
|
||||||
|
if (fsorted)
|
||||||
|
FcFontSetDestroy(fsorted);
|
||||||
|
if (ffullname)
|
||||||
|
FcFontSetDestroy(ffullname);
|
||||||
if (fset)
|
if (fset)
|
||||||
FcFontSetDestroy(fset);
|
FcFontSetDestroy(fset);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -244,11 +315,11 @@ char *fontconfig_select(ASS_Library *library, FCInstance *priv,
|
||||||
}
|
}
|
||||||
if (family && *family)
|
if (family && *family)
|
||||||
res =
|
res =
|
||||||
_select_font(library, priv, family, treat_family_as_pattern,
|
select_font(library, priv, family, treat_family_as_pattern,
|
||||||
bold, italic, index, code);
|
bold, italic, index, code);
|
||||||
if (!res && priv->family_default) {
|
if (!res && priv->family_default) {
|
||||||
res =
|
res =
|
||||||
_select_font(library, priv, priv->family_default, 0, bold,
|
select_font(library, priv, priv->family_default, 0, bold,
|
||||||
italic, index, code);
|
italic, index, code);
|
||||||
if (res)
|
if (res)
|
||||||
ass_msg(library, MSGL_WARN, "fontconfig_select: Using default "
|
ass_msg(library, MSGL_WARN, "fontconfig_select: Using default "
|
||||||
|
@ -263,7 +334,7 @@ char *fontconfig_select(ASS_Library *library, FCInstance *priv,
|
||||||
res, *index);
|
res, *index);
|
||||||
}
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
res = _select_font(library, priv, "Arial", 0, bold, italic,
|
res = select_font(library, priv, "Arial", 0, bold, italic,
|
||||||
index, code);
|
index, code);
|
||||||
if (res)
|
if (res)
|
||||||
ass_msg(library, MSGL_WARN, "fontconfig_select: Using 'Arial' "
|
ass_msg(library, MSGL_WARN, "fontconfig_select: Using 'Arial' "
|
||||||
|
@ -283,8 +354,8 @@ char *fontconfig_select(ASS_Library *library, FCInstance *priv,
|
||||||
* \param library library object
|
* \param library library object
|
||||||
* \param ftlibrary freetype library object
|
* \param ftlibrary freetype library object
|
||||||
* \param idx index of the processed font in library->fontdata
|
* \param idx index of the processed font in library->fontdata
|
||||||
* With FontConfig >= 2.4.2, builds a font pattern in memory via FT_New_Memory_Face/FcFreeTypeQueryFace.
|
*
|
||||||
* With older FontConfig versions, save the font to ~/.mplayer/fonts.
|
* Builds a font pattern in memory via FT_New_Memory_Face/FcFreeTypeQueryFace.
|
||||||
*/
|
*/
|
||||||
static void process_fontdata(FCInstance *priv, ASS_Library *library,
|
static void process_fontdata(FCInstance *priv, ASS_Library *library,
|
||||||
FT_Library ftlibrary, int idx)
|
FT_Library ftlibrary, int idx)
|
||||||
|
@ -311,7 +382,7 @@ static void process_fontdata(FCInstance *priv, ASS_Library *library,
|
||||||
num_faces = face->num_faces;
|
num_faces = face->num_faces;
|
||||||
|
|
||||||
pattern =
|
pattern =
|
||||||
FcFreeTypeQueryFace(face, (unsigned char *) name, 0,
|
FcFreeTypeQueryFace(face, (unsigned char *) name, face_index,
|
||||||
FcConfigGetBlanks(priv->config));
|
FcConfigGetBlanks(priv->config));
|
||||||
if (!pattern) {
|
if (!pattern) {
|
||||||
ass_msg(library, MSGL_WARN, "%s failed", "FcFreeTypeQueryFace");
|
ass_msg(library, MSGL_WARN, "%s failed", "FcFreeTypeQueryFace");
|
||||||
|
@ -388,7 +459,7 @@ FCInstance *fontconfig_init(ASS_Library *library,
|
||||||
process_fontdata(priv, library, ftlibrary, i);
|
process_fontdata(priv, library, ftlibrary, i);
|
||||||
|
|
||||||
if (dir) {
|
if (dir) {
|
||||||
ass_msg(library, MSGL_INFO, "Updating font cache");
|
ass_msg(library, MSGL_V, "Updating font cache");
|
||||||
|
|
||||||
rc = FcConfigAppFontAddDir(priv->config, (const FcChar8 *) dir);
|
rc = FcConfigAppFontAddDir(priv->config, (const FcChar8 *) dir);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
|
@ -448,14 +519,13 @@ int fontconfig_update(FCInstance *priv)
|
||||||
|
|
||||||
void fontconfig_done(FCInstance *priv)
|
void fontconfig_done(FCInstance *priv)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (priv) {
|
||||||
#ifdef CONFIG_FONTCONFIG
|
#ifdef CONFIG_FONTCONFIG
|
||||||
if (priv && priv->config)
|
|
||||||
FcConfigDestroy(priv->config);
|
FcConfigDestroy(priv->config);
|
||||||
#endif
|
#endif
|
||||||
if (priv && priv->path_default)
|
|
||||||
free(priv->path_default);
|
free(priv->path_default);
|
||||||
if (priv && priv->family_default)
|
|
||||||
free(priv->family_default);
|
free(priv->family_default);
|
||||||
if (priv)
|
}
|
||||||
free(priv);
|
free(priv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_FONTCONFIG_H
|
#ifndef LIBASS_FONTCONFIG_H
|
||||||
|
|
|
@ -3,21 +3,21 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -57,7 +57,6 @@ void ass_library_done(ASS_Library *priv)
|
||||||
|
|
||||||
void ass_set_fonts_dir(ASS_Library *priv, const char *fonts_dir)
|
void ass_set_fonts_dir(ASS_Library *priv, const char *fonts_dir)
|
||||||
{
|
{
|
||||||
if (priv->fonts_dir)
|
|
||||||
free(priv->fonts_dir);
|
free(priv->fonts_dir);
|
||||||
|
|
||||||
priv->fonts_dir = fonts_dir ? strdup(fonts_dir) : 0;
|
priv->fonts_dir = fonts_dir ? strdup(fonts_dir) : 0;
|
||||||
|
@ -77,8 +76,8 @@ void ass_set_style_overrides(ASS_Library *priv, char **list)
|
||||||
if (priv->style_overrides) {
|
if (priv->style_overrides) {
|
||||||
for (p = priv->style_overrides; *p; ++p)
|
for (p = priv->style_overrides; *p; ++p)
|
||||||
free(*p);
|
free(*p);
|
||||||
free(priv->style_overrides);
|
|
||||||
}
|
}
|
||||||
|
free(priv->style_overrides);
|
||||||
|
|
||||||
if (!list)
|
if (!list)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_LIBRARY_H
|
#ifndef LIBASS_LIBRARY_H
|
||||||
|
|
|
@ -68,9 +68,15 @@ void update_font(ASS_Renderer *render_priv)
|
||||||
{
|
{
|
||||||
unsigned val;
|
unsigned val;
|
||||||
ASS_FontDesc desc;
|
ASS_FontDesc desc;
|
||||||
|
desc.treat_family_as_pattern = render_priv->state.treat_family_as_pattern;
|
||||||
|
|
||||||
|
if (render_priv->state.family[0] == '@') {
|
||||||
|
desc.vertical = 1;
|
||||||
|
desc.family = strdup(render_priv->state.family + 1);
|
||||||
|
} else {
|
||||||
|
desc.vertical = 0;
|
||||||
desc.family = strdup(render_priv->state.family);
|
desc.family = strdup(render_priv->state.family);
|
||||||
desc.treat_family_as_pattern =
|
}
|
||||||
render_priv->state.treat_family_as_pattern;
|
|
||||||
|
|
||||||
val = render_priv->state.bold;
|
val = render_priv->state.bold;
|
||||||
// 0 = normal, 1 = bold, >1 = exact weight
|
// 0 = normal, 1 = bold, >1 = exact weight
|
||||||
|
@ -208,12 +214,14 @@ static char *parse_vector_clip(ASS_Renderer *render_priv, char *p)
|
||||||
{
|
{
|
||||||
int scale = 1;
|
int scale = 1;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
ASS_Drawing *drawing;
|
ASS_Drawing *drawing = render_priv->state.clip_drawing;
|
||||||
|
|
||||||
|
if (drawing && drawing->glyph)
|
||||||
|
FT_Done_Glyph((FT_Glyph) drawing->glyph);
|
||||||
|
ass_drawing_free(drawing);
|
||||||
render_priv->state.clip_drawing = ass_drawing_new(
|
render_priv->state.clip_drawing = ass_drawing_new(
|
||||||
render_priv->fontconfig_priv,
|
render_priv->fontconfig_priv,
|
||||||
render_priv->state.font,
|
render_priv->state.font,
|
||||||
render_priv->settings.hinting,
|
|
||||||
render_priv->ftlibrary);
|
render_priv->ftlibrary);
|
||||||
drawing = render_priv->state.clip_drawing;
|
drawing = render_priv->state.clip_drawing;
|
||||||
skipopt('(');
|
skipopt('(');
|
||||||
|
@ -227,20 +235,6 @@ static char *parse_vector_clip(ASS_Renderer *render_priv, char *p)
|
||||||
while (*p != ')' && *p != '}' && p != 0)
|
while (*p != ')' && *p != '}' && p != 0)
|
||||||
ass_drawing_add_char(drawing, *p++);
|
ass_drawing_add_char(drawing, *p++);
|
||||||
skipopt(')');
|
skipopt(')');
|
||||||
if (ass_drawing_parse(drawing, 1)) {
|
|
||||||
// We need to translate the clip according to screen borders
|
|
||||||
if (render_priv->settings.left_margin != 0 ||
|
|
||||||
render_priv->settings.top_margin != 0) {
|
|
||||||
FT_Vector trans = {
|
|
||||||
.x = int_to_d6(render_priv->settings.left_margin),
|
|
||||||
.y = -int_to_d6(render_priv->settings.top_margin),
|
|
||||||
};
|
|
||||||
FT_Outline_Translate(&drawing->glyph->outline, trans.x, trans.y);
|
|
||||||
}
|
|
||||||
ass_msg(render_priv->library, MSGL_DBG2,
|
|
||||||
"Parsed vector clip: scale %d, scales (%f, %f) string [%s]\n",
|
|
||||||
scale, drawing->scale_x, drawing->scale_y, drawing->text);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -365,6 +359,22 @@ static char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
|
||||||
render_priv->state.hspacing * (1 - pwr) + val * pwr;
|
render_priv->state.hspacing * (1 - pwr) + val * pwr;
|
||||||
else
|
else
|
||||||
render_priv->state.hspacing = render_priv->state.style->Spacing;
|
render_priv->state.hspacing = render_priv->state.style->Spacing;
|
||||||
|
} else if (mystrcmp(&p, "fs+")) {
|
||||||
|
double val;
|
||||||
|
if (mystrtod(&p, &val)) {
|
||||||
|
val = render_priv->state.font_size + pwr * val;
|
||||||
|
} else
|
||||||
|
val = render_priv->state.style->FontSize;
|
||||||
|
if (render_priv->state.font)
|
||||||
|
change_font_size(render_priv, val);
|
||||||
|
} else if (mystrcmp(&p, "fs-")) {
|
||||||
|
double val;
|
||||||
|
if (mystrtod(&p, &val))
|
||||||
|
val = render_priv->state.font_size - pwr * val;
|
||||||
|
else
|
||||||
|
val = render_priv->state.style->FontSize;
|
||||||
|
if (render_priv->state.font)
|
||||||
|
change_font_size(render_priv, val);
|
||||||
} else if (mystrcmp(&p, "fs")) {
|
} else if (mystrcmp(&p, "fs")) {
|
||||||
double val;
|
double val;
|
||||||
if (mystrtod(&p, &val))
|
if (mystrtod(&p, &val))
|
||||||
|
@ -461,7 +471,6 @@ static char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
|
||||||
family[p - start] = '\0';
|
family[p - start] = '\0';
|
||||||
} else
|
} else
|
||||||
family = strdup(render_priv->state.style->FontName);
|
family = strdup(render_priv->state.style->FontName);
|
||||||
if (render_priv->state.family)
|
|
||||||
free(render_priv->state.family);
|
free(render_priv->state.family);
|
||||||
render_priv->state.family = family;
|
render_priv->state.family = family;
|
||||||
update_font(render_priv);
|
update_font(render_priv);
|
||||||
|
@ -586,7 +595,7 @@ static char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
|
||||||
for (cnt = 0; cnt < 3; ++cnt) {
|
for (cnt = 0; cnt < 3; ++cnt) {
|
||||||
if (*p == '\\')
|
if (*p == '\\')
|
||||||
break;
|
break;
|
||||||
v[cnt] = strtod(p, &p);
|
mystrtod(&p, &v[cnt]);
|
||||||
skip(',');
|
skip(',');
|
||||||
}
|
}
|
||||||
if (cnt == 3) {
|
if (cnt == 3) {
|
||||||
|
@ -836,7 +845,7 @@ void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event)
|
||||||
} else if (strncmp(event->Effect, "Scroll down;", 12) == 0) {
|
} else if (strncmp(event->Effect, "Scroll down;", 12) == 0) {
|
||||||
render_priv->state.scroll_direction = SCROLL_TB;
|
render_priv->state.scroll_direction = SCROLL_TB;
|
||||||
} else {
|
} else {
|
||||||
ass_msg(render_priv->library, MSGL_V,
|
ass_msg(render_priv->library, MSGL_DBG2,
|
||||||
"Unknown transition effect: '%s'", event->Effect);
|
"Unknown transition effect: '%s'", event->Effect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -894,7 +903,7 @@ unsigned get_next_char(ASS_Renderer *render_priv, char **str)
|
||||||
break;
|
break;
|
||||||
} else if (*p != '\\')
|
} else if (*p != '\\')
|
||||||
ass_msg(render_priv->library, MSGL_V,
|
ass_msg(render_priv->library, MSGL_V,
|
||||||
"Unable to parse: '%s'", p);
|
"Unable to parse: '%.30s'", p);
|
||||||
if (*p == 0)
|
if (*p == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -918,6 +927,14 @@ unsigned get_next_char(ASS_Renderer *render_priv, char **str)
|
||||||
p += 2;
|
p += 2;
|
||||||
*str = p;
|
*str = p;
|
||||||
return NBSP;
|
return NBSP;
|
||||||
|
} else if (p[1] == '{') {
|
||||||
|
p += 2;
|
||||||
|
*str = p;
|
||||||
|
return '{';
|
||||||
|
} else if (p[1] == '}') {
|
||||||
|
p += 2;
|
||||||
|
*str = p;
|
||||||
|
return '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chr = ass_utf8_get_char((char **) &p);
|
chr = ass_utf8_get_char((char **) &p);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,19 +4,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_RENDER_H
|
#ifndef LIBASS_RENDER_H
|
||||||
|
@ -38,6 +36,9 @@
|
||||||
#include "ass_library.h"
|
#include "ass_library.h"
|
||||||
#include "ass_drawing.h"
|
#include "ass_drawing.h"
|
||||||
|
|
||||||
|
#define GLYPH_CACHE_MAX 1000
|
||||||
|
#define BITMAP_CACHE_MAX_SIZE 30 * 1048576
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double xMin;
|
double xMin;
|
||||||
double xMax;
|
double xMax;
|
||||||
|
@ -258,5 +259,6 @@ typedef struct {
|
||||||
} Segment;
|
} Segment;
|
||||||
|
|
||||||
void reset_render_context(ASS_Renderer *render_priv);
|
void reset_render_context(ASS_Renderer *render_priv);
|
||||||
|
void ass_free_images(ASS_Image *img);
|
||||||
|
|
||||||
#endif /* LIBASS_RENDER_H */
|
#endif /* LIBASS_RENDER_H */
|
||||||
|
|
139
aegisub/libass/ass_render_api.c
Normal file
139
aegisub/libass/ass_render_api.c
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
|
||||||
|
* Copyright (C) 2010 Grigori Goronzy <greg@geekmind.org>
|
||||||
|
*
|
||||||
|
* This file is part of libass.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "ass_render.h"
|
||||||
|
|
||||||
|
static void ass_reconfigure(ASS_Renderer *priv)
|
||||||
|
{
|
||||||
|
ASS_Settings *settings = &priv->settings;
|
||||||
|
|
||||||
|
priv->render_id++;
|
||||||
|
priv->cache.glyph_cache =
|
||||||
|
ass_glyph_cache_reset(priv->cache.glyph_cache);
|
||||||
|
priv->cache.bitmap_cache =
|
||||||
|
ass_bitmap_cache_reset(priv->cache.bitmap_cache);
|
||||||
|
priv->cache.composite_cache =
|
||||||
|
ass_composite_cache_reset(priv->cache.composite_cache);
|
||||||
|
ass_free_images(priv->prev_images_root);
|
||||||
|
priv->prev_images_root = 0;
|
||||||
|
|
||||||
|
priv->width = settings->frame_width;
|
||||||
|
priv->height = settings->frame_height;
|
||||||
|
priv->orig_width = settings->frame_width - settings->left_margin -
|
||||||
|
settings->right_margin;
|
||||||
|
priv->orig_height = settings->frame_height - settings->top_margin -
|
||||||
|
settings->bottom_margin;
|
||||||
|
priv->orig_width_nocrop =
|
||||||
|
settings->frame_width - FFMAX(settings->left_margin, 0) -
|
||||||
|
FFMAX(settings->right_margin, 0);
|
||||||
|
priv->orig_height_nocrop =
|
||||||
|
settings->frame_height - FFMAX(settings->top_margin, 0) -
|
||||||
|
FFMAX(settings->bottom_margin, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_frame_size(ASS_Renderer *priv, int w, int h)
|
||||||
|
{
|
||||||
|
if (priv->settings.frame_width != w || priv->settings.frame_height != h) {
|
||||||
|
priv->settings.frame_width = w;
|
||||||
|
priv->settings.frame_height = h;
|
||||||
|
if (priv->settings.aspect == 0.) {
|
||||||
|
priv->settings.aspect = ((double) w) / h;
|
||||||
|
priv->settings.storage_aspect = ((double) w) / h;
|
||||||
|
}
|
||||||
|
ass_reconfigure(priv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_margins(ASS_Renderer *priv, int t, int b, int l, int r)
|
||||||
|
{
|
||||||
|
if (priv->settings.left_margin != l || priv->settings.right_margin != r ||
|
||||||
|
priv->settings.top_margin != t || priv->settings.bottom_margin != b) {
|
||||||
|
priv->settings.left_margin = l;
|
||||||
|
priv->settings.right_margin = r;
|
||||||
|
priv->settings.top_margin = t;
|
||||||
|
priv->settings.bottom_margin = b;
|
||||||
|
ass_reconfigure(priv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_use_margins(ASS_Renderer *priv, int use)
|
||||||
|
{
|
||||||
|
priv->settings.use_margins = use;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_aspect_ratio(ASS_Renderer *priv, double dar, double sar)
|
||||||
|
{
|
||||||
|
if (priv->settings.aspect != dar || priv->settings.storage_aspect != sar) {
|
||||||
|
priv->settings.aspect = dar;
|
||||||
|
priv->settings.storage_aspect = sar;
|
||||||
|
ass_reconfigure(priv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_font_scale(ASS_Renderer *priv, double font_scale)
|
||||||
|
{
|
||||||
|
if (priv->settings.font_size_coeff != font_scale) {
|
||||||
|
priv->settings.font_size_coeff = font_scale;
|
||||||
|
ass_reconfigure(priv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_hinting(ASS_Renderer *priv, ASS_Hinting ht)
|
||||||
|
{
|
||||||
|
if (priv->settings.hinting != ht) {
|
||||||
|
priv->settings.hinting = ht;
|
||||||
|
ass_reconfigure(priv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing)
|
||||||
|
{
|
||||||
|
priv->settings.line_spacing = line_spacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
|
||||||
|
const char *default_family, int fc, const char *config,
|
||||||
|
int update)
|
||||||
|
{
|
||||||
|
free(priv->settings.default_font);
|
||||||
|
free(priv->settings.default_family);
|
||||||
|
priv->settings.default_font = default_font ? strdup(default_font) : 0;
|
||||||
|
priv->settings.default_family =
|
||||||
|
default_family ? strdup(default_family) : 0;
|
||||||
|
|
||||||
|
if (priv->fontconfig_priv)
|
||||||
|
fontconfig_done(priv->fontconfig_priv);
|
||||||
|
priv->fontconfig_priv =
|
||||||
|
fontconfig_init(priv->library, priv->ftlibrary, default_family,
|
||||||
|
default_font, fc, config, update);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ass_fonts_update(ASS_Renderer *render_priv)
|
||||||
|
{
|
||||||
|
return fontconfig_update(render_priv->fontconfig_priv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max,
|
||||||
|
int bitmap_max)
|
||||||
|
{
|
||||||
|
render_priv->cache.glyph_max = glyph_max ? glyph_max : GLYPH_CACHE_MAX;
|
||||||
|
render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max :
|
||||||
|
BITMAP_CACHE_MAX_SIZE;
|
||||||
|
}
|
|
@ -16,12 +16,14 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
const
|
||||||
static int maxExponent = 511; /* Largest possible base 10 exponent. Any
|
static int maxExponent = 511; /* Largest possible base 10 exponent. Any
|
||||||
* exponent larger than this will already
|
* exponent larger than this will already
|
||||||
* produce underflow or overflow, so there's
|
* produce underflow or overflow, so there's
|
||||||
* no need to worry about additional digits.
|
* no need to worry about additional digits.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const
|
||||||
static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
|
static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
|
||||||
10., /* is 10^2^i. Used to convert decimal */
|
10., /* is 10^2^i. Used to convert decimal */
|
||||||
100., /* exponents into floating-point numbers. */
|
100., /* exponents into floating-point numbers. */
|
||||||
|
@ -224,7 +226,7 @@ ass_strtod(string, endPtr)
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
}
|
}
|
||||||
dblExp = 1.0;
|
dblExp = 1.0;
|
||||||
for (d = powersOf10; exp != 0; exp >>= 1, d += 1) {
|
for (d = (double *) powersOf10; exp != 0; exp >>= 1, d += 1) {
|
||||||
if (exp & 01) {
|
if (exp & 01) {
|
||||||
dblExp *= *d;
|
dblExp *= *d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_TYPES_H
|
#ifndef LIBASS_TYPES_H
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -25,6 +23,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_GLYPH_H
|
#include FT_GLYPH_H
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
#include "ass_library.h"
|
#include "ass_library.h"
|
||||||
#include "ass.h"
|
#include "ass.h"
|
||||||
|
|
|
@ -3,19 +3,17 @@
|
||||||
*
|
*
|
||||||
* This file is part of libass.
|
* This file is part of libass.
|
||||||
*
|
*
|
||||||
* libass is free software; you can redistribute it and/or modify
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* it under the terms of the GNU General Public License as published by
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* copyright notice and this permission notice appear in all copies.
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
*
|
||||||
* libass is distributed in the hope that it will be useful,
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* GNU General Public License for more details.
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
*
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* You should have received a copy of the GNU General Public License along
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* with libass; if not, write to the Free Software Foundation, Inc.,
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBASS_UTILS_H
|
#ifndef LIBASS_UTILS_H
|
||||||
|
|
Loading…
Reference in a new issue