Convert pango/opentype to the new project called HarfBuzz.

2006-03-31  Behdad Esfahbod  <behdad@gnome.org>

        Convert pango/opentype to the new project called HarfBuzz.

        * pango/opentype/*: Restructured.

        * pango/pango-ot-*: Updated to use HarfBuzz symbol names.
This commit is contained in:
Behdad Esfahbod 2006-03-31 12:28:09 +00:00 committed by Behdad Esfahbod
parent dd2a8d4d49
commit 9f8da38cd1
39 changed files with 16577 additions and 16330 deletions

15
src/COPYING Normal file
View File

@ -0,0 +1,15 @@
HarfBuzz is distributed under two mutually exclusive open-source licenses.
This means that *you* must choose *one* of the two licenses described
below, then obey all its terms and conditions when using HarfBuzz in
any of your projects or products.
- The FreeType License, found in the file `COPYING.FTL', which is similar to
the original BSD license *with* an advertising clause that forces you to
explicitly cite the FreeType project in your product's documentation.
All details are in the license file. This license is suited to
products which don't use the GNU General Public License.
- The GNU General Public License version 2, found in `COPYING.GPL' (any
later version can be used also), for programs which already use the GPL.
Note that the FTL is incompatible with the GPL due to its
advertisement clause.

340
src/COPYING.GPL Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
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 Library 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Library General
Public License instead of this License.

View File

@ -1,28 +0,0 @@
The FreeType 2 font engine is copyrighted work and cannot be used
legally without a software license. In order to make this project
usable to a vast majority of developers, we distribute it under two
mutually exclusive open-source licenses.
This means that *you* must choose *one* of the two licenses described
below, then obey all its terms and conditions when using FreeType 2 in
any of your projects or products.
- The FreeType License, found in the file `FTL.TXT', which is similar
to the original BSD license *with* an advertising clause that forces
you to explicitly cite the FreeType project in your product's
documentation. All details are in the license file. This license
is suited to products which don't use the GNU General Public
License.
- The GNU General Public License version 2, found in `GPL.TXT' (any
later version can be used also), for programs which already use the
GPL. Note that the FTL is incompatible with the GPL due to its
advertisement clause.
The contributed PCF driver comes with a license similar to that of the X
Window System. It is compatible to the above two licenses (see file
src/pcf/readme).
--- end of LICENSE.TXT ---

View File

@ -1,51 +1,58 @@
## Process this file with automake to produce Makefile.in
INCLUDES = \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLIBDIR=\"$(libdir)\" \
$(PANGO_DEBUG_FLAGS) \
-I$(top_srcdir) \
$(GLIB_CFLAGS) \
$(FREETYPE_CFLAGS)
noinst_LTLIBRARIES = libmini-harfbuzz.la
noinst_LTLIBRARIES = libharfbuzz-1.la
libmini_harfbuzz_la_SOURCES = \
ftglue.h \
ftglue.c \
ftxopen.c \
ftxopen.h \
ftxopenf.h \
ftxgdef.c \
ftxgdef.h \
ftxgpos.c \
ftxgpos.h \
ftxgsub.c \
ftxgsub.h \
otlbuffer.c \
otlbuffer.h
SOURCES = \
ftglue.c \
harfbuzz-buffer.c \
harfbuzz-dump.c \
harfbuzz-gdef.c \
harfbuzz-gpos.c \
harfbuzz-gsub.c \
harfbuzz-open.c
libmini_harfbuzz_la_LIBADD = \
$(x_ldflags) \
$(x_libs) \
$(GLIB_LIBS) \
-lm
EXTRA_SOURCES = harfbuzz.c
if BUILD_OT_TESTS
noinst_PROGRAMS = ottest
endif
PUBLICHEADERS = \
harfbuzz.h \
harfbuzz-buffer.h \
harfbuzz-dump.h \
harfbuzz-gdef.h \
harfbuzz-gpos.h \
harfbuzz-gsub.h \
harfbuzz-open.h
ottest_SOURCES = \
ottest.c \
disasm.c \
disasm.h
PRIVATEHEADERS = \
ftglue.h \
harfbuzz-impl.h \
harfbuzz-gdef-private.h \
harfbuzz-gpos-private.h \
harfbuzz-gsub-private.h \
harfbuzz-open-private.h
ottest_LDADD = \
libmini-harfbuzz.la \
libharfbuzz_1_la_SOURCES = \
$(SOURCES) \
$(PUBLICHEADERS) \
$(PRIVATEHEADERS)
libharfbuzz_1_la_LIBADD = \
$(FREETYPE_LIBS)
noinst_PROGRAMS = harfbuzz-dump
harfbuzz_dump_SOURCES = \
harfbuzz-dump-main.c
harfbuzz_dump_LDADD = \
libharfbuzz-1.la
EXTRA_DIST = \
README \
FTL.TXT \
FT-license.txt
COPYING.FTL \
COPYING.GPL \
COPYING \
$(EXTRA_SOURCES)

View File

@ -1,36 +1,18 @@
This directory includes code for using OpenType Layout tables from
OpenType fonts with FreeType and
This is HarfBuzz, an OpenType Layout engine.
The table reading code in:
It was derived originally from the OpenType code in FreeType-1.x, ported to
FreeType2. (This code has been abandoned for FreeType2, but until something
better comes along, should serve our purposes.) In addition to porting to
FreeType-2, it has been modified in various other ways.
ftxopen.[ch]
ftxopenf.h
ftxgdef.[ch]
ftxgpos.[ch]
ftxgdef.[ch]
It also includes a partial XML dumper for OpenType Layout tables useful for
figuring out what is going on. Please extend to cover additional parts of the
tables as you encounter fonts using them. The dumper is written by Owen Taylor.
Is derived from the OpenType code in FreeType-1.x, ported to FreeType2.
(This code has been abandoned for FreeType2, but until something better
comes along, should serve our purposes.)
Bug reports on these files should be sent to the HarfBuzz mailing list as
listed on http://freedesktop.org/wiki/Software/harfbuzz
This code should be left following the FreeType indentation style and
coding conventions.
For license information, see the file COPYING.
In addition to porting to FreeType-2, it has been modified to
add support for PangoGlyphString's log_clusters, and in various
other ways. Bug reports on these files should be sent to
gtk-i18n-list@gtk.org, NOT to the freetype maintainers.
The license for these files is in the file FT-license.txt.
Most of the additional files in this directory implement a high-level
interface to this that follows Pango conventions and integrates with
Pango.
disasm.[ch] is a partial dumper for OpenType layout tables useful
in figuring out what is going on. Please extend to cover additional
parts of the tables as you encounter fonts using them.
Owen Taylor
17 December 2000
Behdad Esfahbod
April 1st, 2006

View File

@ -8,15 +8,14 @@
* See ftglue.h for more information.
*/
#include <config.h>
#include "ftglue.h"
#if 0
#include <stdio.h>
#define LOG(x) ftglue_log x
#define LOG(x) _hb_ftglue_log x
static void
ftglue_log( const char* format, ... )
_hb_ftglue_log( const char* format, ... )
{
va_list ap;
@ -31,7 +30,7 @@ ftglue_log( const char* format, ... )
/* only used internally */
static FT_Pointer
ftglue_qalloc( FT_Memory memory,
_hb_ftglue_qalloc( FT_Memory memory,
FT_ULong size,
FT_Error *perror )
{
@ -50,11 +49,11 @@ ftglue_qalloc( FT_Memory memory,
}
#undef QALLOC /* just in case */
#define QALLOC(ptr,size) ( (ptr) = ftglue_qalloc( memory, (size), &error ), error != 0 )
#define QALLOC(ptr,size) ( (ptr) = _hb_ftglue_qalloc( memory, (size), &error ), error != 0 )
FTGLUE_APIDEF( FT_Pointer )
ftglue_alloc( FT_Memory memory,
_hb_ftglue_alloc( FT_Memory memory,
FT_ULong size,
FT_Error *perror )
{
@ -76,7 +75,7 @@ ftglue_alloc( FT_Memory memory,
FTGLUE_APIDEF( FT_Pointer )
ftglue_realloc( FT_Memory memory,
_hb_ftglue_realloc( FT_Memory memory,
FT_Pointer block,
FT_ULong old_size,
FT_ULong new_size,
@ -87,11 +86,11 @@ ftglue_realloc( FT_Memory memory,
if ( old_size == 0 || block == NULL )
{
block2 = ftglue_alloc( memory, new_size, &error );
block2 = _hb_ftglue_alloc( memory, new_size, &error );
}
else if ( new_size == 0 )
{
ftglue_free( memory, block );
_hb_ftglue_free( memory, block );
}
else
{
@ -111,7 +110,7 @@ ftglue_realloc( FT_Memory memory,
FTGLUE_APIDEF( void )
ftglue_free( FT_Memory memory,
_hb_ftglue_free( FT_Memory memory,
FT_Pointer block )
{
if ( block )
@ -120,7 +119,7 @@ ftglue_free( FT_Memory memory,
FTGLUE_APIDEF( FT_Long )
ftglue_stream_pos( FT_Stream stream )
_hb_ftglue_stream_pos( FT_Stream stream )
{
LOG(( "ftglue:stream:pos() -> %ld\n", stream->pos ));
return stream->pos;
@ -128,7 +127,7 @@ ftglue_stream_pos( FT_Stream stream )
FTGLUE_APIDEF( FT_Error )
ftglue_stream_seek( FT_Stream stream,
_hb_ftglue_stream_seek( FT_Stream stream,
FT_Long pos )
{
FT_Error error = 0;
@ -136,7 +135,7 @@ ftglue_stream_seek( FT_Stream stream,
stream->pos = pos;
if ( stream->read )
{
if ( stream->read( stream, pos, 0, 0 ) )
if ( stream->read( stream, pos, NULL, 0 ) )
error = FT_Err_Invalid_Stream_Operation;
}
else if ( pos > (FT_Long)stream->size )
@ -148,7 +147,7 @@ ftglue_stream_seek( FT_Stream stream,
FTGLUE_APIDEF( FT_Error )
ftglue_stream_frame_enter( FT_Stream stream,
_hb_ftglue_stream_frame_enter( FT_Stream stream,
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
@ -198,7 +197,7 @@ Exit:
FTGLUE_APIDEF( void )
ftglue_stream_frame_exit( FT_Stream stream )
_hb_ftglue_stream_frame_exit( FT_Stream stream )
{
if ( stream->read )
{
@ -206,68 +205,21 @@ ftglue_stream_frame_exit( FT_Stream stream )
FREE( stream->base );
}
stream->cursor = 0;
stream->limit = 0;
stream->cursor = NULL;
stream->limit = NULL;
LOG(( "ftglue:stream:frame_exit()\n" ));
}
FTGLUE_APIDEF( FT_Byte )
ftglue_stream_get_byte( FT_Stream stream )
{
FT_Byte result = 0;
if ( stream->cursor < stream->limit )
result = *stream->cursor++;
return result;
}
FTGLUE_APIDEF( FT_Short )
ftglue_stream_get_short( FT_Stream stream )
{
FT_Byte* p;
FT_Short result = 0;
p = stream->cursor;
if ( p + 2 <= stream->limit )
{
result = (FT_Short)((p[0] << 8) | p[1]);
stream->cursor = p+2;
}
return result;
}
FTGLUE_APIDEF( FT_Long )
ftglue_stream_get_long( FT_Stream stream )
{
FT_Byte* p;
FT_Long result = 0;
p = stream->cursor;
if ( p + 4 <= stream->limit )
{
result = (FT_Long)(((FT_Long)p[0] << 24) |
((FT_Long)p[1] << 16) |
((FT_Long)p[2] << 8) |
p[3] );
stream->cursor = p+4;
}
return result;
}
FTGLUE_APIDEF( FT_Error )
ftglue_face_goto_table( FT_Face face,
_hb_ftglue_face_goto_table( FT_Face face,
FT_ULong the_tag,
FT_Stream stream )
{
FT_Error error;
LOG(( "ftglue_face_goto_table( %p, %c%c%c%c, %p )\n",
LOG(( "_hb_ftglue_face_goto_table( %p, %c%c%c%c, %p )\n",
face,
(int)((the_tag >> 24) & 0xFF),
(int)((the_tag >> 16) & 0xFF),
@ -331,11 +283,11 @@ ftglue_face_goto_table( FT_Face face,
if ( tag == the_tag )
{
LOG(( "TrueType table (start: %ld) (size: %ld)\n", start, size ));
error = ftglue_stream_seek( stream, offset+start );
error = _hb_ftglue_stream_seek( stream, offset+start );
goto FoundIt;
}
}
error = TT_Err_Table_Missing;
error = FT_Err_Table_Missing;
FoundIt:
FORGET_Frame();

View File

@ -1,4 +1,4 @@
/* ftglue.c: Glue code for compiling the OpenType code from
/* ftglue.h: Glue code for compiling the OpenType code from
* FreeType 1 using only the public API of FreeType 2
*
* By David Turner, The FreeType Project (www.freetype.org)
@ -40,8 +40,8 @@
*
* PS: This "glue" code is explicitely put in the public domain
*/
#ifndef __OPENTYPE_FTGLUE_H__
#define __OPENTYPE_FTGLUE_H__
#ifndef FTGLUE_H
#define FTGLUE_H
#include <ft2build.h>
#include FT_FREETYPE_H
@ -50,10 +50,6 @@ FT_BEGIN_HEADER
/* utility macros */
#define TT_Err_Ok FT_Err_Ok
#define TT_Err_Invalid_Argument FT_Err_Invalid_Argument
#define TT_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle
#define TT_Err_Table_Missing FT_Err_Table_Missing
#define SET_ERR(c) ( (error = (c)) != 0 )
@ -66,14 +62,23 @@ FT_BEGIN_HEADER
#endif
/* stream macros used by the OpenType parser */
#define FILE_Pos() ftglue_stream_pos( stream )
#define FILE_Seek(pos) SET_ERR( ftglue_stream_seek( stream, pos ) )
#define ACCESS_Frame(size) SET_ERR( ftglue_stream_frame_enter( stream, size ) )
#define FORGET_Frame() ftglue_stream_frame_exit( stream )
#define FILE_Pos() _hb_ftglue_stream_pos( stream )
#define FILE_Seek(pos) SET_ERR( _hb_ftglue_stream_seek( stream, pos ) )
#define ACCESS_Frame(size) SET_ERR( _hb_ftglue_stream_frame_enter( stream, size ) )
#define FORGET_Frame() _hb_ftglue_stream_frame_exit( stream )
#define GET_Byte() (*stream->cursor++)
#define GET_Short() (stream->cursor += 2, (FT_Short)( \
(*(((FT_Byte*)stream->cursor)-2) << 8) | \
*(((FT_Byte*)stream->cursor)-1) \
))
#define GET_Long() (stream->cursor += 4, (FT_Long)( \
(*(((FT_Byte*)stream->cursor)-4) << 24) | \
(*(((FT_Byte*)stream->cursor)-3) << 16) | \
(*(((FT_Byte*)stream->cursor)-2) << 8) | \
*(((FT_Byte*)stream->cursor)-1) \
))
#define GET_Byte() ftglue_stream_get_byte( stream )
#define GET_Short() ftglue_stream_get_short( stream )
#define GET_Long() ftglue_stream_get_long( stream )
#define GET_Char() ((FT_Char)GET_Byte())
#define GET_UShort() ((FT_UShort)GET_Short())
@ -81,45 +86,36 @@ FT_BEGIN_HEADER
#define GET_Tag4() GET_ULong()
FTGLUE_API( FT_Long )
ftglue_stream_pos( FT_Stream stream );
_hb_ftglue_stream_pos( FT_Stream stream );
FTGLUE_API( FT_Error )
ftglue_stream_seek( FT_Stream stream,
_hb_ftglue_stream_seek( FT_Stream stream,
FT_Long pos );
FTGLUE_API( FT_Error )
ftglue_stream_frame_enter( FT_Stream stream,
_hb_ftglue_stream_frame_enter( FT_Stream stream,
FT_ULong size );
FTGLUE_API( void )
ftglue_stream_frame_exit( FT_Stream stream );
FTGLUE_API( FT_Byte )
ftglue_stream_get_byte( FT_Stream stream );
FTGLUE_API( FT_Short )
ftglue_stream_get_short( FT_Stream stream );
FTGLUE_API( FT_Long )
ftglue_stream_get_long( FT_Stream stream );
_hb_ftglue_stream_frame_exit( FT_Stream stream );
FTGLUE_API( FT_Error )
ftglue_face_goto_table( FT_Face face,
_hb_ftglue_face_goto_table( FT_Face face,
FT_ULong tag,
FT_Stream stream );
/* memory macros used by the OpenType parser */
#define ALLOC(_ptr,_size) \
( (_ptr) = ftglue_alloc( memory, _size, &error ), error != 0 )
( (_ptr) = _hb_ftglue_alloc( memory, _size, &error ), error != 0 )
#define REALLOC(_ptr,_oldsz,_newsz) \
( (_ptr) = ftglue_realloc( memory, (_ptr), (_oldsz), (_newsz), &error ), error != 0 )
( (_ptr) = _hb_ftglue_realloc( memory, (_ptr), (_oldsz), (_newsz), &error ), error != 0 )
#define FREE(_ptr) \
do { \
if ( (_ptr) ) \
{ \
ftglue_free( memory, _ptr ); \
_hb_ftglue_free( memory, _ptr ); \
_ptr = NULL; \
} \
} while (0)
@ -134,23 +130,21 @@ ftglue_face_goto_table( FT_Face face,
FTGLUE_API( FT_Pointer )
ftglue_alloc( FT_Memory memory,
_hb_ftglue_alloc( FT_Memory memory,
FT_ULong size,
FT_Error *perror_ );
FTGLUE_API( FT_Pointer )
ftglue_realloc( FT_Memory memory,
_hb_ftglue_realloc( FT_Memory memory,
FT_Pointer block,
FT_ULong old_size,
FT_ULong new_size,
FT_Error *perror_ );
FTGLUE_API( void )
ftglue_free( FT_Memory memory,
_hb_ftglue_free( FT_Memory memory,
FT_Pointer block );
/* */
FT_END_HEADER
#endif /* __OPENTYPE_FTGLUE_H__ */
#endif /* FTGLUE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,224 +0,0 @@
/*******************************************************************
*
* ftxgdef.h
*
* TrueType Open GDEF table support
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
******************************************************************/
#ifndef FTXOPEN_H
#error "Don't include this file! Use ftxopen.h instead."
#endif
#ifndef FTXGDEF_H
#define FTXGDEF_H
#ifdef __cplusplus
extern "C" {
#endif
#define TTO_Err_Invalid_GDEF_SubTable_Format 0x1030
#define TTO_Err_Invalid_GDEF_SubTable 0x1031
/* GDEF glyph classes */
#define UNCLASSIFIED_GLYPH 0
#define SIMPLE_GLYPH 1
#define LIGATURE_GLYPH 2
#define MARK_GLYPH 3
#define COMPONENT_GLYPH 4
/* GDEF glyph properties, corresponding to class values 1-4. Note that
TTO_COMPONENT has no corresponding flag in the LookupFlag field. */
#define TTO_BASE_GLYPH 0x0002
#define TTO_LIGATURE 0x0004
#define TTO_MARK 0x0008
#define TTO_COMPONENT 0x0010
/* Attachment related structures */
struct TTO_AttachPoint_
{
FT_UShort PointCount; /* size of the PointIndex array */
FT_UShort* PointIndex; /* array of contour points */
};
typedef struct TTO_AttachPoint_ TTO_AttachPoint;
struct TTO_AttachList_
{
FT_Bool loaded;
TTO_Coverage Coverage; /* Coverage table */
FT_UShort GlyphCount; /* number of glyphs with
attachments */
TTO_AttachPoint* AttachPoint; /* array of AttachPoint tables */
};
typedef struct TTO_AttachList_ TTO_AttachList;
/* Ligature Caret related structures */
struct TTO_CaretValueFormat1_
{
FT_Short Coordinate; /* x or y value (in design units) */
};
typedef struct TTO_CaretValueFormat1_ TTO_CaretValueFormat1;
struct TTO_CaretValueFormat2_
{
FT_UShort CaretValuePoint; /* contour point index on glyph */
};
typedef struct TTO_CaretValueFormat2_ TTO_CaretValueFormat2;
struct TTO_CaretValueFormat3_
{
FT_Short Coordinate; /* x or y value (in design units) */
TTO_Device Device; /* Device table for x or y value */
};
typedef struct TTO_CaretValueFormat3_ TTO_CaretValueFormat3;
struct TTO_CaretValueFormat4_
{
FT_UShort IdCaretValue; /* metric ID */
};
typedef struct TTO_CaretValueFormat4_ TTO_CaretValueFormat4;
struct TTO_CaretValue_
{
FT_UShort CaretValueFormat; /* 1, 2, 3, or 4 */
union
{
TTO_CaretValueFormat1 cvf1;
TTO_CaretValueFormat2 cvf2;
TTO_CaretValueFormat3 cvf3;
TTO_CaretValueFormat4 cvf4;
} cvf;
};
typedef struct TTO_CaretValue_ TTO_CaretValue;
struct TTO_LigGlyph_
{
FT_Bool loaded;
FT_UShort CaretCount; /* number of caret values */
TTO_CaretValue* CaretValue; /* array of caret values */
};
typedef struct TTO_LigGlyph_ TTO_LigGlyph;
struct TTO_LigCaretList_
{
FT_Bool loaded;
TTO_Coverage Coverage; /* Coverage table */
FT_UShort LigGlyphCount; /* number of ligature glyphs */
TTO_LigGlyph* LigGlyph; /* array of LigGlyph tables */
};
typedef struct TTO_LigCaretList_ TTO_LigCaretList;
/* The `NewGlyphClasses' field is not defined in the TTO specification.
We use it for fonts with a constructed `GlyphClassDef' structure
(i.e., which don't have a GDEF table) to collect glyph classes
assigned during the lookup process. The number of arrays in this
pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth
array then contains the glyph class values of the glyphs not covered
by the ClassRangeRecords structures with index n-1 and n. We store
glyph class values for four glyphs in a single array element.
`LastGlyph' is identical to the number of glyphs minus one in the
font; we need it only if `NewGlyphClasses' is not NULL (to have an
upper bound for the last array).
Note that we first store the file offset to the `MarkAttachClassDef'
field (which has been introduced in OpenType 1.2) -- since the
`Version' field value hasn't been increased to indicate that we have
one more field for some obscure reason, we must parse the GSUB table
to find out whether class values refer to this table. Only then we
can finally load the MarkAttachClassDef structure if necessary. */
struct TTO_GDEFHeader_
{
FT_Memory memory;
FT_ULong offset;
FT_Fixed Version;
TTO_ClassDefinition GlyphClassDef;
TTO_AttachList AttachList;
TTO_LigCaretList LigCaretList;
FT_ULong MarkAttachClassDef_offset;
TTO_ClassDefinition MarkAttachClassDef; /* new in OT 1.2 */
FT_UShort LastGlyph;
FT_UShort** NewGlyphClasses;
};
typedef struct TTO_GDEFHeader_ TTO_GDEFHeader;
typedef struct TTO_GDEFHeader_* TTO_GDEF;
/* finally, the GDEF API */
/* EXPORT_DEF
FT_Error TT_Init_GDEF_Extension( TT_Engine engine ); */
EXPORT_FUNC
FT_Error TT_New_GDEF_Table( FT_Face face,
TTO_GDEFHeader** retptr );
EXPORT_DEF
FT_Error TT_Load_GDEF_Table( FT_Face face,
TTO_GDEFHeader** gdef );
EXPORT_DEF
FT_Error TT_Done_GDEF_Table ( TTO_GDEFHeader* gdef );
EXPORT_DEF
FT_Error TT_GDEF_Get_Glyph_Property( TTO_GDEFHeader* gdef,
FT_UShort glyphID,
FT_UShort* property );
EXPORT_DEF
FT_Error TT_GDEF_Build_ClassDefinition( TTO_GDEFHeader* gdef,
FT_UShort num_glyphs,
FT_UShort glyph_count,
FT_UShort* glyph_array,
FT_UShort* class_array );
#ifdef __cplusplus
}
#endif
#endif /* FTXGDEF_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@ -1,838 +0,0 @@
/*******************************************************************
*
* ftxgpos.h
*
* TrueType Open GPOS table support
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
******************************************************************/
#ifndef FTXOPEN_H
#error "Don't include this file! Use ftxopen.h instead."
#endif
#ifndef FTXGPOS_H
#define FTXGPOS_H
#ifdef __cplusplus
extern "C" {
#endif
#define TTO_Err_Invalid_GPOS_SubTable_Format 0x1020
#define TTO_Err_Invalid_GPOS_SubTable 0x1021
/* Lookup types for glyph positioning */
#define GPOS_LOOKUP_SINGLE 1
#define GPOS_LOOKUP_PAIR 2
#define GPOS_LOOKUP_CURSIVE 3
#define GPOS_LOOKUP_MARKBASE 4
#define GPOS_LOOKUP_MARKLIG 5
#define GPOS_LOOKUP_MARKMARK 6
#define GPOS_LOOKUP_CONTEXT 7
#define GPOS_LOOKUP_CHAIN 8
#define GPOS_LOOKUP_EXTENSION 9
/* A pointer to a function which loads a glyph. Its parameters are
the same as in a call to TT_Load_Glyph() -- if no glyph loading
function will be registered with TTO_GPOS_Register_Glyph_Function(),
TT_Load_Glyph() will be called indeed. The purpose of this function
pointer is to provide a hook for caching glyph outlines and sbits
(using the instance's generic pointer to hold the data).
If for some reason no outline data is available (e.g. for an
embedded bitmap glyph), _glyph->outline.n_points should be set to
zero. _glyph can be computed with
_glyph = HANDLE_Glyph( glyph ) */
typedef FT_Error (*TTO_GlyphFunction)(FT_Face face,
FT_UInt glyphIndex,
FT_Int loadFlags );
/* A pointer to a function which accesses the PostScript interpreter.
Multiple Master fonts need this interface to convert a metric ID
(as stored in an OpenType font version 1.2 or higher) `metric_id'
into a metric value (returned in `metric_value').
`data' points to the user-defined structure specified during a
call to TT_GPOS_Register_MM_Function().
`metric_value' must be returned as a scaled value (but shouldn't
be rounded). */
typedef FT_Error (*TTO_MMFunction)(FT_Face face,
FT_UShort metric_id,
FT_Pos* metric_value,
void* data );
struct TTO_GPOSHeader_
{
FT_Memory memory;
FT_Fixed Version;
TTO_ScriptList ScriptList;
TTO_FeatureList FeatureList;
TTO_LookupList LookupList;
TTO_GDEFHeader* gdef;
/* the next field is used for a callback function to get the
glyph outline. */
TTO_GlyphFunction gfunc;
/* this is OpenType 1.2 -- Multiple Master fonts need this
callback function to get various metric values from the
PostScript interpreter. */
TTO_MMFunction mmfunc;
void* data;
};
typedef struct TTO_GPOSHeader_ TTO_GPOSHeader;
typedef struct TTO_GPOSHeader_* TTO_GPOS;
/* shared tables */
struct TTO_ValueRecord_
{
FT_Short XPlacement; /* horizontal adjustment for
placement */
FT_Short YPlacement; /* vertical adjustment for
placement */
FT_Short XAdvance; /* horizontal adjustment for
advance */
FT_Short YAdvance; /* vertical adjustment for
advance */
TTO_Device XPlacementDevice; /* device table for horizontal
placement */
TTO_Device YPlacementDevice; /* device table for vertical
placement */
TTO_Device XAdvanceDevice; /* device table for horizontal
advance */
TTO_Device YAdvanceDevice; /* device table for vertical
advance */
FT_UShort XIdPlacement; /* horizontal placement metric ID */
FT_UShort YIdPlacement; /* vertical placement metric ID */
FT_UShort XIdAdvance; /* horizontal advance metric ID */
FT_UShort YIdAdvance; /* vertical advance metric ID */
};
typedef struct TTO_ValueRecord_ TTO_ValueRecord;
/* Mask values to scan the value format of the ValueRecord structure.
We always expand compressed ValueRecords of the font. */
#define HAVE_X_PLACEMENT 0x0001
#define HAVE_Y_PLACEMENT 0x0002
#define HAVE_X_ADVANCE 0x0004
#define HAVE_Y_ADVANCE 0x0008
#define HAVE_X_PLACEMENT_DEVICE 0x0010
#define HAVE_Y_PLACEMENT_DEVICE 0x0020
#define HAVE_X_ADVANCE_DEVICE 0x0040
#define HAVE_Y_ADVANCE_DEVICE 0x0080
#define HAVE_X_ID_PLACEMENT 0x0100
#define HAVE_Y_ID_PLACEMENT 0x0200
#define HAVE_X_ID_ADVANCE 0x0400
#define HAVE_Y_ID_ADVANCE 0x0800
struct TTO_AnchorFormat1_
{
FT_Short XCoordinate; /* horizontal value */
FT_Short YCoordinate; /* vertical value */
};
typedef struct TTO_AnchorFormat1_ TTO_AnchorFormat1;
struct TTO_AnchorFormat2_
{
FT_Short XCoordinate; /* horizontal value */
FT_Short YCoordinate; /* vertical value */
FT_UShort AnchorPoint; /* index to glyph contour point */
};
typedef struct TTO_AnchorFormat2_ TTO_AnchorFormat2;
struct TTO_AnchorFormat3_
{
FT_Short XCoordinate; /* horizontal value */
FT_Short YCoordinate; /* vertical value */
TTO_Device XDeviceTable; /* device table for X coordinate */
TTO_Device YDeviceTable; /* device table for Y coordinate */
};
typedef struct TTO_AnchorFormat3_ TTO_AnchorFormat3;
struct TTO_AnchorFormat4_
{
FT_UShort XIdAnchor; /* horizontal metric ID */
FT_UShort YIdAnchor; /* vertical metric ID */
};
typedef struct TTO_AnchorFormat4_ TTO_AnchorFormat4;
struct TTO_Anchor_
{
FT_UShort PosFormat; /* 1, 2, 3, or 4 -- 0 indicates
that there is no Anchor table */
union
{
TTO_AnchorFormat1 af1;
TTO_AnchorFormat2 af2;
TTO_AnchorFormat3 af3;
TTO_AnchorFormat4 af4;
} af;
};
typedef struct TTO_Anchor_ TTO_Anchor;
struct TTO_MarkRecord_
{
FT_UShort Class; /* mark class */
TTO_Anchor MarkAnchor; /* anchor table */
};
typedef struct TTO_MarkRecord_ TTO_MarkRecord;
struct TTO_MarkArray_
{
FT_UShort MarkCount; /* number of MarkRecord tables */
TTO_MarkRecord* MarkRecord; /* array of MarkRecord tables */
};
typedef struct TTO_MarkArray_ TTO_MarkArray;
/* LookupType 1 */
struct TTO_SinglePosFormat1_
{
TTO_ValueRecord Value; /* ValueRecord for all covered
glyphs */
};
typedef struct TTO_SinglePosFormat1_ TTO_SinglePosFormat1;
struct TTO_SinglePosFormat2_
{
FT_UShort ValueCount; /* number of ValueRecord tables */
TTO_ValueRecord* Value; /* array of ValueRecord tables */
};
typedef struct TTO_SinglePosFormat2_ TTO_SinglePosFormat2;
struct TTO_SinglePos_
{
FT_UShort PosFormat; /* 1 or 2 */
TTO_Coverage Coverage; /* Coverage table */
FT_UShort ValueFormat; /* format of ValueRecord table */
union
{
TTO_SinglePosFormat1 spf1;
TTO_SinglePosFormat2 spf2;
} spf;
};
typedef struct TTO_SinglePos_ TTO_SinglePos;
/* LookupType 2 */
struct TTO_PairValueRecord_
{
FT_UShort SecondGlyph; /* glyph ID for second glyph */
TTO_ValueRecord Value1; /* pos. data for first glyph */
TTO_ValueRecord Value2; /* pos. data for second glyph */
};
typedef struct TTO_PairValueRecord_ TTO_PairValueRecord;
struct TTO_PairSet_
{
FT_UShort PairValueCount;
/* number of PairValueRecord tables */
TTO_PairValueRecord* PairValueRecord;
/* array of PairValueRecord tables */
};
typedef struct TTO_PairSet_ TTO_PairSet;
struct TTO_PairPosFormat1_
{
FT_UShort PairSetCount; /* number of PairSet tables */
TTO_PairSet* PairSet; /* array of PairSet tables */
};
typedef struct TTO_PairPosFormat1_ TTO_PairPosFormat1;
struct TTO_Class2Record_
{
TTO_ValueRecord Value1; /* pos. data for first glyph */
TTO_ValueRecord Value2; /* pos. data for second glyph */
};
typedef struct TTO_Class2Record_ TTO_Class2Record;
struct TTO_Class1Record_
{
TTO_Class2Record* Class2Record; /* array of Class2Record tables */
};
typedef struct TTO_Class1Record_ TTO_Class1Record;
struct TTO_PairPosFormat2_
{
TTO_ClassDefinition ClassDef1; /* class def. for first glyph */
TTO_ClassDefinition ClassDef2; /* class def. for second glyph */
FT_UShort Class1Count; /* number of classes in ClassDef1
table */
FT_UShort Class2Count; /* number of classes in ClassDef2
table */
TTO_Class1Record* Class1Record; /* array of Class1Record tables */
};
typedef struct TTO_PairPosFormat2_ TTO_PairPosFormat2;
struct TTO_PairPos_
{
FT_UShort PosFormat; /* 1 or 2 */
TTO_Coverage Coverage; /* Coverage table */
FT_UShort ValueFormat1; /* format of ValueRecord table
for first glyph */
FT_UShort ValueFormat2; /* format of ValueRecord table
for second glyph */
union
{
TTO_PairPosFormat1 ppf1;
TTO_PairPosFormat2 ppf2;
} ppf;
};
typedef struct TTO_PairPos_ TTO_PairPos;
/* LookupType 3 */
struct TTO_EntryExitRecord_
{
TTO_Anchor EntryAnchor; /* entry Anchor table */
TTO_Anchor ExitAnchor; /* exit Anchor table */
};
typedef struct TTO_EntryExitRecord_ TTO_EntryExitRecord;
struct TTO_CursivePos_
{
FT_UShort PosFormat; /* always 1 */
TTO_Coverage Coverage; /* Coverage table */
FT_UShort EntryExitCount;
/* number of EntryExitRecord tables */
TTO_EntryExitRecord* EntryExitRecord;
/* array of EntryExitRecord tables */
};
typedef struct TTO_CursivePos_ TTO_CursivePos;
/* LookupType 4 */
struct TTO_BaseRecord_
{
TTO_Anchor* BaseAnchor; /* array of base glyph anchor
tables */
};
typedef struct TTO_BaseRecord_ TTO_BaseRecord;
struct TTO_BaseArray_
{
FT_UShort BaseCount; /* number of BaseRecord tables */
TTO_BaseRecord* BaseRecord; /* array of BaseRecord tables */
};
typedef struct TTO_BaseArray_ TTO_BaseArray;
struct TTO_MarkBasePos_
{
FT_UShort PosFormat; /* always 1 */
TTO_Coverage MarkCoverage; /* mark glyph coverage table */
TTO_Coverage BaseCoverage; /* base glyph coverage table */
FT_UShort ClassCount; /* number of mark classes */
TTO_MarkArray MarkArray; /* mark array table */
TTO_BaseArray BaseArray; /* base array table */
};
typedef struct TTO_MarkBasePos_ TTO_MarkBasePos;
/* LookupType 5 */
struct TTO_ComponentRecord_
{
TTO_Anchor* LigatureAnchor; /* array of ligature glyph anchor
tables */
};
typedef struct TTO_ComponentRecord_ TTO_ComponentRecord;
struct TTO_LigatureAttach_
{
FT_UShort ComponentCount;
/* number of ComponentRecord tables */
TTO_ComponentRecord* ComponentRecord;
/* array of ComponentRecord tables */
};
typedef struct TTO_LigatureAttach_ TTO_LigatureAttach;
struct TTO_LigatureArray_
{
FT_UShort LigatureCount; /* number of LigatureAttach tables */
TTO_LigatureAttach* LigatureAttach;
/* array of LigatureAttach tables */
};
typedef struct TTO_LigatureArray_ TTO_LigatureArray;
struct TTO_MarkLigPos_
{
FT_UShort PosFormat; /* always 1 */
TTO_Coverage MarkCoverage; /* mark glyph coverage table */
TTO_Coverage LigatureCoverage;
/* ligature glyph coverage table */
FT_UShort ClassCount; /* number of mark classes */
TTO_MarkArray MarkArray; /* mark array table */
TTO_LigatureArray LigatureArray; /* ligature array table */
};
typedef struct TTO_MarkLigPos_ TTO_MarkLigPos;
/* LookupType 6 */
struct TTO_Mark2Record_
{
TTO_Anchor* Mark2Anchor; /* array of mark glyph anchor
tables */
};
typedef struct TTO_Mark2Record_ TTO_Mark2Record;
struct TTO_Mark2Array_
{
FT_UShort Mark2Count; /* number of Mark2Record tables */
TTO_Mark2Record* Mark2Record; /* array of Mark2Record tables */
};
typedef struct TTO_Mark2Array_ TTO_Mark2Array;
struct TTO_MarkMarkPos_
{
FT_UShort PosFormat; /* always 1 */
TTO_Coverage Mark1Coverage; /* first mark glyph coverage table */
TTO_Coverage Mark2Coverage; /* second mark glyph coverave table */
FT_UShort ClassCount; /* number of combining mark classes */
TTO_MarkArray Mark1Array; /* MarkArray table for first mark */
TTO_Mark2Array Mark2Array; /* MarkArray table for second mark */
};
typedef struct TTO_MarkMarkPos_ TTO_MarkMarkPos;
/* needed by both lookup type 7 and 8 */
struct TTO_PosLookupRecord_
{
FT_UShort SequenceIndex; /* index into current
glyph sequence */
FT_UShort LookupListIndex; /* Lookup to apply to that pos. */
};
typedef struct TTO_PosLookupRecord_ TTO_PosLookupRecord;
/* LookupType 7 */
struct TTO_PosRule_
{
FT_UShort GlyphCount; /* total number of input glyphs */
FT_UShort PosCount; /* number of PosLookupRecord tables */
FT_UShort* Input; /* array of input glyph IDs */
TTO_PosLookupRecord* PosLookupRecord;
/* array of PosLookupRecord tables */
};
typedef struct TTO_PosRule_ TTO_PosRule;
struct TTO_PosRuleSet_
{
FT_UShort PosRuleCount; /* number of PosRule tables */
TTO_PosRule* PosRule; /* array of PosRule tables */
};
typedef struct TTO_PosRuleSet_ TTO_PosRuleSet;
struct TTO_ContextPosFormat1_
{
TTO_Coverage Coverage; /* Coverage table */
FT_UShort PosRuleSetCount; /* number of PosRuleSet tables */
TTO_PosRuleSet* PosRuleSet; /* array of PosRuleSet tables */
};
typedef struct TTO_ContextPosFormat1_ TTO_ContextPosFormat1;
struct TTO_PosClassRule_
{
FT_UShort GlyphCount; /* total number of context classes */
FT_UShort PosCount; /* number of PosLookupRecord tables */
FT_UShort* Class; /* array of classes */
TTO_PosLookupRecord* PosLookupRecord;
/* array of PosLookupRecord tables */
};
typedef struct TTO_PosClassRule_ TTO_PosClassRule;
struct TTO_PosClassSet_
{
FT_UShort PosClassRuleCount;
/* number of PosClassRule tables */
TTO_PosClassRule* PosClassRule; /* array of PosClassRule tables */
};
typedef struct TTO_PosClassSet_ TTO_PosClassSet;
/* The `MaxContextLength' field is not defined in the TTO specification
but simplifies the implementation of this format. It holds the
maximal context length used in the context rules. */
struct TTO_ContextPosFormat2_
{
FT_UShort MaxContextLength;
/* maximal context length */
TTO_Coverage Coverage; /* Coverage table */
TTO_ClassDefinition ClassDef; /* ClassDef table */
FT_UShort PosClassSetCount;
/* number of PosClassSet tables */
TTO_PosClassSet* PosClassSet; /* array of PosClassSet tables */
};
typedef struct TTO_ContextPosFormat2_ TTO_ContextPosFormat2;
struct TTO_ContextPosFormat3_
{
FT_UShort GlyphCount; /* number of input glyphs */
FT_UShort PosCount; /* number of PosLookupRecord tables */
TTO_Coverage* Coverage; /* array of Coverage tables */
TTO_PosLookupRecord* PosLookupRecord;
/* array of PosLookupRecord tables */
};
typedef struct TTO_ContextPosFormat3_ TTO_ContextPosFormat3;
struct TTO_ContextPos_
{
FT_UShort PosFormat; /* 1, 2, or 3 */
union
{
TTO_ContextPosFormat1 cpf1;
TTO_ContextPosFormat2 cpf2;
TTO_ContextPosFormat3 cpf3;
} cpf;
};
typedef struct TTO_ContextPos_ TTO_ContextPos;
/* LookupType 8 */
struct TTO_ChainPosRule_
{
FT_UShort BacktrackGlyphCount;
/* total number of backtrack glyphs */
FT_UShort* Backtrack; /* array of backtrack glyph IDs */
FT_UShort InputGlyphCount;
/* total number of input glyphs */
FT_UShort* Input; /* array of input glyph IDs */
FT_UShort LookaheadGlyphCount;
/* total number of lookahead glyphs */
FT_UShort* Lookahead; /* array of lookahead glyph IDs */
FT_UShort PosCount; /* number of PosLookupRecords */
TTO_PosLookupRecord* PosLookupRecord;
/* array of PosLookupRecords */
};
typedef struct TTO_ChainPosRule_ TTO_ChainPosRule;
struct TTO_ChainPosRuleSet_
{
FT_UShort ChainPosRuleCount;
/* number of ChainPosRule tables */
TTO_ChainPosRule* ChainPosRule; /* array of ChainPosRule tables */
};
typedef struct TTO_ChainPosRuleSet_ TTO_ChainPosRuleSet;
struct TTO_ChainContextPosFormat1_
{
TTO_Coverage Coverage; /* Coverage table */
FT_UShort ChainPosRuleSetCount;
/* number of ChainPosRuleSet tables */
TTO_ChainPosRuleSet* ChainPosRuleSet;
/* array of ChainPosRuleSet tables */
};
typedef struct TTO_ChainContextPosFormat1_ TTO_ChainContextPosFormat1;
struct TTO_ChainPosClassRule_
{
FT_UShort BacktrackGlyphCount;
/* total number of backtrack
classes */
FT_UShort* Backtrack; /* array of backtrack classes */
FT_UShort InputGlyphCount;
/* total number of context classes */
FT_UShort* Input; /* array of context classes */
FT_UShort LookaheadGlyphCount;
/* total number of lookahead
classes */
FT_UShort* Lookahead; /* array of lookahead classes */
FT_UShort PosCount; /* number of PosLookupRecords */
TTO_PosLookupRecord* PosLookupRecord;
/* array of substitution lookups */
};
typedef struct TTO_ChainPosClassRule_ TTO_ChainPosClassRule;
struct TTO_ChainPosClassSet_
{
FT_UShort ChainPosClassRuleCount;
/* number of ChainPosClassRule
tables */
TTO_ChainPosClassRule* ChainPosClassRule;
/* array of ChainPosClassRule
tables */
};
typedef struct TTO_ChainPosClassSet_ TTO_ChainPosClassSet;
/* The `MaxXXXLength' fields are not defined in the TTO specification
but simplifies the implementation of this format. It holds the
maximal context length used in the specific context rules. */
struct TTO_ChainContextPosFormat2_
{
TTO_Coverage Coverage; /* Coverage table */
FT_UShort MaxBacktrackLength;
/* maximal backtrack length */
TTO_ClassDefinition BacktrackClassDef;
/* BacktrackClassDef table */
FT_UShort MaxInputLength;
/* maximal input length */
TTO_ClassDefinition InputClassDef;
/* InputClassDef table */
FT_UShort MaxLookaheadLength;
/* maximal lookahead length */
TTO_ClassDefinition LookaheadClassDef;
/* LookaheadClassDef table */
FT_UShort ChainPosClassSetCount;
/* number of ChainPosClassSet
tables */
TTO_ChainPosClassSet* ChainPosClassSet;
/* array of ChainPosClassSet
tables */
};
typedef struct TTO_ChainContextPosFormat2_ TTO_ChainContextPosFormat2;
struct TTO_ChainContextPosFormat3_
{
FT_UShort BacktrackGlyphCount;
/* number of backtrack glyphs */
TTO_Coverage* BacktrackCoverage;
/* array of backtrack Coverage
tables */
FT_UShort InputGlyphCount;
/* number of input glyphs */
TTO_Coverage* InputCoverage;
/* array of input coverage
tables */
FT_UShort LookaheadGlyphCount;
/* number of lookahead glyphs */
TTO_Coverage* LookaheadCoverage;
/* array of lookahead coverage
tables */
FT_UShort PosCount; /* number of PosLookupRecords */
TTO_PosLookupRecord* PosLookupRecord;
/* array of substitution lookups */
};
typedef struct TTO_ChainContextPosFormat3_ TTO_ChainContextPosFormat3;
struct TTO_ChainContextPos_
{
FT_UShort PosFormat; /* 1, 2, or 3 */
union
{
TTO_ChainContextPosFormat1 ccpf1;
TTO_ChainContextPosFormat2 ccpf2;
TTO_ChainContextPosFormat3 ccpf3;
} ccpf;
};
typedef struct TTO_ChainContextPos_ TTO_ChainContextPos;
union TTO_GPOS_SubTable_
{
TTO_SinglePos single;
TTO_PairPos pair;
TTO_CursivePos cursive;
TTO_MarkBasePos markbase;
TTO_MarkLigPos marklig;
TTO_MarkMarkPos markmark;
TTO_ContextPos context;
TTO_ChainContextPos chain;
};
typedef union TTO_GPOS_SubTable_ TTO_GPOS_SubTable;
/* finally, the GPOS API */
/* EXPORT_DEF
FT_Export ( FT_Error ) TT_Init_GPOS_Extension( TT_Engine engine ); */
EXPORT_DEF
FT_Error TT_Load_GPOS_Table( FT_Face face,
TTO_GPOSHeader** gpos,
TTO_GDEFHeader* gdef );
EXPORT_DEF
FT_Error TT_Done_GPOS_Table( TTO_GPOSHeader* gpos );
EXPORT_DEF
FT_Error TT_GPOS_Select_Script( TTO_GPOSHeader* gpos,
FT_ULong script_tag,
FT_UShort* script_index );
EXPORT_DEF
FT_Error TT_GPOS_Select_Language( TTO_GPOSHeader* gpos,
FT_ULong language_tag,
FT_UShort script_index,
FT_UShort* language_index,
FT_UShort* req_feature_index );
EXPORT_DEF
FT_Error TT_GPOS_Select_Feature( TTO_GPOSHeader* gpos,
FT_ULong feature_tag,
FT_UShort script_index,
FT_UShort language_index,
FT_UShort* feature_index );
EXPORT_DEF
FT_Error TT_GPOS_Query_Scripts( TTO_GPOSHeader* gpos,
FT_ULong** script_tag_list );
EXPORT_DEF
FT_Error TT_GPOS_Query_Languages( TTO_GPOSHeader* gpos,
FT_UShort script_index,
FT_ULong** language_tag_list );
EXPORT_DEF
FT_Error TT_GPOS_Query_Features( TTO_GPOSHeader* gpos,
FT_UShort script_index,
FT_UShort language_index,
FT_ULong** feature_tag_list );
EXPORT_DEF
FT_Error TT_GPOS_Add_Feature( TTO_GPOSHeader* gpos,
FT_UShort feature_index,
FT_UInt property );
EXPORT_DEF
FT_Error TT_GPOS_Clear_Features( TTO_GPOSHeader* gpos );
EXPORT_DEF
FT_Error TT_GPOS_Register_Glyph_Function( TTO_GPOSHeader* gpos,
TTO_GlyphFunction gfunc );
EXPORT_DEF
FT_Error TT_GPOS_Register_MM_Function( TTO_GPOSHeader* gpos,
TTO_MMFunction mmfunc,
void* data );
/* If `dvi' is TRUE, glyph contour points for anchor points and device
tables are ignored -- you will get device independent values. */
EXPORT_DEF
FT_Error TT_GPOS_Apply_String( FT_Face face,
TTO_GPOSHeader* gpos,
FT_UShort load_flags,
OTL_Buffer buffer,
FT_Bool dvi,
FT_Bool r2l );
#ifdef __cplusplus
}
#endif
#endif /* FTXGPOS_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@ -1,594 +0,0 @@
/*******************************************************************
*
* ftxgsub.h
*
* TrueType Open GSUB table support
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
******************************************************************/
#ifndef FTXOPEN_H
#error "Don't include this file! Use ftxopen.h instead."
#endif
#ifndef FTXGSUB_H
#define FTXGSUB_H
#ifdef __cplusplus
extern "C" {
#endif
#define TTO_Err_Invalid_GSUB_SubTable_Format 0x1010
#define TTO_Err_Invalid_GSUB_SubTable 0x1011
/* Lookup types for glyph substitution */
#define GSUB_LOOKUP_SINGLE 1
#define GSUB_LOOKUP_MULTIPLE 2
#define GSUB_LOOKUP_ALTERNATE 3
#define GSUB_LOOKUP_LIGATURE 4
#define GSUB_LOOKUP_CONTEXT 5
#define GSUB_LOOKUP_CHAIN 6
#define GSUB_LOOKUP_EXTENSION 7
#define GSUB_LOOKUP_REVERSE_CHAIN 8
/* Use this if a feature applies to all glyphs */
#define ALL_GLYPHS 0xFFFF
/* A pointer to a function which selects the alternate glyph. `pos' is
the position of the glyph with index `glyphID', `num_alternates'
gives the number of alternates in the `alternates' array. `data'
points to the user-defined structure specified during a call to
TT_GSUB_Register_Alternate_Function(). The function must return an
index into the `alternates' array. */
typedef FT_UShort (*TTO_AltFunction)(FT_ULong pos,
FT_UShort glyphID,
FT_UShort num_alternates,
FT_UShort* alternates,
void* data );
struct TTO_GSUBHeader_
{
FT_Memory memory;
FT_ULong offset;
FT_Fixed Version;
TTO_ScriptList ScriptList;
TTO_FeatureList FeatureList;
TTO_LookupList LookupList;
TTO_GDEFHeader* gdef;
/* the next two fields are used for an alternate substitution callback
function to select the proper alternate glyph. */
TTO_AltFunction altfunc;
void* data;
};
typedef struct TTO_GSUBHeader_ TTO_GSUBHeader;
typedef struct TTO_GSUBHeader_* TTO_GSUB;
/* LookupType 1 */
struct TTO_SingleSubstFormat1_
{
FT_Short DeltaGlyphID; /* constant added to get
substitution glyph index */
};
typedef struct TTO_SingleSubstFormat1_ TTO_SingleSubstFormat1;
struct TTO_SingleSubstFormat2_
{
FT_UShort GlyphCount; /* number of glyph IDs in
Substitute array */
FT_UShort* Substitute; /* array of substitute glyph IDs */
};
typedef struct TTO_SingleSubstFormat2_ TTO_SingleSubstFormat2;
struct TTO_SingleSubst_
{
FT_UShort SubstFormat; /* 1 or 2 */
TTO_Coverage Coverage; /* Coverage table */
union
{
TTO_SingleSubstFormat1 ssf1;
TTO_SingleSubstFormat2 ssf2;
} ssf;
};
typedef struct TTO_SingleSubst_ TTO_SingleSubst;
/* LookupType 2 */
struct TTO_Sequence_
{
FT_UShort GlyphCount; /* number of glyph IDs in the
Substitute array */
FT_UShort* Substitute; /* string of glyph IDs to
substitute */
};
typedef struct TTO_Sequence_ TTO_Sequence;
struct TTO_MultipleSubst_
{
FT_UShort SubstFormat; /* always 1 */
TTO_Coverage Coverage; /* Coverage table */
FT_UShort SequenceCount; /* number of Sequence tables */
TTO_Sequence* Sequence; /* array of Sequence tables */
};
typedef struct TTO_MultipleSubst_ TTO_MultipleSubst;
/* LookupType 3 */
struct TTO_AlternateSet_
{
FT_UShort GlyphCount; /* number of glyph IDs in the
Alternate array */
FT_UShort* Alternate; /* array of alternate glyph IDs */
};
typedef struct TTO_AlternateSet_ TTO_AlternateSet;
struct TTO_AlternateSubst_
{
FT_UShort SubstFormat; /* always 1 */
TTO_Coverage Coverage; /* Coverage table */
FT_UShort AlternateSetCount;
/* number of AlternateSet tables */
TTO_AlternateSet* AlternateSet; /* array of AlternateSet tables */
};
typedef struct TTO_AlternateSubst_ TTO_AlternateSubst;
/* LookupType 4 */
struct TTO_Ligature_
{
FT_UShort LigGlyph; /* glyphID of ligature
to substitute */
FT_UShort ComponentCount; /* number of components in ligature */
FT_UShort* Component; /* array of component glyph IDs */
};
typedef struct TTO_Ligature_ TTO_Ligature;
struct TTO_LigatureSet_
{
FT_UShort LigatureCount; /* number of Ligature tables */
TTO_Ligature* Ligature; /* array of Ligature tables */
};
typedef struct TTO_LigatureSet_ TTO_LigatureSet;
struct TTO_LigatureSubst_
{
FT_UShort SubstFormat; /* always 1 */
TTO_Coverage Coverage; /* Coverage table */
FT_UShort LigatureSetCount; /* number of LigatureSet tables */
TTO_LigatureSet* LigatureSet; /* array of LigatureSet tables */
};
typedef struct TTO_LigatureSubst_ TTO_LigatureSubst;
/* needed by both lookup type 5 and 6 */
struct TTO_SubstLookupRecord_
{
FT_UShort SequenceIndex; /* index into current
glyph sequence */
FT_UShort LookupListIndex; /* Lookup to apply to that pos. */
};
typedef struct TTO_SubstLookupRecord_ TTO_SubstLookupRecord;
/* LookupType 5 */
struct TTO_SubRule_
{
FT_UShort GlyphCount; /* total number of input glyphs */
FT_UShort SubstCount; /* number of SubstLookupRecord
tables */
FT_UShort* Input; /* array of input glyph IDs */
TTO_SubstLookupRecord* SubstLookupRecord;
/* array of SubstLookupRecord
tables */
};
typedef struct TTO_SubRule_ TTO_SubRule;
struct TTO_SubRuleSet_
{
FT_UShort SubRuleCount; /* number of SubRule tables */
TTO_SubRule* SubRule; /* array of SubRule tables */
};
typedef struct TTO_SubRuleSet_ TTO_SubRuleSet;
struct TTO_ContextSubstFormat1_
{
TTO_Coverage Coverage; /* Coverage table */
FT_UShort SubRuleSetCount; /* number of SubRuleSet tables */
TTO_SubRuleSet* SubRuleSet; /* array of SubRuleSet tables */
};
typedef struct TTO_ContextSubstFormat1_ TTO_ContextSubstFormat1;
struct TTO_SubClassRule_
{
FT_UShort GlyphCount; /* total number of context classes */
FT_UShort SubstCount; /* number of SubstLookupRecord
tables */
FT_UShort* Class; /* array of classes */
TTO_SubstLookupRecord* SubstLookupRecord;
/* array of SubstLookupRecord
tables */
};
typedef struct TTO_SubClassRule_ TTO_SubClassRule;
struct TTO_SubClassSet_
{
FT_UShort SubClassRuleCount;
/* number of SubClassRule tables */
TTO_SubClassRule* SubClassRule; /* array of SubClassRule tables */
};
typedef struct TTO_SubClassSet_ TTO_SubClassSet;
/* The `MaxContextLength' field is not defined in the TTO specification
but simplifies the implementation of this format. It holds the
maximal context length used in the context rules. */
struct TTO_ContextSubstFormat2_
{
FT_UShort MaxContextLength;
/* maximal context length */
TTO_Coverage Coverage; /* Coverage table */
TTO_ClassDefinition ClassDef; /* ClassDef table */
FT_UShort SubClassSetCount;
/* number of SubClassSet tables */
TTO_SubClassSet* SubClassSet; /* array of SubClassSet tables */
};
typedef struct TTO_ContextSubstFormat2_ TTO_ContextSubstFormat2;
struct TTO_ContextSubstFormat3_
{
FT_UShort GlyphCount; /* number of input glyphs */
FT_UShort SubstCount; /* number of SubstLookupRecords */
TTO_Coverage* Coverage; /* array of Coverage tables */
TTO_SubstLookupRecord* SubstLookupRecord;
/* array of substitution lookups */
};
typedef struct TTO_ContextSubstFormat3_ TTO_ContextSubstFormat3;
struct TTO_ContextSubst_
{
FT_UShort SubstFormat; /* 1, 2, or 3 */
union
{
TTO_ContextSubstFormat1 csf1;
TTO_ContextSubstFormat2 csf2;
TTO_ContextSubstFormat3 csf3;
} csf;
};
typedef struct TTO_ContextSubst_ TTO_ContextSubst;
/* LookupType 6 */
struct TTO_ChainSubRule_
{
FT_UShort BacktrackGlyphCount;
/* total number of backtrack glyphs */
FT_UShort* Backtrack; /* array of backtrack glyph IDs */
FT_UShort InputGlyphCount;
/* total number of input glyphs */
FT_UShort* Input; /* array of input glyph IDs */
FT_UShort LookaheadGlyphCount;
/* total number of lookahead glyphs */
FT_UShort* Lookahead; /* array of lookahead glyph IDs */
FT_UShort SubstCount; /* number of SubstLookupRecords */
TTO_SubstLookupRecord* SubstLookupRecord;
/* array of SubstLookupRecords */
};
typedef struct TTO_ChainSubRule_ TTO_ChainSubRule;
struct TTO_ChainSubRuleSet_
{
FT_UShort ChainSubRuleCount;
/* number of ChainSubRule tables */
TTO_ChainSubRule* ChainSubRule; /* array of ChainSubRule tables */
};
typedef struct TTO_ChainSubRuleSet_ TTO_ChainSubRuleSet;
struct TTO_ChainContextSubstFormat1_
{
TTO_Coverage Coverage; /* Coverage table */
FT_UShort ChainSubRuleSetCount;
/* number of ChainSubRuleSet tables */
TTO_ChainSubRuleSet* ChainSubRuleSet;
/* array of ChainSubRuleSet tables */
};
typedef struct TTO_ChainContextSubstFormat1_ TTO_ChainContextSubstFormat1;
struct TTO_ChainSubClassRule_
{
FT_UShort BacktrackGlyphCount;
/* total number of backtrack
classes */
FT_UShort* Backtrack; /* array of backtrack classes */
FT_UShort InputGlyphCount;
/* total number of context classes */
FT_UShort* Input; /* array of context classes */
FT_UShort LookaheadGlyphCount;
/* total number of lookahead
classes */
FT_UShort* Lookahead; /* array of lookahead classes */
FT_UShort SubstCount; /* number of SubstLookupRecords */
TTO_SubstLookupRecord* SubstLookupRecord;
/* array of substitution lookups */
};
typedef struct TTO_ChainSubClassRule_ TTO_ChainSubClassRule;
struct TTO_ChainSubClassSet_
{
FT_UShort ChainSubClassRuleCount;
/* number of ChainSubClassRule
tables */
TTO_ChainSubClassRule* ChainSubClassRule;
/* array of ChainSubClassRule
tables */
};
typedef struct TTO_ChainSubClassSet_ TTO_ChainSubClassSet;
/* The `MaxXXXLength' fields are not defined in the TTO specification
but simplifies the implementation of this format. It holds the
maximal context length used in the specific context rules. */
struct TTO_ChainContextSubstFormat2_
{
TTO_Coverage Coverage; /* Coverage table */
FT_UShort MaxBacktrackLength;
/* maximal backtrack length */
TTO_ClassDefinition BacktrackClassDef;
/* BacktrackClassDef table */
FT_UShort MaxInputLength;
/* maximal input length */
TTO_ClassDefinition InputClassDef;
/* InputClassDef table */
FT_UShort MaxLookaheadLength;
/* maximal lookahead length */
TTO_ClassDefinition LookaheadClassDef;
/* LookaheadClassDef table */
FT_UShort ChainSubClassSetCount;
/* number of ChainSubClassSet
tables */
TTO_ChainSubClassSet* ChainSubClassSet;
/* array of ChainSubClassSet
tables */
};
typedef struct TTO_ChainContextSubstFormat2_ TTO_ChainContextSubstFormat2;
struct TTO_ChainContextSubstFormat3_
{
FT_UShort BacktrackGlyphCount;
/* number of backtrack glyphs */
TTO_Coverage* BacktrackCoverage;
/* array of backtrack Coverage
tables */
FT_UShort InputGlyphCount;
/* number of input glyphs */
TTO_Coverage* InputCoverage;
/* array of input coverage
tables */
FT_UShort LookaheadGlyphCount;
/* number of lookahead glyphs */
TTO_Coverage* LookaheadCoverage;
/* array of lookahead coverage
tables */
FT_UShort SubstCount; /* number of SubstLookupRecords */
TTO_SubstLookupRecord* SubstLookupRecord;
/* array of substitution lookups */
};
typedef struct TTO_ChainContextSubstFormat3_ TTO_ChainContextSubstFormat3;
struct TTO_ChainContextSubst_
{
FT_UShort SubstFormat; /* 1, 2, or 3 */
union
{
TTO_ChainContextSubstFormat1 ccsf1;
TTO_ChainContextSubstFormat2 ccsf2;
TTO_ChainContextSubstFormat3 ccsf3;
} ccsf;
};
typedef struct TTO_ChainContextSubst_ TTO_ChainContextSubst;
/* LookupType 8 */
struct TTO_ReverseChainContextSubst_
{
FT_UShort SubstFormat; /* always 1 */
TTO_Coverage Coverage; /* coverage table for input glyphs */
FT_UShort BacktrackGlyphCount; /* number of backtrack glyphs */
TTO_Coverage* BacktrackCoverage; /* array of backtrack Coverage
tables */
FT_UShort LookaheadGlyphCount; /* number of lookahead glyphs */
TTO_Coverage* LookaheadCoverage; /* array of lookahead Coverage
tables */
FT_UShort GlyphCount; /* number of Glyph IDs */
FT_UShort* Substitute; /* array of substitute Glyph ID */
};
typedef struct TTO_ReverseChainContextSubst_ TTO_ReverseChainContextSubst;
union TTO_GSUB_SubTable_
{
TTO_SingleSubst single;
TTO_MultipleSubst multiple;
TTO_AlternateSubst alternate;
TTO_LigatureSubst ligature;
TTO_ContextSubst context;
TTO_ChainContextSubst chain;
TTO_ReverseChainContextSubst reverse;
};
typedef union TTO_GSUB_SubTable_ TTO_GSUB_SubTable;
/* A simple string object. It can both `send' and `receive' data.
In case of sending, `length' and `pos' will be used. In case of
receiving, `pos' points to the first free slot, and `allocated'
specifies the amount of allocated memory (and the `length' field
will be ignored). The routine TT_Add_String() will increase the
amount of memory if necessary. After end of receive, `length'
should be set to the value of `pos', and `pos' will be set to zero.
`properties' (which is treated as a bit field) gives the glyph's
properties: If a certain bit is set for a glyph, the feature which
has the same bit set in its property value is applied.
`components' is an internal array which tracks components of
ligatures. We need this for MarkToLigature Attachment Positioning
Subtables (in GPOS) together with `ligIDs' (which is used to mark
ligatures and the skipped glyphs during a ligature lookup).
`max_ligID' is increased after a successful ligature lookup.
NEVER modify any elements of the structure! You should rather copy
its contents if necessary.
TT_Add_String() will also handle allocation; you should use
free() in case you want to destroy the arrays in the object. */
/* finally, the GSUB API */
/* EXPORT_DEF
TT_Error TT_Init_GSUB_Extension( TT_Engine engine ); */
EXPORT_DEF
FT_Error TT_Load_GSUB_Table( FT_Face face,
TTO_GSUBHeader** gsub,
TTO_GDEFHeader* gdef );
EXPORT_DEF
FT_Error TT_Done_GSUB_Table( TTO_GSUBHeader* gsub );
EXPORT_DEF
FT_Error TT_GSUB_Select_Script( TTO_GSUBHeader* gsub,
FT_ULong script_tag,
FT_UShort* script_index );
EXPORT_DEF
FT_Error TT_GSUB_Select_Language( TTO_GSUBHeader* gsub,
FT_ULong language_tag,
FT_UShort script_index,
FT_UShort* language_index,
FT_UShort* req_feature_index );
EXPORT_DEF
FT_Error TT_GSUB_Select_Feature( TTO_GSUBHeader* gsub,
FT_ULong feature_tag,
FT_UShort script_index,
FT_UShort language_index,
FT_UShort* feature_index );
EXPORT_DEF
FT_Error TT_GSUB_Query_Scripts( TTO_GSUBHeader* gsub,
FT_ULong** script_tag_list );
EXPORT_DEF
FT_Error TT_GSUB_Query_Languages( TTO_GSUBHeader* gsub,
FT_UShort script_index,
FT_ULong** language_tag_list );
EXPORT_DEF
FT_Error TT_GSUB_Query_Features( TTO_GSUBHeader* gsub,
FT_UShort script_index,
FT_UShort language_index,
FT_ULong** feature_tag_list );
EXPORT_DEF
FT_Error TT_GSUB_Add_Feature( TTO_GSUBHeader* gsub,
FT_UShort feature_index,
FT_UInt property );
EXPORT_DEF
FT_Error TT_GSUB_Clear_Features( TTO_GSUBHeader* gsub );
EXPORT_DEF
FT_Error TT_GSUB_Register_Alternate_Function( TTO_GSUBHeader* gsub,
TTO_AltFunction altfunc,
void* data );
EXPORT_DEF
FT_Error TT_GSUB_Apply_String( TTO_GSUBHeader* gsub,
OTL_Buffer buffer );
#ifdef __cplusplus
}
#endif
#endif /* FTXGSUB_H */
/* END */

File diff suppressed because it is too large Load Diff

View File

@ -1,317 +0,0 @@
/*******************************************************************
*
* ftxopen.h
*
* TrueType Open support.
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
* This file should be included by the application. Nevertheless,
* the table specific APIs (and structures) are located in files like
* ftxgsub.h or ftxgpos.h; these header files are read by ftxopen.h .
*
******************************************************************/
#ifndef FTXOPEN_H
#define FTXOPEN_H
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef __cplusplus
extern "C" {
#endif
#define EXPORT_DEF
#define EXPORT_FUNC
#define TTO_MAX_NESTING_LEVEL 100
#define TTO_Err_Invalid_SubTable_Format 0x1000
#define TTO_Err_Invalid_SubTable 0x1001
#define TTO_Err_Not_Covered 0x1002
#define TTO_Err_Too_Many_Nested_Contexts 0x1003
#define TTO_Err_No_MM_Interpreter 0x1004
#define TTO_Err_Empty_Script 0x1005
/* Script list related structures */
struct TTO_LangSys_
{
FT_UShort LookupOrderOffset; /* always 0 for TT Open 1.0 */
FT_UShort ReqFeatureIndex; /* required FeatureIndex */
FT_UShort FeatureCount; /* number of Feature indices */
FT_UShort* FeatureIndex; /* array of Feature indices */
};
typedef struct TTO_LangSys_ TTO_LangSys;
struct TTO_LangSysRecord_
{
FT_ULong LangSysTag; /* LangSysTag identifier */
TTO_LangSys LangSys; /* LangSys table */
};
typedef struct TTO_LangSysRecord_ TTO_LangSysRecord;
struct TTO_Script_
{
TTO_LangSys DefaultLangSys; /* DefaultLangSys table */
FT_UShort LangSysCount; /* number of LangSysRecords */
TTO_LangSysRecord* LangSysRecord; /* array of LangSysRecords */
};
typedef struct TTO_Script_ TTO_Script;
struct TTO_ScriptRecord_
{
FT_ULong ScriptTag; /* ScriptTag identifier */
TTO_Script Script; /* Script table */
};
typedef struct TTO_ScriptRecord_ TTO_ScriptRecord;
struct TTO_ScriptList_
{
FT_UShort ScriptCount; /* number of ScriptRecords */
TTO_ScriptRecord* ScriptRecord; /* array of ScriptRecords */
};
typedef struct TTO_ScriptList_ TTO_ScriptList;
/* Feature list related structures */
struct TTO_Feature_
{
FT_UShort FeatureParams; /* always 0 for TT Open 1.0 */
FT_UShort LookupListCount; /* number of LookupList indices */
FT_UShort* LookupListIndex; /* array of LookupList indices */
};
typedef struct TTO_Feature_ TTO_Feature;
struct TTO_FeatureRecord_
{
FT_ULong FeatureTag; /* FeatureTag identifier */
TTO_Feature Feature; /* Feature table */
};
typedef struct TTO_FeatureRecord_ TTO_FeatureRecord;
struct TTO_FeatureList_
{
FT_UShort FeatureCount; /* number of FeatureRecords */
TTO_FeatureRecord* FeatureRecord; /* array of FeatureRecords */
FT_UShort* ApplyOrder; /* order to apply features */
FT_UShort ApplyCount; /* number of elements in ApplyOrder */
};
typedef struct TTO_FeatureList_ TTO_FeatureList;
/* Lookup list related structures */
struct TTO_SubTable_; /* defined below after inclusion
of ftxgsub.h and ftxgpos.h */
typedef struct TTO_SubTable_ TTO_SubTable;
struct TTO_Lookup_
{
FT_UShort LookupType; /* Lookup type */
FT_UShort LookupFlag; /* Lookup qualifiers */
FT_UShort SubTableCount; /* number of SubTables */
TTO_SubTable* SubTable; /* array of SubTables */
};
typedef struct TTO_Lookup_ TTO_Lookup;
/* The `Properties' field is not defined in the TTO specification but
is needed for processing lookups. If properties[n] is > 0, the
functions TT_GSUB_Apply_String() resp. TT_GPOS_Apply_String() will
process Lookup[n] for glyphs which have the specific bit not set in
the `properties' field of the input string object. */
struct TTO_LookupList_
{
FT_UShort LookupCount; /* number of Lookups */
TTO_Lookup* Lookup; /* array of Lookup records */
FT_UInt* Properties; /* array of flags */
};
typedef struct TTO_LookupList_ TTO_LookupList;
/* Possible LookupFlag bit masks. `IGNORE_SPECIAL_MARKS' comes from the
OpenType 1.2 specification; RIGHT_TO_LEFT has been (re)introduced in
OpenType 1.3 -- if set, the last glyph in a cursive attachment
sequence has to be positioned on the baseline -- regardless of the
writing direction. */
#define RIGHT_TO_LEFT 0x0001
#define IGNORE_BASE_GLYPHS 0x0002
#define IGNORE_LIGATURES 0x0004
#define IGNORE_MARKS 0x0008
#define IGNORE_SPECIAL_MARKS 0xFF00
struct TTO_CoverageFormat1_
{
FT_UShort GlyphCount; /* number of glyphs in GlyphArray */
FT_UShort* GlyphArray; /* array of glyph IDs */
};
typedef struct TTO_CoverageFormat1_ TTO_CoverageFormat1;
struct TTO_RangeRecord_
{
FT_UShort Start; /* first glyph ID in the range */
FT_UShort End; /* last glyph ID in the range */
FT_UShort StartCoverageIndex; /* coverage index of first
glyph ID in the range */
};
typedef struct TTO_RangeRecord_ TTO_RangeRecord;
struct TTO_CoverageFormat2_
{
FT_UShort RangeCount; /* number of RangeRecords */
TTO_RangeRecord* RangeRecord; /* array of RangeRecords */
};
typedef struct TTO_CoverageFormat2_ TTO_CoverageFormat2;
struct TTO_Coverage_
{
FT_UShort CoverageFormat; /* 1 or 2 */
union
{
TTO_CoverageFormat1 cf1;
TTO_CoverageFormat2 cf2;
} cf;
};
typedef struct TTO_Coverage_ TTO_Coverage;
struct TTO_ClassDefFormat1_
{
FT_UShort StartGlyph; /* first glyph ID of the
ClassValueArray */
FT_UShort GlyphCount; /* size of the ClassValueArray */
FT_UShort* ClassValueArray; /* array of class values */
};
typedef struct TTO_ClassDefFormat1_ TTO_ClassDefFormat1;
struct TTO_ClassRangeRecord_
{
FT_UShort Start; /* first glyph ID in the range */
FT_UShort End; /* last glyph ID in the range */
FT_UShort Class; /* applied to all glyphs in range */
};
typedef struct TTO_ClassRangeRecord_ TTO_ClassRangeRecord;
struct TTO_ClassDefFormat2_
{
FT_UShort ClassRangeCount;
/* number of ClassRangeRecords */
TTO_ClassRangeRecord* ClassRangeRecord;
/* array of ClassRangeRecords */
};
typedef struct TTO_ClassDefFormat2_ TTO_ClassDefFormat2;
/* The `Defined' field is not defined in the TTO specification but
apparently needed for processing fonts like trado.ttf: This font
refers to a class which contains not a single element. We map such
classes to class 0. */
struct TTO_ClassDefinition_
{
FT_Bool loaded;
FT_Bool* Defined; /* array of Booleans.
If Defined[n] is FALSE,
class n contains no glyphs. */
FT_UShort ClassFormat; /* 1 or 2 */
union
{
TTO_ClassDefFormat1 cd1;
TTO_ClassDefFormat2 cd2;
} cd;
};
typedef struct TTO_ClassDefinition_ TTO_ClassDefinition;
struct TTO_Device_
{
FT_UShort StartSize; /* smallest size to correct */
FT_UShort EndSize; /* largest size to correct */
FT_UShort DeltaFormat; /* DeltaValue array data format:
1, 2, or 3 */
FT_UShort* DeltaValue; /* array of compressed data */
};
typedef struct TTO_Device_ TTO_Device;
#include "otlbuffer.h"
#include "ftxgdef.h"
#include "ftxgsub.h"
#include "ftxgpos.h"
struct TTO_SubTable_
{
union
{
TTO_GSUB_SubTable gsub;
TTO_GPOS_SubTable gpos;
} st;
};
enum TTO_Type_
{
GSUB,
GPOS
};
typedef enum TTO_Type_ TTO_Type;
#ifdef __cplusplus
}
#endif
#endif /* FTXOPEN_H */
/* END */

View File

@ -1,166 +0,0 @@
/*******************************************************************
*
* ftxopenf.h
*
* internal TrueType Open functions
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
******************************************************************/
#ifndef FTXOPENF_H
#define FTXOPENF_H
#include "ftxopen.h"
#ifdef __cplusplus
extern "C" {
#endif
/* functions from ftxopen.c */
FT_Error Load_ScriptList( TTO_ScriptList* sl,
FT_Stream stream );
FT_Error Load_FeatureList( TTO_FeatureList* fl,
FT_Stream input );
FT_Error Load_LookupList( TTO_LookupList* ll,
FT_Stream input,
TTO_Type type );
FT_Error Load_Coverage( TTO_Coverage* c,
FT_Stream input );
FT_Error Load_ClassDefinition( TTO_ClassDefinition* cd,
FT_UShort limit,
FT_Stream input );
FT_Error Load_EmptyClassDefinition( TTO_ClassDefinition* cd,
FT_Stream input );
FT_Error Load_Device( TTO_Device* d,
FT_Stream input );
void Free_ScriptList( TTO_ScriptList* sl,
FT_Memory memory );
void Free_FeatureList( TTO_FeatureList* fl,
FT_Memory memory );
void Free_LookupList( TTO_LookupList* ll,
TTO_Type type,
FT_Memory memory );
void Free_Coverage( TTO_Coverage* c,
FT_Memory memory );
void Free_ClassDefinition( TTO_ClassDefinition* cd,
FT_Memory memory );
void Free_Device( TTO_Device* d,
FT_Memory memory );
/* functions from ftxgsub.c */
FT_Error Load_SingleSubst( TTO_SingleSubst* ss,
FT_Stream input );
FT_Error Load_MultipleSubst( TTO_MultipleSubst* ms,
FT_Stream input );
FT_Error Load_AlternateSubst( TTO_AlternateSubst* as,
FT_Stream input );
FT_Error Load_LigatureSubst( TTO_LigatureSubst* ls,
FT_Stream input );
FT_Error Load_ContextSubst( TTO_ContextSubst* cs,
FT_Stream input );
FT_Error Load_ChainContextSubst( TTO_ChainContextSubst* ccs,
FT_Stream input );
FT_Error Load_ReverseChainContextSubst( TTO_ReverseChainContextSubst* rccs,
FT_Stream input );
void Free_SingleSubst( TTO_SingleSubst* ss,
FT_Memory memory );
void Free_MultipleSubst( TTO_MultipleSubst* ms,
FT_Memory memory );
void Free_AlternateSubst( TTO_AlternateSubst* as,
FT_Memory memory );
void Free_LigatureSubst( TTO_LigatureSubst* ls,
FT_Memory memory );
void Free_ContextSubst( TTO_ContextSubst* cs,
FT_Memory memory );
void Free_ChainContextSubst( TTO_ChainContextSubst* ccs,
FT_Memory memory );
void Free_ReverseChainContextSubst( TTO_ReverseChainContextSubst* rccs,
FT_Memory memory );
/* functions from ftxgpos.c */
FT_Error Load_SinglePos( TTO_SinglePos* sp,
FT_Stream input );
FT_Error Load_PairPos( TTO_PairPos* pp,
FT_Stream input );
FT_Error Load_CursivePos( TTO_CursivePos* cp,
FT_Stream input );
FT_Error Load_MarkBasePos( TTO_MarkBasePos* mbp,
FT_Stream input );
FT_Error Load_MarkLigPos( TTO_MarkLigPos* mlp,
FT_Stream input );
FT_Error Load_MarkMarkPos( TTO_MarkMarkPos* mmp,
FT_Stream input );
FT_Error Load_ContextPos( TTO_ContextPos* cp,
FT_Stream input );
FT_Error Load_ChainContextPos( TTO_ChainContextPos* ccp,
FT_Stream input );
void Free_SinglePos( TTO_SinglePos* sp,
FT_Memory memory );
void Free_PairPos( TTO_PairPos* pp,
FT_Memory memory );
void Free_CursivePos( TTO_CursivePos* cp,
FT_Memory memory );
void Free_MarkBasePos( TTO_MarkBasePos* mbp,
FT_Memory memory );
void Free_MarkLigPos( TTO_MarkLigPos* mlp,
FT_Memory memory );
void Free_MarkMarkPos( TTO_MarkMarkPos* mmp,
FT_Memory memory );
void Free_ContextPos( TTO_ContextPos* cp,
FT_Memory memory );
void Free_ChainContextPos( TTO_ChainContextPos* ccp,
FT_Memory memory );
/* query functions */
FT_Error Coverage_Index( TTO_Coverage* c,
FT_UShort glyphID,
FT_UShort* index );
FT_Error Get_Class( TTO_ClassDefinition* cd,
FT_UShort glyphID,
FT_UShort* class,
FT_UShort* index );
FT_Error Get_Device( TTO_Device* d,
FT_UShort size,
FT_Short* value );
/* functions from ftxgdef.c */
FT_Error Add_Glyph_Property( TTO_GDEFHeader* gdef,
FT_UShort glyphID,
FT_UShort property );
FT_Error Check_Property( TTO_GDEFHeader* gdef,
OTL_GlyphItem item,
FT_UShort flags,
FT_UShort* property );
#define CHECK_Property( gdef, index, flags, property ) \
( ( error = Check_Property( (gdef), (index), (flags), \
(property) ) ) != TT_Err_Ok )
#ifdef __cplusplus
}
#endif
#endif /* FTXOPENF_H */
/* END */

227
src/harfbuzz-buffer.c Normal file
View File

@ -0,0 +1,227 @@
/* harfbuzz-buffer.c: Buffer of glyphs for substitution/positioning
*
* Copyright 2004 Red Hat Software
*
* Portions Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*/
#include "harfbuzz-impl.h"
#include "harfbuzz-buffer.h"
#include "harfbuzz-gsub-private.h"
#include "harfbuzz-gpos-private.h"
static FT_Error
hb_buffer_ensure( HB_Buffer buffer,
FT_ULong size )
{
FT_Memory memory = buffer->memory;
FT_ULong new_allocated = buffer->allocated;
if (size > new_allocated)
{
FT_Error error;
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
if ( REALLOC_ARRAY( buffer->in_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) )
return error;
if ( REALLOC_ARRAY( buffer->out_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) )
return error;
if ( REALLOC_ARRAY( buffer->positions, buffer->allocated, new_allocated, HB_PositionRec ) )
return error;
buffer->allocated = new_allocated;
}
return FT_Err_Ok;
}
FT_Error
hb_buffer_new( FT_Memory memory,
HB_Buffer *buffer )
{
FT_Error error;
if ( ALLOC( *buffer, sizeof( HB_BufferRec ) ) )
return error;
(*buffer)->memory = memory;
(*buffer)->in_length = 0;
(*buffer)->out_length = 0;
(*buffer)->allocated = 0;
(*buffer)->in_pos = 0;
(*buffer)->out_pos = 0;
(*buffer)->in_string = NULL;
(*buffer)->out_string = NULL;
(*buffer)->positions = NULL;
(*buffer)->max_ligID = 0;
return FT_Err_Ok;
}
FT_Error
hb_buffer_swap( HB_Buffer buffer )
{
HB_GlyphItem tmp_string;
tmp_string = buffer->in_string;
buffer->in_string = buffer->out_string;
buffer->out_string = tmp_string;
buffer->in_length = buffer->out_length;
buffer->out_length = 0;
buffer->in_pos = 0;
buffer->out_pos = 0;
return FT_Err_Ok;
}
FT_Error
hb_buffer_free( HB_Buffer buffer )
{
FT_Memory memory = buffer->memory;
FREE( buffer->in_string );
FREE( buffer->out_string );
FREE( buffer->positions );
FREE( buffer );
return FT_Err_Ok;
}
FT_Error
hb_buffer_clear( HB_Buffer buffer )
{
buffer->in_length = 0;
buffer->out_length = 0;
buffer->in_pos = 0;
buffer->out_pos = 0;
return FT_Err_Ok;
}
FT_Error
hb_buffer_add_glyph( HB_Buffer buffer,
FT_UInt glyph_index,
FT_UInt properties,
FT_UInt cluster )
{
FT_Error error;
HB_GlyphItem glyph;
error = hb_buffer_ensure( buffer, buffer->in_length + 1 );
if ( error )
return error;
glyph = &buffer->in_string[buffer->in_length];
glyph->gindex = glyph_index;
glyph->properties = properties;
glyph->cluster = cluster;
glyph->component = 0;
glyph->ligID = 0;
glyph->gproperties = HB_GLYPH_PROPERTIES_UNKNOWN;
buffer->in_length++;
return FT_Err_Ok;
}
/* The following function copies `num_out' elements from `glyph_data'
to `buffer->out_string', advancing the in array pointer in the structure
by `num_in' elements, and the out array pointer by `num_out' elements.
Finally, it sets the `length' field of `out' equal to
`pos' of the `out' structure.
If `component' is 0xFFFF, the component value from buffer->in_pos
will copied `num_out' times, otherwise `component' itself will
be used to fill the `component' fields.
If `ligID' is 0xFFFF, the ligID value from buffer->in_pos
will copied `num_out' times, otherwise `ligID' itself will
be used to fill the `ligID' fields.
The properties for all replacement glyphs are taken
from the glyph at position `buffer->in_pos'.
The cluster value for the glyph at position buffer->in_pos is used
for all replacement glyphs */
FT_Error
hb_buffer_add_output_glyphs( HB_Buffer buffer,
FT_UShort num_in,
FT_UShort num_out,
FT_UShort *glyph_data,
FT_UShort component,
FT_UShort ligID )
{
FT_Error error;
FT_UShort i;
FT_UInt properties;
FT_UInt cluster;
error = hb_buffer_ensure( buffer, buffer->out_pos + num_out );
if ( error )
return error;
properties = buffer->in_string[buffer->in_pos].properties;
cluster = buffer->in_string[buffer->in_pos].cluster;
if ( component == 0xFFFF )
component = buffer->in_string[buffer->in_pos].component;
if ( ligID == 0xFFFF )
ligID = buffer->in_string[buffer->in_pos].ligID;
for ( i = 0; i < num_out; i++ )
{
HB_GlyphItem item = &buffer->out_string[buffer->out_pos + i];
item->gindex = glyph_data[i];
item->properties = properties;
item->cluster = cluster;
item->component = component;
item->ligID = ligID;
item->gproperties = HB_GLYPH_PROPERTIES_UNKNOWN;
}
buffer->in_pos += num_in;
buffer->out_pos += num_out;
buffer->out_length = buffer->out_pos;
return FT_Err_Ok;
}
FT_Error
hb_buffer_add_output_glyph( HB_Buffer buffer,
FT_UInt glyph_index,
FT_UShort component,
FT_UShort ligID )
{
FT_UShort glyph_data = glyph_index;
return hb_buffer_add_output_glyphs ( buffer, 1, 1,
&glyph_data, component, ligID );
}
FT_Error
hb_buffer_copy_output_glyph ( HB_Buffer buffer )
{
FT_Error error;
error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );
if ( error )
return error;
buffer->out_string[buffer->out_pos++] = buffer->in_string[buffer->in_pos++];
buffer->out_length = buffer->out_pos;
return FT_Err_Ok;
}
FT_UShort
hb_buffer_allocate_ligid( HB_Buffer buffer )
{
return buffer->max_ligID++;
}

106
src/harfbuzz-buffer.h Normal file
View File

@ -0,0 +1,106 @@
/* harfbuzz-buffer.h: Buffer of glyphs for substitution/positioning
*
* Copyrigh 2004 Red Hat Software
*
* Portions Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*/
#ifndef HARFBUZZ_BUFFER_H
#define HARFBUZZ_BUFFER_H
#include <ft2build.h>
#include FT_FREETYPE_H
FT_BEGIN_HEADER
#define HB_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
typedef struct HB_GlyphItemRec_ {
FT_UInt gindex;
FT_UInt properties;
FT_UInt cluster;
FT_UShort component;
FT_UShort ligID;
FT_UShort gproperties;
} HB_GlyphItemRec, *HB_GlyphItem;
typedef struct HB_PositionRec_ {
FT_Pos x_pos;
FT_Pos y_pos;
FT_Pos x_advance;
FT_Pos y_advance;
FT_UShort back; /* number of glyphs to go back
for drawing current glyph */
FT_Bool new_advance; /* if set, the advance width values are
absolute, i.e., they won't be
added to the original glyph's value
but rather replace them. */
FT_Short cursive_chain; /* character to which this connects,
may be positive or negative; used
only internally */
} HB_PositionRec, *HB_Position;
typedef struct HB_BufferRec_{
FT_Memory memory;
FT_ULong allocated;
FT_ULong in_length;
FT_ULong out_length;
FT_ULong in_pos;
FT_ULong out_pos;
HB_GlyphItem in_string;
HB_GlyphItem out_string;
HB_Position positions;
FT_UShort max_ligID;
} HB_BufferRec, *HB_Buffer;
FT_Error
hb_buffer_new( FT_Memory memory,
HB_Buffer *buffer );
FT_Error
hb_buffer_swap( HB_Buffer buffer );
FT_Error
hb_buffer_free( HB_Buffer buffer );
FT_Error
hb_buffer_clear( HB_Buffer buffer );
FT_Error
hb_buffer_add_glyph( HB_Buffer buffer,
FT_UInt glyph_index,
FT_UInt properties,
FT_UInt cluster );
FT_Error
hb_buffer_add_output_glyphs( HB_Buffer buffer,
FT_UShort num_in,
FT_UShort num_out,
FT_UShort *glyph_data,
FT_UShort component,
FT_UShort ligID );
FT_Error
hb_buffer_add_output_glyph ( HB_Buffer buffer,
FT_UInt glyph_index,
FT_UShort component,
FT_UShort ligID );
FT_Error
hb_buffer_copy_output_glyph ( HB_Buffer buffer );
FT_UShort
hb_buffer_allocate_ligid( HB_Buffer buffer );
FT_END_HEADER
#endif /* HARFBUZZ_BUFFER_H */

View File

@ -1,5 +1,4 @@
/* Pango
* otttest.c: Test program for OpenType
/* harfbuzz-dump-main.c: Test program for OpenType
*
* Copyright (C) 2000 Red Hat Software
*
@ -19,13 +18,12 @@
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include "ftxopen.h"
#include "harfbuzz-open.h"
#include "disasm.h"
#include "harfbuzz-dump.h"
#define N_ELEMENTS(arr) (sizeof(arr)/ sizeof((arr)[0]))
@ -56,7 +54,7 @@ print_tag (FT_ULong tag)
}
static void
maybe_add_feature (TTO_GSUB gsub,
maybe_add_feature (HB_GSUB gsub,
FT_UShort script_index,
FT_ULong tag,
FT_UShort property)
@ -65,22 +63,22 @@ maybe_add_feature (TTO_GSUB gsub,
FT_UShort feature_index;
/* 0xffff == default language system */
error = TT_GSUB_Select_Feature (gsub, tag, script_index, 0xffff, &feature_index);
error = HB_GSUB_Select_Feature (gsub, tag, script_index, 0xffff, &feature_index);
if (error)
{
if (error == TTO_Err_Not_Covered)
if (error == HB_Err_Not_Covered)
{
print_tag (tag);
fprintf (stderr, " not covered, ignored\n");
return;
}
croak ("TT_GSUB_Select_Feature", error);
croak ("HB_GSUB_Select_Feature", error);
}
if ((error = TT_GSUB_Add_Feature (gsub, feature_index, property)))
croak ("TT_GSUB_Add_Feature", error);
if ((error = HB_GSUB_Add_Feature (gsub, feature_index, property)))
croak ("HB_GSUB_Add_Feature", error);
}
static void
@ -122,23 +120,23 @@ select_cmap (FT_Face face)
}
static void
add_features (TTO_GSUB gsub)
add_features (HB_GSUB gsub)
{
FT_Error error;
FT_ULong tag = FT_MAKE_TAG ('a', 'r', 'a', 'b');
FT_UShort script_index;
error = TT_GSUB_Select_Script (gsub, tag, &script_index);
error = HB_GSUB_Select_Script (gsub, tag, &script_index);
if (error)
{
if (error == TTO_Err_Not_Covered)
if (error == HB_Err_Not_Covered)
{
fprintf (stderr, "Arabic not covered, no features used\n");
return;
}
croak ("TT_GSUB_Select_Script", error);
croak ("HB_GSUB_Select_Script", error);
}
maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('i', 'n', 'i', 't'), I);
@ -150,7 +148,7 @@ add_features (TTO_GSUB gsub)
#if 0
void
dump_string (TTO_GSUB_String *str)
dump_string (HB_GSUB_String *str)
{
FT_ULong i;
@ -173,20 +171,20 @@ FT_UShort arabic_props[] = { I|L, M|L, M|L, M|L, M|L, F|L, I|L, M|L
void
try_string (FT_Library library,
FT_Face face,
TTO_GSUB gsub)
HB_GSUB gsub)
{
FT_Error error;
TTO_GSUB_String *in_str;
TTO_GSUB_String *out_str;
HB_GSUB_String *in_str;
HB_GSUB_String *out_str;
FT_ULong i;
if ((error = TT_GSUB_String_New (face->memory, &in_str)))
croak ("TT_GSUB_String_New", error);
if ((error = TT_GSUB_String_New (face->memory, &out_str)))
croak ("TT_GSUB_String_New", error);
if ((error = HB_GSUB_String_New (face->memory, &in_str)))
croak ("HB_GSUB_String_New", error);
if ((error = HB_GSUB_String_New (face->memory, &out_str)))
croak ("HB_GSUB_String_New", error);
if ((error = TT_GSUB_String_Set_Length (in_str, N_ELEMENTS (arabic_str))))
croak ("TT_GSUB_String_Set_Length", error);
if ((error = HB_GSUB_String_Set_Length (in_str, N_ELEMENTS (arabic_str))))
croak ("HB_GSUB_String_Set_Length", error);
for (i=0; i < N_ELEMENTS (arabic_str); i++)
{
@ -196,16 +194,16 @@ try_string (FT_Library library,
in_str->ligIDs[i] = i;
}
if ((error = TT_GSUB_Apply_String (gsub, in_str, out_str)))
croak ("TT_GSUB_Apply_String", error);
if ((error = HB_GSUB_Apply_String (gsub, in_str, out_str)))
croak ("HB_GSUB_Apply_String", error);
dump_string (in_str);
dump_string (out_str);
if ((error = TT_GSUB_String_Done (in_str)))
croak ("TT_GSUB_String_New", error);
if ((error = TT_GSUB_String_Done (out_str)))
croak ("TT_GSUB_String_New", error);
if ((error = HB_GSUB_String_Done (in_str)))
croak ("HB_GSUB_String_New", error);
if ((error = HB_GSUB_String_Done (out_str)))
croak ("HB_GSUB_String_New", error);
}
#endif
@ -215,8 +213,8 @@ main (int argc, char **argv)
FT_Error error;
FT_Library library;
FT_Face face;
TTO_GSUB gsub;
TTO_GPOS gpos;
HB_GSUB gsub;
HB_GPOS gpos;
if (argc != 2)
{
@ -233,25 +231,25 @@ main (int argc, char **argv)
printf ("<?xml version=\"1.0\"?>\n");
printf ("<OpenType>\n");
if (!(error = TT_Load_GSUB_Table (face, &gsub, NULL)))
if (!(error = HB_Load_GSUB_Table (face, &gsub, NULL)))
{
TT_Dump_GSUB_Table (gsub, stdout);
HB_Dump_GSUB_Table (gsub, stdout);
if ((error = TT_Done_GSUB_Table (gsub)))
croak ("FT_Done_GSUB_Table", error);
if ((error = HB_Done_GSUB_Table (gsub)))
croak ("HB_Done_GSUB_Table", error);
}
else if (error != FT_Err_Table_Missing)
fprintf (stderr, "TT_Load_GSUB_Table %x\n", error);
fprintf (stderr, "HB_Load_GSUB_Table %x\n", error);
if (!(error = TT_Load_GPOS_Table (face, &gpos, NULL)))
if (!(error = HB_Load_GPOS_Table (face, &gpos, NULL)))
{
TT_Dump_GPOS_Table (gpos, stdout);
HB_Dump_GPOS_Table (gpos, stdout);
if ((error = TT_Done_GPOS_Table (gpos)))
croak ("FT_Done_GPOS_Table", error);
if ((error = HB_Done_GPOS_Table (gpos)))
croak ("HB_Done_GPOS_Table", error);
}
else if (error != FT_Err_Table_Missing)
fprintf (stderr, "TT_Load_GPOS_Table %x\n", error);
fprintf (stderr, "HB_Load_GPOS_Table %x\n", error);
printf ("</OpenType>\n");

View File

@ -1,5 +1,4 @@
/* Pango
* disasm.c: Dump OpenType layout tables
/* harfbuzz-dump.c: Dump OpenType layout tables
*
* Copyright (C) 2000 Red Hat Software
*
@ -19,28 +18,29 @@
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <glib.h> /* For G_HAVE_ISO_VARARGS */
#include "harfbuzz-impl.h"
#include "harfbuzz-dump.h"
#include "harfbuzz-gdef-private.h"
#include "harfbuzz-gsub-private.h"
#include "harfbuzz-gpos-private.h"
#include "harfbuzz-open-private.h"
#include <stdarg.h>
#include "disasm.h"
#define DUMP(format) dump (stream, indent, format)
#define DUMP1(format, arg1) dump (stream, indent, format, arg1)
#define DUMP2(format, arg1, arg2) dump (stream, indent, format, arg1, arg2)
#define DUMP3(format, arg1, arg2, arg3) dump (stream, indent, format, arg1, arg2, arg3)
#ifdef G_HAVE_ISO_VARARGS
#define DUMP(...) dump (stream, indent, __VA_ARGS__)
#elif defined (G_HAVE_GNUC_VARARGS)
#define DUMP(args...) dump (stream, indent, args)
#endif
#define DUMP_FINT(strct,fld) dump (stream, indent, "<" #fld ">%d</" #fld ">\n", (strct)->fld)
#define DUMP_FUINT(strct,fld) dump (stream, indent, "<" #fld ">%u</" #fld ">\n", (strct)->fld)
#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)
#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)
#define DUMP_USHORT_ARRAY(strct,fld,cnt) Dump_UShort_Array ((strct)->fld, cnt, #fld, stream, indent);
#define DEF_DUMP(type) static void Dump_ ## type (TTO_ ## type *type, FILE *stream, int indent, FT_Bool G_GNUC_UNUSED is_gsub)
#define RECURSE(name, type, val) do { DUMP ("<" #name ">\n"); Dump_ ## type (val, stream, indent + 1, is_gsub); DUMP ("</" #name ">\n"); } while (0)
#define RECURSE_NUM(name, i, type, val) do { DUMP ("<" #name "> <!-- %d -->\n", i); Dump_ ## type (val, stream, indent + 1, is_gsub); DUMP ("</" #name ">\n"); } while (0)
#define DUMP_VALUE_RECORD(val, frmt) do { DUMP ("<ValueRecord>\n"); Dump_ValueRecord (val, stream, indent + 1, is_gsub, frmt); DUMP ("</ValueRecord>\n"); } while (0)
#define DEF_DUMP(type) static void Dump_ ## type (HB_ ## type *type, FILE *stream, int indent, HB_Type hb_type)
#define RECURSE(name, type, val) do { DUMP ("<" #name ">\n"); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)
#define RECURSE_NUM(name, i, type, val) do { DUMP1 ("<" #name "> <!-- %d -->\n", i); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)
#define DUMP_VALUE_RECORD(val, frmt) do { DUMP ("<ValueRecord>\n"); Dump_ValueRecord (val, stream, indent + 1, hb_type, frmt); DUMP ("</ValueRecord>\n"); } while (0)
static void
do_indent (FILE *stream, int indent)
@ -92,7 +92,7 @@ DEF_DUMP (LangSys)
DUMP_FUINT (LangSys, FeatureCount);
for (i=0; i < LangSys->FeatureCount; i++)
DUMP("<FeatureIndex>%d</FeatureIndex>\n", LangSys->FeatureIndex[i]);
DUMP1("<FeatureIndex>%d</FeatureIndex>\n", LangSys->FeatureIndex[i]);
}
DEF_DUMP (Script)
@ -137,13 +137,13 @@ DEF_DUMP (Feature)
DUMP_FUINT (Feature, LookupListCount);
for (i=0; i < Feature->LookupListCount; i++)
DUMP("<LookupIndex>%d</LookupIndex>\n", Feature->LookupListIndex[i]);
DUMP1("<LookupIndex>%d</LookupIndex>\n", Feature->LookupListIndex[i]);
}
DEF_DUMP (MarkRecord)
{
DUMP_FUINT (MarkRecord, Class);
DUMP("<Anchor>%d</Anchor>\n", MarkRecord->MarkAnchor.PosFormat );
DUMP1("<Anchor>%d</Anchor>\n", MarkRecord->MarkAnchor.PosFormat );
}
DEF_DUMP (MarkArray)
@ -182,8 +182,8 @@ DEF_DUMP (Coverage)
DUMP_FUINT (&Coverage->cf.cf1, GlyphCount);
for (i = 0; i < Coverage->cf.cf1.GlyphCount; i++)
DUMP("<Glyph>%#06x</Glyph> <!-- %d -->\n",
Coverage->cf.cf1.GlyphArray[i], i);
DUMP2("<Glyph>%#06x</Glyph> <!-- %d -->\n",
Coverage->cf.cf1.GlyphArray[i], i);
}
else
{
@ -191,9 +191,9 @@ DEF_DUMP (Coverage)
DUMP_FUINT (&Coverage->cf.cf2, RangeCount);
for ( i = 0; i < Coverage->cf.cf2.RangeCount; i++ )
DUMP("<Glyph>%#06x - %#06x</Glyph> <!-- %d -->\n",
Coverage->cf.cf2.RangeRecord[i].Start,
Coverage->cf.cf2.RangeRecord[i].End);
DUMP3("<Glyph>%#06x - %#06x</Glyph> <!-- %d -->\n",
Coverage->cf.cf2.RangeRecord[i].Start,
Coverage->cf.cf2.RangeRecord[i].End, i);
}
}
@ -212,18 +212,18 @@ DEF_DUMP (ClassDefinition)
if (ClassDefinition->ClassFormat == 1)
{
int i;
TTO_ClassDefFormat1 *ClassDefFormat1 = &ClassDefinition->cd.cd1;
HB_ClassDefFormat1 *ClassDefFormat1 = &ClassDefinition->cd.cd1;
DUMP("<ClassDefinition>\n");
DUMP_FUINT (ClassDefFormat1, StartGlyph );
DUMP_FUINT (ClassDefFormat1, GlyphCount );
for (i = 0; i < ClassDefFormat1->GlyphCount; i++)
DUMP(" <Class>%d</Class> <!-- %#06x -->", ClassDefFormat1->ClassValueArray[i],
ClassDefFormat1->StartGlyph+i );
DUMP2(" <Class>%d</Class> <!-- %#06x -->", ClassDefFormat1->ClassValueArray[i],
ClassDefFormat1->StartGlyph+i );
}
else if (ClassDefinition->ClassFormat == 2)
{
int i;
TTO_ClassDefFormat2 *ClassDefFormat2 = &ClassDefinition->cd.cd2;
HB_ClassDefFormat2 *ClassDefFormat2 = &ClassDefinition->cd.cd2;
DUMP_FUINT (ClassDefFormat2, ClassRangeCount);
for (i = 0; i < ClassDefFormat2->ClassRangeCount; i++)
@ -263,9 +263,9 @@ DEF_DUMP (ChainSubClassSet)
}
static void
Dump_GSUB_Lookup_Single (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
Dump_GSUB_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
{
TTO_SingleSubst *SingleSubst = &subtable->st.gsub.single;
HB_SingleSubst *SingleSubst = &subtable->st.gsub.single;
DUMP_FUINT (SingleSubst, SubstFormat);
RECURSE (Coverage, Coverage, &SingleSubst->Coverage);
@ -280,7 +280,7 @@ Dump_GSUB_Lookup_Single (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bo
DUMP_FINT (&SingleSubst->ssf.ssf2, GlyphCount);
for (i=0; i < SingleSubst->ssf.ssf2.GlyphCount; i++)
DUMP("<Substitute>%#06x</Substitute> <!-- %d -->\n", SingleSubst->ssf.ssf2.Substitute[i], i);
DUMP2("<Substitute>%#06x</Substitute> <!-- %d -->\n", SingleSubst->ssf.ssf2.Substitute[i], i);
}
}
@ -292,7 +292,7 @@ DEF_DUMP (Ligature)
DUMP_FUINT (Ligature, ComponentCount);
for (i=0; i < Ligature->ComponentCount - 1; i++)
DUMP("<Component>%#06x</Component>\n", Ligature->Component[i]);
DUMP1("<Component>%#06x</Component>\n", Ligature->Component[i]);
}
DEF_DUMP (LigatureSet)
@ -306,10 +306,10 @@ DEF_DUMP (LigatureSet)
}
static void
Dump_GSUB_Lookup_Ligature (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
Dump_GSUB_Lookup_Ligature (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
{
int i;
TTO_LigatureSubst *LigatureSubst = &subtable->st.gsub.ligature;
HB_LigatureSubst *LigatureSubst = &subtable->st.gsub.ligature;
DUMP_FUINT (LigatureSubst, SubstFormat);
RECURSE (Coverage, Coverage, &LigatureSubst->Coverage);
@ -338,21 +338,21 @@ DEF_DUMP (ContextSubstFormat3)
}
static void
Dump_GSUB_Lookup_Context (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
Dump_GSUB_Lookup_Context (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
{
TTO_ContextSubst *ContextSubst = &subtable->st.gsub.context;
HB_ContextSubst *ContextSubst = &subtable->st.gsub.context;
DUMP_FUINT (ContextSubst, SubstFormat);
switch( ContextSubst->SubstFormat )
{
case 1:
Dump_ContextSubstFormat1 (&ContextSubst->csf.csf1, stream, indent+2, is_gsub);
Dump_ContextSubstFormat1 (&ContextSubst->csf.csf1, stream, indent+2, hb_type);
break;
case 2:
Dump_ContextSubstFormat2 (&ContextSubst->csf.csf2, stream, indent+2, is_gsub);
Dump_ContextSubstFormat2 (&ContextSubst->csf.csf2, stream, indent+2, hb_type);
break;
case 3:
Dump_ContextSubstFormat3 (&ContextSubst->csf.csf3, stream, indent+2, is_gsub);
Dump_ContextSubstFormat3 (&ContextSubst->csf.csf3, stream, indent+2, hb_type);
break;
default:
fprintf(stderr, "invalid subformat!!!!!\n");
@ -401,21 +401,21 @@ DEF_DUMP (ChainContextSubstFormat3)
}
static void
Dump_GSUB_Lookup_Chain (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
Dump_GSUB_Lookup_Chain (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
{
TTO_ChainContextSubst *chain = &subtable->st.gsub.chain;
HB_ChainContextSubst *chain = &subtable->st.gsub.chain;
DUMP_FUINT (chain, SubstFormat);
switch (chain->SubstFormat)
{
case 1:
Dump_ChainContextSubstFormat1 (&chain->ccsf.ccsf1, stream, indent+2, is_gsub);
Dump_ChainContextSubstFormat1 (&chain->ccsf.ccsf1, stream, indent+2, hb_type);
break;
case 2:
Dump_ChainContextSubstFormat2 (&chain->ccsf.ccsf2, stream, indent+2, is_gsub);
Dump_ChainContextSubstFormat2 (&chain->ccsf.ccsf2, stream, indent+2, hb_type);
break;
case 3:
Dump_ChainContextSubstFormat3 (&chain->ccsf.ccsf3, stream, indent+2, is_gsub);
Dump_ChainContextSubstFormat3 (&chain->ccsf.ccsf3, stream, indent+2, hb_type);
break;
default:
fprintf(stderr, "invalid subformat!!!!!\n");
@ -423,7 +423,7 @@ Dump_GSUB_Lookup_Chain (TTO_SubTable *subtable, FILE *stream, int indent, FT_Boo
}
static void
Dump_Device (TTO_Device *Device, FILE *stream, int indent, FT_Bool is_gsub)
Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
{
int i;
int bits = 0;
@ -471,38 +471,38 @@ Dump_Device (TTO_Device *Device, FILE *stream, int indent, FT_Bool is_gsub)
}
static void
Dump_ValueRecord (TTO_ValueRecord *ValueRecord, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort value_format)
Dump_ValueRecord (HB_ValueRecord *ValueRecord, FILE *stream, int indent, HB_Type hb_type, FT_UShort value_format)
{
if (value_format & HAVE_X_PLACEMENT)
if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT)
DUMP_FINT (ValueRecord, XPlacement);
if (value_format & HAVE_Y_PLACEMENT)
if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT)
DUMP_FINT (ValueRecord, YPlacement);
if (value_format & HAVE_X_ADVANCE)
if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE)
DUMP_FINT (ValueRecord, XAdvance);
if (value_format & HAVE_Y_ADVANCE)
if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE)
DUMP_FINT (ValueRecord, XAdvance);
if (value_format & HAVE_X_PLACEMENT_DEVICE)
if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE)
RECURSE (Device, Device, &ValueRecord->XPlacementDevice);
if (value_format & HAVE_Y_PLACEMENT_DEVICE)
if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE)
RECURSE (Device, Device, &ValueRecord->YPlacementDevice);
if (value_format & HAVE_X_ADVANCE_DEVICE)
if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE)
RECURSE (Device, Device, &ValueRecord->XAdvanceDevice);
if (value_format & HAVE_Y_ADVANCE_DEVICE)
if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE)
RECURSE (Device, Device, &ValueRecord->YAdvanceDevice);
if (value_format & HAVE_X_ID_PLACEMENT)
if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT)
DUMP_FUINT (ValueRecord, XIdPlacement);
if (value_format & HAVE_Y_ID_PLACEMENT)
if (value_format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT)
DUMP_FUINT (ValueRecord, YIdPlacement);
if (value_format & HAVE_X_ID_ADVANCE)
if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE)
DUMP_FUINT (ValueRecord, XIdAdvance);
if (value_format & HAVE_Y_ID_ADVANCE)
if (value_format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE)
DUMP_FUINT (ValueRecord, XIdAdvance);
}
static void
Dump_GPOS_Lookup_Single (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
Dump_GPOS_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
{
TTO_SinglePos *SinglePos = &subtable->st.gpos.single;
HB_SinglePos *SinglePos = &subtable->st.gpos.single;
DUMP_FUINT (SinglePos, PosFormat);
RECURSE (Coverage, Coverage, &SinglePos->Coverage);
@ -524,7 +524,7 @@ Dump_GPOS_Lookup_Single (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bo
}
static void
Dump_PairValueRecord (TTO_PairValueRecord *PairValueRecord, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort ValueFormat1, FT_UShort ValueFormat2)
Dump_PairValueRecord (HB_PairValueRecord *PairValueRecord, FILE *stream, int indent, HB_Type hb_type, FT_UShort ValueFormat1, FT_UShort ValueFormat2)
{
DUMP_FUINT (PairValueRecord, SecondGlyph);
DUMP_VALUE_RECORD (&PairValueRecord->Value1, ValueFormat1);
@ -532,7 +532,7 @@ Dump_PairValueRecord (TTO_PairValueRecord *PairValueRecord, FILE *stream, int in
}
static void
Dump_PairSet (TTO_PairSet *PairSet, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort ValueFormat1, FT_UShort ValueFormat2)
Dump_PairSet (HB_PairSet *PairSet, FILE *stream, int indent, HB_Type hb_type, FT_UShort ValueFormat1, FT_UShort ValueFormat2)
{
int i;
DUMP_FUINT (PairSet, PairValueCount);
@ -540,15 +540,15 @@ Dump_PairSet (TTO_PairSet *PairSet, FILE *stream, int indent, FT_Bool is_gsub, F
for (i = 0; i < PairSet->PairValueCount; i++)
{
DUMP ("<PairValueRecord>\n");
Dump_PairValueRecord (&PairSet->PairValueRecord[i], stream, indent + 1, is_gsub, ValueFormat1, ValueFormat2);
Dump_PairValueRecord (&PairSet->PairValueRecord[i], stream, indent + 1, hb_type, ValueFormat1, ValueFormat2);
DUMP ("</PairValueRecord>\n");
}
}
static void
Dump_GPOS_Lookup_Pair (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
Dump_GPOS_Lookup_Pair (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
{
TTO_PairPos *PairPos = &subtable->st.gpos.pair;
HB_PairPos *PairPos = &subtable->st.gpos.pair;
DUMP_FUINT (PairPos, PosFormat);
RECURSE (Coverage, Coverage, &PairPos->Coverage);
@ -564,7 +564,7 @@ Dump_GPOS_Lookup_Pair (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool
for (i = 0; i < PairPos->ppf.ppf1.PairSetCount; i++)
{
DUMP ("<PairSet>\n");
Dump_PairSet (&PairPos->ppf.ppf1.PairSet[i], stream, indent + 1, is_gsub, PairPos->ValueFormat1, PairPos->ValueFormat2);
Dump_PairSet (&PairPos->ppf.ppf1.PairSet[i], stream, indent + 1, hb_type, PairPos->ValueFormat1, PairPos->ValueFormat2);
DUMP ("</PairSet>\n");
}
}
@ -574,10 +574,10 @@ Dump_GPOS_Lookup_Pair (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool
}
static void
Dump_GPOS_Lookup_Markbase (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub)
Dump_GPOS_Lookup_Markbase (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
{
int i;
TTO_MarkBasePos *markbase = &subtable->st.gpos.markbase;
HB_MarkBasePos *markbase = &subtable->st.gpos.markbase;
DUMP_FUINT (markbase, PosFormat);
RECURSE (Coverage, Coverage, &markbase->MarkCoverage);
@ -592,10 +592,10 @@ Dump_GPOS_Lookup_Markbase (TTO_SubTable *subtable, FILE *stream, int indent, FT_
for (i = 0; i < markbase->BaseArray.BaseCount; i++)
{
int j;
TTO_BaseRecord *r = &markbase->BaseArray.BaseRecord[i];
DUMP ("<BaseRecord> <!-- %d -->\n", i);
HB_BaseRecord *r = &markbase->BaseArray.BaseRecord[i];
DUMP1 ("<BaseRecord> <!-- %d -->\n", i);
for (j = 0; j < markbase->ClassCount; j++)
DUMP (" <Anchor>%d</Anchor>\n", r->BaseAnchor->PosFormat);
DUMP1 (" <Anchor>%d</Anchor>\n", r->BaseAnchor->PosFormat);
DUMP ("<BaseRecord>\n");
}
@ -607,31 +607,31 @@ DEF_DUMP (Lookup)
{
int i;
const char *lookup_name = NULL;
void (*lookup_func) (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) = NULL;
void (*lookup_func) (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type) = NULL;
if (is_gsub)
if (hb_type == HB_Type_GSUB)
{
switch (Lookup->LookupType)
{
case GSUB_LOOKUP_SINGLE:
case HB_GSUB_LOOKUP_SINGLE:
lookup_name = "SINGLE";
lookup_func = Dump_GSUB_Lookup_Single;
break;
case GSUB_LOOKUP_MULTIPLE:
case HB_GSUB_LOOKUP_MULTIPLE:
lookup_name = "MULTIPLE";
break;
case GSUB_LOOKUP_ALTERNATE:
case HB_GSUB_LOOKUP_ALTERNATE:
lookup_name = "ALTERNATE";
break;
case GSUB_LOOKUP_LIGATURE:
case HB_GSUB_LOOKUP_LIGATURE:
lookup_name = "LIGATURE";
lookup_func = Dump_GSUB_Lookup_Ligature;
break;
case GSUB_LOOKUP_CONTEXT:
case HB_GSUB_LOOKUP_CONTEXT:
lookup_name = "CONTEXT";
lookup_func = Dump_GSUB_Lookup_Context;
break;
case GSUB_LOOKUP_CHAIN:
case HB_GSUB_LOOKUP_CHAIN:
lookup_name = "CHAIN";
lookup_func = Dump_GSUB_Lookup_Chain;
break;
@ -641,44 +641,44 @@ DEF_DUMP (Lookup)
{
switch (Lookup->LookupType)
{
case GPOS_LOOKUP_SINGLE:
case HB_GPOS_LOOKUP_SINGLE:
lookup_name = "SINGLE";
lookup_func = Dump_GPOS_Lookup_Single;
break;
case GPOS_LOOKUP_PAIR:
case HB_GPOS_LOOKUP_PAIR:
lookup_name = "PAIR";
lookup_func = Dump_GPOS_Lookup_Pair;
break;
case GPOS_LOOKUP_CURSIVE:
case HB_GPOS_LOOKUP_CURSIVE:
lookup_name = "CURSIVE";
break;
case GPOS_LOOKUP_MARKBASE:
case HB_GPOS_LOOKUP_MARKBASE:
lookup_name = "MARKBASE";
lookup_func = Dump_GPOS_Lookup_Markbase;
break;
case GPOS_LOOKUP_MARKLIG:
case HB_GPOS_LOOKUP_MARKLIG:
lookup_name = "MARKLIG";
break;
case GPOS_LOOKUP_MARKMARK:
case HB_GPOS_LOOKUP_MARKMARK:
lookup_name = "MARKMARK";
break;
case GPOS_LOOKUP_CONTEXT:
case HB_GPOS_LOOKUP_CONTEXT:
lookup_name = "CONTEXT";
break;
case GPOS_LOOKUP_CHAIN:
case HB_GPOS_LOOKUP_CHAIN:
lookup_name = "CHAIN";
break;
}
}
DUMP("<LookupType>%s</LookupType> <!-- %d -->\n", lookup_name, Lookup->LookupType);
DUMP("<LookupFlag>%#06x</LookupFlag>\n", Lookup->LookupFlag);
DUMP2("<LookupType>%s</LookupType> <!-- %d -->\n", lookup_name, Lookup->LookupType);
DUMP1("<LookupFlag>%#06x</LookupFlag>\n", Lookup->LookupFlag);
for (i=0; i < Lookup->SubTableCount; i++)
{
DUMP ("<Subtable>\n");
if (lookup_func)
(*lookup_func) (&Lookup->SubTable[i], stream, indent + 1, is_gsub);
(*lookup_func) (&Lookup->SubTable[i], stream, indent + 1, hb_type);
DUMP ("</Subtable>\n");
}
}
@ -694,10 +694,10 @@ DEF_DUMP (LookupList)
}
void
TT_Dump_GSUB_Table (TTO_GSUB gsub, FILE *stream)
HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream)
{
int indent = 1;
FT_Bool is_gsub = 1;
HB_Type hb_type = HB_Type_GSUB;
do_indent (stream, indent);
fprintf(stream, "<!-- GSUB -->\n");
@ -707,10 +707,10 @@ TT_Dump_GSUB_Table (TTO_GSUB gsub, FILE *stream)
}
void
TT_Dump_GPOS_Table (TTO_GPOS gpos, FILE *stream)
HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream)
{
int indent = 1;
FT_Bool is_gsub = 0;
HB_Type hb_type = HB_Type_GPOS;
do_indent (stream, indent);
fprintf(stream, "<!-- GPOS -->\n");

View File

@ -1,5 +1,4 @@
/* Pango
* disasm.h: Dump OpenType layout tables
/* harfbuzz-dump.h: Dump OpenType layout tables
*
* Copyright (C) 2000 Red Hat Software
*
@ -18,9 +17,18 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef HARFBUZZ_DUMP_H
#define HARFBUZZ_DUMP_H
#include <stdio.h>
#include "ftxopen.h"
#include "harfbuzz-gsub.h"
#include "harfbuzz-gpos.h"
void TT_Dump_GSUB_Table (TTO_GSUB gsub, FILE *stream);
void TT_Dump_GPOS_Table (TTO_GPOS gpos, FILE *stream);
FT_BEGIN_HEADER
void HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream);
void HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream);
FT_END_HEADER
#endif /* HARFBUZZ_DUMP_H */

101
src/harfbuzz-gdef-private.h Normal file
View File

@ -0,0 +1,101 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_GDEF_PRIVATE_H
#define HARFBUZZ_GDEF_PRIVATE_H
#include "harfbuzz-gdef.h"
#include "harfbuzz-buffer.h"
FT_BEGIN_HEADER
/* Attachment related structures */
struct HB_AttachPoint_
{
FT_UShort PointCount; /* size of the PointIndex array */
FT_UShort* PointIndex; /* array of contour points */
};
/* Ligature Caret related structures */
struct HB_CaretValueFormat1_
{
FT_Short Coordinate; /* x or y value (in design units) */
};
typedef struct HB_CaretValueFormat1_ HB_CaretValueFormat1;
struct HB_CaretValueFormat2_
{
FT_UShort CaretValuePoint; /* contour point index on glyph */
};
typedef struct HB_CaretValueFormat2_ HB_CaretValueFormat2;
struct HB_CaretValueFormat3_
{
FT_Short Coordinate; /* x or y value (in design units) */
HB_Device Device; /* Device table for x or y value */
};
typedef struct HB_CaretValueFormat3_ HB_CaretValueFormat3;
struct HB_CaretValueFormat4_
{
FT_UShort IdCaretValue; /* metric ID */
};
typedef struct HB_CaretValueFormat4_ HB_CaretValueFormat4;
struct HB_CaretValue_
{
FT_UShort CaretValueFormat; /* 1, 2, 3, or 4 */
union
{
HB_CaretValueFormat1 cvf1;
HB_CaretValueFormat2 cvf2;
HB_CaretValueFormat3 cvf3;
HB_CaretValueFormat4 cvf4;
} cvf;
};
typedef struct HB_CaretValue_ HB_CaretValue;
struct HB_LigGlyph_
{
FT_Bool loaded;
FT_UShort CaretCount; /* number of caret values */
HB_CaretValue* CaretValue; /* array of caret values */
};
FT_Error _HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
FT_UShort glyphID,
FT_UShort property );
FT_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
HB_GlyphItem item,
FT_UShort flags,
FT_UShort* property );
FT_END_HEADER
#endif /* HARFBUZZ_GDEF_PRIVATE_H */

1228
src/harfbuzz-gdef.c Normal file

File diff suppressed because it is too large Load Diff

127
src/harfbuzz-gdef.h Normal file
View File

@ -0,0 +1,127 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_GDEF_H
#define HARFBUZZ_GDEF_H
#include "harfbuzz-open.h"
FT_BEGIN_HEADER
#define HB_Err_Invalid_GDEF_SubTable_Format 0x1030
#define HB_Err_Invalid_GDEF_SubTable 0x1031
/* GDEF glyph properties. Note that HB_GDEF_COMPONENT has no corresponding
* flag in the LookupFlag field. */
#define HB_GDEF_BASE_GLYPH 0x0002
#define HB_GDEF_LIGATURE 0x0004
#define HB_GDEF_MARK 0x0008
#define HB_GDEF_COMPONENT 0x0010
typedef struct HB_AttachPoint_ HB_AttachPoint;
struct HB_AttachList_
{
FT_Bool loaded;
HB_Coverage Coverage; /* Coverage table */
FT_UShort GlyphCount; /* number of glyphs with
attachments */
HB_AttachPoint* AttachPoint; /* array of AttachPoint tables */
};
typedef struct HB_AttachList_ HB_AttachList;
typedef struct HB_LigGlyph_ HB_LigGlyph;
struct HB_LigCaretList_
{
FT_Bool loaded;
HB_Coverage Coverage; /* Coverage table */
FT_UShort LigGlyphCount; /* number of ligature glyphs */
HB_LigGlyph* LigGlyph; /* array of LigGlyph tables */
};
typedef struct HB_LigCaretList_ HB_LigCaretList;
/* The `NewGlyphClasses' field is not defined in the TTO specification.
We use it for fonts with a constructed `GlyphClassDef' structure
(i.e., which don't have a GDEF table) to collect glyph classes
assigned during the lookup process. The number of arrays in this
pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth
array then contains the glyph class values of the glyphs not covered
by the ClassRangeRecords structures with index n-1 and n. We store
glyph class values for four glyphs in a single array element.
`LastGlyph' is identical to the number of glyphs minus one in the
font; we need it only if `NewGlyphClasses' is not NULL (to have an
upper bound for the last array).
Note that we first store the file offset to the `MarkAttachClassDef'
field (which has been introduced in OpenType 1.2) -- since the
`Version' field value hasn't been increased to indicate that we have
one more field for some obscure reason, we must parse the GSUB table
to find out whether class values refer to this table. Only then we
can finally load the MarkAttachClassDef structure if necessary. */
struct HB_GDEFHeader_
{
FT_Memory memory;
FT_ULong offset;
FT_Fixed Version;
HB_ClassDefinition GlyphClassDef;
HB_AttachList AttachList;
HB_LigCaretList LigCaretList;
FT_ULong MarkAttachClassDef_offset;
HB_ClassDefinition MarkAttachClassDef; /* new in OT 1.2 */
FT_UShort LastGlyph;
FT_UShort** NewGlyphClasses;
};
typedef struct HB_GDEFHeader_ HB_GDEFHeader;
typedef struct HB_GDEFHeader_* HB_GDEF;
FT_Error HB_New_GDEF_Table( FT_Face face,
HB_GDEFHeader** retptr );
FT_Error HB_Load_GDEF_Table( FT_Face face,
HB_GDEFHeader** gdef );
FT_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );
FT_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
FT_UShort glyphID,
FT_UShort* property );
FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
FT_UShort num_glyphs,
FT_UShort glyph_count,
FT_UShort* glyph_array,
FT_UShort* class_array );
FT_END_HEADER
#endif /* HARFBUZZ_GDEF_H */

683
src/harfbuzz-gpos-private.h Normal file
View File

@ -0,0 +1,683 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_GPOS_PRIVATE_H
#define HARFBUZZ_GPOS_PRIVATE_H
#include "harfbuzz-gpos.h"
FT_BEGIN_HEADER
/* shared tables */
struct HB_ValueRecord_
{
FT_Short XPlacement; /* horizontal adjustment for
placement */
FT_Short YPlacement; /* vertical adjustment for
placement */
FT_Short XAdvance; /* horizontal adjustment for
advance */
FT_Short YAdvance; /* vertical adjustment for
advance */
HB_Device XPlacementDevice; /* device table for horizontal
placement */
HB_Device YPlacementDevice; /* device table for vertical
placement */
HB_Device XAdvanceDevice; /* device table for horizontal
advance */
HB_Device YAdvanceDevice; /* device table for vertical
advance */
FT_UShort XIdPlacement; /* horizontal placement metric ID */
FT_UShort YIdPlacement; /* vertical placement metric ID */
FT_UShort XIdAdvance; /* horizontal advance metric ID */
FT_UShort YIdAdvance; /* vertical advance metric ID */
};
typedef struct HB_ValueRecord_ HB_ValueRecord;
/* Mask values to scan the value format of the ValueRecord structure.
We always expand compressed ValueRecords of the font. */
#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT 0x0001
#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT 0x0002
#define HB_GPOS_FORMAT_HAVE_X_ADVANCE 0x0004
#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE 0x0008
#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE 0x0010
#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE 0x0020
#define HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE 0x0040
#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE 0x0080
#define HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT 0x0100
#define HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT 0x0200
#define HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE 0x0400
#define HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE 0x0800
struct HB_AnchorFormat1_
{
FT_Short XCoordinate; /* horizontal value */
FT_Short YCoordinate; /* vertical value */
};
typedef struct HB_AnchorFormat1_ HB_AnchorFormat1;
struct HB_AnchorFormat2_
{
FT_Short XCoordinate; /* horizontal value */
FT_Short YCoordinate; /* vertical value */
FT_UShort AnchorPoint; /* index to glyph contour point */
};
typedef struct HB_AnchorFormat2_ HB_AnchorFormat2;
struct HB_AnchorFormat3_
{
FT_Short XCoordinate; /* horizontal value */
FT_Short YCoordinate; /* vertical value */
HB_Device XDeviceTable; /* device table for X coordinate */
HB_Device YDeviceTable; /* device table for Y coordinate */
};
typedef struct HB_AnchorFormat3_ HB_AnchorFormat3;
struct HB_AnchorFormat4_
{
FT_UShort XIdAnchor; /* horizontal metric ID */
FT_UShort YIdAnchor; /* vertical metric ID */
};
typedef struct HB_AnchorFormat4_ HB_AnchorFormat4;
struct HB_Anchor_
{
FT_UShort PosFormat; /* 1, 2, 3, or 4 -- 0 indicates
that there is no Anchor table */
union
{
HB_AnchorFormat1 af1;
HB_AnchorFormat2 af2;
HB_AnchorFormat3 af3;
HB_AnchorFormat4 af4;
} af;
};
typedef struct HB_Anchor_ HB_Anchor;
struct HB_MarkRecord_
{
FT_UShort Class; /* mark class */
HB_Anchor MarkAnchor; /* anchor table */
};
typedef struct HB_MarkRecord_ HB_MarkRecord;
struct HB_MarkArray_
{
FT_UShort MarkCount; /* number of MarkRecord tables */
HB_MarkRecord* MarkRecord; /* array of MarkRecord tables */
};
typedef struct HB_MarkArray_ HB_MarkArray;
/* LookupType 1 */
struct HB_SinglePosFormat1_
{
HB_ValueRecord Value; /* ValueRecord for all covered
glyphs */
};
typedef struct HB_SinglePosFormat1_ HB_SinglePosFormat1;
struct HB_SinglePosFormat2_
{
FT_UShort ValueCount; /* number of ValueRecord tables */
HB_ValueRecord* Value; /* array of ValueRecord tables */
};
typedef struct HB_SinglePosFormat2_ HB_SinglePosFormat2;
struct HB_SinglePos_
{
FT_UShort PosFormat; /* 1 or 2 */
HB_Coverage Coverage; /* Coverage table */
FT_UShort ValueFormat; /* format of ValueRecord table */
union
{
HB_SinglePosFormat1 spf1;
HB_SinglePosFormat2 spf2;
} spf;
};
typedef struct HB_SinglePos_ HB_SinglePos;
/* LookupType 2 */
struct HB_PairValueRecord_
{
FT_UShort SecondGlyph; /* glyph ID for second glyph */
HB_ValueRecord Value1; /* pos. data for first glyph */
HB_ValueRecord Value2; /* pos. data for second glyph */
};
typedef struct HB_PairValueRecord_ HB_PairValueRecord;
struct HB_PairSet_
{
FT_UShort PairValueCount;
/* number of PairValueRecord tables */
HB_PairValueRecord* PairValueRecord;
/* array of PairValueRecord tables */
};
typedef struct HB_PairSet_ HB_PairSet;
struct HB_PairPosFormat1_
{
FT_UShort PairSetCount; /* number of PairSet tables */
HB_PairSet* PairSet; /* array of PairSet tables */
};
typedef struct HB_PairPosFormat1_ HB_PairPosFormat1;
struct HB_Class2Record_
{
HB_ValueRecord Value1; /* pos. data for first glyph */
HB_ValueRecord Value2; /* pos. data for second glyph */
};
typedef struct HB_Class2Record_ HB_Class2Record;
struct HB_Class1Record_
{
HB_Class2Record* Class2Record; /* array of Class2Record tables */
};
typedef struct HB_Class1Record_ HB_Class1Record;
struct HB_PairPosFormat2_
{
HB_ClassDefinition ClassDef1; /* class def. for first glyph */
HB_ClassDefinition ClassDef2; /* class def. for second glyph */
FT_UShort Class1Count; /* number of classes in ClassDef1
table */
FT_UShort Class2Count; /* number of classes in ClassDef2
table */
HB_Class1Record* Class1Record; /* array of Class1Record tables */
};
typedef struct HB_PairPosFormat2_ HB_PairPosFormat2;
struct HB_PairPos_
{
FT_UShort PosFormat; /* 1 or 2 */
HB_Coverage Coverage; /* Coverage table */
FT_UShort ValueFormat1; /* format of ValueRecord table
for first glyph */
FT_UShort ValueFormat2; /* format of ValueRecord table
for second glyph */
union
{
HB_PairPosFormat1 ppf1;
HB_PairPosFormat2 ppf2;
} ppf;
};
typedef struct HB_PairPos_ HB_PairPos;
/* LookupType 3 */
struct HB_EntryExitRecord_
{
HB_Anchor EntryAnchor; /* entry Anchor table */
HB_Anchor ExitAnchor; /* exit Anchor table */
};
typedef struct HB_EntryExitRecord_ HB_EntryExitRecord;
struct HB_CursivePos_
{
FT_UShort PosFormat; /* always 1 */
HB_Coverage Coverage; /* Coverage table */
FT_UShort EntryExitCount;
/* number of EntryExitRecord tables */
HB_EntryExitRecord* EntryExitRecord;
/* array of EntryExitRecord tables */
};
typedef struct HB_CursivePos_ HB_CursivePos;
/* LookupType 4 */
struct HB_BaseRecord_
{
HB_Anchor* BaseAnchor; /* array of base glyph anchor
tables */
};
typedef struct HB_BaseRecord_ HB_BaseRecord;
struct HB_BaseArray_
{
FT_UShort BaseCount; /* number of BaseRecord tables */
HB_BaseRecord* BaseRecord; /* array of BaseRecord tables */
};
typedef struct HB_BaseArray_ HB_BaseArray;
struct HB_MarkBasePos_
{
FT_UShort PosFormat; /* always 1 */
HB_Coverage MarkCoverage; /* mark glyph coverage table */
HB_Coverage BaseCoverage; /* base glyph coverage table */
FT_UShort ClassCount; /* number of mark classes */
HB_MarkArray MarkArray; /* mark array table */
HB_BaseArray BaseArray; /* base array table */
};
typedef struct HB_MarkBasePos_ HB_MarkBasePos;
/* LookupType 5 */
struct HB_ComponentRecord_
{
HB_Anchor* LigatureAnchor; /* array of ligature glyph anchor
tables */
};
typedef struct HB_ComponentRecord_ HB_ComponentRecord;
struct HB_LigatureAttach_
{
FT_UShort ComponentCount;
/* number of ComponentRecord tables */
HB_ComponentRecord* ComponentRecord;
/* array of ComponentRecord tables */
};
typedef struct HB_LigatureAttach_ HB_LigatureAttach;
struct HB_LigatureArray_
{
FT_UShort LigatureCount; /* number of LigatureAttach tables */
HB_LigatureAttach* LigatureAttach;
/* array of LigatureAttach tables */
};
typedef struct HB_LigatureArray_ HB_LigatureArray;
struct HB_MarkLigPos_
{
FT_UShort PosFormat; /* always 1 */
HB_Coverage MarkCoverage; /* mark glyph coverage table */
HB_Coverage LigatureCoverage;
/* ligature glyph coverage table */
FT_UShort ClassCount; /* number of mark classes */
HB_MarkArray MarkArray; /* mark array table */
HB_LigatureArray LigatureArray; /* ligature array table */
};
typedef struct HB_MarkLigPos_ HB_MarkLigPos;
/* LookupType 6 */
struct HB_Mark2Record_
{
HB_Anchor* Mark2Anchor; /* array of mark glyph anchor
tables */
};
typedef struct HB_Mark2Record_ HB_Mark2Record;
struct HB_Mark2Array_
{
FT_UShort Mark2Count; /* number of Mark2Record tables */
HB_Mark2Record* Mark2Record; /* array of Mark2Record tables */
};
typedef struct HB_Mark2Array_ HB_Mark2Array;
struct HB_MarkMarkPos_
{
FT_UShort PosFormat; /* always 1 */
HB_Coverage Mark1Coverage; /* first mark glyph coverage table */
HB_Coverage Mark2Coverage; /* second mark glyph coverave table */
FT_UShort ClassCount; /* number of combining mark classes */
HB_MarkArray Mark1Array; /* MarkArray table for first mark */
HB_Mark2Array Mark2Array; /* MarkArray table for second mark */
};
typedef struct HB_MarkMarkPos_ HB_MarkMarkPos;
/* needed by both lookup type 7 and 8 */
struct HB_PosLookupRecord_
{
FT_UShort SequenceIndex; /* index into current
glyph sequence */
FT_UShort LookupListIndex; /* Lookup to apply to that pos. */
};
typedef struct HB_PosLookupRecord_ HB_PosLookupRecord;
/* LookupType 7 */
struct HB_PosRule_
{
FT_UShort GlyphCount; /* total number of input glyphs */
FT_UShort PosCount; /* number of PosLookupRecord tables */
FT_UShort* Input; /* array of input glyph IDs */
HB_PosLookupRecord* PosLookupRecord;
/* array of PosLookupRecord tables */
};
typedef struct HB_PosRule_ HB_PosRule;
struct HB_PosRuleSet_
{
FT_UShort PosRuleCount; /* number of PosRule tables */
HB_PosRule* PosRule; /* array of PosRule tables */
};
typedef struct HB_PosRuleSet_ HB_PosRuleSet;
struct HB_ContextPosFormat1_
{
HB_Coverage Coverage; /* Coverage table */
FT_UShort PosRuleSetCount; /* number of PosRuleSet tables */
HB_PosRuleSet* PosRuleSet; /* array of PosRuleSet tables */
};
typedef struct HB_ContextPosFormat1_ HB_ContextPosFormat1;
struct HB_PosClassRule_
{
FT_UShort GlyphCount; /* total number of context classes */
FT_UShort PosCount; /* number of PosLookupRecord tables */
FT_UShort* Class; /* array of classes */
HB_PosLookupRecord* PosLookupRecord;
/* array of PosLookupRecord tables */
};
typedef struct HB_PosClassRule_ HB_PosClassRule;
struct HB_PosClassSet_
{
FT_UShort PosClassRuleCount;
/* number of PosClassRule tables */
HB_PosClassRule* PosClassRule; /* array of PosClassRule tables */
};
typedef struct HB_PosClassSet_ HB_PosClassSet;
/* The `MaxContextLength' field is not defined in the TTO specification
but simplifies the implementation of this format. It holds the
maximal context length used in the context rules. */
struct HB_ContextPosFormat2_
{
FT_UShort MaxContextLength;
/* maximal context length */
HB_Coverage Coverage; /* Coverage table */
HB_ClassDefinition ClassDef; /* ClassDef table */
FT_UShort PosClassSetCount;
/* number of PosClassSet tables */
HB_PosClassSet* PosClassSet; /* array of PosClassSet tables */
};
typedef struct HB_ContextPosFormat2_ HB_ContextPosFormat2;
struct HB_ContextPosFormat3_
{
FT_UShort GlyphCount; /* number of input glyphs */
FT_UShort PosCount; /* number of PosLookupRecord tables */
HB_Coverage* Coverage; /* array of Coverage tables */
HB_PosLookupRecord* PosLookupRecord;
/* array of PosLookupRecord tables */
};
typedef struct HB_ContextPosFormat3_ HB_ContextPosFormat3;
struct HB_ContextPos_
{
FT_UShort PosFormat; /* 1, 2, or 3 */
union
{
HB_ContextPosFormat1 cpf1;
HB_ContextPosFormat2 cpf2;
HB_ContextPosFormat3 cpf3;
} cpf;
};
typedef struct HB_ContextPos_ HB_ContextPos;
/* LookupType 8 */
struct HB_ChainPosRule_
{
FT_UShort BacktrackGlyphCount;
/* total number of backtrack glyphs */
FT_UShort* Backtrack; /* array of backtrack glyph IDs */
FT_UShort InputGlyphCount;
/* total number of input glyphs */
FT_UShort* Input; /* array of input glyph IDs */
FT_UShort LookaheadGlyphCount;
/* total number of lookahead glyphs */
FT_UShort* Lookahead; /* array of lookahead glyph IDs */
FT_UShort PosCount; /* number of PosLookupRecords */
HB_PosLookupRecord* PosLookupRecord;
/* array of PosLookupRecords */
};
typedef struct HB_ChainPosRule_ HB_ChainPosRule;
struct HB_ChainPosRuleSet_
{
FT_UShort ChainPosRuleCount;
/* number of ChainPosRule tables */
HB_ChainPosRule* ChainPosRule; /* array of ChainPosRule tables */
};
typedef struct HB_ChainPosRuleSet_ HB_ChainPosRuleSet;
struct HB_ChainContextPosFormat1_
{
HB_Coverage Coverage; /* Coverage table */
FT_UShort ChainPosRuleSetCount;
/* number of ChainPosRuleSet tables */
HB_ChainPosRuleSet* ChainPosRuleSet;
/* array of ChainPosRuleSet tables */
};
typedef struct HB_ChainContextPosFormat1_ HB_ChainContextPosFormat1;
struct HB_ChainPosClassRule_
{
FT_UShort BacktrackGlyphCount;
/* total number of backtrack
classes */
FT_UShort* Backtrack; /* array of backtrack classes */
FT_UShort InputGlyphCount;
/* total number of context classes */
FT_UShort* Input; /* array of context classes */
FT_UShort LookaheadGlyphCount;
/* total number of lookahead
classes */
FT_UShort* Lookahead; /* array of lookahead classes */
FT_UShort PosCount; /* number of PosLookupRecords */
HB_PosLookupRecord* PosLookupRecord;
/* array of substitution lookups */
};
typedef struct HB_ChainPosClassRule_ HB_ChainPosClassRule;
struct HB_ChainPosClassSet_
{
FT_UShort ChainPosClassRuleCount;
/* number of ChainPosClassRule
tables */
HB_ChainPosClassRule* ChainPosClassRule;
/* array of ChainPosClassRule
tables */
};
typedef struct HB_ChainPosClassSet_ HB_ChainPosClassSet;
/* The `MaxXXXLength' fields are not defined in the TTO specification
but simplifies the implementation of this format. It holds the
maximal context length used in the specific context rules. */
struct HB_ChainContextPosFormat2_
{
HB_Coverage Coverage; /* Coverage table */
FT_UShort MaxBacktrackLength;
/* maximal backtrack length */
HB_ClassDefinition BacktrackClassDef;
/* BacktrackClassDef table */
FT_UShort MaxInputLength;
/* maximal input length */
HB_ClassDefinition InputClassDef;
/* InputClassDef table */
FT_UShort MaxLookaheadLength;
/* maximal lookahead length */
HB_ClassDefinition LookaheadClassDef;
/* LookaheadClassDef table */
FT_UShort ChainPosClassSetCount;
/* number of ChainPosClassSet
tables */
HB_ChainPosClassSet* ChainPosClassSet;
/* array of ChainPosClassSet
tables */
};
typedef struct HB_ChainContextPosFormat2_ HB_ChainContextPosFormat2;
struct HB_ChainContextPosFormat3_
{
FT_UShort BacktrackGlyphCount;
/* number of backtrack glyphs */
HB_Coverage* BacktrackCoverage;
/* array of backtrack Coverage
tables */
FT_UShort InputGlyphCount;
/* number of input glyphs */
HB_Coverage* InputCoverage;
/* array of input coverage
tables */
FT_UShort LookaheadGlyphCount;
/* number of lookahead glyphs */
HB_Coverage* LookaheadCoverage;
/* array of lookahead coverage
tables */
FT_UShort PosCount; /* number of PosLookupRecords */
HB_PosLookupRecord* PosLookupRecord;
/* array of substitution lookups */
};
typedef struct HB_ChainContextPosFormat3_ HB_ChainContextPosFormat3;
struct HB_ChainContextPos_
{
FT_UShort PosFormat; /* 1, 2, or 3 */
union
{
HB_ChainContextPosFormat1 ccpf1;
HB_ChainContextPosFormat2 ccpf2;
HB_ChainContextPosFormat3 ccpf3;
} ccpf;
};
typedef struct HB_ChainContextPos_ HB_ChainContextPos;
union HB_GPOS_SubTable_
{
HB_SinglePos single;
HB_PairPos pair;
HB_CursivePos cursive;
HB_MarkBasePos markbase;
HB_MarkLigPos marklig;
HB_MarkMarkPos markmark;
HB_ContextPos context;
HB_ChainContextPos chain;
};
typedef union HB_GPOS_SubTable_ HB_GPOS_SubTable;
FT_Error _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
FT_Stream stream,
FT_UShort lookup_type );
void _HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,
FT_Memory memory,
FT_UShort lookup_type );
FT_END_HEADER
#endif /* HARFBUZZ_GPOS_PRIVATE_H */

6269
src/harfbuzz-gpos.c Normal file

File diff suppressed because it is too large Load Diff

168
src/harfbuzz-gpos.h Normal file
View File

@ -0,0 +1,168 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_GPOS_H
#define HARFBUZZ_GPOS_H
#include "harfbuzz-gdef.h"
#include "harfbuzz-buffer.h"
FT_BEGIN_HEADER
#define HB_Err_Invalid_GPOS_SubTable_Format 0x1020
#define HB_Err_Invalid_GPOS_SubTable 0x1021
/* Lookup types for glyph positioning */
#define HB_GPOS_LOOKUP_SINGLE 1
#define HB_GPOS_LOOKUP_PAIR 2
#define HB_GPOS_LOOKUP_CURSIVE 3
#define HB_GPOS_LOOKUP_MARKBASE 4
#define HB_GPOS_LOOKUP_MARKLIG 5
#define HB_GPOS_LOOKUP_MARKMARK 6
#define HB_GPOS_LOOKUP_CONTEXT 7
#define HB_GPOS_LOOKUP_CHAIN 8
#define HB_GPOS_LOOKUP_EXTENSION 9
/* A pointer to a function which loads a glyph. Its parameters are
the same as in a call to Load_Glyph() -- if no glyph loading
function will be registered with HB_GPOS_Register_Glyph_Function(),
Load_Glyph() will be called indeed. The purpose of this function
pointer is to provide a hook for caching glyph outlines and sbits
(using the instance's generic pointer to hold the data).
If for some reason no outline data is available (e.g. for an
embedded bitmap glyph), _glyph->outline.n_points should be set to
zero. _glyph can be computed with
_glyph = HANDLE_Glyph( glyph ) */
typedef FT_Error (*HB_GlyphFunction)(FT_Face face,
FT_UInt glyphIndex,
FT_Int loadFlags );
/* A pointer to a function which accesses the PostScript interpreter.
Multiple Master fonts need this interface to convert a metric ID
(as stored in an OpenType font version 1.2 or higher) `metric_id'
into a metric value (returned in `metric_value').
`data' points to the user-defined structure specified during a
call to HB_GPOS_Register_MM_Function().
`metric_value' must be returned as a scaled value (but shouldn't
be rounded). */
typedef FT_Error (*HB_MMFunction)(FT_Face face,
FT_UShort metric_id,
FT_Pos* metric_value,
void* data );
struct HB_GPOSHeader_
{
FT_Memory memory;
FT_Fixed Version;
HB_ScriptList ScriptList;
HB_FeatureList FeatureList;
HB_LookupList LookupList;
HB_GDEFHeader* gdef;
/* the next field is used for a callback function to get the
glyph outline. */
HB_GlyphFunction gfunc;
/* this is OpenType 1.2 -- Multiple Master fonts need this
callback function to get various metric values from the
PostScript interpreter. */
HB_MMFunction mmfunc;
void* data;
};
typedef struct HB_GPOSHeader_ HB_GPOSHeader;
typedef HB_GPOSHeader* HB_GPOS;
FT_Error HB_Load_GPOS_Table( FT_Face face,
HB_GPOSHeader** gpos,
HB_GDEFHeader* gdef );
FT_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos );
FT_Error HB_GPOS_Select_Script( HB_GPOSHeader* gpos,
FT_ULong script_tag,
FT_UShort* script_index );
FT_Error HB_GPOS_Select_Language( HB_GPOSHeader* gpos,
FT_ULong language_tag,
FT_UShort script_index,
FT_UShort* language_index,
FT_UShort* req_feature_index );
FT_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
FT_ULong feature_tag,
FT_UShort script_index,
FT_UShort language_index,
FT_UShort* feature_index );
FT_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos,
FT_ULong** script_tag_list );
FT_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos,
FT_UShort script_index,
FT_ULong** language_tag_list );
FT_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
FT_UShort script_index,
FT_UShort language_index,
FT_ULong** feature_tag_list );
FT_Error HB_GPOS_Add_Feature( HB_GPOSHeader* gpos,
FT_UShort feature_index,
FT_UInt property );
FT_Error HB_GPOS_Clear_Features( HB_GPOSHeader* gpos );
FT_Error HB_GPOS_Register_Glyph_Function( HB_GPOSHeader* gpos,
HB_GlyphFunction gfunc );
FT_Error HB_GPOS_Register_MM_Function( HB_GPOSHeader* gpos,
HB_MMFunction mmfunc,
void* data );
/* If `dvi' is TRUE, glyph contour points for anchor points and device
tables are ignored -- you will get device independent values. */
FT_Error HB_GPOS_Apply_String( FT_Face face,
HB_GPOSHeader* gpos,
FT_UShort load_flags,
HB_Buffer buffer,
FT_Bool dvi,
FT_Bool r2l );
FT_END_HEADER
#endif /* HARFBUZZ_GPOS_H */

448
src/harfbuzz-gsub-private.h Normal file
View File

@ -0,0 +1,448 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_GSUB_PRIVATE_H
#define HARFBUZZ_GSUB_PRIVATE_H
#include "harfbuzz-gsub.h"
FT_BEGIN_HEADER
typedef union HB_GSUB_SubTable_ HB_GSUB_SubTable;
/* LookupType 1 */
struct HB_SingleSubstFormat1_
{
FT_Short DeltaGlyphID; /* constant added to get
substitution glyph index */
};
typedef struct HB_SingleSubstFormat1_ HB_SingleSubstFormat1;
struct HB_SingleSubstFormat2_
{
FT_UShort GlyphCount; /* number of glyph IDs in
Substitute array */
FT_UShort* Substitute; /* array of substitute glyph IDs */
};
typedef struct HB_SingleSubstFormat2_ HB_SingleSubstFormat2;
struct HB_SingleSubst_
{
FT_UShort SubstFormat; /* 1 or 2 */
HB_Coverage Coverage; /* Coverage table */
union
{
HB_SingleSubstFormat1 ssf1;
HB_SingleSubstFormat2 ssf2;
} ssf;
};
typedef struct HB_SingleSubst_ HB_SingleSubst;
/* LookupType 2 */
struct HB_Sequence_
{
FT_UShort GlyphCount; /* number of glyph IDs in the
Substitute array */
FT_UShort* Substitute; /* string of glyph IDs to
substitute */
};
typedef struct HB_Sequence_ HB_Sequence;
struct HB_MultipleSubst_
{
FT_UShort SubstFormat; /* always 1 */
HB_Coverage Coverage; /* Coverage table */
FT_UShort SequenceCount; /* number of Sequence tables */
HB_Sequence* Sequence; /* array of Sequence tables */
};
typedef struct HB_MultipleSubst_ HB_MultipleSubst;
/* LookupType 3 */
struct HB_AlternateSet_
{
FT_UShort GlyphCount; /* number of glyph IDs in the
Alternate array */
FT_UShort* Alternate; /* array of alternate glyph IDs */
};
typedef struct HB_AlternateSet_ HB_AlternateSet;
struct HB_AlternateSubst_
{
FT_UShort SubstFormat; /* always 1 */
HB_Coverage Coverage; /* Coverage table */
FT_UShort AlternateSetCount;
/* number of AlternateSet tables */
HB_AlternateSet* AlternateSet; /* array of AlternateSet tables */
};
typedef struct HB_AlternateSubst_ HB_AlternateSubst;
/* LookupType 4 */
struct HB_Ligature_
{
FT_UShort LigGlyph; /* glyphID of ligature
to substitute */
FT_UShort ComponentCount; /* number of components in ligature */
FT_UShort* Component; /* array of component glyph IDs */
};
typedef struct HB_Ligature_ HB_Ligature;
struct HB_LigatureSet_
{
FT_UShort LigatureCount; /* number of Ligature tables */
HB_Ligature* Ligature; /* array of Ligature tables */
};
typedef struct HB_LigatureSet_ HB_LigatureSet;
struct HB_LigatureSubst_
{
FT_UShort SubstFormat; /* always 1 */
HB_Coverage Coverage; /* Coverage table */
FT_UShort LigatureSetCount; /* number of LigatureSet tables */
HB_LigatureSet* LigatureSet; /* array of LigatureSet tables */
};
typedef struct HB_LigatureSubst_ HB_LigatureSubst;
/* needed by both lookup type 5 and 6 */
struct HB_SubstLookupRecord_
{
FT_UShort SequenceIndex; /* index into current
glyph sequence */
FT_UShort LookupListIndex; /* Lookup to apply to that pos. */
};
typedef struct HB_SubstLookupRecord_ HB_SubstLookupRecord;
/* LookupType 5 */
struct HB_SubRule_
{
FT_UShort GlyphCount; /* total number of input glyphs */
FT_UShort SubstCount; /* number of SubstLookupRecord
tables */
FT_UShort* Input; /* array of input glyph IDs */
HB_SubstLookupRecord* SubstLookupRecord;
/* array of SubstLookupRecord
tables */
};
typedef struct HB_SubRule_ HB_SubRule;
struct HB_SubRuleSet_
{
FT_UShort SubRuleCount; /* number of SubRule tables */
HB_SubRule* SubRule; /* array of SubRule tables */
};
typedef struct HB_SubRuleSet_ HB_SubRuleSet;
struct HB_ContextSubstFormat1_
{
HB_Coverage Coverage; /* Coverage table */
FT_UShort SubRuleSetCount; /* number of SubRuleSet tables */
HB_SubRuleSet* SubRuleSet; /* array of SubRuleSet tables */
};
typedef struct HB_ContextSubstFormat1_ HB_ContextSubstFormat1;
struct HB_SubClassRule_
{
FT_UShort GlyphCount; /* total number of context classes */
FT_UShort SubstCount; /* number of SubstLookupRecord
tables */
FT_UShort* Class; /* array of classes */
HB_SubstLookupRecord* SubstLookupRecord;
/* array of SubstLookupRecord
tables */
};
typedef struct HB_SubClassRule_ HB_SubClassRule;
struct HB_SubClassSet_
{
FT_UShort SubClassRuleCount;
/* number of SubClassRule tables */
HB_SubClassRule* SubClassRule; /* array of SubClassRule tables */
};
typedef struct HB_SubClassSet_ HB_SubClassSet;
/* The `MaxContextLength' field is not defined in the TTO specification
but simplifies the implementation of this format. It holds the
maximal context length used in the context rules. */
struct HB_ContextSubstFormat2_
{
FT_UShort MaxContextLength;
/* maximal context length */
HB_Coverage Coverage; /* Coverage table */
HB_ClassDefinition ClassDef; /* ClassDef table */
FT_UShort SubClassSetCount;
/* number of SubClassSet tables */
HB_SubClassSet* SubClassSet; /* array of SubClassSet tables */
};
typedef struct HB_ContextSubstFormat2_ HB_ContextSubstFormat2;
struct HB_ContextSubstFormat3_
{
FT_UShort GlyphCount; /* number of input glyphs */
FT_UShort SubstCount; /* number of SubstLookupRecords */
HB_Coverage* Coverage; /* array of Coverage tables */
HB_SubstLookupRecord* SubstLookupRecord;
/* array of substitution lookups */
};
typedef struct HB_ContextSubstFormat3_ HB_ContextSubstFormat3;
struct HB_ContextSubst_
{
FT_UShort SubstFormat; /* 1, 2, or 3 */
union
{
HB_ContextSubstFormat1 csf1;
HB_ContextSubstFormat2 csf2;
HB_ContextSubstFormat3 csf3;
} csf;
};
typedef struct HB_ContextSubst_ HB_ContextSubst;
/* LookupType 6 */
struct HB_ChainSubRule_
{
FT_UShort BacktrackGlyphCount;
/* total number of backtrack glyphs */
FT_UShort* Backtrack; /* array of backtrack glyph IDs */
FT_UShort InputGlyphCount;
/* total number of input glyphs */
FT_UShort* Input; /* array of input glyph IDs */
FT_UShort LookaheadGlyphCount;
/* total number of lookahead glyphs */
FT_UShort* Lookahead; /* array of lookahead glyph IDs */
FT_UShort SubstCount; /* number of SubstLookupRecords */
HB_SubstLookupRecord* SubstLookupRecord;
/* array of SubstLookupRecords */
};
typedef struct HB_ChainSubRule_ HB_ChainSubRule;
struct HB_ChainSubRuleSet_
{
FT_UShort ChainSubRuleCount;
/* number of ChainSubRule tables */
HB_ChainSubRule* ChainSubRule; /* array of ChainSubRule tables */
};
typedef struct HB_ChainSubRuleSet_ HB_ChainSubRuleSet;
struct HB_ChainContextSubstFormat1_
{
HB_Coverage Coverage; /* Coverage table */
FT_UShort ChainSubRuleSetCount;
/* number of ChainSubRuleSet tables */
HB_ChainSubRuleSet* ChainSubRuleSet;
/* array of ChainSubRuleSet tables */
};
typedef struct HB_ChainContextSubstFormat1_ HB_ChainContextSubstFormat1;
struct HB_ChainSubClassRule_
{
FT_UShort BacktrackGlyphCount;
/* total number of backtrack
classes */
FT_UShort* Backtrack; /* array of backtrack classes */
FT_UShort InputGlyphCount;
/* total number of context classes */
FT_UShort* Input; /* array of context classes */
FT_UShort LookaheadGlyphCount;
/* total number of lookahead
classes */
FT_UShort* Lookahead; /* array of lookahead classes */
FT_UShort SubstCount; /* number of SubstLookupRecords */
HB_SubstLookupRecord* SubstLookupRecord;
/* array of substitution lookups */
};
typedef struct HB_ChainSubClassRule_ HB_ChainSubClassRule;
struct HB_ChainSubClassSet_
{
FT_UShort ChainSubClassRuleCount;
/* number of ChainSubClassRule
tables */
HB_ChainSubClassRule* ChainSubClassRule;
/* array of ChainSubClassRule
tables */
};
typedef struct HB_ChainSubClassSet_ HB_ChainSubClassSet;
/* The `MaxXXXLength' fields are not defined in the TTO specification
but simplifies the implementation of this format. It holds the
maximal context length used in the specific context rules. */
struct HB_ChainContextSubstFormat2_
{
HB_Coverage Coverage; /* Coverage table */
FT_UShort MaxBacktrackLength;
/* maximal backtrack length */
HB_ClassDefinition BacktrackClassDef;
/* BacktrackClassDef table */
FT_UShort MaxInputLength;
/* maximal input length */
HB_ClassDefinition InputClassDef;
/* InputClassDef table */
FT_UShort MaxLookaheadLength;
/* maximal lookahead length */
HB_ClassDefinition LookaheadClassDef;
/* LookaheadClassDef table */
FT_UShort ChainSubClassSetCount;
/* number of ChainSubClassSet
tables */
HB_ChainSubClassSet* ChainSubClassSet;
/* array of ChainSubClassSet
tables */
};
typedef struct HB_ChainContextSubstFormat2_ HB_ChainContextSubstFormat2;
struct HB_ChainContextSubstFormat3_
{
FT_UShort BacktrackGlyphCount;
/* number of backtrack glyphs */
HB_Coverage* BacktrackCoverage;
/* array of backtrack Coverage
tables */
FT_UShort InputGlyphCount;
/* number of input glyphs */
HB_Coverage* InputCoverage;
/* array of input coverage
tables */
FT_UShort LookaheadGlyphCount;
/* number of lookahead glyphs */
HB_Coverage* LookaheadCoverage;
/* array of lookahead coverage
tables */
FT_UShort SubstCount; /* number of SubstLookupRecords */
HB_SubstLookupRecord* SubstLookupRecord;
/* array of substitution lookups */
};
typedef struct HB_ChainContextSubstFormat3_ HB_ChainContextSubstFormat3;
struct HB_ChainContextSubst_
{
FT_UShort SubstFormat; /* 1, 2, or 3 */
union
{
HB_ChainContextSubstFormat1 ccsf1;
HB_ChainContextSubstFormat2 ccsf2;
HB_ChainContextSubstFormat3 ccsf3;
} ccsf;
};
typedef struct HB_ChainContextSubst_ HB_ChainContextSubst;
/* LookupType 8 */
struct HB_ReverseChainContextSubst_
{
FT_UShort SubstFormat; /* always 1 */
HB_Coverage Coverage; /* coverage table for input glyphs */
FT_UShort BacktrackGlyphCount; /* number of backtrack glyphs */
HB_Coverage* BacktrackCoverage; /* array of backtrack Coverage
tables */
FT_UShort LookaheadGlyphCount; /* number of lookahead glyphs */
HB_Coverage* LookaheadCoverage; /* array of lookahead Coverage
tables */
FT_UShort GlyphCount; /* number of Glyph IDs */
FT_UShort* Substitute; /* array of substitute Glyph ID */
};
typedef struct HB_ReverseChainContextSubst_ HB_ReverseChainContextSubst;
union HB_GSUB_SubTable_
{
HB_SingleSubst single;
HB_MultipleSubst multiple;
HB_AlternateSubst alternate;
HB_LigatureSubst ligature;
HB_ContextSubst context;
HB_ChainContextSubst chain;
HB_ReverseChainContextSubst reverse;
};
FT_Error _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
FT_Stream stream,
FT_UShort lookup_type );
void _HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
FT_Memory memory,
FT_UShort lookup_type );
FT_END_HEADER
#endif /* HARFBUZZ_GSUB_PRIVATE_H */

4581
src/harfbuzz-gsub.c Normal file

File diff suppressed because it is too large Load Diff

132
src/harfbuzz-gsub.h Normal file
View File

@ -0,0 +1,132 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_GSUB_H
#define HARFBUZZ_GSUB_H
#include "harfbuzz-gdef.h"
#include "harfbuzz-buffer.h"
FT_BEGIN_HEADER
#define HB_Err_Invalid_GSUB_SubTable_Format 0x1010
#define HB_Err_Invalid_GSUB_SubTable 0x1011
/* Lookup types for glyph substitution */
#define HB_GSUB_LOOKUP_SINGLE 1
#define HB_GSUB_LOOKUP_MULTIPLE 2
#define HB_GSUB_LOOKUP_ALTERNATE 3
#define HB_GSUB_LOOKUP_LIGATURE 4
#define HB_GSUB_LOOKUP_CONTEXT 5
#define HB_GSUB_LOOKUP_CHAIN 6
#define HB_GSUB_LOOKUP_EXTENSION 7
#define HB_GSUB_LOOKUP_REVERSE_CHAIN 8
/* A pointer to a function which selects the alternate glyph. `pos' is
the position of the glyph with index `glyphID', `num_alternates'
gives the number of alternates in the `alternates' array. `data'
points to the user-defined structure specified during a call to
HB_GSUB_Register_Alternate_Function(). The function must return an
index into the `alternates' array. */
typedef FT_UShort (*HB_AltFunction)(FT_ULong pos,
FT_UShort glyphID,
FT_UShort num_alternates,
FT_UShort* alternates,
void* data );
struct HB_GSUBHeader_
{
FT_Memory memory;
FT_ULong offset;
FT_Fixed Version;
HB_ScriptList ScriptList;
HB_FeatureList FeatureList;
HB_LookupList LookupList;
HB_GDEFHeader* gdef;
/* the next two fields are used for an alternate substitution callback
function to select the proper alternate glyph. */
HB_AltFunction altfunc;
void* data;
};
typedef struct HB_GSUBHeader_ HB_GSUBHeader;
typedef HB_GSUBHeader* HB_GSUB;
FT_Error HB_Load_GSUB_Table( FT_Face face,
HB_GSUBHeader** gsub,
HB_GDEFHeader* gdef );
FT_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub );
FT_Error HB_GSUB_Select_Script( HB_GSUBHeader* gsub,
FT_ULong script_tag,
FT_UShort* script_index );
FT_Error HB_GSUB_Select_Language( HB_GSUBHeader* gsub,
FT_ULong language_tag,
FT_UShort script_index,
FT_UShort* language_index,
FT_UShort* req_feature_index );
FT_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
FT_ULong feature_tag,
FT_UShort script_index,
FT_UShort language_index,
FT_UShort* feature_index );
FT_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub,
FT_ULong** script_tag_list );
FT_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
FT_UShort script_index,
FT_ULong** language_tag_list );
FT_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
FT_UShort script_index,
FT_UShort language_index,
FT_ULong** feature_tag_list );
FT_Error HB_GSUB_Add_Feature( HB_GSUBHeader* gsub,
FT_UShort feature_index,
FT_UInt property );
FT_Error HB_GSUB_Clear_Features( HB_GSUBHeader* gsub );
FT_Error HB_GSUB_Register_Alternate_Function( HB_GSUBHeader* gsub,
HB_AltFunction altfunc,
void* data );
FT_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub,
HB_Buffer buffer );
FT_END_HEADER
#endif /* HARFBUZZ_GSUB_H */

64
src/harfbuzz-impl.h Normal file
View File

@ -0,0 +1,64 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_IMPL_H
#define HARFBUZZ_IMPL_H
#include <ft2build.h>
#include FT_FREETYPE_H
FT_BEGIN_HEADER
#include "ftglue.h"
#ifndef FALSE
# define FALSE 0
#endif
#ifndef TRUE
# define TRUE 1
#endif
#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))
#define IN_GLYPH( pos ) (buffer->in_string[(pos)].gindex)
#define IN_ITEM( pos ) (&buffer->in_string[(pos)])
#define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].gindex)
#define IN_CURITEM() (&buffer->in_string[buffer->in_pos])
#define IN_PROPERTIES( pos ) (buffer->in_string[(pos)].properties)
#define IN_LIGID( pos ) (buffer->in_string[(pos)].ligID)
#define IN_COMPONENT( pos ) (buffer->in_string[(pos)].component)
#define POSITION( pos ) (&buffer->positions[(pos)])
#define OUT_GLYPH( pos ) (buffer->out_string[(pos)].gindex)
#define OUT_ITEM( pos ) (&buffer->out_string[(pos)])
#define CHECK_Property( gdef, index, flags, property ) \
( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags), \
(property) ) ) != FT_Err_Ok )
#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID ) \
( ( error = hb_buffer_add_output_glyphs( (buffer), \
(num_in), (num_out), \
(glyph_data), (component), (ligID) \
) ) != FT_Err_Ok )
#define ADD_Glyph( buffer, glyph_index, component, ligID ) \
( ( error = hb_buffer_add_output_glyph( (buffer), \
(glyph_index), (component), (ligID) \
) ) != FT_Err_Ok )
FT_END_HEADER
#endif /* HARFBUZZ_IMPL_H */

View File

@ -0,0 +1,81 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_OPEN_PRIVATE_H
#define HARFBUZZ_OPEN_PRIVATE_H
#include "harfbuzz-open.h"
#include "harfbuzz-gsub-private.h"
#include "harfbuzz-gpos-private.h"
FT_BEGIN_HEADER
struct HB_SubTable_
{
union
{
HB_GSUB_SubTable gsub;
HB_GPOS_SubTable gpos;
} st;
};
FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
FT_Stream stream );
FT_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
FT_Stream input );
FT_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
FT_Stream input,
HB_Type type );
FT_Error _HB_OPEN_Load_Coverage( HB_Coverage* c,
FT_Stream input );
FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
FT_UShort limit,
FT_Stream input );
FT_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd,
FT_Stream input );
FT_Error _HB_OPEN_Load_Device( HB_Device* d,
FT_Stream input );
void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl,
FT_Memory memory );
void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl,
FT_Memory memory );
void _HB_OPEN_Free_LookupList( HB_LookupList* ll,
HB_Type type,
FT_Memory memory );
void _HB_OPEN_Free_Coverage( HB_Coverage* c,
FT_Memory memory );
void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd,
FT_Memory memory );
void _HB_OPEN_Free_Device( HB_Device* d,
FT_Memory memory );
FT_Error _HB_OPEN_Coverage_Index( HB_Coverage* c,
FT_UShort glyphID,
FT_UShort* index );
FT_Error _HB_OPEN_Get_Class( HB_ClassDefinition* cd,
FT_UShort glyphID,
FT_UShort* class,
FT_UShort* index );
FT_Error _HB_OPEN_Get_Device( HB_Device* d,
FT_UShort size,
FT_Short* value );
FT_END_HEADER
#endif /* HARFBUZZ_OPEN_PRIVATE_H */

1426
src/harfbuzz-open.c Normal file

File diff suppressed because it is too large Load Diff

285
src/harfbuzz-open.h Normal file
View File

@ -0,0 +1,285 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_OPEN_H
#define HARFBUZZ_OPEN_H
#include <ft2build.h>
#include FT_FREETYPE_H
FT_BEGIN_HEADER
/* Use this if a feature applies to all glyphs */
#define HB_ALL_GLYPHS 0xFFFF
#define HB_DEFAULT_LANGUAGE 0xFFFF
#define HB_MAX_NESTING_LEVEL 100
#define HB_Err_Invalid_SubTable_Format 0x1000
#define HB_Err_Invalid_SubTable 0x1001
#define HB_Err_Not_Covered 0x1002
#define HB_Err_Too_Many_Nested_Contexts 0x1003
#define HB_Err_No_MM_Interpreter 0x1004
#define HB_Err_Empty_Script 0x1005
/* Script list related structures */
struct HB_LangSys_
{
FT_UShort LookupOrderOffset; /* always 0 for TT Open 1.0 */
FT_UShort ReqFeatureIndex; /* required FeatureIndex */
FT_UShort FeatureCount; /* number of Feature indices */
FT_UShort* FeatureIndex; /* array of Feature indices */
};
typedef struct HB_LangSys_ HB_LangSys;
struct HB_LangSysRecord_
{
FT_ULong LangSysTag; /* LangSysTag identifier */
HB_LangSys LangSys; /* LangSys table */
};
typedef struct HB_LangSysRecord_ HB_LangSysRecord;
struct HB_Script_
{
HB_LangSys DefaultLangSys; /* DefaultLangSys table */
FT_UShort LangSysCount; /* number of LangSysRecords */
HB_LangSysRecord* LangSysRecord; /* array of LangSysRecords */
};
typedef struct HB_Script_ HB_Script;
struct HB_ScriptRecord_
{
FT_ULong ScriptTag; /* ScriptTag identifier */
HB_Script Script; /* Script table */
};
typedef struct HB_ScriptRecord_ HB_ScriptRecord;
struct HB_ScriptList_
{
FT_UShort ScriptCount; /* number of ScriptRecords */
HB_ScriptRecord* ScriptRecord; /* array of ScriptRecords */
};
typedef struct HB_ScriptList_ HB_ScriptList;
/* Feature list related structures */
struct HB_Feature_
{
FT_UShort FeatureParams; /* always 0 for TT Open 1.0 */
FT_UShort LookupListCount; /* number of LookupList indices */
FT_UShort* LookupListIndex; /* array of LookupList indices */
};
typedef struct HB_Feature_ HB_Feature;
struct HB_FeatureRecord_
{
FT_ULong FeatureTag; /* FeatureTag identifier */
HB_Feature Feature; /* Feature table */
};
typedef struct HB_FeatureRecord_ HB_FeatureRecord;
struct HB_FeatureList_
{
FT_UShort FeatureCount; /* number of FeatureRecords */
HB_FeatureRecord* FeatureRecord; /* array of FeatureRecords */
FT_UShort* ApplyOrder; /* order to apply features */
FT_UShort ApplyCount; /* number of elements in ApplyOrder */
};
typedef struct HB_FeatureList_ HB_FeatureList;
/* Lookup list related structures */
typedef struct HB_SubTable_ HB_SubTable;
struct HB_Lookup_
{
FT_UShort LookupType; /* Lookup type */
FT_UShort LookupFlag; /* Lookup qualifiers */
FT_UShort SubTableCount; /* number of SubTables */
HB_SubTable* SubTable; /* array of SubTables */
};
typedef struct HB_Lookup_ HB_Lookup;
/* The `Properties' field is not defined in the OpenType specification but
is needed for processing lookups. If properties[n] is > 0, the
functions HB_GSUB_Apply_String() resp. HB_GPOS_Apply_String() will
process Lookup[n] for glyphs which have the specific bit not set in
the `properties' field of the input string object. */
struct HB_LookupList_
{
FT_UShort LookupCount; /* number of Lookups */
HB_Lookup* Lookup; /* array of Lookup records */
FT_UInt* Properties; /* array of flags */
};
typedef struct HB_LookupList_ HB_LookupList;
/* Possible LookupFlag bit masks. `HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS' comes from the
OpenType 1.2 specification; HB_LOOKUP_FLAG_RIGHT_TO_LEFT has been (re)introduced in
OpenType 1.3 -- if set, the last glyph in a cursive attachment
sequence has to be positioned on the baseline -- regardless of the
writing direction. */
#define HB_LOOKUP_FLAG_RIGHT_TO_LEFT 0x0001
#define HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS 0x0002
#define HB_LOOKUP_FLAG_IGNORE_LIGATURES 0x0004
#define HB_LOOKUP_FLAG_IGNORE_MARKS 0x0008
#define HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS 0xFF00
struct HB_CoverageFormat1_
{
FT_UShort GlyphCount; /* number of glyphs in GlyphArray */
FT_UShort* GlyphArray; /* array of glyph IDs */
};
typedef struct HB_CoverageFormat1_ HB_CoverageFormat1;
struct HB_RangeRecord_
{
FT_UShort Start; /* first glyph ID in the range */
FT_UShort End; /* last glyph ID in the range */
FT_UShort StartCoverageIndex; /* coverage index of first
glyph ID in the range */
};
typedef struct HB_RangeRecord_ HB_RangeRecord;
struct HB_CoverageFormat2_
{
FT_UShort RangeCount; /* number of RangeRecords */
HB_RangeRecord* RangeRecord; /* array of RangeRecords */
};
typedef struct HB_CoverageFormat2_ HB_CoverageFormat2;
struct HB_Coverage_
{
FT_UShort CoverageFormat; /* 1 or 2 */
union
{
HB_CoverageFormat1 cf1;
HB_CoverageFormat2 cf2;
} cf;
};
typedef struct HB_Coverage_ HB_Coverage;
struct HB_ClassDefFormat1_
{
FT_UShort StartGlyph; /* first glyph ID of the
ClassValueArray */
FT_UShort GlyphCount; /* size of the ClassValueArray */
FT_UShort* ClassValueArray; /* array of class values */
};
typedef struct HB_ClassDefFormat1_ HB_ClassDefFormat1;
struct HB_ClassRangeRecord_
{
FT_UShort Start; /* first glyph ID in the range */
FT_UShort End; /* last glyph ID in the range */
FT_UShort Class; /* applied to all glyphs in range */
};
typedef struct HB_ClassRangeRecord_ HB_ClassRangeRecord;
struct HB_ClassDefFormat2_
{
FT_UShort ClassRangeCount;
/* number of ClassRangeRecords */
HB_ClassRangeRecord* ClassRangeRecord;
/* array of ClassRangeRecords */
};
typedef struct HB_ClassDefFormat2_ HB_ClassDefFormat2;
/* The `Defined' field is not defined in the OpenType specification but
apparently needed for processing fonts like trado.ttf: This font
refers to a class which contains not a single element. We map such
classes to class 0. */
struct HB_ClassDefinition_
{
FT_Bool loaded;
FT_Bool* Defined; /* array of Booleans.
If Defined[n] is FALSE,
class n contains no glyphs. */
FT_UShort ClassFormat; /* 1 or 2 */
union
{
HB_ClassDefFormat1 cd1;
HB_ClassDefFormat2 cd2;
} cd;
};
typedef struct HB_ClassDefinition_ HB_ClassDefinition;
struct HB_Device_
{
FT_UShort StartSize; /* smallest size to correct */
FT_UShort EndSize; /* largest size to correct */
FT_UShort DeltaFormat; /* DeltaValue array data format:
1, 2, or 3 */
FT_UShort* DeltaValue; /* array of compressed data */
};
typedef struct HB_Device_ HB_Device;
enum HB_Type_
{
HB_Type_GSUB,
HB_Type_GPOS
};
typedef enum HB_Type_ HB_Type;
FT_END_HEADER
#endif /* HARFBUZZ_OPEN_H */

19
src/harfbuzz.c Normal file
View File

@ -0,0 +1,19 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#include "ftglue.c"
#include "harfbuzz-open.c"
#include "harfbuzz-buffer.c"
#include "harfbuzz-gdef.c"
#include "harfbuzz-gsub.c"
#include "harfbuzz-gpos.c"
#include "harfbuzz-dump.c"

23
src/harfbuzz.h Normal file
View File

@ -0,0 +1,23 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* See the file name COPYING for licensing information.
*
******************************************************************/
#ifndef HARFBUZZ_H
#define HARFBUZZ_H
#include "harfbuzz-open.h"
#include "harfbuzz-buffer.h"
#include "harfbuzz-gdef.h"
#include "harfbuzz-gsub.h"
#include "harfbuzz-gpos.h"
#include "harfbuzz-dump.h"
#endif /* HARFBUZZ_OPEN_H */

View File

@ -1,238 +0,0 @@
/* otlbuffer.c: Buffer of glyphs for substitution/positioning
*
* Copyright 2004 Red Hat Software
*
* Portions Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*/
#include <config.h>
#include <otlbuffer.h>
/* To get the gcc-3.3 strict-aliasing compatible versions
* FREE/REALLOC_ARRAY/etc. rather than the FT_* versions
* that
*/
#include "ftglue.h"
static FT_Error
otl_buffer_ensure( OTL_Buffer buffer,
FT_ULong size )
{
FT_Memory memory = buffer->memory;
FT_ULong new_allocated = buffer->allocated;
if (size > new_allocated)
{
FT_Error error;
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
if ( REALLOC_ARRAY( buffer->in_string, buffer->allocated, new_allocated, OTL_GlyphItemRec ) )
return error;
if ( REALLOC_ARRAY( buffer->out_string, buffer->allocated, new_allocated, OTL_GlyphItemRec ) )
return error;
if ( REALLOC_ARRAY( buffer->positions, buffer->allocated, new_allocated, OTL_PositionRec ) )
return error;
buffer->allocated = new_allocated;
}
return FT_Err_Ok;
}
FT_Error
otl_buffer_new( FT_Memory memory,
OTL_Buffer *buffer )
{
FT_Error error;
if ( ALLOC( *buffer, sizeof( OTL_BufferRec ) ) )
return error;
(*buffer)->memory = memory;
(*buffer)->in_length = 0;
(*buffer)->out_length = 0;
(*buffer)->allocated = 0;
(*buffer)->in_pos = 0;
(*buffer)->out_pos = 0;
(*buffer)->in_string = NULL;
(*buffer)->out_string = NULL;
(*buffer)->positions = NULL;
(*buffer)->max_ligID = 0;
return FT_Err_Ok;
}
FT_Error
otl_buffer_swap( OTL_Buffer buffer )
{
OTL_GlyphItem tmp_string;
tmp_string = buffer->in_string;
buffer->in_string = buffer->out_string;
buffer->out_string = tmp_string;
buffer->in_length = buffer->out_length;
buffer->out_length = 0;
buffer->in_pos = 0;
buffer->out_pos = 0;
return FT_Err_Ok;
}
FT_Error
otl_buffer_free( OTL_Buffer buffer )
{
FT_Memory memory = buffer->memory;
FREE( buffer->in_string );
FREE( buffer->out_string );
FREE( buffer->positions );
FREE( buffer );
return FT_Err_Ok;
}
FT_Error
otl_buffer_clear( OTL_Buffer buffer )
{
buffer->in_length = 0;
buffer->out_length = 0;
buffer->in_pos = 0;
buffer->out_pos = 0;
return FT_Err_Ok;
}
FT_Error
otl_buffer_add_glyph( OTL_Buffer buffer,
FT_UInt glyph_index,
FT_UInt properties,
FT_UInt cluster )
{
FT_Error error;
OTL_GlyphItem glyph;
error = otl_buffer_ensure( buffer, buffer->in_length + 1 );
if ( error )
return error;
glyph = &buffer->in_string[buffer->in_length];
glyph->gindex = glyph_index;
glyph->properties = properties;
glyph->cluster = cluster;
glyph->component = 0;
glyph->ligID = 0;
glyph->gproperties = OTL_GLYPH_PROPERTIES_UNKNOWN;
buffer->in_length++;
return FT_Err_Ok;
}
/* The following function copies `num_out' elements from `glyph_data'
to `buffer->out_string', advancing the in array pointer in the structure
by `num_in' elements, and the out array pointer by `num_out' elements.
Finally, it sets the `length' field of `out' equal to
`pos' of the `out' structure.
If `component' is 0xFFFF, the component value from buffer->in_pos
will copied `num_out' times, otherwise `component' itself will
be used to fill the `component' fields.
If `ligID' is 0xFFFF, the ligID value from buffer->in_pos
will copied `num_out' times, otherwise `ligID' itself will
be used to fill the `ligID' fields.
The properties for all replacement glyphs are taken
from the glyph at position `buffer->in_pos'.
The cluster value for the glyph at position buffer->in_pos is used
for all replacement glyphs */
FT_Error
otl_buffer_add_output_glyphs( OTL_Buffer buffer,
FT_UShort num_in,
FT_UShort num_out,
FT_UShort *glyph_data,
FT_UShort component,
FT_UShort ligID )
{
FT_Error error;
FT_UShort i;
FT_UInt properties;
FT_UInt cluster;
error = otl_buffer_ensure( buffer, buffer->out_pos + num_out );
if ( error )
return error;
properties = buffer->in_string[buffer->in_pos].properties;
cluster = buffer->in_string[buffer->in_pos].cluster;
if ( component == 0xFFFF )
component = buffer->in_string[buffer->in_pos].component;
if ( ligID == 0xFFFF )
ligID = buffer->in_string[buffer->in_pos].ligID;
for ( i = 0; i < num_out; i++ )
{
OTL_GlyphItem item = &buffer->out_string[buffer->out_pos + i];
item->gindex = glyph_data[i];
item->properties = properties;
item->cluster = cluster;
item->component = component;
item->ligID = ligID;
item->gproperties = OTL_GLYPH_PROPERTIES_UNKNOWN;
}
buffer->in_pos += num_in;
buffer->out_pos += num_out;
buffer->out_length = buffer->out_pos;
return FT_Err_Ok;
}
FT_Error
otl_buffer_add_output_glyph( OTL_Buffer buffer,
FT_UInt glyph_index,
FT_UShort component,
FT_UShort ligID )
{
FT_UShort glyph_data = glyph_index;
return otl_buffer_add_output_glyphs ( buffer, 1, 1,
&glyph_data, component, ligID );
}
FT_Error
otl_buffer_copy_output_glyph ( OTL_Buffer buffer )
{
FT_Error error;
error = otl_buffer_ensure( buffer, buffer->out_pos + 1 );
if ( error )
return error;
buffer->out_string[buffer->out_pos++] = buffer->in_string[buffer->in_pos++];
buffer->out_length = buffer->out_pos;
return FT_Err_Ok;
}
FT_UShort
otl_buffer_allocate_ligid( OTL_Buffer buffer )
{
return buffer->max_ligID++;
}

View File

@ -1,103 +0,0 @@
/* otlbuffer.h: Buffer of glyphs for substitution/positioning
*
* Copyrigh 2004 Red Hat Software
*
* Portions Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*/
#include <ft2build.h>
#include FT_FREETYPE_H
#include <glib.h>
G_BEGIN_DECLS
#define OTL_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
typedef struct OTL_GlyphItemRec_ {
FT_UInt gindex;
FT_UInt properties;
FT_UInt cluster;
FT_UShort component;
FT_UShort ligID;
FT_UShort gproperties;
} OTL_GlyphItemRec, *OTL_GlyphItem;
typedef struct OTL_PositionRec_ {
FT_Pos x_pos;
FT_Pos y_pos;
FT_Pos x_advance;
FT_Pos y_advance;
FT_UShort back; /* number of glyphs to go back
for drawing current glyph */
FT_Bool new_advance; /* if set, the advance width values are
absolute, i.e., they won't be
added to the original glyph's value
but rather replace them. */
FT_Short cursive_chain; /* character to which this connects,
may be positive or negative; used
only internally */
} OTL_PositionRec, *OTL_Position;
typedef struct OTL_BufferRec_{
FT_Memory memory;
FT_ULong allocated;
FT_ULong in_length;
FT_ULong out_length;
FT_ULong in_pos;
FT_ULong out_pos;
OTL_GlyphItem in_string;
OTL_GlyphItem out_string;
OTL_Position positions;
FT_UShort max_ligID;
} OTL_BufferRec, *OTL_Buffer;
FT_Error
otl_buffer_new( FT_Memory memory,
OTL_Buffer *buffer );
FT_Error
otl_buffer_swap( OTL_Buffer buffer );
FT_Error
otl_buffer_free( OTL_Buffer buffer );
FT_Error
otl_buffer_clear( OTL_Buffer buffer );
FT_Error
otl_buffer_add_glyph( OTL_Buffer buffer,
FT_UInt glyph_index,
FT_UInt properties,
FT_UInt cluster );
FT_Error
otl_buffer_add_output_glyphs( OTL_Buffer buffer,
FT_UShort num_in,
FT_UShort num_out,
FT_UShort *glyph_data,
FT_UShort component,
FT_UShort ligID );
FT_Error
otl_buffer_add_output_glyph ( OTL_Buffer buffer,
FT_UInt glyph_index,
FT_UShort component,
FT_UShort ligID );
FT_Error
otl_buffer_copy_output_glyph ( OTL_Buffer buffer );
FT_UShort
otl_buffer_allocate_ligid( OTL_Buffer buffer );
G_END_DECLS