mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-13 17:55:37 +00:00
Windows Libraries + FTGL and Textures working on Win32
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@494 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
481
src/WinLibs/FTGL/COPYING.txt
Normal file
481
src/WinLibs/FTGL/COPYING.txt
Normal file
@ -0,0 +1,481 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 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.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, 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 library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, 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 companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, 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 library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete 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 distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
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 Library or any portion
|
||||
of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
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 Library, 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 Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you 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.
|
||||
|
||||
If distribution of 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 satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. 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.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library 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.
|
||||
|
||||
9. 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 Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
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.
|
||||
|
||||
11. 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 Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library 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 Library.
|
||||
|
||||
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.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library 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.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library 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 Library
|
||||
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 Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
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
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. 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 LIBRARY 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
|
||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. 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 library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
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.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
307
src/WinLibs/FTGL/HISTORY.txt
Normal file
307
src/WinLibs/FTGL/HISTORY.txt
Normal file
@ -0,0 +1,307 @@
|
||||
FTGL 2.1.2 (FTGL_2_1_2)
|
||||
11 December 2004
|
||||
- Changed the way the colour is specified for Pixmap fonts. It can now be
|
||||
done per string rather than at start up as previous.
|
||||
- Fixed a couple of compilation errors caused by the new FTPoint stuff,
|
||||
mostly...
|
||||
- More const correctness. It's like a virus!
|
||||
|
||||
5 December 2004
|
||||
2.1.1 (FTGL_2_1_1)
|
||||
- Added the xCode project properly this time.
|
||||
|
||||
5 December 2004
|
||||
2.1.0 (FTGL_2_1_0)
|
||||
- Added texture co-ordinates to the geometry based font types.
|
||||
- Added the ability to turn off (or on) glDisplayList creation inside FTGL.
|
||||
- Removed unnecessary translates in the glyph rendering code.
|
||||
- Moved the Mac project to XCode.
|
||||
- Added a line height function to FTFont.
|
||||
- Got rid of the GL_TEXTURE_2D_BINDING_EXT call and replaced it with a
|
||||
static member.
|
||||
- Fixed a bug where resizing FTGLTextureFont caused a GL error.
|
||||
- Refactored FTPoint quite a bit.
|
||||
- More unit tests. Fixed a heap of bugs.
|
||||
|
||||
16 August 2004
|
||||
2.0.11 (FTGL_2_0_11)
|
||||
- Updated FTFont( *pBufferBytes, bufferSizeInBytes) documentation.
|
||||
|
||||
16 August 2004
|
||||
2.0.10 (FTGL_2_0_10)
|
||||
- Fixed tab problem in unix Makefile.
|
||||
- Added CYGWIN GLUTesselatorFunction define to FTVectoriser.
|
||||
|
||||
21 April 2004
|
||||
2.0.9 (FTGL_2_0_9)
|
||||
- Fixed includes for pre 2.1.7 versions of freetype
|
||||
- Changed unix build to create FTGL subdir for includes
|
||||
|
||||
9 April 2004
|
||||
2.0.8 (FTGL_2_0_8)
|
||||
- Fixes for deprecated identifiers in 2.1.5
|
||||
- Changed the internals to use FTGlyphSlot instead of FTGlyph
|
||||
- Added a unit test for FTBitmapGlyph, FTCharToGlyphIndexMap.
|
||||
- Fixed a memory leak in FTGlyphContainer.
|
||||
- Added the ability to get the list of charmaps in the font.
|
||||
- Changed FTGLTextureFont to use FTVector for texture id list.
|
||||
|
||||
31 August 2003
|
||||
2.07 (FTGL_2_0_7)
|
||||
- Minor fix for unix build scripts.
|
||||
- Minor fix for unit tests.
|
||||
|
||||
25 August 2003
|
||||
2.06 (FTGL_2_0_6)
|
||||
- Updated the unix build scripts.
|
||||
|
||||
25 August 2003
|
||||
2.05 (FTGL_2_0_5)
|
||||
- Refactored FTGlyphContainer & FTCharmap. They now store FTGlyphs
|
||||
sequentially rather than by glyph index. This should save a heap of
|
||||
memory and a bit of time at startup.
|
||||
- Changed the Mac font paths in the demos.
|
||||
- Changed the unit tests for new hinter in Freetype 2.1.4.
|
||||
- Added a test for broken contour tags.
|
||||
|
||||
12 April 2003
|
||||
2.04 (FTGL_2_0_4)
|
||||
- Fixed resize behavior in FTGLTextureFont.
|
||||
|
||||
9 April 2003
|
||||
2.03 (FTGL_2_0_3)
|
||||
- Fix in FTContour to handle broken contours.
|
||||
|
||||
3 April 2003
|
||||
2.02 (FTGL_2_0_2)
|
||||
- Fixed memory leaks
|
||||
|
||||
14 March 2003
|
||||
2.01 (FTGL_2_0_1)
|
||||
- Minor changes to autoconf to detect glu
|
||||
|
||||
11 March 2003
|
||||
2.0 (FTGL_2_0_0)
|
||||
- Fixed some alignment bugs caused by changes to Freetype ( > 2.0.9).
|
||||
- Minor fixes to float declarations.
|
||||
- Moved FTBBox and FTPoint to their own files and added Move() and
|
||||
operator += to FTBBox
|
||||
- Replaced FT_Vector with FTPoint for kerning.
|
||||
- Fixed the glPushAttrib calls.
|
||||
- Changed gluTess callback def.
|
||||
- Rewriting FTGLDemo.
|
||||
- Minor fixes for irix.
|
||||
- Removed a bunch of redundant members and made them function locals.
|
||||
- Removed the Open() & Close() functions from FTFont because there was
|
||||
no way to handle Close correctly which makes Open redundant.
|
||||
- Removed Open() from FTface.
|
||||
- Improved the robustness of some of the error handling.
|
||||
- Removed the FTCharmap Platform/Encoding function.
|
||||
- Added unit tests.
|
||||
- Removed the precache flag.
|
||||
- Unvirtualised functions in FTLibrary and FTGlyphContainer.
|
||||
- Fixed empty string bug in FTFont::BBox.
|
||||
- Refactored FTContour and moved it to it's own file.
|
||||
- Removed unnecessary memory allocations in vector Glyphs. They now
|
||||
access the vector data directly.
|
||||
- Made vectoriser a local variable in vector glyphs.
|
||||
- Fixed a long standing visual bug in FTVectoriser.
|
||||
- Changed size calculations to use floats instead of ints. This includes
|
||||
FTBBox.
|
||||
- Refactored FTGlyph. Now calculates advance (as a float) and bbox.
|
||||
- Changed contourList from FTVector to an array in FTVectoriser.
|
||||
- Made function and member names more consistant.
|
||||
- Moved header files to include directory.
|
||||
- Mesh now uses a list for glCombine points.
|
||||
- Delete the display lists.
|
||||
- Unix AutoConf support.
|
||||
- Attach 'files' from memory.
|
||||
|
||||
October 23 2002
|
||||
1.4 (FTGL_1_4)
|
||||
- FTGL now requires 2.0.9 or later. See below for reason.
|
||||
- Merged 1.32 branch with main tree
|
||||
- Glyph loading has been optimised for pixel based glyphs.
|
||||
- Removed mmgr
|
||||
- Added FTFont::Attach
|
||||
- Updated API docs
|
||||
- Removed stl map and vector. Replaced by code supplied by Sebastien Barre
|
||||
- Removed work around for Type1 height and width bug in freetype. It seems
|
||||
to be fixed in 2.0.9
|
||||
- Added a test target to the Mac OSX project
|
||||
- Inline some private functions.
|
||||
|
||||
April 23 2002
|
||||
1.32 (FTGL_1_3_2)
|
||||
- Fixed enable state attribute in FTGLBitmapFont
|
||||
- Wrapped tb.h & trackball.h in EXTERN "C"
|
||||
- Renamed FTGLDemo to .cpp
|
||||
Ellers...
|
||||
- New MSVC projects updated to v1.3
|
||||
- Removed a lot of unnecessary Windows stuff from ftgl.h
|
||||
- Added functions to load font from memory.
|
||||
- Fixed a couple of Windows 'for' scope problems in FTExtrdGlyph
|
||||
- FTGLDemo - Added #define for windows font
|
||||
|
||||
January 30 2002
|
||||
1.31 (FTGL_1_3_1)
|
||||
- Forgot to update readme etc for 1.3
|
||||
|
||||
January 27 2002
|
||||
1.3b5 (FTGL_1_3_BETA_5)
|
||||
- FTBbox now uses float rather then int
|
||||
- Fixed some more warnings (size_t)
|
||||
- Removed the contour winding function because it didn't fix the problem!!
|
||||
- Fixed up some state settings in fonts.
|
||||
|
||||
December 11 2001
|
||||
1.3b4 (FTGL_1_3_BETA_4)
|
||||
- Added MAC OSX project (Project Builder)
|
||||
- Added a function for extruded glyphs that calculates the winding order of
|
||||
the glyph contour.
|
||||
- Added FTGL_DEBUG to include memory debugger.
|
||||
- Added a couple of typedefs to FTGL.h, mainly to aid debugging
|
||||
- Cleaned up the includes.
|
||||
|
||||
November 13 2001
|
||||
1.3b3 (FTGL_1_3_BETA_3)
|
||||
- Texture fonts now behave the same as the others and can be loaded on
|
||||
demand. This made FTGLTextureFont MUCH simpler!!!! It has also improved
|
||||
the grid fitting so less texture mem is needed.
|
||||
- Refactored FTVectoriser...
|
||||
This now builds contours and meshes internally and then passes the raw
|
||||
point data onto the glyphs. The gluTess data is captured in an internal
|
||||
non static data structure fixing a memory Leak in PolyGlyph (glCombine).
|
||||
This has enabled...
|
||||
- Extruded fonts. FTGLExtrdFont & FTExtrdGlyph.
|
||||
- Reversed the winding for polyglyphs, extruded glyphs and texture glyphs to
|
||||
make them CCW
|
||||
- Bounding box function
|
||||
- Fixed the != and == operators in ftPoint
|
||||
- Un-virtualised some functions in FTFont
|
||||
- Added a demo app to dist.
|
||||
|
||||
November 9 2001
|
||||
1.21 (FTGL_1_2_1)
|
||||
- Visual Studio projects updated for .cpp source file extensions.
|
||||
- A couple of windows 'cast' warnings have been fixed.
|
||||
|
||||
November 6 2001
|
||||
1.2 (FTGL_1_2_0)
|
||||
- Glyphs can now be loaded on the fly instead of being pre-cached. If
|
||||
FTFont::Open() is called with false, FTGlyphContainer will build a list of
|
||||
null pointers. Then when ever a glyph needs to be access eg by
|
||||
FTFont::advance or FTFont::render, it will be built and slotted into the
|
||||
glyphlist in the correct position.
|
||||
- Removed glext.h from FTGL.h and replaced it with a test for
|
||||
GL_EXT_texture_object.
|
||||
- Added padding to texture size calculations.
|
||||
- Fixed a NASTY bug in FTGLTextureFont. Only came to light after changes to
|
||||
the glyph preprocessing.
|
||||
|
||||
October 31 2001
|
||||
1.1 (FTGL_1_1_0)
|
||||
- Renamed the source to .cpp
|
||||
- Removed the static activeTextureID from FTTextureGlyph and replaced it
|
||||
with a call to
|
||||
glGetIntegerv( GL_TEXTURE_2D_BINDING_EXT, &activeTextureID);
|
||||
- Added an include for glext.h in FTGL.h
|
||||
- Tidied up the glbegin/glEnd pairs in FTTextureGlyph & FTGLTextureFont
|
||||
- Fixed the problem with doc filenames.
|
||||
- Tidied up some implicit type conversions.
|
||||
- Fixed FTCharMap to ensure that a valid default charmap is always created
|
||||
by the c_stor.
|
||||
|
||||
October 26 2001
|
||||
1.01 (FTGL_1_0_1)
|
||||
- Removed the glEnable( GL_TEXTURE_2D) from FTGLTextureFont
|
||||
- Removed the redundant tempGlyph members in the FTGLXXXXFont classes
|
||||
- Made a change in FTGL.h to include correct headers for MAC OSX
|
||||
- FTGL.h now includes glu.h
|
||||
- Minor fixes to get rid of Project Builder warnings (MAC OSX)
|
||||
- Fixed some of the docs
|
||||
|
||||
October 24 2001
|
||||
1.0 (FTGL_1_0_0)
|
||||
- Version 1.0 release
|
||||
|
||||
September 29 2001
|
||||
1.0b7 (FTGL_1_0_BETA_7)
|
||||
- Tesselation winding rules
|
||||
- Fixed bug in FTContour Add point function
|
||||
- Cleaned up disposal of FTCharmap in FTFace
|
||||
- renamed FTVectorGlyph to FTOutlineGlyph
|
||||
- New distribution structure
|
||||
- Minor changes for windows (VC 6)
|
||||
- Windows and Linux ports.
|
||||
|
||||
September 20 2001
|
||||
1.0b6 (FTGL_1_0_BETA_6)
|
||||
- Implemented the new FTCharmap class. The performance improvement is
|
||||
dramatic.
|
||||
- Tidied up the way the freetype FT_Face object is disposed of by FTFont and
|
||||
FTFace. This was a potential crash.
|
||||
- FTVectorGlyph and FTPolyGlyph now disposes of the freetype glyph correctly
|
||||
after initialsation. This was a potential crash.
|
||||
- Preliminary support for unicode...wchar_t Tested with non european fonts.
|
||||
- Added function to calc the advance width of a string.
|
||||
- Minor tidy ups.
|
||||
|
||||
August 29 2001
|
||||
1.0b5 (FTGL_1_0_BETA_5)
|
||||
- Settled on integers for FTSize stuff. NOTE the FTGlyph stuff is still up
|
||||
in the air.
|
||||
- Fixed the positional stuff.
|
||||
- Added Java Doc comments. NOT COMPLETE
|
||||
- Fixes for linux, mainly to clear warnings.
|
||||
- changed the return type for FTFace::Glyph() from a reference to a pointer
|
||||
so it can return NULL on failure.
|
||||
- Related to above...better error handling and reporting in
|
||||
FTGLXXXFont::MakeGlyphList()
|
||||
- Fixed a bug in FTVectoriser that was ignoring non printing characters.
|
||||
This meant that the pen wasn't advanced for spaces etc. It affected
|
||||
polygon and outline font rendering.
|
||||
- Minor tidy ups.
|
||||
|
||||
August 21 2001
|
||||
1.0b4
|
||||
- Changed the mode for FT_Load_Glyph to FT_LOAD_NO_HINTING |
|
||||
FT_LOAD_NO_BITMAP for outline and polygon fonts & FT_LOAD_NO_HINTING for
|
||||
texture fonts. Seems to produce better looking glyphs.
|
||||
- FTGLTextureFont can now use multiple textures to render glyphs if they
|
||||
don't fit within one GL_MAX_TEXTURE_SIZE texture.
|
||||
- Changed FTSize to use bbox for global width and height. Needs more work
|
||||
(eg float or int?) and need to check inconsistancies in freetype.
|
||||
- Being more strict with types eg integer indices and sizes are now
|
||||
unsigned.
|
||||
|
||||
August 8 2001
|
||||
1.0b3 (FTGL_1_0_BETA_3)
|
||||
- I've made fundamental change to the way the glyphlist is built. This is to
|
||||
get round the problems I was having with charmaps. At this stage it is a
|
||||
temporary solution. Previously the glyphList was indexed by char code. Now
|
||||
it's indexed by glyph index and the conversion is done by the freetype
|
||||
function FT_Get_Char_Index(). If this proves to be too slow I'll make my
|
||||
own charmap and use it to index into the glyphlist. This has fixed all the
|
||||
charmap related problems/bugs.
|
||||
- Enabled alpha blend in Pixmap font.
|
||||
- Enabled LINE_SMOOTH in Outline font
|
||||
- Fixed bug that prevented the display of chars >127
|
||||
- Moved pixel store stuff out of BitmapGlyph into BitmapFont.
|
||||
- Minor changes for IRIX (compiles but isn't tested)
|
||||
- Pixmap fonts can now be in colour. It uses the current colour when the
|
||||
font is CREATED. This isn't ideal but is better than the alternatives.
|
||||
- Tidied up the error handling.
|
||||
- Minor code clean ups.
|
||||
|
||||
August 6 2001
|
||||
BETA release 1.0b2 (FTGL_1_0_BETA_2)
|
||||
- Minor tidy ups for first public release.
|
||||
|
||||
August 3 2001
|
||||
First BETA release 1.0b1 (FTGL_1_0_BETA_1)
|
||||
- All font types are now working, Bitmaps, Pixmaps, Texture, Outline and
|
||||
Polygons. Quality of output and performance varies wildly:)
|
||||
|
||||
July 22 2001
|
||||
First ALPHA Release 1.0a1
|
||||
51
src/WinLibs/FTGL/README.txt
Normal file
51
src/WinLibs/FTGL/README.txt
Normal file
@ -0,0 +1,51 @@
|
||||
FTGL 2.1
|
||||
5 December 2004
|
||||
|
||||
DESCRIPTION:
|
||||
|
||||
FTGL is a free open source library to enable developers to use arbitrary
|
||||
fonts in their OpenGL (www.opengl.org) applications.
|
||||
Unlike other OpenGL font libraries FTGL uses standard font file formats
|
||||
so doesn't need a preprocessing step to convert the high quality font data
|
||||
into a lesser quality, proprietary format.
|
||||
FTGL uses the Freetype (www.freetype.org) font library to open and 'decode'
|
||||
the fonts. It then takes that output and stores it in a format most efficient
|
||||
for OpenGL rendering.
|
||||
|
||||
Rendering modes supported are
|
||||
- Bit maps
|
||||
- Antialiased Pix maps
|
||||
- Texture maps
|
||||
- Outlines
|
||||
- Polygon meshes
|
||||
- Extruded polygon meshes
|
||||
|
||||
FTGL is designed to be used in commercial quality software. It has been
|
||||
written with performance, robustness and simplicity in mind.
|
||||
|
||||
USAGE:
|
||||
|
||||
FTGLPixmapFont font( "Fonts:Arial");
|
||||
|
||||
font.FaceSize( 72);
|
||||
|
||||
font.render( "Hello World!");
|
||||
|
||||
This library was inspired by gltt, Copyright (C) 1998-1999 Stephane Rehel
|
||||
(http://gltt.sourceforge.net)
|
||||
Bezier curve code contributed by Jed Soane.
|
||||
Demo, Linux port, extrusion code and gltt maintainance by Gerard Lanois.
|
||||
Linux port by Matthias Kretz.
|
||||
Windows port by Andrew Ellerton & Max Rheiner.
|
||||
Bug fixes by Robert Osfield, Marcelo E. Magallon, Markku Rontu, Mark A. Fox,
|
||||
Patrick Rogers, Kai Huettemann.
|
||||
Containers and optimisations by Sebastien Barre.
|
||||
Autoconf Marcelo E. Magallon.
|
||||
Pixmap font modifications by Robert Bell.
|
||||
|
||||
Please contact me if you have any suggestions, feature requests, or problems.
|
||||
|
||||
Henry Maddocks
|
||||
ftgl@opengl.geek.nz
|
||||
http://homepages.paradise.net.nz/henryj/
|
||||
|
||||
4
src/WinLibs/FTGL/cleanup
Normal file
4
src/WinLibs/FTGL/cleanup
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh -fx
|
||||
# script to get rid of the grabage that MAC OSX drops in all the directories
|
||||
|
||||
find . -name .DS_Store -print -exec rm {} \;
|
||||
498
src/WinLibs/FTGL/demo/FTGLDemo.cpp
Normal file
498
src/WinLibs/FTGL/demo/FTGLDemo.cpp
Normal file
@ -0,0 +1,498 @@
|
||||
#ifdef __APPLE_CC__
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "tb.h"
|
||||
|
||||
#include "FTGLExtrdFont.h"
|
||||
#include "FTGLOutlineFont.h"
|
||||
#include "FTGLPolygonFont.h"
|
||||
#include "FTGLTextureFont.h"
|
||||
#include "FTGLPixmapFont.h"
|
||||
#include "FTGLBitmapFont.h"
|
||||
|
||||
// YOU'LL PROBABLY WANT TO CHANGE THESE
|
||||
#ifdef __linux__
|
||||
#define FONT_FILE "/usr/share/fonts/truetype/arial.ttf"
|
||||
#endif
|
||||
#ifdef __APPLE_CC__
|
||||
#define FONT_FILE "/Users/henry/Development/PROJECTS/FTGL/test/font_pack/arial.ttf"
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#define FONT_FILE "C:\\WINNT\\Fonts\\arial.ttf"
|
||||
#endif
|
||||
#ifndef FONT_FILE
|
||||
#define FONT_FILE 0
|
||||
#endif
|
||||
|
||||
#define EDITING 1
|
||||
#define INTERACTIVE 2
|
||||
|
||||
#define FTGL_BITMAP 0
|
||||
#define FTGL_PIXMAP 1
|
||||
#define FTGL_OUTLINE 2
|
||||
#define FTGL_POLYGON 3
|
||||
#define FTGL_EXTRUDE 4
|
||||
#define FTGL_TEXTURE 5
|
||||
|
||||
char* fontfile = FONT_FILE;
|
||||
int current_font = FTGL_EXTRUDE;
|
||||
|
||||
GLint w_win = 640, h_win = 480;
|
||||
int mode = INTERACTIVE;
|
||||
int carat = 0;
|
||||
|
||||
//wchar_t myString[16] = { 0x6FB3, 0x9580};
|
||||
wchar_t myString[16];
|
||||
|
||||
static FTFont* fonts[6];
|
||||
static FTGLPixmapFont* infoFont;
|
||||
|
||||
static float texture[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
static GLuint textureID;
|
||||
|
||||
void SetCamera(void);
|
||||
|
||||
void setUpLighting()
|
||||
{
|
||||
// Set up lighting.
|
||||
float light1_ambient[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||
float light1_diffuse[4] = { 1.0, 0.9, 0.9, 1.0 };
|
||||
float light1_specular[4] = { 1.0, 0.7, 0.7, 1.0 };
|
||||
float light1_position[4] = { -1.0, 1.0, 1.0, 0.0 };
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
|
||||
glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular);
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
|
||||
glEnable(GL_LIGHT1);
|
||||
|
||||
float light2_ambient[4] = { 0.2, 0.2, 0.2, 1.0 };
|
||||
float light2_diffuse[4] = { 0.9, 0.9, 0.9, 1.0 };
|
||||
float light2_specular[4] = { 0.7, 0.7, 0.7, 1.0 };
|
||||
float light2_position[4] = { 1.0, -1.0, -1.0, 0.0 };
|
||||
glLightfv(GL_LIGHT2, GL_AMBIENT, light2_ambient);
|
||||
glLightfv(GL_LIGHT2, GL_DIFFUSE, light2_diffuse);
|
||||
glLightfv(GL_LIGHT2, GL_SPECULAR, light2_specular);
|
||||
glLightfv(GL_LIGHT2, GL_POSITION, light2_position);
|
||||
// glEnable(GL_LIGHT2);
|
||||
|
||||
float front_emission[4] = { 0.3, 0.2, 0.1, 0.0 };
|
||||
float front_ambient[4] = { 0.2, 0.2, 0.2, 0.0 };
|
||||
float front_diffuse[4] = { 0.95, 0.95, 0.8, 0.0 };
|
||||
float front_specular[4] = { 0.6, 0.6, 0.6, 0.0 };
|
||||
glMaterialfv(GL_FRONT, GL_EMISSION, front_emission);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT, front_ambient);
|
||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, front_diffuse);
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, front_specular);
|
||||
glMaterialf(GL_FRONT, GL_SHININESS, 16.0);
|
||||
glColor4fv(front_diffuse);
|
||||
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
glColorMaterial(GL_FRONT, GL_DIFFUSE);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
|
||||
void setUpFonts( const char* fontfile)
|
||||
{
|
||||
fonts[FTGL_BITMAP] = new FTGLBitmapFont( fontfile);
|
||||
fonts[FTGL_PIXMAP] = new FTGLPixmapFont( fontfile);
|
||||
fonts[FTGL_OUTLINE] = new FTGLOutlineFont( fontfile);
|
||||
fonts[FTGL_POLYGON] = new FTGLPolygonFont( fontfile);
|
||||
fonts[FTGL_EXTRUDE] = new FTGLExtrdFont( fontfile);
|
||||
fonts[FTGL_TEXTURE] = new FTGLTextureFont( fontfile);
|
||||
|
||||
for( int x = 0; x < 6; ++x)
|
||||
{
|
||||
if( fonts[x]->Error())
|
||||
{
|
||||
fprintf( stderr, "Failed to open font %s", fontfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if( !fonts[x]->FaceSize( 144))
|
||||
{
|
||||
fprintf( stderr, "Failed to set size");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fonts[x]->Depth(20);
|
||||
|
||||
fonts[x]->CharMap(ft_encoding_unicode);
|
||||
}
|
||||
|
||||
infoFont = new FTGLPixmapFont( fontfile);
|
||||
|
||||
if( infoFont->Error())
|
||||
{
|
||||
fprintf( stderr, "Failed to open font %s", fontfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
infoFont->FaceSize( 18);
|
||||
|
||||
myString[0] = 65;
|
||||
myString[1] = 0;
|
||||
}
|
||||
|
||||
|
||||
void renderFontmetrics()
|
||||
{
|
||||
float x1, y1, z1, x2, y2, z2;
|
||||
fonts[current_font]->BBox( myString, x1, y1, z1, x2, y2, z2);
|
||||
|
||||
// Draw the bounding box
|
||||
glDisable( GL_LIGHTING);
|
||||
glDisable( GL_TEXTURE_2D);
|
||||
glEnable( GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE); // GL_ONE_MINUS_SRC_ALPHA
|
||||
|
||||
glColor3f( 0.0, 1.0, 0.0);
|
||||
// Draw the front face
|
||||
glBegin( GL_LINE_LOOP);
|
||||
glVertex3f( x1, y1, z1);
|
||||
glVertex3f( x1, y2, z1);
|
||||
glVertex3f( x2, y2, z1);
|
||||
glVertex3f( x2, y1, z1);
|
||||
glEnd();
|
||||
// Draw the back face
|
||||
if( current_font == FTGL_EXTRUDE && z1 != z2)
|
||||
{
|
||||
glBegin( GL_LINE_LOOP);
|
||||
glVertex3f( x1, y1, z2);
|
||||
glVertex3f( x1, y2, z2);
|
||||
glVertex3f( x2, y2, z2);
|
||||
glVertex3f( x2, y1, z2);
|
||||
glEnd();
|
||||
// Join the faces
|
||||
glBegin( GL_LINES);
|
||||
glVertex3f( x1, y1, z1);
|
||||
glVertex3f( x1, y1, z2);
|
||||
|
||||
glVertex3f( x1, y2, z1);
|
||||
glVertex3f( x1, y2, z2);
|
||||
|
||||
glVertex3f( x2, y2, z1);
|
||||
glVertex3f( x2, y2, z2);
|
||||
|
||||
glVertex3f( x2, y1, z1);
|
||||
glVertex3f( x2, y1, z2);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
// Draw the baseline, Ascender and Descender
|
||||
glBegin( GL_LINES);
|
||||
glColor3f( 0.0, 0.0, 1.0);
|
||||
glVertex3f( 0.0, 0.0, 0.0);
|
||||
glVertex3f( fonts[current_font]->Advance( myString), 0.0, 0.0);
|
||||
glVertex3f( 0.0, fonts[current_font]->Ascender(), 0.0);
|
||||
glVertex3f( 0.0, fonts[current_font]->Descender(), 0.0);
|
||||
|
||||
glEnd();
|
||||
|
||||
// Draw the origin
|
||||
glColor3f( 1.0, 0.0, 0.0);
|
||||
glPointSize( 5.0);
|
||||
glBegin( GL_POINTS);
|
||||
glVertex3f( 0.0, 0.0, 0.0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
void renderFontInfo()
|
||||
{
|
||||
glMatrixMode( GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluOrtho2D(0, w_win, 0, h_win);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
// draw mode
|
||||
glColor3f( 1.0, 1.0, 1.0);
|
||||
glRasterPos2f( 20.0f , h_win - ( 20.0f + infoFont->Ascender()));
|
||||
|
||||
switch( mode)
|
||||
{
|
||||
case EDITING:
|
||||
infoFont->Render("Edit Mode");
|
||||
break;
|
||||
case INTERACTIVE:
|
||||
break;
|
||||
}
|
||||
|
||||
// draw font type
|
||||
glRasterPos2i( 20 , 20);
|
||||
switch( current_font)
|
||||
{
|
||||
case FTGL_BITMAP:
|
||||
infoFont->Render("Bitmap Font");
|
||||
break;
|
||||
case FTGL_PIXMAP:
|
||||
infoFont->Render("Pixmap Font");
|
||||
break;
|
||||
case FTGL_OUTLINE:
|
||||
infoFont->Render("Outline Font");
|
||||
break;
|
||||
case FTGL_POLYGON:
|
||||
infoFont->Render("Polygon Font");
|
||||
break;
|
||||
case FTGL_EXTRUDE:
|
||||
infoFont->Render("Extruded Font");
|
||||
break;
|
||||
case FTGL_TEXTURE:
|
||||
infoFont->Render("Texture Font");
|
||||
break;
|
||||
}
|
||||
|
||||
glRasterPos2f( 20.0f , 20.0f + infoFont->LineHeight());
|
||||
infoFont->Render(fontfile);
|
||||
}
|
||||
|
||||
|
||||
void do_display (void)
|
||||
{
|
||||
switch( current_font)
|
||||
{
|
||||
case FTGL_BITMAP:
|
||||
case FTGL_PIXMAP:
|
||||
case FTGL_OUTLINE:
|
||||
break;
|
||||
case FTGL_POLYGON:
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, textureID);
|
||||
glDisable( GL_BLEND);
|
||||
setUpLighting();
|
||||
break;
|
||||
case FTGL_EXTRUDE:
|
||||
glEnable( GL_DEPTH_TEST);
|
||||
glDisable( GL_BLEND);
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, textureID);
|
||||
setUpLighting();
|
||||
break;
|
||||
case FTGL_TEXTURE:
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
glDisable( GL_DEPTH_TEST);
|
||||
setUpLighting();
|
||||
glNormal3f( 0.0, 0.0, 1.0);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
glColor3f( 1.0, 1.0, 1.0);
|
||||
// If you do want to switch the color of bitmaps rendered with glBitmap,
|
||||
// you will need to explicitly call glRasterPos3f (or its ilk) to lock
|
||||
// in a changed current color.
|
||||
|
||||
glPushMatrix();
|
||||
fonts[current_font]->Render( myString);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
renderFontmetrics();
|
||||
glPopMatrix();
|
||||
|
||||
renderFontInfo();
|
||||
}
|
||||
|
||||
|
||||
void display(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
SetCamera();
|
||||
|
||||
switch( current_font)
|
||||
{
|
||||
case FTGL_BITMAP:
|
||||
case FTGL_PIXMAP:
|
||||
glRasterPos2i( w_win / 2, h_win / 2);
|
||||
glTranslatef( w_win / 2, h_win / 2, 0.0);
|
||||
break;
|
||||
case FTGL_OUTLINE:
|
||||
case FTGL_POLYGON:
|
||||
case FTGL_EXTRUDE:
|
||||
case FTGL_TEXTURE:
|
||||
tbMatrix();
|
||||
break;
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
do_display();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
void myinit( const char* fontfile)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glClearColor( 0.13, 0.17, 0.32, 0.0);
|
||||
glColor3f( 1.0, 1.0, 1.0);
|
||||
|
||||
glEnable( GL_CULL_FACE);
|
||||
glFrontFace( GL_CCW);
|
||||
|
||||
glEnable( GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glEnable( GL_POLYGON_OFFSET_LINE);
|
||||
glPolygonOffset( 1.0, 1.0); // ????
|
||||
|
||||
SetCamera();
|
||||
|
||||
tbInit(GLUT_LEFT_BUTTON);
|
||||
tbAnimate( GL_FALSE);
|
||||
|
||||
setUpFonts( fontfile);
|
||||
|
||||
glGenTextures(1, &textureID);
|
||||
glBindTexture(GL_TEXTURE_2D, textureID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_FLOAT, texture);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void parsekey(unsigned char key, int x, int y)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 27: exit(0); break;
|
||||
case 13:
|
||||
if( mode == EDITING)
|
||||
{
|
||||
mode = INTERACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = EDITING;
|
||||
carat = 0;
|
||||
}
|
||||
break;
|
||||
case ' ':
|
||||
current_font++;
|
||||
if(current_font > 5)
|
||||
current_font = 0;
|
||||
break;
|
||||
default:
|
||||
if( mode == INTERACTIVE)
|
||||
{
|
||||
myString[0] = key;
|
||||
myString[1] = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
myString[carat] = key;
|
||||
myString[carat + 1] = 0;
|
||||
carat = carat > 14 ? 14 : ++carat;
|
||||
}
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void motion(int x, int y)
|
||||
{
|
||||
tbMotion( x, y);
|
||||
}
|
||||
|
||||
void mouse(int button, int state, int x, int y)
|
||||
{
|
||||
tbMouse( button, state, x, y);
|
||||
}
|
||||
|
||||
void myReshape(int w, int h)
|
||||
{
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glViewport (0, 0, w, h);
|
||||
glLoadIdentity();
|
||||
|
||||
w_win = w;
|
||||
h_win = h;
|
||||
SetCamera();
|
||||
|
||||
tbReshape(w_win, h_win);
|
||||
}
|
||||
|
||||
void SetCamera(void)
|
||||
{
|
||||
switch( current_font)
|
||||
{
|
||||
case FTGL_BITMAP:
|
||||
case FTGL_PIXMAP:
|
||||
glMatrixMode( GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluOrtho2D(0, w_win, 0, h_win);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
break;
|
||||
case FTGL_OUTLINE:
|
||||
case FTGL_POLYGON:
|
||||
case FTGL_EXTRUDE:
|
||||
case FTGL_TEXTURE:
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
gluPerspective( 90, (float)w_win / (float)h_win, 1, 1000);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt( 0.0, 0.0, (float)h_win / 2.0f, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef __APPLE_CC__ // Bloody finder args???
|
||||
if (argc == 2)
|
||||
fontfile = argv[1];
|
||||
#endif
|
||||
|
||||
if (!fontfile)
|
||||
{
|
||||
fprintf(stderr, "A font file must be specified on the command line\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInit( &argc, argv);
|
||||
glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
|
||||
glutInitWindowPosition(50, 50);
|
||||
glutInitWindowSize( w_win, h_win);
|
||||
glutCreateWindow("FTGL TEST");
|
||||
glutDisplayFunc(display);
|
||||
glutKeyboardFunc(parsekey);
|
||||
glutMouseFunc(mouse);
|
||||
glutMotionFunc(motion);
|
||||
glutReshapeFunc(myReshape);
|
||||
glutIdleFunc(display);
|
||||
|
||||
myinit( fontfile);
|
||||
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
15
src/WinLibs/FTGL/demo/README.txt
Normal file
15
src/WinLibs/FTGL/demo/README.txt
Normal file
@ -0,0 +1,15 @@
|
||||
FTGL Version 2.0 Demo
|
||||
|
||||
This demo demonstrates the different rendering styles available with FTGL.
|
||||
Press <spacebar> to change the font rendering style.
|
||||
Press <enter> to enable edit mode.
|
||||
|
||||
When compiling you will need to check the paths to the font files as they are
|
||||
hard coded. See #define FONT_FILE and #define FONT_INFO in FTGLDemo.c
|
||||
|
||||
|
||||
Please contact me if you have any suggestions, feature requests, or problems.
|
||||
|
||||
Henry Maddocks
|
||||
henryj@paradise.net.nz
|
||||
http://homepages.paradise.net.nz/henryj/
|
||||
127
src/WinLibs/FTGL/demo/tb.c
Normal file
127
src/WinLibs/FTGL/demo/tb.c
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Simple trackball-like motion adapted (ripped off) from projtex.c
|
||||
* (written by David Yu and David Blythe). See the SIGGRAPH '96
|
||||
* Advanced OpenGL course notes.
|
||||
*/
|
||||
|
||||
|
||||
/* includes */
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#ifdef __APPLE_CC__
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
#include "tb.h"
|
||||
#include "trackball.h"
|
||||
|
||||
/* globals */
|
||||
static GLuint tb_lasttime;
|
||||
|
||||
float curquat[4];
|
||||
float lastquat[4];
|
||||
int beginx, beginy;
|
||||
|
||||
static GLuint tb_width;
|
||||
static GLuint tb_height;
|
||||
|
||||
static GLint tb_button = -1;
|
||||
static GLboolean tb_tracking = GL_FALSE;
|
||||
static GLboolean tb_animate = GL_TRUE;
|
||||
|
||||
static void
|
||||
_tbAnimate(void)
|
||||
{
|
||||
add_quats(lastquat, curquat, curquat);
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
void
|
||||
_tbStartMotion(int x, int y, int time)
|
||||
{
|
||||
assert(tb_button != -1);
|
||||
|
||||
glutIdleFunc(0);
|
||||
tb_tracking = GL_TRUE;
|
||||
tb_lasttime = time;
|
||||
beginx = x;
|
||||
beginy = y;
|
||||
}
|
||||
|
||||
void
|
||||
_tbStopMotion(unsigned time)
|
||||
{
|
||||
assert(tb_button != -1);
|
||||
|
||||
tb_tracking = GL_FALSE;
|
||||
|
||||
if (time == tb_lasttime && tb_animate) {
|
||||
glutIdleFunc(_tbAnimate);
|
||||
} else {
|
||||
if (tb_animate) {
|
||||
glutIdleFunc(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tbAnimate(GLboolean animate)
|
||||
{
|
||||
tb_animate = animate;
|
||||
}
|
||||
|
||||
void
|
||||
tbInit(GLuint button)
|
||||
{
|
||||
tb_button = button;
|
||||
trackball(curquat, 0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
void
|
||||
tbMatrix(void)
|
||||
{
|
||||
GLfloat m[4][4];
|
||||
|
||||
assert(tb_button != -1);
|
||||
build_rotmatrix(m, curquat);
|
||||
glMultMatrixf(&m[0][0]);
|
||||
}
|
||||
|
||||
void
|
||||
tbReshape(int width, int height)
|
||||
{
|
||||
assert(tb_button != -1);
|
||||
|
||||
tb_width = width;
|
||||
tb_height = height;
|
||||
}
|
||||
|
||||
void
|
||||
tbMouse(int button, int state, int x, int y)
|
||||
{
|
||||
assert(tb_button != -1);
|
||||
|
||||
if (state == GLUT_DOWN && button == tb_button)
|
||||
_tbStartMotion(x, y, glutGet(GLUT_ELAPSED_TIME));
|
||||
else if (state == GLUT_UP && button == tb_button)
|
||||
_tbStopMotion(glutGet(GLUT_ELAPSED_TIME));
|
||||
}
|
||||
|
||||
void
|
||||
tbMotion(int x, int y)
|
||||
{
|
||||
if (tb_tracking) {
|
||||
trackball(lastquat,
|
||||
(2.0 * beginx - tb_width) / tb_width,
|
||||
(tb_height - 2.0 * beginy) / tb_height,
|
||||
(2.0 * x - tb_width) / tb_width,
|
||||
(tb_height - 2.0 * y) / tb_height
|
||||
);
|
||||
beginx = x;
|
||||
beginy = y;
|
||||
tb_animate = 1;
|
||||
tb_lasttime = glutGet(GLUT_ELAPSED_TIME);
|
||||
_tbAnimate();
|
||||
}
|
||||
}
|
||||
103
src/WinLibs/FTGL/demo/tb.h
Normal file
103
src/WinLibs/FTGL/demo/tb.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Simple trackball-like motion adapted (ripped off) from projtex.c
|
||||
* (written by David Yu and David Blythe). See the SIGGRAPH '96
|
||||
* Advanced OpenGL course notes.
|
||||
*
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* o call tbInit() in before any other tb call
|
||||
* o call tbReshape() from the reshape callback
|
||||
* o call tbMatrix() to get the trackball matrix rotation
|
||||
* o call tbStartMotion() to begin trackball movememt
|
||||
* o call tbStopMotion() to stop trackball movememt
|
||||
* o call tbMotion() from the motion callback
|
||||
* o call tbAnimate(GL_TRUE) if you want the trackball to continue
|
||||
* spinning after the mouse button has been released
|
||||
* o call tbAnimate(GL_FALSE) if you want the trackball to stop
|
||||
* spinning after the mouse button has been released
|
||||
*
|
||||
* Typical setup:
|
||||
*
|
||||
*
|
||||
void
|
||||
init(void)
|
||||
{
|
||||
tbInit(GLUT_MIDDLE_BUTTON);
|
||||
tbAnimate(GL_TRUE);
|
||||
. . .
|
||||
}
|
||||
|
||||
void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
tbReshape(width, height);
|
||||
. . .
|
||||
}
|
||||
|
||||
void
|
||||
display(void)
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
tbMatrix();
|
||||
. . . draw the scene . . .
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void
|
||||
mouse(int button, int state, int x, int y)
|
||||
{
|
||||
tbMouse(button, state, x, y);
|
||||
. . .
|
||||
}
|
||||
|
||||
void
|
||||
motion(int x, int y)
|
||||
{
|
||||
tbMotion(x, y);
|
||||
. . .
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
. . .
|
||||
init();
|
||||
glutReshapeFunc(reshape);
|
||||
glutDisplayFunc(display);
|
||||
glutMouseFunc(mouse);
|
||||
glutMotionFunc(motion);
|
||||
. . .
|
||||
}
|
||||
*
|
||||
* */
|
||||
|
||||
|
||||
/* functions */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void
|
||||
tbInit(GLuint button);
|
||||
|
||||
void
|
||||
tbMatrix(void);
|
||||
|
||||
void
|
||||
tbReshape(int width, int height);
|
||||
|
||||
void
|
||||
tbMouse(int button, int state, int x, int y);
|
||||
|
||||
void
|
||||
tbMotion(int x, int y);
|
||||
|
||||
void
|
||||
tbAnimate(GLboolean animate);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
324
src/WinLibs/FTGL/demo/trackball.c
Normal file
324
src/WinLibs/FTGL/demo/trackball.c
Normal file
@ -0,0 +1,324 @@
|
||||
/*
|
||||
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
||||
* ALL RIGHTS RESERVED
|
||||
* Permission to use, copy, modify, and distribute this software for
|
||||
* any purpose and without fee is hereby granted, provided that the above
|
||||
* copyright notice appear in all copies and that both the copyright notice
|
||||
* and this permission notice appear in supporting documentation, and that
|
||||
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission.
|
||||
*
|
||||
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* US Government Users Restricted Rights
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||
* Unpublished-- rights reserved under the copyright laws of the
|
||||
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||
*
|
||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
* Trackball code:
|
||||
*
|
||||
* Implementation of a virtual trackball.
|
||||
* Implemented by Gavin Bell, lots of ideas from Thant Tessman and
|
||||
* the August '88 issue of Siggraph's "Computer Graphics," pp. 121-129.
|
||||
*
|
||||
* Vector manip code:
|
||||
*
|
||||
* Original code from:
|
||||
* David M. Ciemiewicz, Mark Grossman, Henry Moreton, and Paul Haeberli
|
||||
*
|
||||
* Much mucking with by:
|
||||
* Gavin Bell
|
||||
*/
|
||||
#include <math.h>
|
||||
#include "trackball.h"
|
||||
|
||||
/*
|
||||
* This size should really be based on the distance from the center of
|
||||
* rotation to the point on the object underneath the mouse. That
|
||||
* point would then track the mouse as closely as possible. This is a
|
||||
* simple example, though, so that is left as an Exercise for the
|
||||
* Programmer.
|
||||
*/
|
||||
#define TRACKBALLSIZE (0.4)
|
||||
|
||||
/*
|
||||
* Local function prototypes (not defined in trackball.h)
|
||||
*/
|
||||
static float tb_project_to_sphere(float, float, float);
|
||||
static void normalize_quat(float [4]);
|
||||
|
||||
void
|
||||
vzero(float *v)
|
||||
{
|
||||
v[0] = 0.0;
|
||||
v[1] = 0.0;
|
||||
v[2] = 0.0;
|
||||
}
|
||||
|
||||
void
|
||||
vset(float *v, float x, float y, float z)
|
||||
{
|
||||
v[0] = x;
|
||||
v[1] = y;
|
||||
v[2] = z;
|
||||
}
|
||||
|
||||
void
|
||||
vsub(const float *src1, const float *src2, float *dst)
|
||||
{
|
||||
dst[0] = src1[0] - src2[0];
|
||||
dst[1] = src1[1] - src2[1];
|
||||
dst[2] = src1[2] - src2[2];
|
||||
}
|
||||
|
||||
void
|
||||
vcopy(const float *v1, float *v2)
|
||||
{
|
||||
register int i;
|
||||
for (i = 0 ; i < 3 ; i++)
|
||||
v2[i] = v1[i];
|
||||
}
|
||||
|
||||
void
|
||||
vcross(const float *v1, const float *v2, float *cross)
|
||||
{
|
||||
float temp[3];
|
||||
|
||||
temp[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]);
|
||||
temp[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]);
|
||||
temp[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]);
|
||||
vcopy(temp, cross);
|
||||
}
|
||||
|
||||
float
|
||||
vlength(const float *v)
|
||||
{
|
||||
return sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
}
|
||||
|
||||
void
|
||||
vscale(float *v, float div)
|
||||
{
|
||||
v[0] *= div;
|
||||
v[1] *= div;
|
||||
v[2] *= div;
|
||||
}
|
||||
|
||||
void
|
||||
vnormal(float *v)
|
||||
{
|
||||
vscale(v,1.0/vlength(v));
|
||||
}
|
||||
|
||||
float
|
||||
vdot(const float *v1, const float *v2)
|
||||
{
|
||||
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
||||
}
|
||||
|
||||
void
|
||||
vadd(const float *src1, const float *src2, float *dst)
|
||||
{
|
||||
dst[0] = src1[0] + src2[0];
|
||||
dst[1] = src1[1] + src2[1];
|
||||
dst[2] = src1[2] + src2[2];
|
||||
}
|
||||
|
||||
/*
|
||||
* Ok, simulate a track-ball. Project the points onto the virtual
|
||||
* trackball, then figure out the axis of rotation, which is the cross
|
||||
* product of P1 P2 and O P1 (O is the center of the ball, 0,0,0)
|
||||
* Note: This is a deformed trackball-- is a trackball in the center,
|
||||
* but is deformed into a hyperbolic sheet of rotation away from the
|
||||
* center. This particular function was chosen after trying out
|
||||
* several variations.
|
||||
*
|
||||
* It is assumed that the arguments to this routine are in the range
|
||||
* (-1.0 ... 1.0)
|
||||
*/
|
||||
void
|
||||
trackball(float q[4], float p1x, float p1y, float p2x, float p2y)
|
||||
{
|
||||
float a[3]; /* Axis of rotation */
|
||||
float phi; /* how much to rotate about axis */
|
||||
float p1[3], p2[3], d[3];
|
||||
float t;
|
||||
|
||||
if (p1x == p2x && p1y == p2y) {
|
||||
/* Zero rotation */
|
||||
vzero(q);
|
||||
q[3] = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* First, figure out z-coordinates for projection of P1 and P2 to
|
||||
* deformed sphere
|
||||
*/
|
||||
vset(p1,p1x,p1y,tb_project_to_sphere(TRACKBALLSIZE,p1x,p1y));
|
||||
vset(p2,p2x,p2y,tb_project_to_sphere(TRACKBALLSIZE,p2x,p2y));
|
||||
|
||||
/*
|
||||
* Now, we want the cross product of P1 and P2
|
||||
*/
|
||||
vcross(p2,p1,a);
|
||||
|
||||
/*
|
||||
* Figure out how much to rotate around that axis.
|
||||
*/
|
||||
vsub(p1,p2,d);
|
||||
t = vlength(d) / (2.0*TRACKBALLSIZE);
|
||||
|
||||
/*
|
||||
* Avoid problems with out-of-control values...
|
||||
*/
|
||||
if (t > 1.0) t = 1.0;
|
||||
if (t < -1.0) t = -1.0;
|
||||
phi = 2.0 * asin(t);
|
||||
|
||||
axis_to_quat(a,phi,q);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given an axis and angle, compute quaternion.
|
||||
*/
|
||||
void
|
||||
axis_to_quat(float a[3], float phi, float q[4])
|
||||
{
|
||||
vnormal(a);
|
||||
vcopy(a,q);
|
||||
vscale(q,sin(phi/2.0));
|
||||
q[3] = cos(phi/2.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet
|
||||
* if we are away from the center of the sphere.
|
||||
*/
|
||||
static float
|
||||
tb_project_to_sphere(float r, float x, float y)
|
||||
{
|
||||
float d, t, z;
|
||||
|
||||
d = sqrt(x*x + y*y);
|
||||
if (d < r * 0.70710678118654752440) { /* Inside sphere */
|
||||
z = sqrt(r*r - d*d);
|
||||
} else { /* On hyperbola */
|
||||
t = r / 1.41421356237309504880;
|
||||
z = t*t / d;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given two rotations, e1 and e2, expressed as quaternion rotations,
|
||||
* figure out the equivalent single rotation and stuff it into dest.
|
||||
*
|
||||
* This routine also normalizes the result every RENORMCOUNT times it is
|
||||
* called, to keep error from creeping in.
|
||||
*
|
||||
* NOTE: This routine is written so that q1 or q2 may be the same
|
||||
* as dest (or each other).
|
||||
*/
|
||||
|
||||
#define RENORMCOUNT 97
|
||||
|
||||
void
|
||||
add_quats(float q1[4], float q2[4], float dest[4])
|
||||
{
|
||||
static int count=0;
|
||||
float t1[4], t2[4], t3[4];
|
||||
float tf[4];
|
||||
|
||||
vcopy(q1,t1);
|
||||
vscale(t1,q2[3]);
|
||||
|
||||
vcopy(q2,t2);
|
||||
vscale(t2,q1[3]);
|
||||
|
||||
vcross(q2,q1,t3);
|
||||
vadd(t1,t2,tf);
|
||||
vadd(t3,tf,tf);
|
||||
tf[3] = q1[3] * q2[3] - vdot(q1,q2);
|
||||
|
||||
dest[0] = tf[0];
|
||||
dest[1] = tf[1];
|
||||
dest[2] = tf[2];
|
||||
dest[3] = tf[3];
|
||||
|
||||
if (++count > RENORMCOUNT) {
|
||||
count = 0;
|
||||
normalize_quat(dest);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0
|
||||
* If they don't add up to 1.0, dividing by their magnitued will
|
||||
* renormalize them.
|
||||
*
|
||||
* Note: See the following for more information on quaternions:
|
||||
*
|
||||
* - Shoemake, K., Animating rotation with quaternion curves, Computer
|
||||
* Graphics 19, No 3 (Proc. SIGGRAPH'85), 245-254, 1985.
|
||||
* - Pletinckx, D., Quaternion calculus as a basic tool in computer
|
||||
* graphics, The Visual Computer 5, 2-13, 1989.
|
||||
*/
|
||||
static void
|
||||
normalize_quat(float q[4])
|
||||
{
|
||||
int i;
|
||||
float mag;
|
||||
|
||||
mag = (q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3]);
|
||||
for (i = 0; i < 4; i++) q[i] /= mag;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build a rotation matrix, given a quaternion rotation.
|
||||
*
|
||||
*/
|
||||
void
|
||||
build_rotmatrix(float m[4][4], float q[4])
|
||||
{
|
||||
m[0][0] = 1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2]);
|
||||
m[0][1] = 2.0 * (q[0] * q[1] - q[2] * q[3]);
|
||||
m[0][2] = 2.0 * (q[2] * q[0] + q[1] * q[3]);
|
||||
m[0][3] = 0.0;
|
||||
|
||||
m[1][0] = 2.0 * (q[0] * q[1] + q[2] * q[3]);
|
||||
m[1][1]= 1.0 - 2.0 * (q[2] * q[2] + q[0] * q[0]);
|
||||
m[1][2] = 2.0 * (q[1] * q[2] - q[0] * q[3]);
|
||||
m[1][3] = 0.0;
|
||||
|
||||
m[2][0] = 2.0 * (q[2] * q[0] - q[1] * q[3]);
|
||||
m[2][1] = 2.0 * (q[1] * q[2] + q[0] * q[3]);
|
||||
m[2][2] = 1.0 - 2.0 * (q[1] * q[1] + q[0] * q[0]);
|
||||
m[2][3] = 0.0;
|
||||
|
||||
m[3][0] = 0.0;
|
||||
m[3][1] = 0.0;
|
||||
m[3][2] = 0.0;
|
||||
m[3][3] = 1.0;
|
||||
}
|
||||
|
||||
85
src/WinLibs/FTGL/demo/trackball.h
Normal file
85
src/WinLibs/FTGL/demo/trackball.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
||||
* ALL RIGHTS RESERVED
|
||||
* Permission to use, copy, modify, and distribute this software for
|
||||
* any purpose and without fee is hereby granted, provided that the above
|
||||
* copyright notice appear in all copies and that both the copyright notice
|
||||
* and this permission notice appear in supporting documentation, and that
|
||||
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission.
|
||||
*
|
||||
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* US Government Users Restricted Rights
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||
* Unpublished-- rights reserved under the copyright laws of the
|
||||
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||
*
|
||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
* trackball.h
|
||||
* A virtual trackball implementation
|
||||
* Written by Gavin Bell for Silicon Graphics, November 1988.
|
||||
*/
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Pass the x and y coordinates of the last and current positions of
|
||||
* the mouse, scaled so they are from (-1.0 ... 1.0).
|
||||
*
|
||||
* The resulting rotation is returned as a quaternion rotation in the
|
||||
* first paramater.
|
||||
*/
|
||||
void
|
||||
trackball(float q[4], float p1x, float p1y, float p2x, float p2y);
|
||||
|
||||
/*
|
||||
* Given two quaternions, add them together to get a third quaternion.
|
||||
* Adding quaternions to get a compound rotation is analagous to adding
|
||||
* translations to get a compound translation. When incrementally
|
||||
* adding rotations, the first argument here should be the new
|
||||
* rotation, the second and third the total rotation (which will be
|
||||
* over-written with the resulting new total rotation).
|
||||
*/
|
||||
void
|
||||
add_quats(float *q1, float *q2, float *dest);
|
||||
|
||||
/*
|
||||
* A useful function, builds a rotation matrix in Matrix based on
|
||||
* given quaternion.
|
||||
*/
|
||||
void
|
||||
build_rotmatrix(float m[4][4], float q[4]);
|
||||
|
||||
/*
|
||||
* This function computes a quaternion based on an axis (defined by
|
||||
* the given vector) and an angle about which to rotate. The angle is
|
||||
* expressed in radians. The result is put into the third argument.
|
||||
*/
|
||||
void
|
||||
axis_to_quat(float a[3], float phi, float q[4]);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
332
src/WinLibs/FTGL/docs/FTGL.html
Normal file
332
src/WinLibs/FTGL/docs/FTGL.html
Normal file
@ -0,0 +1,332 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
||||
<title>FTGL User Guide</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<TABLE BORDER="0" WIDTH="70%" CELLSPACING="0" CELLPADDING="0" ALIGN="center">
|
||||
<TR>
|
||||
<TD>
|
||||
|
||||
<h1>FTGL User Guide
|
||||
</h1>
|
||||
<h2>(work in progress)
|
||||
</h2>
|
||||
<P ALIGN="center">
|
||||
<IMG SRC="images/ftgldemo.jpg" ALT="FTGL Demo screen shot" WIDTH="480" HEIGHT="383" BORDER="0">
|
||||
</P>
|
||||
|
||||
<H2>Contents</H2>
|
||||
<UL>
|
||||
<LI><H3><a href="#INT">Introduction</a></H3></LI>
|
||||
<LI><H3><a href="#CFT">Choosing a font type</a></H3></LI>
|
||||
<LI><H3><a href="#CAT">Creating a font</a></H3></LI>
|
||||
<LI><H3><a href="#MFC">More font commands</a></H3></LI>
|
||||
<LI><H3><a href="#FAQ">FAQ</a></H3></LI>
|
||||
<LI><H3><a href="#GLS">Glossary</a></H3></LI>
|
||||
</UL>
|
||||
<HR ALIGN="center" SIZE="2" WIDTH="80%">
|
||||
<A NAME="INT">
|
||||
<h2>Introduction
|
||||
</h2>
|
||||
<P>
|
||||
OpenGL doesn't provide direct font support, so the application must use any of OpenGL's other features for font rendering, such as drawing bitmaps or pixmaps, creating texture maps containing an entire character set, drawing character outlines, or creating 3D geometry for each character.
|
||||
</P>
|
||||
|
||||
|
||||
<P>http://www.opengl.org/developers/faqs/technical/fonts.htm</P>
|
||||
<P>http://www.opengl.org/developers/code/features/fontsurvey/index.html</P>
|
||||
<P>
|
||||
?????One thing all of these systems have in comman is they require a pre-processing stage to take the native fonts and convert them into proprietry format.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
FTGL was borne out of the need to treat fonts in OpenGL applications just like any other application. For example when using Adobe Photoshop or Microsoft Word you don't need an intermediate pre-processing step to use high quality scalable fonts.
|
||||
</P>
|
||||
|
||||
<HR ALIGN="center" SIZE="2" WIDTH="80%">
|
||||
<A NAME="CFT">
|
||||
<H2>Choosing a font type</H2>
|
||||
<P>
|
||||
FTGL supports 6 font output types in 3 groups, raster fonts, vector fonts and texure fonts which are a mixture of both. Each font type has it's advantages and disadvantages
|
||||
</P>
|
||||
The two raster types are
|
||||
<UL>
|
||||
<LI>Bitmapped</LI>
|
||||
<LI>Antialiased pixmapped</LI>
|
||||
</UL>
|
||||
|
||||
|
||||
|
||||
The vector types are
|
||||
<UL>
|
||||
<LI>Outline</LI>
|
||||
<LI>Polygonal</LI>
|
||||
<LI>Extruded polygon</LI>
|
||||
</UL>
|
||||
|
||||
|
||||
|
||||
|
||||
<UL>
|
||||
<LI>Texture mapped</LI>
|
||||
</UL>
|
||||
<P>
|
||||
This is probably the most versatile type. It is fast, antialised and can be transformed just like any openGL primitive.
|
||||
</P>
|
||||
|
||||
<HR ALIGN="center" SIZE="2" WIDTH="80%">
|
||||
|
||||
<A NAME="CAF">
|
||||
<H2>Creating a font
|
||||
</H2>
|
||||
<font color="blue"><PRE>
|
||||
FTGLPixmapFont font;
|
||||
|
||||
font.Open( "Fonts:Arial");
|
||||
font.FaceSize( 72);
|
||||
|
||||
font.render( "Hello World!");
|
||||
|
||||
FTFont::Open( string, cache);
|
||||
const char* string;
|
||||
bool cache;
|
||||
</PRE></font>
|
||||
<P>
|
||||
<font color="blue"><PRE>
|
||||
bool Open( fontname, preCache = true);
|
||||
const char* fontname:
|
||||
bool preCache:
|
||||
|
||||
</PRE></font>
|
||||
|
||||
|
||||
<P>
|
||||
A side effect of this is you can specify a sub set of glyphs to be pre-loaded. This will let you use larger higher quality glyphs without consuming huge amounts of ram as you would if you loaded the entire font. For example if your application only needs numbers, eg for scores, you can use the following code to preload them.
|
||||
</P>
|
||||
|
||||
<font color="blue"><PRE>
|
||||
// Open the font with pre-cache set to false
|
||||
font.Open( "Fonts:Arial", false);
|
||||
|
||||
// Set the size
|
||||
font.FaceSize( 72);
|
||||
|
||||
// Cause the font to preload the number chars without rendering them.
|
||||
font.Advance( "0123456789");
|
||||
</PRE></font>
|
||||
|
||||
|
||||
|
||||
<HR ALIGN="center" SIZE="2" WIDTH="80%">
|
||||
|
||||
<A NAME="MFC">
|
||||
<H2>More font commands</H2>
|
||||
<H3>Font Metrics</H3>
|
||||
<P ALIGN="center">
|
||||
<IMG SRC="images/metrics.png" ALT="glyph metrics" WIDTH="388" HEIGHT="253" BORDER="0">
|
||||
</P>
|
||||
|
||||
<P>
|
||||
If you ask a font to render at 0.0, 0.0 the bottom left most pixel or polygon may not be aligned to 0.0, 0.0.
|
||||
</P>
|
||||
|
||||
<font color="blue"><PRE>
|
||||
int FTFont::Ascender() const;
|
||||
int FTFont::Descender() const;
|
||||
|
||||
float FTFont::Advance( string);
|
||||
</PRE></font>
|
||||
|
||||
|
||||
<P>
|
||||
With these three functions an approximate bounding box can be calculated. For an exact bounding box use the FTFont::BBox function.
|
||||
</P>
|
||||
|
||||
<font color="blue"><PRE>
|
||||
void FTFont::BBox( string, llx, lly, llz, urx, ury, urz);
|
||||
const char* string: String of text to be tested
|
||||
float& llx: The bottom left near most ?? in the x axis
|
||||
float& lly: The bottom left near most ?? in the y axis
|
||||
float& llz: The bottom left near most ?? in the z axis
|
||||
float& urx: The top right far most ?? in the x axis
|
||||
float& ury: The top right far most ?? in the y axis
|
||||
float& urz: The top right far most ?? in the z axis
|
||||
</PRE></font>
|
||||
|
||||
<P>
|
||||
This function returns the extent of the volume containing 'string'. 0.0 on the y axis will be aligned with the font baseline.
|
||||
</P>
|
||||
|
||||
<H3>Specifying a character map encoding.
|
||||
</H3>
|
||||
From the freetype docs...<br>
|
||||
"By default, when a new face object is created, (freetype) lists all the charmaps contained in the font face and selects the one that supports Unicode character codes if it finds one. Otherwise, it tries to find support for Latin-1, then ASCII."
|
||||
<BR>
|
||||
It then gives up. In this case FTGL will set the charmap to the first it finds in the fonts charmap list.
|
||||
|
||||
You can expilcitly set the char encoding with Charmap:
|
||||
<font color="blue"><PRE>
|
||||
bool FTFont::CharMap( encoding);
|
||||
FT_Encoding encoding; Freetype code
|
||||
</PRE></font>
|
||||
|
||||
Valid encodings as at Freetype 2.0.4
|
||||
<font color="blue"><PRE>
|
||||
ft_encoding_none
|
||||
ft_encoding_symbol
|
||||
ft_encoding_unicode
|
||||
ft_encoding_latin_2
|
||||
ft_encoding_sjis
|
||||
ft_encoding_gb2312
|
||||
ft_encoding_big5
|
||||
ft_encoding_wansung
|
||||
ft_encoding_johab
|
||||
ft_encoding_adobe_standard
|
||||
ft_encoding_adobe_expert
|
||||
ft_encoding_adobe_custom
|
||||
ft_encoding_apple_roman
|
||||
</PRE></font>
|
||||
|
||||
for example...
|
||||
<font color="blue"><PRE>
|
||||
font.CharMap( ft_encoding_apple_roman);
|
||||
</PRE></font>
|
||||
|
||||
This will return an error if the requested encoding can't be found in the font.
|
||||
|
||||
|
||||
|
||||
<HR ALIGN="center" SIZE="2" WIDTH="80%">
|
||||
|
||||
<A NAME="FAQ">
|
||||
<H2>FAQ</H2>
|
||||
|
||||
WhenI try to compile FTGL it complains about a missing file from the include:
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
FTGL relies on freetype 2 for opening and decoding font files. This include is the main include for freetype. You will need to download Freetype 2 and install it. Then make sure that the FTGL project that you are using points to your freetype installation.
|
||||
|
||||
|
||||
2) Is it possible to map a font to a "unit" size? My application relies on
|
||||
the fonts being a certain "physical" height (in OpenGL coordinate space)
|
||||
rather than a point size in display space. Any thoughts/suggestions?
|
||||
|
||||
|
||||
We can do anything:) It would be easy to allow you to set the size in pixels, though I'm not sure this is what you want. Setting the size to 'opengl units' may be a bit harder. What does 1.0 in opengl space mean and how does that relate to point size? For one person it might mean scaling the font up, for someone else it may mean scaling down. Plus bitmaps and pixmaps have a pixel to pixel relationship that you can't change.
|
||||
|
||||
Here's some guidelines for vector and texture fonts. Take note that I say 'should' a lot:)
|
||||
One point in pixel space maps to 1 unit in opengl space, so a glyph that is 18 points high should be 18.0 units high.
|
||||
If you set an ortho projection to the window size and draw a glyph it's screen size should be the correct physical size ie a 72 point glyph on a 72dpi screen will be 1 inch high. Also if you set a perspective projection that maps 0.0 in the z axis to screen size you will get the same eg...
|
||||
gluPerspective( 90, window_height / 2 , small_number, large_number);
|
||||
So basically it all depends on your projection matrix. Obviously you can use glScale but I understand if you don't want to.
|
||||
Couple of extra things to note. The quality of vector glyphs will not change when you change the size. ie a really small polygon glyph up close will look exactly the same as a big one from far away. They both contain the same amount of data. This doesn't apply to texture fonts. Secondly there is a bug in the advance/ kerning code that will cause ugliness at really small point sizes. This is because the advance and kerning use ints so an advance of 0.4 will become zero. If this is going to be a probelm, I can fix this.
|
||||
|
||||
Early on I did a lot of head scratching over the opengl unit to font size thing because when I was first integrating FTGL into my engine the fonts weren't the size I was expecting. I was tempted to build in some scaling but I decided doing nothing was the best approach because you can't please everyone. Plus it's 'correct' as it is.
|
||||
|
||||
|
||||
|
||||
<H3>Sample font manager class.</H3>
|
||||
|
||||
|
||||
<font color="blue"><pre>
|
||||
FTGLTextureFont* myFont = FTGLFontManager::Instance().GetFont( "arial.ttf", 72);
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "FTGLTextureFont.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef map< string, FTFont*> FontList;
|
||||
typedef FontList::const_iterator FontIter;
|
||||
|
||||
class FTGLFontManager
|
||||
{
|
||||
public:
|
||||
// NOTE
|
||||
// This is shown here for brevity. The implementation should be in the source
|
||||
// file otherwise your compiler may inline the function resulting in
|
||||
// multiple instances of FTGLFontManager
|
||||
static FTGLFontManager& Instance()
|
||||
{
|
||||
static FTGLFontManager tm;
|
||||
return tm;
|
||||
}
|
||||
|
||||
~FTGLFontManager()
|
||||
{
|
||||
FontIter font;
|
||||
for( font = fonts.begin(); font != fonts.end(); font++)
|
||||
{
|
||||
delete (*font).second;;
|
||||
}
|
||||
|
||||
fonts.clear();
|
||||
}
|
||||
|
||||
|
||||
FTFont* GetFont( const char *filename, int size)
|
||||
{
|
||||
char buf[256];
|
||||
sprintf(buf, "%s%i", filename, size);
|
||||
string fontKey = string(buf);
|
||||
|
||||
FontIter result = fonts.find( fontKey);
|
||||
if( result != fonts.end())
|
||||
{
|
||||
LOGMSG( "Found font %s in list", filename);
|
||||
return result->second;
|
||||
}
|
||||
|
||||
FTFont* font = new FTGLTextureFont;
|
||||
|
||||
string fullname = path + string( filename);
|
||||
|
||||
if( !font->Open( fullname.c_str()))
|
||||
{
|
||||
LOGERROR( "Font %s failed to open", fullname.c_str());
|
||||
delete font;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !font->FaceSize( size))
|
||||
{
|
||||
LOGERROR( "Font %s failed to set size %i", filename, size);
|
||||
delete font;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fonts[fontKey] = font;
|
||||
|
||||
return font;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// Hide these 'cause this is a singleton.
|
||||
FTGLFontManager(){}
|
||||
FTGLFontManager( const FTGLFontManager&){};
|
||||
FTGLFontManager& operator = ( const FTGLFontManager&){ return *this;};
|
||||
|
||||
// container for fonts
|
||||
FontList fonts;
|
||||
|
||||
};
|
||||
</PRE></font>
|
||||
|
||||
|
||||
<HR ALIGN="center" SIZE="2" WIDTH="80%">
|
||||
|
||||
<A NAME="GLS">
|
||||
<H2>Glossary</H2>
|
||||
|
||||
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</body>
|
||||
</html>
|
||||
BIN
src/WinLibs/FTGL/docs/FTGL_1_3.gif
Normal file
BIN
src/WinLibs/FTGL/docs/FTGL_1_3.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
211
src/WinLibs/FTGL/docs/ftgl_dox
Normal file
211
src/WinLibs/FTGL/docs/ftgl_dox
Normal file
@ -0,0 +1,211 @@
|
||||
# Doxyfile 1.3.6
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = FTGL
|
||||
PROJECT_NUMBER = 2.1
|
||||
OUTPUT_DIRECTORY = .
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = YES
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 4
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../src \
|
||||
../include
|
||||
FILE_PATTERNS = *.cpp \
|
||||
*.h
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
BIN
src/WinLibs/FTGL/docs/html.tar.gz
Normal file
BIN
src/WinLibs/FTGL/docs/html.tar.gz
Normal file
Binary file not shown.
BIN
src/WinLibs/FTGL/docs/images/ftgldemo.jpg
Normal file
BIN
src/WinLibs/FTGL/docs/images/ftgldemo.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
BIN
src/WinLibs/FTGL/docs/images/metrics.png
Normal file
BIN
src/WinLibs/FTGL/docs/images/metrics.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
124
src/WinLibs/FTGL/include/FTBBox.h
Normal file
124
src/WinLibs/FTGL/include/FTBBox.h
Normal file
@ -0,0 +1,124 @@
|
||||
#ifndef __FTBBox__
|
||||
#define __FTBBox__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
//#include FT_GLYPH_H
|
||||
#include FT_OUTLINE_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTPoint.h"
|
||||
|
||||
|
||||
/**
|
||||
* FTBBox is a convenience class for handling bounding boxes.
|
||||
*/
|
||||
class FTGL_EXPORT FTBBox
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor. Bounding box is set to zero.
|
||||
*/
|
||||
FTBBox()
|
||||
: lowerX(0.0f),
|
||||
lowerY(0.0f),
|
||||
lowerZ(0.0f),
|
||||
upperX(0.0f),
|
||||
upperY(0.0f),
|
||||
upperZ(0.0f)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
FTBBox( float lx, float ly, float lz, float ux, float uy, float uz)
|
||||
: lowerX(lx),
|
||||
lowerY(ly),
|
||||
lowerZ(lz),
|
||||
upperX(ux),
|
||||
upperY(uy),
|
||||
upperZ(uz)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Constructor. Extracts a bounding box from a freetype glyph. Uses
|
||||
* the control box for the glyph. <code>FT_Glyph_Get_CBox()</code>
|
||||
*
|
||||
* @param glyph A freetype glyph
|
||||
*/
|
||||
FTBBox( FT_GlyphSlot glyph)
|
||||
: lowerX(0.0f),
|
||||
lowerY(0.0f),
|
||||
lowerZ(0.0f),
|
||||
upperX(0.0f),
|
||||
upperY(0.0f),
|
||||
upperZ(0.0f)
|
||||
{
|
||||
FT_BBox bbox;
|
||||
FT_Outline_Get_CBox( &(glyph->outline), &bbox);
|
||||
|
||||
lowerX = static_cast<float>( bbox.xMin) / 64.0f;
|
||||
lowerY = static_cast<float>( bbox.yMin) / 64.0f;
|
||||
lowerZ = 0.0f;
|
||||
upperX = static_cast<float>( bbox.xMax) / 64.0f;
|
||||
upperY = static_cast<float>( bbox.yMax) / 64.0f;
|
||||
upperZ = 0.0f;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTBBox()
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* Move the Bounding Box by a vector.
|
||||
*
|
||||
* @param distance The distance to move the bbox in 3D space.
|
||||
*/
|
||||
FTBBox& Move( FTPoint distance)
|
||||
{
|
||||
lowerX += distance.X();
|
||||
lowerY += distance.Y();
|
||||
lowerZ += distance.Z();
|
||||
upperX += distance.X();
|
||||
upperY += distance.Y();
|
||||
upperZ += distance.Z();
|
||||
return *this;
|
||||
}
|
||||
|
||||
FTBBox& operator += ( const FTBBox& bbox)
|
||||
{
|
||||
lowerX = bbox.lowerX < lowerX? bbox.lowerX: lowerX;
|
||||
lowerY = bbox.lowerY < lowerY? bbox.lowerY: lowerY;
|
||||
lowerZ = bbox.lowerZ < lowerZ? bbox.lowerZ: lowerZ;
|
||||
upperX = bbox.upperX > upperX? bbox.upperX: upperX;
|
||||
upperY = bbox.upperY > upperY? bbox.upperY: upperY;
|
||||
upperZ = bbox.upperZ > upperZ? bbox.upperZ: upperZ;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SetDepth( float depth)
|
||||
{
|
||||
upperZ = lowerZ + depth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The bounds of the box
|
||||
*/
|
||||
// Make these ftPoints & private
|
||||
float lowerX, lowerY, lowerZ, upperX, upperY, upperZ;
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTBBox__
|
||||
|
||||
76
src/WinLibs/FTGL/include/FTBitmapGlyph.h
Normal file
76
src/WinLibs/FTGL/include/FTBitmapGlyph.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef __FTBitmapGlyph__
|
||||
#define __FTBitmapGlyph__
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTGlyph.h"
|
||||
|
||||
|
||||
/**
|
||||
* FTBitmapGlyph is a specialisation of FTGlyph for creating bitmaps.
|
||||
*
|
||||
* It provides the interface between Freetype glyphs and their openGL
|
||||
* Renderable counterparts. This is an abstract class and derived classes
|
||||
* must implement the <code>Render</code> function.
|
||||
*
|
||||
* @see FTGlyphContainer
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTBitmapGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param glyph The Freetype glyph to be processed
|
||||
*/
|
||||
FTBitmapGlyph( FT_GlyphSlot glyph);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTBitmapGlyph();
|
||||
|
||||
/**
|
||||
* Renders this glyph at the current pen position.
|
||||
*
|
||||
* @param pen The current pen position.
|
||||
* @return The advance distance for this glyph.
|
||||
*/
|
||||
virtual const FTPoint& Render( const FTPoint& pen);
|
||||
|
||||
private:
|
||||
/**
|
||||
* The width of the glyph 'image'
|
||||
*/
|
||||
unsigned int destWidth;
|
||||
|
||||
/**
|
||||
* The height of the glyph 'image'
|
||||
*/
|
||||
unsigned int destHeight;
|
||||
|
||||
/**
|
||||
* The pitch of the glyph 'image'
|
||||
*/
|
||||
unsigned int destPitch;
|
||||
|
||||
/**
|
||||
* Vector from the pen position to the topleft corner of the bitmap
|
||||
*/
|
||||
FTPoint pos;
|
||||
|
||||
/**
|
||||
* Pointer to the 'image' data
|
||||
*/
|
||||
unsigned char* data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTBitmapGlyph__
|
||||
|
||||
130
src/WinLibs/FTGL/include/FTCharToGlyphIndexMap.h
Normal file
130
src/WinLibs/FTGL/include/FTCharToGlyphIndexMap.h
Normal file
@ -0,0 +1,130 @@
|
||||
#ifndef __FTCharToGlyphIndexMap__
|
||||
#define __FTCharToGlyphIndexMap__
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "FTGL.h"
|
||||
|
||||
/**
|
||||
* Provides a non-STL alternative to the STL map<unsigned long, unsigned long>
|
||||
* which maps character codes to glyph indices inside FTCharmap.
|
||||
*
|
||||
* Implementation:
|
||||
* - NumberOfBuckets buckets are considered.
|
||||
* - Each bucket has BucketSize entries.
|
||||
* - When the glyph index for the character code C has to be stored, the
|
||||
* bucket this character belongs to is found using 'C div BucketSize'.
|
||||
* If this bucket has not been allocated yet, do it now.
|
||||
* The entry in the bucked is found using 'C mod BucketSize'.
|
||||
* If it is set to IndexNotFound, then the glyph entry has not been set.
|
||||
* - Try to mimic the calls made to the STL map API.
|
||||
*
|
||||
* Caveats:
|
||||
* - The glyph index is now a signed long instead of unsigned long, so
|
||||
* the special value IndexNotFound (= -1) can be used to specify that the
|
||||
* glyph index has not been stored yet.
|
||||
*/
|
||||
class FTGL_EXPORT FTCharToGlyphIndexMap
|
||||
{
|
||||
public:
|
||||
|
||||
typedef unsigned long CharacterCode;
|
||||
typedef signed long GlyphIndex;
|
||||
|
||||
enum
|
||||
{
|
||||
NumberOfBuckets = 256,
|
||||
BucketSize = 256,
|
||||
IndexNotFound = -1
|
||||
};
|
||||
|
||||
FTCharToGlyphIndexMap()
|
||||
{
|
||||
this->Indices = 0;
|
||||
}
|
||||
|
||||
virtual ~FTCharToGlyphIndexMap()
|
||||
{
|
||||
if( this->Indices)
|
||||
{
|
||||
// Free all buckets
|
||||
this->clear();
|
||||
|
||||
// Free main structure
|
||||
delete [] this->Indices;
|
||||
this->Indices = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
if(this->Indices)
|
||||
{
|
||||
for( int i = 0; i < FTCharToGlyphIndexMap::NumberOfBuckets; i++)
|
||||
{
|
||||
if( this->Indices[i])
|
||||
{
|
||||
delete [] this->Indices[i];
|
||||
this->Indices[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const GlyphIndex find( CharacterCode c)
|
||||
{
|
||||
if( !this->Indices)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Find position of char code in buckets
|
||||
div_t pos = div( c, FTCharToGlyphIndexMap::BucketSize);
|
||||
|
||||
if( !this->Indices[pos.quot])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const FTCharToGlyphIndexMap::GlyphIndex *ptr = &this->Indices[pos.quot][pos.rem];
|
||||
if( *ptr == FTCharToGlyphIndexMap::IndexNotFound)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
void insert( CharacterCode c, GlyphIndex g)
|
||||
{
|
||||
if( !this->Indices)
|
||||
{
|
||||
this->Indices = new GlyphIndex* [FTCharToGlyphIndexMap::NumberOfBuckets];
|
||||
for( int i = 0; i < FTCharToGlyphIndexMap::NumberOfBuckets; i++)
|
||||
{
|
||||
this->Indices[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Find position of char code in buckets
|
||||
div_t pos = div(c, FTCharToGlyphIndexMap::BucketSize);
|
||||
|
||||
// Allocate bucket if does not exist yet
|
||||
if( !this->Indices[pos.quot])
|
||||
{
|
||||
this->Indices[pos.quot] = new GlyphIndex [FTCharToGlyphIndexMap::BucketSize];
|
||||
for( int i = 0; i < FTCharToGlyphIndexMap::BucketSize; i++)
|
||||
{
|
||||
this->Indices[pos.quot][i] = FTCharToGlyphIndexMap::IndexNotFound;
|
||||
}
|
||||
}
|
||||
|
||||
this->Indices[pos.quot][pos.rem] = g;
|
||||
}
|
||||
|
||||
private:
|
||||
GlyphIndex** Indices;
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTCharToGlyphIndexMap__
|
||||
136
src/WinLibs/FTGL/include/FTCharmap.h
Normal file
136
src/WinLibs/FTGL/include/FTCharmap.h
Normal file
@ -0,0 +1,136 @@
|
||||
#ifndef __FTCharmap__
|
||||
#define __FTCharmap__
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTCharToGlyphIndexMap.h"
|
||||
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
/**
|
||||
* FTCharmap takes care of specifying the encoding for a font and mapping
|
||||
* character codes to glyph indices.
|
||||
*
|
||||
* It doesn't preprocess all indices, only on an as needed basis. This may
|
||||
* seem like a performance penalty but it is quicker than using the 'raw'
|
||||
* freetype calls and will save significant amounts of memory when dealing
|
||||
* with unicode encoding
|
||||
*
|
||||
* @see "Freetype 2 Documentation"
|
||||
*
|
||||
*/
|
||||
|
||||
class FTFace;
|
||||
|
||||
class FTGL_EXPORT FTCharmap
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
FTCharmap( FTFace* face);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTCharmap();
|
||||
|
||||
/**
|
||||
* Queries for the current character map code.
|
||||
*
|
||||
* @return The current character map code.
|
||||
*/
|
||||
FT_Encoding Encoding() const { return ftEncoding;}
|
||||
|
||||
/**
|
||||
* Sets the character map for the face.
|
||||
* Valid encodings as at Freetype 2.0.4
|
||||
* ft_encoding_none
|
||||
* ft_encoding_symbol
|
||||
* ft_encoding_unicode
|
||||
* ft_encoding_latin_2
|
||||
* ft_encoding_sjis
|
||||
* ft_encoding_gb2312
|
||||
* ft_encoding_big5
|
||||
* ft_encoding_wansung
|
||||
* ft_encoding_johab
|
||||
* ft_encoding_adobe_standard
|
||||
* ft_encoding_adobe_expert
|
||||
* ft_encoding_adobe_custom
|
||||
* ft_encoding_apple_roman
|
||||
*
|
||||
* @param encoding the Freetype encoding symbol. See above.
|
||||
* @return <code>true</code> if charmap was valid and set
|
||||
* correctly. If the requested encoding is
|
||||
* unavailable it will be set to ft_encoding_none.
|
||||
*/
|
||||
bool CharMap( FT_Encoding encoding);
|
||||
|
||||
/**
|
||||
* Get the FTGlyphContainer index of the input character.
|
||||
*
|
||||
* @param characterCode The character code of the requested glyph in
|
||||
* the current encoding eg apple roman.
|
||||
* @return The FTGlyphContainer index for the character or zero
|
||||
* if it wasn't found
|
||||
*/
|
||||
unsigned int GlyphListIndex( const unsigned int characterCode);
|
||||
|
||||
/**
|
||||
* Get the font glyph index of the input character.
|
||||
*
|
||||
* @param characterCode The character code of the requested glyph in
|
||||
* the current encoding eg apple roman.
|
||||
* @return The glyph index for the character.
|
||||
*/
|
||||
unsigned int FontIndex( const unsigned int characterCode);
|
||||
|
||||
/**
|
||||
* Set the FTGlyphContainer index of the character code.
|
||||
*
|
||||
* @param characterCode The character code of the requested glyph in
|
||||
* the current encoding eg apple roman.
|
||||
* @param containerIndex The index into the FTGlyphContainer of the
|
||||
* character code.
|
||||
*/
|
||||
void InsertIndex( const unsigned int characterCode, const unsigned int containerIndex);
|
||||
|
||||
/**
|
||||
* Queries for errors.
|
||||
*
|
||||
* @return The current error code. Zero means no error.
|
||||
*/
|
||||
FT_Error Error() const { return err;}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Current character map code.
|
||||
*/
|
||||
FT_Encoding ftEncoding;
|
||||
|
||||
/**
|
||||
* The current Freetype face.
|
||||
*/
|
||||
const FT_Face ftFace;
|
||||
|
||||
/**
|
||||
* A structure that maps glyph indices to character codes
|
||||
*
|
||||
* < character code, face glyph index>
|
||||
*/
|
||||
typedef FTCharToGlyphIndexMap CharacterMap;
|
||||
CharacterMap charMap;
|
||||
|
||||
/**
|
||||
* Current error code.
|
||||
*/
|
||||
FT_Error err;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTCharmap__
|
||||
88
src/WinLibs/FTGL/include/FTContour.h
Normal file
88
src/WinLibs/FTGL/include/FTContour.h
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef __FTContour__
|
||||
#define __FTContour__
|
||||
|
||||
#include "FTPoint.h"
|
||||
#include "FTVector.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
/**
|
||||
* FTContour class is a container of points that describe a vector font
|
||||
* outline. It is used as a container for the output of the bezier curve
|
||||
* evaluator in FTVectoriser.
|
||||
*
|
||||
* @see FTOutlineGlyph
|
||||
* @see FTPolyGlyph
|
||||
* @see FTPoint
|
||||
*/
|
||||
class FTGL_EXPORT FTContour
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param contour
|
||||
* @param pointTags
|
||||
* @param numberOfPoints
|
||||
*/
|
||||
FTContour( FT_Vector* contour, char* pointTags, unsigned int numberOfPoints);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTContour()
|
||||
{
|
||||
pointList.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a point at index.
|
||||
*
|
||||
* @param index of the point in the curve.
|
||||
* @return const point reference
|
||||
*/
|
||||
const FTPoint& Point( unsigned int index) const { return pointList[index];}
|
||||
|
||||
/**
|
||||
* How many points define this contour
|
||||
*
|
||||
* @return the number of points in this contour
|
||||
*/
|
||||
size_t PointCount() const { return pointList.size();}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Add a point to this contour. This function tests for duplicate
|
||||
* points.
|
||||
*
|
||||
* @param point The point to be added to the contour.
|
||||
*/
|
||||
inline void AddPoint( FTPoint point);
|
||||
|
||||
inline void AddPoint( float x, float y);
|
||||
|
||||
/**
|
||||
* De Casteljau (bezier) algorithm contributed by Jed Soane
|
||||
* Evaluates a quadratic or conic (second degree) curve
|
||||
*/
|
||||
inline void evaluateQuadraticCurve();
|
||||
|
||||
/**
|
||||
* De Casteljau (bezier) algorithm contributed by Jed Soane
|
||||
* Evaluates a cubic (third degree) curve
|
||||
*/
|
||||
inline void evaluateCubicCurve();
|
||||
|
||||
/**
|
||||
* The list of points in this contour
|
||||
*/
|
||||
typedef FTVector<FTPoint> PointVector;
|
||||
PointVector pointList;
|
||||
|
||||
/**
|
||||
* 2D array storing values of de Casteljau algorithm.
|
||||
*/
|
||||
float controlPoints[4][2];
|
||||
};
|
||||
|
||||
#endif // __FTContour__
|
||||
69
src/WinLibs/FTGL/include/FTExtrdGlyph.h
Normal file
69
src/WinLibs/FTGL/include/FTExtrdGlyph.h
Normal file
@ -0,0 +1,69 @@
|
||||
#ifndef __FTExtrdGlyph__
|
||||
#define __FTExtrdGlyph__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTGlyph.h"
|
||||
|
||||
class FTVectoriser;
|
||||
|
||||
/**
|
||||
* FTExtrdGlyph is a specialisation of FTGlyph for creating tessellated
|
||||
* extruded polygon glyphs.
|
||||
*
|
||||
* @see FTGlyphContainer
|
||||
* @see FTVectoriser
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTExtrdGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor. Sets the Error to Invalid_Outline if the glyph isn't an outline.
|
||||
*
|
||||
* @param glyph The Freetype glyph to be processed
|
||||
* @param depth The distance along the z axis to extrude the glyph
|
||||
* @param useDisplayList Enable or disable the use of Display Lists for this glyph
|
||||
* <code>true</code> turns ON display lists.
|
||||
* <code>false</code> turns OFF display lists.
|
||||
*/
|
||||
FTExtrdGlyph( FT_GlyphSlot glyph, float depth, bool useDisplayList);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTExtrdGlyph();
|
||||
|
||||
/**
|
||||
* Renders this glyph at the current pen position.
|
||||
*
|
||||
* @param pen The current pen position.
|
||||
* @return The advance distance for this glyph.
|
||||
*/
|
||||
virtual const FTPoint& Render( const FTPoint& pen);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Calculate the normal vector to 2 points. This is 2D and ignores
|
||||
* the z component. The normal will be normalised
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
FTPoint GetNormal( const FTPoint &a, const FTPoint &b);
|
||||
|
||||
|
||||
/**
|
||||
* OpenGL display list
|
||||
*/
|
||||
GLuint glList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTExtrdGlyph__
|
||||
|
||||
147
src/WinLibs/FTGL/include/FTFace.h
Normal file
147
src/WinLibs/FTGL/include/FTFace.h
Normal file
@ -0,0 +1,147 @@
|
||||
#ifndef __FTFace__
|
||||
#define __FTFace__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTPoint.h"
|
||||
#include "FTSize.h"
|
||||
|
||||
/**
|
||||
* FTFace class provides an abstraction layer for the Freetype Face.
|
||||
*
|
||||
* @see "Freetype 2 Documentation"
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTFace
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Opens and reads a face file. Error is set.
|
||||
*
|
||||
* @param fontFilePath font file path.
|
||||
*/
|
||||
FTFace( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Read face data from an in-memory buffer. Error is set.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
*/
|
||||
FTFace( const unsigned char *pBufferBytes, size_t bufferSizeInBytes );
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
* Disposes of the current Freetype Face.
|
||||
*/
|
||||
virtual ~FTFace();
|
||||
|
||||
/**
|
||||
* Attach auxilliary file to font (e.g., font metrics).
|
||||
*
|
||||
* @param fontFilePath auxilliary font file path.
|
||||
* @return <code>true</code> if file has opened
|
||||
* successfully.
|
||||
*/
|
||||
bool Attach( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Attach auxilliary data to font (e.g., font metrics) from memory
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
* @return <code>true</code> if file has opened
|
||||
* successfully.
|
||||
*/
|
||||
bool Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Get the freetype face object..
|
||||
*
|
||||
* @return pointer to an FT_Face.
|
||||
*/
|
||||
FT_Face* Face() const { return ftFace;}
|
||||
|
||||
/**
|
||||
* Sets the char size for the current face.
|
||||
*
|
||||
* This doesn't guarantee that the size was set correctly. Clients
|
||||
* should check errors.
|
||||
*
|
||||
* @param size the face size in points (1/72 inch)
|
||||
* @param res the resolution of the target device.
|
||||
* @return <code>FTSize</code> object
|
||||
*/
|
||||
const FTSize& Size( const unsigned int size, const unsigned int res);
|
||||
|
||||
/**
|
||||
* Get the number of character maps in this face.
|
||||
*
|
||||
* @return character map count.
|
||||
*/
|
||||
unsigned int CharMapCount();
|
||||
|
||||
/**
|
||||
* Get a list of character maps in this face.
|
||||
*
|
||||
* @return pointer to the first encoding.
|
||||
*/
|
||||
FT_Encoding* CharMapList();
|
||||
|
||||
/**
|
||||
* Gets the kerning vector between two glyphs
|
||||
*/
|
||||
FTPoint KernAdvance( unsigned int index1, unsigned int index2);
|
||||
|
||||
/**
|
||||
* Loads and creates a Freetype glyph.
|
||||
*/
|
||||
FT_GlyphSlot Glyph( unsigned int index, FT_Int load_flags);
|
||||
|
||||
/**
|
||||
* Gets the number of glyphs in the current face.
|
||||
*/
|
||||
unsigned int GlyphCount() const { return numGlyphs;}
|
||||
|
||||
/**
|
||||
* Queries for errors.
|
||||
*
|
||||
* @return The current error code.
|
||||
*/
|
||||
FT_Error Error() const { return err; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* The Freetype face
|
||||
*/
|
||||
FT_Face* ftFace;
|
||||
|
||||
/**
|
||||
* The size object associated with this face
|
||||
*/
|
||||
FTSize charSize;
|
||||
|
||||
/**
|
||||
* The number of glyphs in this face
|
||||
*/
|
||||
int numGlyphs;
|
||||
|
||||
FT_Encoding* fontEncodingList;
|
||||
|
||||
/**
|
||||
* This face has kerning tables
|
||||
*/
|
||||
bool hasKerningTable;
|
||||
|
||||
/**
|
||||
* Current error code. Zero means no error.
|
||||
*/
|
||||
FT_Error err;
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTFace__
|
||||
276
src/WinLibs/FTGL/include/FTFont.h
Normal file
276
src/WinLibs/FTGL/include/FTFont.h
Normal file
@ -0,0 +1,276 @@
|
||||
#ifndef __FTFont__
|
||||
#define __FTFont__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#include "FTFace.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
class FTGlyphContainer;
|
||||
class FTGlyph;
|
||||
|
||||
|
||||
/**
|
||||
* FTFont is the public interface for the FTGL library.
|
||||
*
|
||||
* Specific font classes are derived from this class. It uses the helper
|
||||
* classes FTFace and FTSize to access the Freetype library. This class
|
||||
* is abstract and deriving classes must implement the protected
|
||||
* <code>MakeGlyph</code> function to create glyphs of the
|
||||
* appropriate type.
|
||||
*
|
||||
* It is good practice after using these functions to test the error
|
||||
* code returned. <code>FT_Error Error()</code>. Check the freetype file fterrdef.h
|
||||
* for error definitions.
|
||||
*
|
||||
* @see FTFace
|
||||
* @see FTSize
|
||||
* @see FTGlyphContainer
|
||||
* @see FTGlyph
|
||||
*/
|
||||
class FTGL_EXPORT FTFont
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Open and read a font file. Sets Error flag.
|
||||
*
|
||||
* @param fontFilePath font file path.
|
||||
*/
|
||||
FTFont( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Open and read a font from a buffer in memory. Sets Error flag.
|
||||
* The buffer is owned by the client and is NOT copied by FTGL. The
|
||||
* pointer must be valid while using FTGL.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
*/
|
||||
FTFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTFont();
|
||||
|
||||
/**
|
||||
* Attach auxilliary file to font e.g font metrics.
|
||||
*
|
||||
* Note: not all font formats implement this function.
|
||||
*
|
||||
* @param fontFilePath auxilliary font file path.
|
||||
* @return <code>true</code> if file has been attached
|
||||
* successfully.
|
||||
*/
|
||||
bool Attach( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Attach auxilliary data to font e.g font metrics, from memory
|
||||
*
|
||||
* Note: not all font formats implement this function.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
* @return <code>true</code> if file has been attached
|
||||
* successfully.
|
||||
*/
|
||||
bool Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Set the character map for the face.
|
||||
*
|
||||
* @param encoding Freetype enumerate for char map code.
|
||||
* @return <code>true</code> if charmap was valid and
|
||||
* set correctly
|
||||
*/
|
||||
bool CharMap( FT_Encoding encoding );
|
||||
|
||||
/**
|
||||
* Get the number of character maps in this face.
|
||||
*
|
||||
* @return character map count.
|
||||
*/
|
||||
unsigned int CharMapCount();
|
||||
|
||||
/**
|
||||
* Get a list of character maps in this face.
|
||||
*
|
||||
* @return pointer to the first encoding.
|
||||
*/
|
||||
FT_Encoding* CharMapList();
|
||||
|
||||
/**
|
||||
* Set the char size for the current face.
|
||||
*
|
||||
* @param size the face size in points (1/72 inch)
|
||||
* @param res the resolution of the target device.
|
||||
* @return <code>true</code> if size was set correctly
|
||||
*/
|
||||
virtual bool FaceSize( const unsigned int size, const unsigned int res = 72);
|
||||
|
||||
/**
|
||||
* Get the current face size in points.
|
||||
*
|
||||
* @return face size
|
||||
*/
|
||||
unsigned int FaceSize() const;
|
||||
|
||||
/**
|
||||
* Set the extrusion distance for the font. Only implemented by
|
||||
* FTGLExtrdFont
|
||||
*
|
||||
* @param depth The extrusion distance.
|
||||
*/
|
||||
virtual void Depth( float depth){}
|
||||
|
||||
/**
|
||||
* Enable or disable the use of Display Lists inside FTGL
|
||||
*
|
||||
* @param useList <code>true</code> turns ON display lists.
|
||||
* <code>false</code> turns OFF display lists.
|
||||
*/
|
||||
void UseDisplayList( bool useList);
|
||||
|
||||
/**
|
||||
* Get the global ascender height for the face.
|
||||
*
|
||||
* @return Ascender height
|
||||
*/
|
||||
float Ascender() const;
|
||||
|
||||
/**
|
||||
* Gets the global descender height for the face.
|
||||
*
|
||||
* @return Descender height
|
||||
*/
|
||||
float Descender() const;
|
||||
|
||||
/**
|
||||
* Gets the line spacing for the font.
|
||||
*
|
||||
* @return Line height
|
||||
*/
|
||||
float LineHeight() const;
|
||||
|
||||
/**
|
||||
* Get the bounding box for a string.
|
||||
*
|
||||
* @param string a char string
|
||||
* @param llx lower left near x coord
|
||||
* @param lly lower left near y coord
|
||||
* @param llz lower left near z coord
|
||||
* @param urx upper right far x coord
|
||||
* @param ury upper right far y coord
|
||||
* @param urz upper right far z coord
|
||||
*/
|
||||
void BBox( const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz);
|
||||
|
||||
/**
|
||||
* Get the bounding box for a string.
|
||||
*
|
||||
* @param string a wchar_t string
|
||||
* @param llx lower left near x coord
|
||||
* @param lly lower left near y coord
|
||||
* @param llz lower left near z coord
|
||||
* @param urx upper right far x coord
|
||||
* @param ury upper right far y coord
|
||||
* @param urz upper right far z coord
|
||||
*/
|
||||
void BBox( const wchar_t* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz);
|
||||
|
||||
/**
|
||||
* Get the advance width for a string.
|
||||
*
|
||||
* @param string a wchar_t string
|
||||
* @return advance width
|
||||
*/
|
||||
float Advance( const wchar_t* string);
|
||||
|
||||
/**
|
||||
* Get the advance width for a string.
|
||||
*
|
||||
* @param string a char string
|
||||
* @return advance width
|
||||
*/
|
||||
float Advance( const char* string);
|
||||
|
||||
/**
|
||||
* Render a string of characters
|
||||
*
|
||||
* @param string 'C' style string to be output.
|
||||
*/
|
||||
virtual void Render( const char* string );
|
||||
|
||||
/**
|
||||
* Render a string of characters
|
||||
*
|
||||
* @param string wchar_t string to be output.
|
||||
*/
|
||||
virtual void Render( const wchar_t* string );
|
||||
|
||||
/**
|
||||
* Queries the Font for errors.
|
||||
*
|
||||
* @return The current error code.
|
||||
*/
|
||||
FT_Error Error() const { return err;}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Construct a glyph of the correct type.
|
||||
*
|
||||
* Clients must overide the function and return their specialised
|
||||
* FTGlyph.
|
||||
*
|
||||
* @param g The glyph index NOT the char code.
|
||||
* @return An FT****Glyph or <code>null</code> on failure.
|
||||
*/
|
||||
virtual FTGlyph* MakeGlyph( unsigned int g) = 0;
|
||||
|
||||
/**
|
||||
* Current face object
|
||||
*/
|
||||
FTFace face;
|
||||
|
||||
/**
|
||||
* Current size object
|
||||
*/
|
||||
FTSize charSize;
|
||||
|
||||
/**
|
||||
* Flag to enable or disable the use of Display Lists inside FTGL
|
||||
* <code>true</code> turns ON display lists.
|
||||
* <code>false</code> turns OFF display lists.
|
||||
*/
|
||||
bool useDisplayLists;
|
||||
|
||||
/**
|
||||
* Current error code. Zero means no error.
|
||||
*/
|
||||
FT_Error err;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Check that the glyph at <code>chr</code> exist. If not load it.
|
||||
*
|
||||
* @param chr character index
|
||||
* @return <code>true</code> if the glyph can be created.
|
||||
*/
|
||||
inline bool CheckGlyph( const unsigned int chr);
|
||||
|
||||
/**
|
||||
* An object that holds a list of glyphs
|
||||
*/
|
||||
FTGlyphContainer* glyphList;
|
||||
|
||||
/**
|
||||
* Current pen or cursor position;
|
||||
*/
|
||||
FTPoint pen;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTFont__
|
||||
|
||||
86
src/WinLibs/FTGL/include/FTGL.h
Normal file
86
src/WinLibs/FTGL/include/FTGL.h
Normal file
@ -0,0 +1,86 @@
|
||||
#ifndef __FTGL__
|
||||
#define __FTGL__
|
||||
|
||||
|
||||
typedef double FTGL_DOUBLE;
|
||||
typedef float FTGL_FLOAT;
|
||||
|
||||
// Fixes for deprecated identifiers in 2.1.5
|
||||
#ifndef FT_OPEN_MEMORY
|
||||
#define FT_OPEN_MEMORY (FT_Open_Flags)1
|
||||
#endif
|
||||
|
||||
#ifndef FT_RENDER_MODE_MONO
|
||||
#define FT_RENDER_MODE_MONO ft_render_mode_mono
|
||||
#endif
|
||||
|
||||
#ifndef FT_RENDER_MODE_NORMAL
|
||||
#define FT_RENDER_MODE_NORMAL ft_render_mode_normal
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
// Under windows avoid including <windows.h> is overrated.
|
||||
// Sure, it can be avoided and "name space pollution" can be
|
||||
// avoided, but why? It really doesn't make that much difference
|
||||
// these days.
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef __gl_h_
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// Non windows platforms - don't require nonsense as seen above :-)
|
||||
#ifndef __gl_h_
|
||||
#ifdef __APPLE_CC__
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Required for compatibility with glext.h style function definitions of
|
||||
// OpenGL extensions, such as in src/osg/Point.cpp.
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Compiler-specific conditional compilation
|
||||
#ifdef _MSC_VER // MS Visual C++
|
||||
|
||||
// Disable various warning.
|
||||
// 4786: template name too long
|
||||
#pragma warning( disable : 4251 )
|
||||
#pragma warning( disable : 4275 )
|
||||
#pragma warning( disable : 4786 )
|
||||
|
||||
// The following definitions control how symbols are exported.
|
||||
// If the target is a static library ensure that FTGL_LIBRARY_STATIC
|
||||
// is defined. If building a dynamic library (ie DLL) ensure the
|
||||
// FTGL_LIBRARY macro is defined, as it will mark symbols for
|
||||
// export. If compiling a project to _use_ the _dynamic_ library
|
||||
// version of the library, no definition is required.
|
||||
#ifdef FTGL_LIBRARY_STATIC // static lib - no special export required
|
||||
# define FTGL_EXPORT
|
||||
#elif FTGL_LIBRARY // dynamic lib - must export/import symbols appropriately.
|
||||
# define FTGL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
# define FTGL_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#else
|
||||
// Compiler that is not MS Visual C++.
|
||||
// Ensure that the export symbol is defined (and blank)
|
||||
#define FTGL_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // __FTGL__
|
||||
65
src/WinLibs/FTGL/include/FTGLBitmapFont.h
Normal file
65
src/WinLibs/FTGL/include/FTGLBitmapFont.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef __FTGLBitmapFont__
|
||||
#define __FTGLBitmapFont__
|
||||
|
||||
#include "FTFont.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
class FTGlyph;
|
||||
|
||||
/**
|
||||
* FTGLBitmapFont is a specialisation of the FTFont class for handling
|
||||
* Bitmap fonts
|
||||
*
|
||||
* @see FTFont
|
||||
*/
|
||||
class FTGL_EXPORT FTGLBitmapFont : public FTFont
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Open and read a font file. Sets Error flag.
|
||||
*
|
||||
* @param fontFilePath font file path.
|
||||
*/
|
||||
FTGLBitmapFont( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Open and read a font from a buffer in memory. Sets Error flag.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
*/
|
||||
FTGLBitmapFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTGLBitmapFont();
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
*
|
||||
* @param string 'C' style string to be output.
|
||||
*/
|
||||
void Render( const char* string);
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
*
|
||||
* @param string 'C' style wide string to be output.
|
||||
*/
|
||||
void Render( const wchar_t* string);
|
||||
|
||||
// attributes
|
||||
|
||||
private:
|
||||
/**
|
||||
* Construct a FTBitmapGlyph.
|
||||
*
|
||||
* @param g The glyph index NOT the char code.
|
||||
* @return An FTBitmapGlyph or <code>null</code> on failure.
|
||||
*/
|
||||
inline virtual FTGlyph* MakeGlyph( unsigned int g);
|
||||
|
||||
};
|
||||
#endif // __FTGLBitmapFont__
|
||||
63
src/WinLibs/FTGL/include/FTGLExtrdFont.h
Normal file
63
src/WinLibs/FTGL/include/FTGLExtrdFont.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef __FTGLExtrdFont__
|
||||
#define __FTGLExtrdFont__
|
||||
|
||||
#include "FTFont.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
class FTGlyph;
|
||||
|
||||
/**
|
||||
* FTGLExtrdFont is a specialisation of the FTFont class for handling
|
||||
* extruded Polygon fonts
|
||||
*
|
||||
* @see FTFont
|
||||
* @see FTGLPolygonFont
|
||||
*/
|
||||
class FTGL_EXPORT FTGLExtrdFont : public FTFont
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Open and read a font file. Sets Error flag.
|
||||
*
|
||||
* @param fontFilePath font file path.
|
||||
*/
|
||||
FTGLExtrdFont( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Open and read a font from a buffer in memory. Sets Error flag.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
*/
|
||||
FTGLExtrdFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTGLExtrdFont();
|
||||
|
||||
/**
|
||||
* Set the extrusion distance for the font.
|
||||
*
|
||||
* @param d The extrusion distance.
|
||||
*/
|
||||
void Depth( float d) { depth = d;}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Construct a FTPolyGlyph.
|
||||
*
|
||||
* @param glyphIndex The glyph index NOT the char code.
|
||||
* @return An FTExtrdGlyph or <code>null</code> on failure.
|
||||
*/
|
||||
inline virtual FTGlyph* MakeGlyph( unsigned int glyphIndex);
|
||||
|
||||
/**
|
||||
* The extrusion distance for the font.
|
||||
*/
|
||||
float depth;
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTGLExtrdFont__
|
||||
|
||||
64
src/WinLibs/FTGL/include/FTGLOutlineFont.h
Normal file
64
src/WinLibs/FTGL/include/FTGLOutlineFont.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef __FTGLOutlineFont__
|
||||
#define __FTGLOutlineFont__
|
||||
|
||||
|
||||
#include "FTFont.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
class FTGlyph;
|
||||
|
||||
|
||||
/**
|
||||
* FTGLOutlineFont is a specialisation of the FTFont class for handling
|
||||
* Vector Outline fonts
|
||||
*
|
||||
* @see FTFont
|
||||
*/
|
||||
class FTGL_EXPORT FTGLOutlineFont : public FTFont
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Open and read a font file. Sets Error flag.
|
||||
*
|
||||
* @param fontFilePath font file path.
|
||||
*/
|
||||
FTGLOutlineFont( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Open and read a font from a buffer in memory. Sets Error flag.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
*/
|
||||
FTGLOutlineFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTGLOutlineFont();
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
*
|
||||
* @param string 'C' style string to be output.
|
||||
*/
|
||||
void Render( const char* string);
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
*
|
||||
* @param string wchar_t string to be output.
|
||||
*/
|
||||
void Render( const wchar_t* string);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Construct a FTOutlineGlyph.
|
||||
*
|
||||
* @param g The glyph index NOT the char code.
|
||||
* @return An FTOutlineGlyph or <code>null</code> on failure.
|
||||
*/
|
||||
inline virtual FTGlyph* MakeGlyph( unsigned int g);
|
||||
|
||||
};
|
||||
#endif // __FTGLOutlineFont__
|
||||
68
src/WinLibs/FTGL/include/FTGLPixmapFont.h
Normal file
68
src/WinLibs/FTGL/include/FTGLPixmapFont.h
Normal file
@ -0,0 +1,68 @@
|
||||
#ifndef __FTGLPixmapFont__
|
||||
#define __FTGLPixmapFont__
|
||||
|
||||
|
||||
#include "FTFont.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
class FTGlyph;
|
||||
|
||||
|
||||
/**
|
||||
* FTGLPixmapFont is a specialisation of the FTFont class for handling
|
||||
* Pixmap (Grey Scale) fonts
|
||||
*
|
||||
* @see FTFont
|
||||
*/
|
||||
class FTGL_EXPORT FTGLPixmapFont : public FTFont
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Open and read a font file. Sets Error flag.
|
||||
*
|
||||
* @param fontFilePath font file path.
|
||||
*/
|
||||
FTGLPixmapFont( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Open and read a font from a buffer in memory. Sets Error flag.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
*/
|
||||
FTGLPixmapFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTGLPixmapFont();
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
*
|
||||
* @param string 'C' style string to be output.
|
||||
*/
|
||||
void Render( const char* string);
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
*
|
||||
* @param string wchar_t string to be output.
|
||||
*/
|
||||
void Render( const wchar_t* string);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Construct a FTPixmapGlyph.
|
||||
*
|
||||
* @param g The glyph index NOT the char code.
|
||||
* @return An FTPixmapGlyph or <code>null</code> on failure.
|
||||
*/
|
||||
inline virtual FTGlyph* MakeGlyph( unsigned int g);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTGLPixmapFont__
|
||||
|
||||
53
src/WinLibs/FTGL/include/FTGLPolygonFont.h
Normal file
53
src/WinLibs/FTGL/include/FTGLPolygonFont.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef __FTGLPolygonFont__
|
||||
#define __FTGLPolygonFont__
|
||||
|
||||
|
||||
#include "FTFont.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
class FTGlyph;
|
||||
|
||||
|
||||
/**
|
||||
* FTGLPolygonFont is a specialisation of the FTFont class for handling
|
||||
* tesselated Polygon Mesh fonts
|
||||
*
|
||||
* @see FTFont
|
||||
*/
|
||||
class FTGL_EXPORT FTGLPolygonFont : public FTFont
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Open and read a font file. Sets Error flag.
|
||||
*
|
||||
* @param fontFilePath font file path.
|
||||
*/
|
||||
FTGLPolygonFont( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Open and read a font from a buffer in memory. Sets Error flag.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
*/
|
||||
FTGLPolygonFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTGLPolygonFont();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Construct a FTPolyGlyph.
|
||||
*
|
||||
* @param g The glyph index NOT the char code.
|
||||
* @return An FTPolyGlyph or <code>null</code> on failure.
|
||||
*/
|
||||
inline virtual FTGlyph* MakeGlyph( unsigned int g);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTGLPolygonFont__
|
||||
|
||||
151
src/WinLibs/FTGL/include/FTGLTextureFont.h
Normal file
151
src/WinLibs/FTGL/include/FTGLTextureFont.h
Normal file
@ -0,0 +1,151 @@
|
||||
#ifndef __FTGLTextureFont__
|
||||
#define __FTGLTextureFont__
|
||||
|
||||
#include "FTFont.h"
|
||||
#include "FTVector.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
class FTTextureGlyph;
|
||||
|
||||
|
||||
/**
|
||||
* FTGLTextureFont is a specialisation of the FTFont class for handling
|
||||
* Texture mapped fonts
|
||||
*
|
||||
* @see FTFont
|
||||
*/
|
||||
class FTGL_EXPORT FTGLTextureFont : public FTFont
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Open and read a font file. Sets Error flag.
|
||||
*
|
||||
* @param fontFilePath font file path.
|
||||
*/
|
||||
FTGLTextureFont( const char* fontFilePath);
|
||||
|
||||
/**
|
||||
* Open and read a font from a buffer in memory. Sets Error flag.
|
||||
*
|
||||
* @param pBufferBytes the in-memory buffer
|
||||
* @param bufferSizeInBytes the length of the buffer in bytes
|
||||
*/
|
||||
FTGLTextureFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTGLTextureFont();
|
||||
|
||||
/**
|
||||
* Set the char size for the current face.
|
||||
*
|
||||
* @param size the face size in points (1/72 inch)
|
||||
* @param res the resolution of the target device.
|
||||
* @return <code>true</code> if size was set correctly
|
||||
*/
|
||||
virtual bool FaceSize( const unsigned int size, const unsigned int res = 72);
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
*
|
||||
* @param string 'C' style string to be output.
|
||||
*/
|
||||
virtual void Render( const char* string);
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
*
|
||||
* @param string wchar_t string to be output.
|
||||
*/
|
||||
virtual void Render( const wchar_t* string);
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Construct a FTTextureGlyph.
|
||||
*
|
||||
* @param glyphIndex The glyph index NOT the char code.
|
||||
* @return An FTTextureGlyph or <code>null</code> on failure.
|
||||
*/
|
||||
inline virtual FTGlyph* MakeGlyph( unsigned int glyphIndex);
|
||||
|
||||
/**
|
||||
* Get the size of a block of memory required to layout the glyphs
|
||||
*
|
||||
* Calculates a width and height based on the glyph sizes and the
|
||||
* number of glyphs. It over estimates.
|
||||
*/
|
||||
inline void CalculateTextureSize();
|
||||
|
||||
/**
|
||||
* Creates a 'blank' OpenGL texture object.
|
||||
*
|
||||
* The format is GL_ALPHA and the params are
|
||||
* GL_TEXTURE_WRAP_S = GL_CLAMP
|
||||
* GL_TEXTURE_WRAP_T = GL_CLAMP
|
||||
* GL_TEXTURE_MAG_FILTER = GL_LINEAR
|
||||
* GL_TEXTURE_MIN_FILTER = GL_LINEAR
|
||||
* Note that mipmapping is NOT used
|
||||
*/
|
||||
inline GLuint CreateTexture();
|
||||
|
||||
/**
|
||||
* The maximum texture dimension on this OpenGL implemetation
|
||||
*/
|
||||
GLsizei maximumGLTextureSize;
|
||||
|
||||
/**
|
||||
* The minimum texture width required to hold the glyphs
|
||||
*/
|
||||
GLsizei textureWidth;
|
||||
|
||||
/**
|
||||
* The minimum texture height required to hold the glyphs
|
||||
*/
|
||||
GLsizei textureHeight;
|
||||
|
||||
/**
|
||||
*An array of texture ids
|
||||
*/
|
||||
FTVector<GLuint> textureIDList;
|
||||
|
||||
/**
|
||||
* The max height for glyphs in the current font
|
||||
*/
|
||||
int glyphHeight;
|
||||
|
||||
/**
|
||||
* The max width for glyphs in the current font
|
||||
*/
|
||||
int glyphWidth;
|
||||
|
||||
/**
|
||||
* A value to be added to the height and width to ensure that
|
||||
* glyphs don't overlap in the texture
|
||||
*/
|
||||
unsigned int padding;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
unsigned int numGlyphs;
|
||||
|
||||
/**
|
||||
*/
|
||||
unsigned int remGlyphs;
|
||||
|
||||
/**
|
||||
*/
|
||||
int xOffset;
|
||||
|
||||
/**
|
||||
*/
|
||||
int yOffset;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTGLTextureFont__
|
||||
|
||||
|
||||
101
src/WinLibs/FTGL/include/FTGlyph.h
Normal file
101
src/WinLibs/FTGL/include/FTGlyph.h
Normal file
@ -0,0 +1,101 @@
|
||||
#ifndef __FTGlyph__
|
||||
#define __FTGlyph__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTBBox.h"
|
||||
#include "FTPoint.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
/**
|
||||
* FTGlyph is the base class for FTGL glyphs.
|
||||
*
|
||||
* It provides the interface between Freetype glyphs and their openGL
|
||||
* renderable counterparts. This is an abstract class and derived classes
|
||||
* must implement the <code>render</code> function.
|
||||
*
|
||||
* @see FTGlyphContainer
|
||||
* @see FTBBox
|
||||
* @see FTPoint
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTGlyph
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param glyph The Freetype glyph to be processed
|
||||
* @param useDisplayList Enable or disable the use of Display Lists for this glyph
|
||||
* <code>true</code> turns ON display lists.
|
||||
* <code>false</code> turns OFF display lists.
|
||||
*/
|
||||
FTGlyph( FT_GlyphSlot glyph, bool useDisplayList = true);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTGlyph();
|
||||
|
||||
/**
|
||||
* Renders this glyph at the current pen position.
|
||||
*
|
||||
* @param pen The current pen position.
|
||||
* @return The advance distance for this glyph.
|
||||
*/
|
||||
virtual const FTPoint& Render( const FTPoint& pen) = 0;
|
||||
|
||||
/**
|
||||
* Return the advance width for this glyph.
|
||||
*
|
||||
* @return advance width.
|
||||
*/
|
||||
const FTPoint& Advance() const { return advance;}
|
||||
|
||||
/**
|
||||
* Return the bounding box for this glyph.
|
||||
*
|
||||
* @return bounding box.
|
||||
*/
|
||||
const FTBBox& BBox() const { return bBox;}
|
||||
|
||||
/**
|
||||
* Queries for errors.
|
||||
*
|
||||
* @return The current error code.
|
||||
*/
|
||||
FT_Error Error() const { return err;}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The advance distance for this glyph
|
||||
*/
|
||||
FTPoint advance;
|
||||
|
||||
/**
|
||||
* The bounding box of this glyph.
|
||||
*/
|
||||
FTBBox bBox;
|
||||
|
||||
/**
|
||||
* Flag to enable or disable the use of Display Lists inside FTGL
|
||||
* <code>true</code> turns ON display lists.
|
||||
* <code>false</code> turns OFF display lists.
|
||||
*/
|
||||
bool useDisplayList;
|
||||
|
||||
/**
|
||||
* Current error code. Zero means no error.
|
||||
*/
|
||||
FT_Error err;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTGlyph__
|
||||
|
||||
127
src/WinLibs/FTGL/include/FTGlyphContainer.h
Normal file
127
src/WinLibs/FTGL/include/FTGlyphContainer.h
Normal file
@ -0,0 +1,127 @@
|
||||
#ifndef __FTGlyphContainer__
|
||||
#define __FTGlyphContainer__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTBBox.h"
|
||||
#include "FTPoint.h"
|
||||
#include "FTVector.h"
|
||||
|
||||
class FTFace;
|
||||
class FTGlyph;
|
||||
class FTCharmap;
|
||||
|
||||
/**
|
||||
* FTGlyphContainer holds the post processed FTGlyph objects.
|
||||
*
|
||||
* @see FTGlyph
|
||||
*/
|
||||
class FTGL_EXPORT FTGlyphContainer
|
||||
{
|
||||
typedef FTVector<FTGlyph*> GlyphVector;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param face The Freetype face
|
||||
*/
|
||||
FTGlyphContainer( FTFace* face);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTGlyphContainer();
|
||||
|
||||
/**
|
||||
* Sets the character map for the face.
|
||||
*
|
||||
* @param encoding the Freetype encoding symbol. See above.
|
||||
* @return <code>true</code> if charmap was valid
|
||||
* and set correctly
|
||||
*/
|
||||
bool CharMap( FT_Encoding encoding);
|
||||
|
||||
/**
|
||||
* Get the font index of the input character.
|
||||
*
|
||||
* @param characterCode The character code of the requested glyph in the
|
||||
* current encoding eg apple roman.
|
||||
* @return The font index for the character.
|
||||
*/
|
||||
unsigned int FontIndex( const unsigned int characterCode ) const;
|
||||
|
||||
/**
|
||||
* Adds a glyph to this glyph list.
|
||||
*
|
||||
* @param glyph The FTGlyph to be inserted into the container
|
||||
* @param characterCode The char code of the glyph NOT the glyph index.
|
||||
*/
|
||||
void Add( FTGlyph* glyph, const unsigned int characterCode);
|
||||
|
||||
/**
|
||||
* Get a glyph from the glyph list
|
||||
*
|
||||
* @param characterCode The char code of the glyph NOT the glyph index
|
||||
* @return An FTGlyph or <code>null</code> is it hasn't been
|
||||
* loaded.
|
||||
*/
|
||||
const FTGlyph* const Glyph( const unsigned int characterCode) const;
|
||||
|
||||
/**
|
||||
* Get the bounding box for a character.
|
||||
* @param characterCode The char code of the glyph NOT the glyph index
|
||||
*/
|
||||
FTBBox BBox( const unsigned int characterCode) const;
|
||||
|
||||
/**
|
||||
* Returns the kerned advance width for a glyph.
|
||||
*
|
||||
* @param characterCode glyph index of the character
|
||||
* @param nextCharacterCode the next glyph in a string
|
||||
* @return advance width
|
||||
*/
|
||||
float Advance( const unsigned int characterCode, const unsigned int nextCharacterCode);
|
||||
|
||||
/**
|
||||
* Renders a character
|
||||
* @param characterCode the glyph to be Rendered
|
||||
* @param nextCharacterCode the next glyph in the string. Used for kerning.
|
||||
* @param penPosition the position to Render the glyph
|
||||
* @return The distance to advance the pen position after Rendering
|
||||
*/
|
||||
FTPoint Render( const unsigned int characterCode, const unsigned int nextCharacterCode, FTPoint penPosition);
|
||||
|
||||
/**
|
||||
* Queries the Font for errors.
|
||||
*
|
||||
* @return The current error code.
|
||||
*/
|
||||
FT_Error Error() const { return err;}
|
||||
|
||||
private:
|
||||
/**
|
||||
* The FTGL face
|
||||
*/
|
||||
FTFace* face;
|
||||
|
||||
/**
|
||||
* The Character Map object associated with the current face
|
||||
*/
|
||||
FTCharmap* charMap;
|
||||
|
||||
/**
|
||||
* A structure to hold the glyphs
|
||||
*/
|
||||
GlyphVector glyphs;
|
||||
|
||||
/**
|
||||
* Current error code. Zero means no error.
|
||||
*/
|
||||
FT_Error err;
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTGlyphContainer__
|
||||
97
src/WinLibs/FTGL/include/FTLibrary.h
Normal file
97
src/WinLibs/FTGL/include/FTLibrary.h
Normal file
@ -0,0 +1,97 @@
|
||||
#ifndef __FTLibrary__
|
||||
#define __FTLibrary__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
//#include FT_CACHE_H
|
||||
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
/**
|
||||
* FTLibrary class is the global accessor for the Freetype library.
|
||||
*
|
||||
* This class encapsulates the Freetype Library. This is a singleton class
|
||||
* and ensures that only one FT_Library is in existence at any one time.
|
||||
* All constructors are private therefore clients cannot create or
|
||||
* instantiate this class themselves and must access it's methods via the
|
||||
* static <code>FTLibrary::Instance()</code> function.
|
||||
*
|
||||
* Just because this class returns a valid <code>FTLibrary</code> object
|
||||
* doesn't mean that the Freetype Library has been successfully initialised.
|
||||
* Clients should check for errors. You can initialse the library AND check
|
||||
* for errors using the following code...
|
||||
* <code>err = FTLibrary::Instance().Error();</code>
|
||||
*
|
||||
* @see "Freetype 2 Documentation"
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTLibrary
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Global acces point to the single FTLibrary object.
|
||||
*
|
||||
* @return The global <code>FTLibrary</code> object.
|
||||
*/
|
||||
static const FTLibrary& Instance();
|
||||
|
||||
/**
|
||||
* Gets a pointer to the native Freetype library.
|
||||
*
|
||||
* @return A handle to a FreeType library instance.
|
||||
*/
|
||||
const FT_Library* const GetLibrary() const { return library;}
|
||||
|
||||
/**
|
||||
* Queries the library for errors.
|
||||
*
|
||||
* @return The current error code.
|
||||
*/
|
||||
FT_Error Error() const { return err;}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
* Disposes of the Freetype library
|
||||
*/
|
||||
~FTLibrary();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Default constructors.
|
||||
*
|
||||
* Made private to stop clients creating there own FTLibrary
|
||||
* objects.
|
||||
*/
|
||||
FTLibrary();
|
||||
FTLibrary( const FT_Library&){}
|
||||
FTLibrary& operator=( const FT_Library&) { return *this; }
|
||||
|
||||
/**
|
||||
* Initialises the Freetype library
|
||||
*
|
||||
* Even though this function indicates success via the return value,
|
||||
* clients can't see this so must check the error codes. This function
|
||||
* is only ever called by the default c_stor
|
||||
*
|
||||
* @return <code>true</code> if the Freetype library was
|
||||
* successfully initialised, <code>false</code>
|
||||
* otherwise.
|
||||
*/
|
||||
bool Initialise();
|
||||
|
||||
/**
|
||||
* Freetype library handle.
|
||||
*/
|
||||
FT_Library* library;
|
||||
// FTC_Manager* manager;
|
||||
|
||||
/**
|
||||
* Current error code. Zero means no error.
|
||||
*/
|
||||
FT_Error err;
|
||||
|
||||
};
|
||||
|
||||
#endif // __FTLibrary__
|
||||
112
src/WinLibs/FTGL/include/FTList.h
Normal file
112
src/WinLibs/FTGL/include/FTList.h
Normal file
@ -0,0 +1,112 @@
|
||||
#ifndef __FTList__
|
||||
#define __FTList__
|
||||
|
||||
#include "FTGL.h"
|
||||
|
||||
/**
|
||||
* Provides a non-STL alternative to the STL list
|
||||
*/
|
||||
template <typename FT_LIST_ITEM_TYPE>
|
||||
class FTGL_EXPORT FTList
|
||||
{
|
||||
public:
|
||||
typedef FT_LIST_ITEM_TYPE value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef size_t size_type;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
FTList()
|
||||
: listSize(0),
|
||||
tail(0)
|
||||
{
|
||||
tail = NULL;
|
||||
head = new Node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTList()
|
||||
{
|
||||
Node* next;
|
||||
|
||||
for( Node *walk = head; walk; walk = next)
|
||||
{
|
||||
next = walk->next;
|
||||
delete walk;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of items in the list
|
||||
*/
|
||||
size_type size() const
|
||||
{
|
||||
return listSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the end of the list
|
||||
*/
|
||||
void push_back( const value_type& item)
|
||||
{
|
||||
Node* node = new Node( item);
|
||||
|
||||
if( head->next == NULL)
|
||||
{
|
||||
head->next = node;
|
||||
}
|
||||
|
||||
if( tail)
|
||||
{
|
||||
tail->next = node;
|
||||
}
|
||||
tail = node;
|
||||
++listSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item at the front of the list
|
||||
*/
|
||||
reference front() const
|
||||
{
|
||||
return head->next->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item at the end of the list
|
||||
*/
|
||||
reference back() const
|
||||
{
|
||||
return tail->payload;
|
||||
}
|
||||
|
||||
private:
|
||||
struct Node
|
||||
{
|
||||
Node()
|
||||
: next(NULL)
|
||||
{}
|
||||
|
||||
Node( const value_type& item)
|
||||
: next(NULL)
|
||||
{
|
||||
payload = item;
|
||||
}
|
||||
|
||||
Node* next;
|
||||
|
||||
value_type payload;
|
||||
};
|
||||
|
||||
size_type listSize;
|
||||
|
||||
Node* head;
|
||||
Node* tail;
|
||||
};
|
||||
|
||||
#endif // __FTList__
|
||||
|
||||
57
src/WinLibs/FTGL/include/FTOutlineGlyph.h
Normal file
57
src/WinLibs/FTGL/include/FTOutlineGlyph.h
Normal file
@ -0,0 +1,57 @@
|
||||
#ifndef __FTOutlineGlyph__
|
||||
#define __FTOutlineGlyph__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTGlyph.h"
|
||||
|
||||
class FTVectoriser;
|
||||
|
||||
|
||||
/**
|
||||
* FTOutlineGlyph is a specialisation of FTGlyph for creating outlines.
|
||||
*
|
||||
* @see FTGlyphContainer
|
||||
* @see FTVectoriser
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTOutlineGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor. Sets the Error to Invalid_Outline if the glyphs isn't an outline.
|
||||
*
|
||||
* @param glyph The Freetype glyph to be processed
|
||||
* @param useDisplayList Enable or disable the use of Display Lists for this glyph
|
||||
* <code>true</code> turns ON display lists.
|
||||
* <code>false</code> turns OFF display lists.
|
||||
*/
|
||||
FTOutlineGlyph( FT_GlyphSlot glyph, bool useDisplayList);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTOutlineGlyph();
|
||||
|
||||
/**
|
||||
* Renders this glyph at the current pen position.
|
||||
*
|
||||
* @param pen The current pen position.
|
||||
* @return The advance distance for this glyph.
|
||||
*/
|
||||
virtual const FTPoint& Render( const FTPoint& pen);
|
||||
|
||||
private:
|
||||
/**
|
||||
* OpenGL display list
|
||||
*/
|
||||
GLuint glList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTOutlineGlyph__
|
||||
|
||||
68
src/WinLibs/FTGL/include/FTPixmapGlyph.h
Normal file
68
src/WinLibs/FTGL/include/FTPixmapGlyph.h
Normal file
@ -0,0 +1,68 @@
|
||||
#ifndef __FTPixmapGlyph__
|
||||
#define __FTPixmapGlyph__
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTGlyph.h"
|
||||
|
||||
|
||||
/**
|
||||
* FTPixmapGlyph is a specialisation of FTGlyph for creating pixmaps.
|
||||
*
|
||||
* @see FTGlyphContainer
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTPixmapGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param glyph The Freetype glyph to be processed
|
||||
*/
|
||||
FTPixmapGlyph( FT_GlyphSlot glyph);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTPixmapGlyph();
|
||||
|
||||
/**
|
||||
* Renders this glyph at the current pen position.
|
||||
*
|
||||
* @param pen The current pen position.
|
||||
* @return The advance distance for this glyph.
|
||||
*/
|
||||
virtual const FTPoint& Render( const FTPoint& pen);
|
||||
|
||||
// attributes
|
||||
|
||||
private:
|
||||
/**
|
||||
* The width of the glyph 'image'
|
||||
*/
|
||||
int destWidth;
|
||||
|
||||
/**
|
||||
* The height of the glyph 'image'
|
||||
*/
|
||||
int destHeight;
|
||||
|
||||
/**
|
||||
* Vector from the pen position to the topleft corner of the pixmap
|
||||
*/
|
||||
FTPoint pos;
|
||||
|
||||
/**
|
||||
* Pointer to the 'image' data
|
||||
*/
|
||||
unsigned char* data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTPixmapGlyph__
|
||||
162
src/WinLibs/FTGL/include/FTPoint.h
Normal file
162
src/WinLibs/FTGL/include/FTPoint.h
Normal file
@ -0,0 +1,162 @@
|
||||
#ifndef __FTPoint__
|
||||
#define __FTPoint__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
|
||||
/**
|
||||
* FTPoint class is a basic 3 dimensional point or vector.
|
||||
*/
|
||||
class FTGL_EXPORT FTPoint
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor. Point is set to zero.
|
||||
*/
|
||||
FTPoint()
|
||||
{
|
||||
values[0] = 0;
|
||||
values[1] = 0;
|
||||
values[2] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param x First component
|
||||
* @param y Second component
|
||||
* @param z Third component
|
||||
*/
|
||||
FTPoint( const FTGL_DOUBLE x, const FTGL_DOUBLE y, const FTGL_DOUBLE z)
|
||||
{
|
||||
values[0] = x;
|
||||
values[1] = y;
|
||||
values[2] = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. This converts an FT_Vector to an FT_Point
|
||||
*
|
||||
* @param ft_vector A freetype vector
|
||||
*/
|
||||
FTPoint( const FT_Vector& ft_vector)
|
||||
{
|
||||
values[0] = ft_vector.x;
|
||||
values[1] = ft_vector.y;
|
||||
values[2] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operator += In Place Addition.
|
||||
*
|
||||
* @param point
|
||||
* @return this plus point.
|
||||
*/
|
||||
FTPoint& operator += ( const FTPoint& point)
|
||||
{
|
||||
values[0] += point.values[0];
|
||||
values[1] += point.values[1];
|
||||
values[2] += point.values[2];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operator +
|
||||
*
|
||||
* @param point
|
||||
* @return this plus point.
|
||||
*/
|
||||
FTPoint operator + ( const FTPoint& point)
|
||||
{
|
||||
FTPoint temp;
|
||||
temp.values[0] = values[0] + point.values[0];
|
||||
temp.values[1] = values[1] + point.values[1];
|
||||
temp.values[2] = values[2] + point.values[2];
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Operator *
|
||||
*
|
||||
* @param multiplier
|
||||
* @return <code>this</code> multiplied by <code>multiplier</code>.
|
||||
*/
|
||||
FTPoint operator * ( double multiplier)
|
||||
{
|
||||
FTPoint temp;
|
||||
temp.values[0] = values[0] * multiplier;
|
||||
temp.values[1] = values[1] * multiplier;
|
||||
temp.values[2] = values[2] * multiplier;
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Operator *
|
||||
*
|
||||
* @param point
|
||||
* @param multiplier
|
||||
* @return <code>multiplier</code> multiplied by <code>point</code>.
|
||||
*/
|
||||
friend FTPoint operator*( double multiplier, FTPoint& point);
|
||||
|
||||
|
||||
/**
|
||||
* Operator == Tests for eqaulity
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return true if a & b are equal
|
||||
*/
|
||||
friend bool operator == ( const FTPoint &a, const FTPoint &b);
|
||||
|
||||
/**
|
||||
* Operator != Tests for non equality
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return true if a & b are not equal
|
||||
*/
|
||||
friend bool operator != ( const FTPoint &a, const FTPoint &b);
|
||||
|
||||
|
||||
/**
|
||||
* Cast to FTGL_DOUBLE*
|
||||
*/
|
||||
operator const FTGL_DOUBLE*() const
|
||||
{
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setters
|
||||
*/
|
||||
void X( FTGL_DOUBLE x) { values[0] = x;};
|
||||
void Y( FTGL_DOUBLE y) { values[1] = y;};
|
||||
void Z( FTGL_DOUBLE z) { values[2] = z;};
|
||||
|
||||
|
||||
/**
|
||||
* Getters
|
||||
*/
|
||||
FTGL_DOUBLE X() const { return values[0];};
|
||||
FTGL_DOUBLE Y() const { return values[1];};
|
||||
FTGL_DOUBLE Z() const { return values[2];};
|
||||
|
||||
private:
|
||||
/**
|
||||
* The point data
|
||||
*/
|
||||
FTGL_DOUBLE values[3];
|
||||
};
|
||||
|
||||
#endif // __FTPoint__
|
||||
|
||||
59
src/WinLibs/FTGL/include/FTPolyGlyph.h
Normal file
59
src/WinLibs/FTGL/include/FTPolyGlyph.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef __FTPolyGlyph__
|
||||
#define __FTPolyGlyph__
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTGlyph.h"
|
||||
|
||||
class FTVectoriser;
|
||||
|
||||
/**
|
||||
* FTPolyGlyph is a specialisation of FTGlyph for creating tessellated
|
||||
* polygon glyphs.
|
||||
*
|
||||
* @see FTGlyphContainer
|
||||
* @see FTVectoriser
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTPolyGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor. Sets the Error to Invalid_Outline if the glyphs isn't an outline.
|
||||
*
|
||||
* @param glyph The Freetype glyph to be processed
|
||||
* @param glyph The Freetype glyph to be processed
|
||||
* @param useDisplayList Enable or disable the use of Display Lists for this glyph
|
||||
* <code>true</code> turns ON display lists.
|
||||
* <code>false</code> turns OFF display lists.
|
||||
*/
|
||||
FTPolyGlyph( FT_GlyphSlot glyph, bool useDisplayList);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTPolyGlyph();
|
||||
|
||||
/**
|
||||
* Renders this glyph at the current pen position.
|
||||
*
|
||||
* @param pen The current pen position.
|
||||
* @return The advance distance for this glyph.
|
||||
*/
|
||||
virtual const FTPoint& Render( const FTPoint& pen);
|
||||
|
||||
private:
|
||||
/**
|
||||
* OpenGL display list
|
||||
*/
|
||||
GLuint glList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTPolyGlyph__
|
||||
|
||||
138
src/WinLibs/FTGL/include/FTSize.h
Normal file
138
src/WinLibs/FTGL/include/FTSize.h
Normal file
@ -0,0 +1,138 @@
|
||||
#ifndef __FTSize__
|
||||
#define __FTSize__
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* FTSize class provides an abstraction layer for the Freetype Size.
|
||||
*
|
||||
* @see "Freetype 2 Documentation"
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTSize
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
FTSize();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTSize();
|
||||
|
||||
/**
|
||||
* Sets the char size for the current face.
|
||||
*
|
||||
* This doesn't guarantee that the size was set correctly. Clients
|
||||
* should check errors.
|
||||
*
|
||||
* @param face Parent face for this size object
|
||||
* @param point_size the face size in points (1/72 inch)
|
||||
* @param x_resolution the horizontal resolution of the target device.
|
||||
* @param y_resolution the vertical resolution of the target device.
|
||||
* @return <code>true</code> if the size has been set. Clients should check Error() for more information if this function returns false()
|
||||
*/
|
||||
bool CharSize( FT_Face* face, unsigned int point_size, unsigned int x_resolution, unsigned int y_resolution);
|
||||
|
||||
/**
|
||||
* get the char size for the current face.
|
||||
*
|
||||
* @return The char size in points
|
||||
*/
|
||||
unsigned int CharSize() const;
|
||||
|
||||
/**
|
||||
* Gets the global ascender height for the face in pixels.
|
||||
*
|
||||
* @return Ascender height
|
||||
*/
|
||||
float Ascender() const;
|
||||
|
||||
/**
|
||||
* Gets the global descender height for the face in pixels.
|
||||
*
|
||||
* @return Ascender height
|
||||
*/
|
||||
float Descender() const;
|
||||
|
||||
/**
|
||||
* Gets the global face height for the face.
|
||||
*
|
||||
* If the face is scalable this returns the height of the global
|
||||
* bounding box which ensures that any glyph will be less than or
|
||||
* equal to this height. If the font isn't scalable there is no
|
||||
* guarantee that glyphs will not be taller than this value.
|
||||
*
|
||||
* @return height in pixels.
|
||||
*/
|
||||
float Height() const;
|
||||
|
||||
/**
|
||||
* Gets the global face width for the face.
|
||||
*
|
||||
* If the face is scalable this returns the width of the global
|
||||
* bounding box which ensures that any glyph will be less than or
|
||||
* equal to this width. If the font isn't scalable this value is
|
||||
* the max_advance for the face.
|
||||
*
|
||||
* @return width in pixels.
|
||||
*/
|
||||
float Width() const;
|
||||
|
||||
/**
|
||||
* Gets the underline position for the face.
|
||||
*
|
||||
* @return underline position in pixels
|
||||
*/
|
||||
float Underline() const;
|
||||
|
||||
/**
|
||||
* Queries for errors.
|
||||
*
|
||||
* @return The current error code.
|
||||
*/
|
||||
FT_Error Error() const { return err; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* The current Freetype face that this FTSize object relates to.
|
||||
*/
|
||||
FT_Face* ftFace;
|
||||
|
||||
/**
|
||||
* The Freetype size.
|
||||
*/
|
||||
FT_Size ftSize;
|
||||
|
||||
/**
|
||||
* The size in points.
|
||||
*/
|
||||
unsigned int size;
|
||||
|
||||
/**
|
||||
* The horizontal resolution.
|
||||
*/
|
||||
unsigned int xResolution;
|
||||
|
||||
/**
|
||||
* The vertical resolution.
|
||||
*/
|
||||
unsigned int yResolution;
|
||||
|
||||
/**
|
||||
* Current error code. Zero means no error.
|
||||
*/
|
||||
FT_Error err;
|
||||
|
||||
};
|
||||
|
||||
#endif // __FTSize__
|
||||
|
||||
94
src/WinLibs/FTGL/include/FTTextureGlyph.h
Normal file
94
src/WinLibs/FTGL/include/FTTextureGlyph.h
Normal file
@ -0,0 +1,94 @@
|
||||
#ifndef __FTTextureGlyph__
|
||||
#define __FTTextureGlyph__
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGL.h"
|
||||
#include "FTGlyph.h"
|
||||
|
||||
|
||||
/**
|
||||
* FTTextureGlyph is a specialisation of FTGlyph for creating texture
|
||||
* glyphs.
|
||||
*
|
||||
* @see FTGlyphContainer
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTTextureGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param glyph The Freetype glyph to be processed
|
||||
* @param id The id of the texture that this glyph will be
|
||||
* drawn in
|
||||
* @param xOffset The x offset into the parent texture to draw
|
||||
* this glyph
|
||||
* @param yOffset The y offset into the parent texture to draw
|
||||
* this glyph
|
||||
* @param width The width of the parent texture
|
||||
* @param height The height (number of rows) of the parent texture
|
||||
*/
|
||||
FTTextureGlyph( FT_GlyphSlot glyph, int id, int xOffset, int yOffset, GLsizei width, GLsizei height);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTTextureGlyph();
|
||||
|
||||
/**
|
||||
* Renders this glyph at the current pen position.
|
||||
*
|
||||
* @param pen The current pen position.
|
||||
* @return The advance distance for this glyph.
|
||||
*/
|
||||
virtual const FTPoint& Render( const FTPoint& pen);
|
||||
|
||||
/**
|
||||
* Reset the currently active texture to zero to get into a known state before
|
||||
* drawing a string. This is to get round possible threading issues.
|
||||
*/
|
||||
static void FTTextureGlyph::ResetActiveTexture(){ activeTextureID = 0;}
|
||||
|
||||
private:
|
||||
/**
|
||||
* The width of the glyph 'image'
|
||||
*/
|
||||
int destWidth;
|
||||
|
||||
/**
|
||||
* The height of the glyph 'image'
|
||||
*/
|
||||
int destHeight;
|
||||
|
||||
/**
|
||||
* Vector from the pen position to the topleft corner of the pixmap
|
||||
*/
|
||||
FTPoint pos;
|
||||
|
||||
/**
|
||||
* The texture co-ords of this glyph within the texture.
|
||||
*/
|
||||
FTPoint uv[2];
|
||||
|
||||
/**
|
||||
* The texture index that this glyph is contained in.
|
||||
*/
|
||||
int glTextureID;
|
||||
|
||||
/**
|
||||
* The texture index of the currently active texture
|
||||
*
|
||||
* We keep track of the currently active texture to try to reduce the number
|
||||
* of texture bind operations.
|
||||
*/
|
||||
static GLint activeTextureID;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTTextureGlyph__
|
||||
190
src/WinLibs/FTGL/include/FTVector.h
Normal file
190
src/WinLibs/FTGL/include/FTVector.h
Normal file
@ -0,0 +1,190 @@
|
||||
#ifndef __FTVector__
|
||||
#define __FTVector__
|
||||
|
||||
#include "FTGL.h"
|
||||
|
||||
/**
|
||||
* Provides a non-STL alternative to the STL vector
|
||||
*/
|
||||
template <typename FT_VECTOR_ITEM_TYPE>
|
||||
class FTGL_EXPORT FTVector
|
||||
{
|
||||
public:
|
||||
typedef FT_VECTOR_ITEM_TYPE value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef size_t size_type;
|
||||
|
||||
FTVector()
|
||||
{
|
||||
Capacity = Size = 0;
|
||||
Items = 0;
|
||||
}
|
||||
|
||||
|
||||
virtual ~FTVector()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
FTVector& operator =(const FTVector& v)
|
||||
{
|
||||
reserve(v.capacity());
|
||||
|
||||
iterator ptr = begin();
|
||||
const_iterator vbegin = v.begin();
|
||||
const_iterator vend = v.end();
|
||||
|
||||
while( vbegin != vend)
|
||||
{
|
||||
*ptr++ = *vbegin++;
|
||||
}
|
||||
|
||||
Size = v.size();
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_type size() const
|
||||
{
|
||||
return Size;
|
||||
}
|
||||
|
||||
size_type capacity() const
|
||||
{
|
||||
return Capacity;
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
return Items;
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return Items;
|
||||
}
|
||||
|
||||
iterator end()
|
||||
{
|
||||
return begin() + size();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return begin() + size();
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
reference operator [](size_type pos)
|
||||
{
|
||||
return( *(begin() + pos));
|
||||
}
|
||||
|
||||
const_reference operator []( size_type pos) const
|
||||
{
|
||||
return( *(begin() + pos));
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
if( Capacity)
|
||||
{
|
||||
delete [] Items;
|
||||
Capacity = Size = 0;
|
||||
Items = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void reserve( size_type n)
|
||||
{
|
||||
if( capacity() < n)
|
||||
{
|
||||
expand(n);
|
||||
}
|
||||
}
|
||||
|
||||
void push_back(const value_type& x)
|
||||
{
|
||||
if( size() == capacity())
|
||||
{
|
||||
expand();
|
||||
}
|
||||
|
||||
( *this)[size()] = x;
|
||||
++Size;
|
||||
}
|
||||
|
||||
void resize(size_type n, value_type x)
|
||||
{
|
||||
if( n == size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
reserve(n);
|
||||
iterator begin, end;
|
||||
|
||||
if( n >= Size)
|
||||
{
|
||||
begin = this->end();
|
||||
end = this->begin() + n;
|
||||
}
|
||||
else
|
||||
{
|
||||
begin = this->begin() + n;
|
||||
end = this->end();
|
||||
}
|
||||
|
||||
while( begin != end)
|
||||
{
|
||||
*begin++ = x;
|
||||
}
|
||||
|
||||
Size = n;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void expand(size_type capacity_hint = 0)
|
||||
{
|
||||
size_type new_capacity =( capacity() == 0) ? 256 : capacity()* 2;
|
||||
if( capacity_hint)
|
||||
{
|
||||
while( new_capacity < capacity_hint)
|
||||
{
|
||||
new_capacity *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
value_type *new_items = new value_type[new_capacity];
|
||||
|
||||
iterator begin = this->begin();
|
||||
iterator end = this->end();
|
||||
value_type *ptr = new_items;
|
||||
|
||||
while( begin != end)
|
||||
{
|
||||
*ptr++ = *begin++;
|
||||
}
|
||||
|
||||
if( Capacity)
|
||||
{
|
||||
delete [] Items;
|
||||
}
|
||||
|
||||
Items = new_items;
|
||||
Capacity = new_capacity;
|
||||
}
|
||||
|
||||
size_type Capacity;
|
||||
size_type Size;
|
||||
value_type* Items;
|
||||
};
|
||||
|
||||
#endif // __FTVector__
|
||||
275
src/WinLibs/FTGL/include/FTVectoriser.h
Normal file
275
src/WinLibs/FTGL/include/FTVectoriser.h
Normal file
@ -0,0 +1,275 @@
|
||||
#ifndef __FTVectoriser__
|
||||
#define __FTVectoriser__
|
||||
|
||||
|
||||
#include "FTContour.h"
|
||||
#include "FTList.h"
|
||||
#include "FTPoint.h"
|
||||
#include "FTVector.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
#ifndef CALLBACK
|
||||
#define CALLBACK
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* FTTesselation captures points that are output by OpenGL's gluTesselator.
|
||||
*/
|
||||
class FTGL_EXPORT FTTesselation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
FTTesselation( GLenum m)
|
||||
: meshType(m)
|
||||
{
|
||||
pointList.reserve( 128);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTTesselation()
|
||||
{
|
||||
pointList.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a point to the mesh.
|
||||
*/
|
||||
void AddPoint( const FTGL_DOUBLE x, const FTGL_DOUBLE y, const FTGL_DOUBLE z)
|
||||
{
|
||||
pointList.push_back( FTPoint( x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of points in this mesh
|
||||
*/
|
||||
size_t PointCount() const { return pointList.size();}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const FTPoint& Point( unsigned int index) const { return pointList[index];}
|
||||
|
||||
/**
|
||||
* Return the OpenGL polygon type.
|
||||
*/
|
||||
GLenum PolygonType() const { return meshType;}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Points generated by gluTesselator.
|
||||
*/
|
||||
typedef FTVector<FTPoint> PointVector;
|
||||
PointVector pointList;
|
||||
|
||||
/**
|
||||
* OpenGL primitive type from gluTesselator.
|
||||
*/
|
||||
GLenum meshType;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* FTMesh is a container of FTTesselation's that make up a polygon glyph
|
||||
*/
|
||||
class FTGL_EXPORT FTMesh
|
||||
{
|
||||
typedef FTVector<FTTesselation*> TesselationVector;
|
||||
typedef FTList<FTPoint> PointList;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
FTMesh();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTMesh();
|
||||
|
||||
/**
|
||||
* Add a point to the mesh
|
||||
*/
|
||||
void AddPoint( const FTGL_DOUBLE x, const FTGL_DOUBLE y, const FTGL_DOUBLE z);
|
||||
|
||||
/**
|
||||
* Create a combine point for the gluTesselator
|
||||
*/
|
||||
const FTGL_DOUBLE* Combine( const FTGL_DOUBLE x, const FTGL_DOUBLE y, const FTGL_DOUBLE z);
|
||||
|
||||
/**
|
||||
* Begin a new polygon
|
||||
*/
|
||||
void Begin( GLenum meshType);
|
||||
|
||||
/**
|
||||
* End a polygon
|
||||
*/
|
||||
void End();
|
||||
|
||||
/**
|
||||
* Record a gluTesselation error
|
||||
*/
|
||||
void Error( GLenum e) { err = e;}
|
||||
|
||||
/**
|
||||
* The number of tesselations in the mesh
|
||||
*/
|
||||
unsigned int TesselationCount() const { return tesselationList.size();}
|
||||
|
||||
/**
|
||||
* Get a tesselation by index
|
||||
*/
|
||||
const FTTesselation* const Tesselation( unsigned int index) const;
|
||||
|
||||
/**
|
||||
* Return the temporary point list. For testing only.
|
||||
*/
|
||||
const PointList& TempPointList() const { return tempPointList;}
|
||||
|
||||
/**
|
||||
* Get the GL ERROR returned by the glu tesselator
|
||||
*/
|
||||
GLenum Error() const { return err;}
|
||||
|
||||
private:
|
||||
/**
|
||||
* The current sub mesh that we are constructing.
|
||||
*/
|
||||
FTTesselation* currentTesselation;
|
||||
|
||||
/**
|
||||
* Holds each sub mesh that comprises this glyph.
|
||||
*/
|
||||
TesselationVector tesselationList;
|
||||
|
||||
/**
|
||||
* Holds extra points created by gluTesselator. See ftglCombine.
|
||||
*/
|
||||
PointList tempPointList;
|
||||
|
||||
/**
|
||||
* GL ERROR returned by the glu tesselator
|
||||
*/
|
||||
GLenum err;
|
||||
|
||||
};
|
||||
|
||||
const FTGL_DOUBLE FTGL_FRONT_FACING = 1.0;
|
||||
const FTGL_DOUBLE FTGL_BACK_FACING = -1.0;
|
||||
|
||||
/**
|
||||
* FTVectoriser class is a helper class that converts font outlines into
|
||||
* point data.
|
||||
*
|
||||
* @see FTExtrdGlyph
|
||||
* @see FTOutlineGlyph
|
||||
* @see FTPolyGlyph
|
||||
* @see FTContour
|
||||
* @see FTPoint
|
||||
*
|
||||
*/
|
||||
class FTGL_EXPORT FTVectoriser
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param glyph The freetype glyph to be processed
|
||||
*/
|
||||
FTVectoriser( const FT_GlyphSlot glyph);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~FTVectoriser();
|
||||
|
||||
/**
|
||||
* Build an FTMesh from the vector outline data.
|
||||
*
|
||||
* @param zNormal The direction of the z axis of the normal
|
||||
* for this mesh
|
||||
*/
|
||||
void MakeMesh( FTGL_DOUBLE zNormal = FTGL_FRONT_FACING);
|
||||
|
||||
/**
|
||||
* Get the current mesh.
|
||||
*/
|
||||
const FTMesh* const GetMesh() const { return mesh;}
|
||||
|
||||
/**
|
||||
* Get the total count of points in this outline
|
||||
*
|
||||
* @return the number of points
|
||||
*/
|
||||
size_t PointCount();
|
||||
|
||||
/**
|
||||
* Get the count of contours in this outline
|
||||
*
|
||||
* @return the number of contours
|
||||
*/
|
||||
size_t ContourCount() const { return ftContourCount;}
|
||||
|
||||
/**
|
||||
* Return a contour at index
|
||||
*
|
||||
* @return the number of contours
|
||||
*/
|
||||
const FTContour* const Contour( unsigned int index) const;
|
||||
|
||||
/**
|
||||
* Get the number of points in a specific contour in this outline
|
||||
*
|
||||
* @param c The contour index
|
||||
* @return the number of points in contour[c]
|
||||
*/
|
||||
size_t ContourSize( int c) const { return contourList[c]->PointCount();}
|
||||
|
||||
/**
|
||||
* Get the flag for the tesselation rule for this outline
|
||||
*
|
||||
* @return The contour flag
|
||||
*/
|
||||
int ContourFlag() const { return contourFlag;}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Process the freetype outline data into contours of points
|
||||
*/
|
||||
void ProcessContours();
|
||||
|
||||
/**
|
||||
* The list of contours in the glyph
|
||||
*/
|
||||
FTContour** contourList;
|
||||
|
||||
/**
|
||||
* A Mesh for tesselations
|
||||
*/
|
||||
FTMesh* mesh;
|
||||
|
||||
/**
|
||||
* The number of contours reported by Freetype
|
||||
*/
|
||||
short ftContourCount;
|
||||
|
||||
/**
|
||||
* A flag indicating the tesselation rule for the glyph
|
||||
*/
|
||||
int contourFlag;
|
||||
|
||||
/**
|
||||
* A Freetype outline
|
||||
*/
|
||||
FT_Outline outline;
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTVectoriser__
|
||||
27
src/WinLibs/FTGL/license.txt
Normal file
27
src/WinLibs/FTGL/license.txt
Normal file
@ -0,0 +1,27 @@
|
||||
FTGL
|
||||
|
||||
Herewith is a license. I've also chucked in a gnu (see COPYING.txt) license
|
||||
for those that are that way inclined. Basically I want you to use this
|
||||
software and if you think this license is preventing you from doing so
|
||||
let me know.
|
||||
|
||||
Copyright (C) 2001-3 Henry Maddocks
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
1350
src/WinLibs/FTGL/mac/FTGL.xcode/henry.mode1
Normal file
1350
src/WinLibs/FTGL/mac/FTGL.xcode/henry.mode1
Normal file
File diff suppressed because it is too large
Load Diff
2333
src/WinLibs/FTGL/mac/FTGL.xcode/henry.pbxuser
Normal file
2333
src/WinLibs/FTGL/mac/FTGL.xcode/henry.pbxuser
Normal file
File diff suppressed because it is too large
Load Diff
1996
src/WinLibs/FTGL/mac/FTGL.xcode/project.pbxproj
Normal file
1996
src/WinLibs/FTGL/mac/FTGL.xcode/project.pbxproj
Normal file
File diff suppressed because it is too large
Load Diff
20
src/WinLibs/FTGL/mac/README.txt
Normal file
20
src/WinLibs/FTGL/mac/README.txt
Normal file
@ -0,0 +1,20 @@
|
||||
FTGL Version 2.0
|
||||
|
||||
This project will build a static library (archive) in this directory.
|
||||
|
||||
FTGL requires the Freetype2 library (version 2.0.9 or later) and OpenGL (glu
|
||||
version 1.2 or later). You may need to edit the paths to point to the correct
|
||||
place.
|
||||
|
||||
To use FTGL in your own projects you will need to link against this lib. Your
|
||||
project will also need to point to Freetype and OpenGL.
|
||||
|
||||
For instructions on using Freetype go to www.freetype.org
|
||||
For instructions on using OpenGL go to www.opengl.org
|
||||
|
||||
Please contact me if you have any suggestions, feature requests, or problems.
|
||||
|
||||
|
||||
Henry Maddocks
|
||||
henryj@paradise.net.nz
|
||||
http://homepages.paradise.net.nz/henryj/
|
||||
65
src/WinLibs/FTGL/src/FTBitmapGlyph.cpp
Normal file
65
src/WinLibs/FTGL/src/FTBitmapGlyph.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
#include <string>
|
||||
|
||||
#include "FTBitmapGlyph.h"
|
||||
|
||||
FTBitmapGlyph::FTBitmapGlyph( FT_GlyphSlot glyph)
|
||||
: FTGlyph( glyph),
|
||||
destWidth(0),
|
||||
destHeight(0),
|
||||
data(0)
|
||||
{
|
||||
err = FT_Render_Glyph( glyph, FT_RENDER_MODE_MONO);
|
||||
if( err || ft_glyph_format_bitmap != glyph->format)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FT_Bitmap bitmap = glyph->bitmap;
|
||||
|
||||
unsigned int srcWidth = bitmap.width;
|
||||
unsigned int srcHeight = bitmap.rows;
|
||||
unsigned int srcPitch = bitmap.pitch;
|
||||
|
||||
destWidth = srcWidth;
|
||||
destHeight = srcHeight;
|
||||
destPitch = srcPitch;
|
||||
|
||||
if( destWidth && destHeight)
|
||||
{
|
||||
data = new unsigned char[destPitch * destHeight];
|
||||
unsigned char* dest = data + (( destHeight - 1) * destPitch);
|
||||
|
||||
unsigned char* src = bitmap.buffer;
|
||||
|
||||
for( unsigned int y = 0; y < srcHeight; ++y)
|
||||
{
|
||||
memcpy( dest, src, srcPitch);
|
||||
dest -= destPitch;
|
||||
src += srcPitch;
|
||||
}
|
||||
}
|
||||
|
||||
pos = FTPoint(glyph->bitmap_left, static_cast<int>(srcHeight) - glyph->bitmap_top, 0.0);
|
||||
}
|
||||
|
||||
|
||||
FTBitmapGlyph::~FTBitmapGlyph()
|
||||
{
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
|
||||
const FTPoint& FTBitmapGlyph::Render( const FTPoint& pen)
|
||||
{
|
||||
glBitmap( 0, 0, 0.0f, 0.0f, pen.X() + pos.X(), pen.Y() - pos.Y(), (const GLubyte*)0 );
|
||||
|
||||
if( data)
|
||||
{
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, destPitch * 8);
|
||||
glBitmap( destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0, (const GLubyte*)data);
|
||||
}
|
||||
|
||||
glBitmap( 0, 0, 0.0f, 0.0f, -pos.X(), pos.Y(), (const GLubyte*)0 );
|
||||
|
||||
return advance;
|
||||
}
|
||||
62
src/WinLibs/FTGL/src/FTCharmap.cpp
Normal file
62
src/WinLibs/FTGL/src/FTCharmap.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "FTFace.h"
|
||||
#include "FTCharmap.h"
|
||||
|
||||
|
||||
FTCharmap::FTCharmap( FTFace* face)
|
||||
: ftFace( *(face->Face())),
|
||||
err(0)
|
||||
{
|
||||
if( !ftFace->charmap)
|
||||
{
|
||||
err = FT_Set_Charmap( ftFace, ftFace->charmaps[0]);
|
||||
}
|
||||
|
||||
ftEncoding = ftFace->charmap->encoding;
|
||||
}
|
||||
|
||||
|
||||
FTCharmap::~FTCharmap()
|
||||
{
|
||||
charMap.clear();
|
||||
}
|
||||
|
||||
|
||||
bool FTCharmap::CharMap( FT_Encoding encoding)
|
||||
{
|
||||
if( ftEncoding == encoding)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
err = FT_Select_Charmap( ftFace, encoding );
|
||||
|
||||
if( !err)
|
||||
{
|
||||
ftEncoding = encoding;
|
||||
}
|
||||
else
|
||||
{
|
||||
ftEncoding = ft_encoding_none;
|
||||
}
|
||||
|
||||
charMap.clear();
|
||||
return !err;
|
||||
}
|
||||
|
||||
|
||||
unsigned int FTCharmap::GlyphListIndex( unsigned int characterCode )
|
||||
{
|
||||
return charMap.find( characterCode);
|
||||
}
|
||||
|
||||
|
||||
unsigned int FTCharmap::FontIndex( unsigned int characterCode )
|
||||
{
|
||||
return FT_Get_Char_Index( ftFace, characterCode);
|
||||
}
|
||||
|
||||
|
||||
void FTCharmap::InsertIndex( const unsigned int characterCode, const unsigned int containerIndex)
|
||||
{
|
||||
charMap.insert( characterCode, containerIndex);
|
||||
}
|
||||
147
src/WinLibs/FTGL/src/FTContour.cpp
Normal file
147
src/WinLibs/FTGL/src/FTContour.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
#include "FTContour.h"
|
||||
|
||||
static const float BEZIER_STEP_SIZE = 0.2f;
|
||||
|
||||
|
||||
void FTContour::AddPoint( FTPoint point)
|
||||
{
|
||||
if( pointList.empty() || point != pointList[pointList.size() - 1])
|
||||
{
|
||||
pointList.push_back( point);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FTContour::AddPoint( float x, float y)
|
||||
{
|
||||
AddPoint( FTPoint( x, y, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
void FTContour::evaluateQuadraticCurve()
|
||||
{
|
||||
for( unsigned int i = 0; i <= ( 1.0f / BEZIER_STEP_SIZE); i++)
|
||||
{
|
||||
float bezierValues[2][2];
|
||||
|
||||
float t = static_cast<float>(i) * BEZIER_STEP_SIZE;
|
||||
|
||||
bezierValues[0][0] = (1.0f - t) * controlPoints[0][0] + t * controlPoints[1][0];
|
||||
bezierValues[0][1] = (1.0f - t) * controlPoints[0][1] + t * controlPoints[1][1];
|
||||
|
||||
bezierValues[1][0] = (1.0f - t) * controlPoints[1][0] + t * controlPoints[2][0];
|
||||
bezierValues[1][1] = (1.0f - t) * controlPoints[1][1] + t * controlPoints[2][1];
|
||||
|
||||
bezierValues[0][0] = (1.0f - t) * bezierValues[0][0] + t * bezierValues[1][0];
|
||||
bezierValues[0][1] = (1.0f - t) * bezierValues[0][1] + t * bezierValues[1][1];
|
||||
|
||||
AddPoint( bezierValues[0][0], bezierValues[0][1]);
|
||||
}
|
||||
}
|
||||
|
||||
void FTContour::evaluateCubicCurve()
|
||||
{
|
||||
for( unsigned int i = 0; i <= ( 1.0f / BEZIER_STEP_SIZE); i++)
|
||||
{
|
||||
float bezierValues[3][2];
|
||||
|
||||
float t = static_cast<float>(i) * BEZIER_STEP_SIZE;
|
||||
|
||||
bezierValues[0][0] = (1.0f - t) * controlPoints[0][0] + t * controlPoints[1][0];
|
||||
bezierValues[0][1] = (1.0f - t) * controlPoints[0][1] + t * controlPoints[1][1];
|
||||
|
||||
bezierValues[1][0] = (1.0f - t) * controlPoints[1][0] + t * controlPoints[2][0];
|
||||
bezierValues[1][1] = (1.0f - t) * controlPoints[1][1] + t * controlPoints[2][1];
|
||||
|
||||
bezierValues[2][0] = (1.0f - t) * controlPoints[2][0] + t * controlPoints[3][0];
|
||||
bezierValues[2][1] = (1.0f - t) * controlPoints[2][1] + t * controlPoints[3][1];
|
||||
|
||||
bezierValues[0][0] = (1.0f - t) * bezierValues[0][0] + t * bezierValues[1][0];
|
||||
bezierValues[0][1] = (1.0f - t) * bezierValues[0][1] + t * bezierValues[1][1];
|
||||
|
||||
bezierValues[1][0] = (1.0f - t) * bezierValues[1][0] + t * bezierValues[2][0];
|
||||
bezierValues[1][1] = (1.0f - t) * bezierValues[1][1] + t * bezierValues[2][1];
|
||||
|
||||
bezierValues[0][0] = (1.0f - t) * bezierValues[0][0] + t * bezierValues[1][0];
|
||||
bezierValues[0][1] = (1.0f - t) * bezierValues[0][1] + t * bezierValues[1][1];
|
||||
|
||||
AddPoint( bezierValues[0][0], bezierValues[0][1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTContour::FTContour( FT_Vector* contour, char* pointTags, unsigned int numberOfPoints)
|
||||
{
|
||||
for( unsigned int pointIndex = 0; pointIndex < numberOfPoints; ++ pointIndex)
|
||||
{
|
||||
char pointTag = pointTags[pointIndex];
|
||||
|
||||
if( pointTag == FT_Curve_Tag_On || numberOfPoints < 2)
|
||||
{
|
||||
AddPoint( contour[pointIndex].x, contour[pointIndex].y);
|
||||
continue;
|
||||
}
|
||||
|
||||
FTPoint controlPoint( contour[pointIndex]);
|
||||
FTPoint previousPoint = ( 0 == pointIndex)
|
||||
? FTPoint( contour[numberOfPoints - 1])
|
||||
: pointList[pointList.size() - 1];
|
||||
|
||||
FTPoint nextPoint = ( pointIndex == numberOfPoints - 1)
|
||||
? pointList[0]
|
||||
: FTPoint( contour[pointIndex + 1]);
|
||||
|
||||
if( pointTag == FT_Curve_Tag_Conic)
|
||||
{
|
||||
char nextPointTag = ( pointIndex == numberOfPoints - 1)
|
||||
? pointTags[0]
|
||||
: pointTags[pointIndex + 1];
|
||||
|
||||
while( nextPointTag == FT_Curve_Tag_Conic)
|
||||
{
|
||||
nextPoint = ( controlPoint + nextPoint) * 0.5f;
|
||||
|
||||
controlPoints[0][0] = previousPoint.X(); controlPoints[0][1] = previousPoint.Y();
|
||||
controlPoints[1][0] = controlPoint.X(); controlPoints[1][1] = controlPoint.Y();
|
||||
controlPoints[2][0] = nextPoint.X(); controlPoints[2][1] = nextPoint.Y();
|
||||
|
||||
evaluateQuadraticCurve();
|
||||
++pointIndex;
|
||||
|
||||
previousPoint = nextPoint;
|
||||
controlPoint = FTPoint( contour[pointIndex]);
|
||||
nextPoint = ( pointIndex == numberOfPoints - 1)
|
||||
? pointList[0]
|
||||
: FTPoint( contour[pointIndex + 1]);
|
||||
nextPointTag = ( pointIndex == numberOfPoints - 1)
|
||||
? pointTags[0]
|
||||
: pointTags[pointIndex + 1];
|
||||
}
|
||||
|
||||
controlPoints[0][0] = previousPoint.X(); controlPoints[0][1] = previousPoint.Y();
|
||||
controlPoints[1][0] = controlPoint.X(); controlPoints[1][1] = controlPoint.Y();
|
||||
controlPoints[2][0] = nextPoint.X(); controlPoints[2][1] = nextPoint.Y();
|
||||
|
||||
evaluateQuadraticCurve();
|
||||
continue;
|
||||
}
|
||||
|
||||
if( pointTag == FT_Curve_Tag_Cubic)
|
||||
{
|
||||
FTPoint controlPoint2 = nextPoint;
|
||||
|
||||
FTPoint nextPoint = ( pointIndex == numberOfPoints - 2)
|
||||
? pointList[0]
|
||||
: FTPoint( contour[pointIndex + 2]);
|
||||
|
||||
controlPoints[0][0] = previousPoint.X(); controlPoints[0][1] = previousPoint.Y();
|
||||
controlPoints[1][0] = controlPoint.X(); controlPoints[1][1] = controlPoint.Y();
|
||||
controlPoints[2][0] = controlPoint2.X(); controlPoints[2][1] = controlPoint2.Y();
|
||||
controlPoints[3][0] = nextPoint.X(); controlPoints[3][1] = nextPoint.Y();
|
||||
|
||||
evaluateCubicCurve();
|
||||
++pointIndex;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
173
src/WinLibs/FTGL/src/FTExtrdGlyph.cpp
Normal file
173
src/WinLibs/FTGL/src/FTExtrdGlyph.cpp
Normal file
@ -0,0 +1,173 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "FTExtrdGlyph.h"
|
||||
#include "FTVectoriser.h"
|
||||
|
||||
|
||||
FTExtrdGlyph::FTExtrdGlyph( FT_GlyphSlot glyph, float depth, bool useDisplayList)
|
||||
: FTGlyph( glyph),
|
||||
glList(0)
|
||||
{
|
||||
bBox.SetDepth( -depth);
|
||||
|
||||
if( ft_glyph_format_outline != glyph->format)
|
||||
{
|
||||
err = 0x14; // Invalid_Outline
|
||||
return;
|
||||
}
|
||||
|
||||
FTVectoriser vectoriser( glyph);
|
||||
if( ( vectoriser.ContourCount() < 1) || ( vectoriser.PointCount() < 3))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int tesselationIndex;
|
||||
|
||||
if(useDisplayList)
|
||||
{
|
||||
glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
}
|
||||
|
||||
vectoriser.MakeMesh( 1.0);
|
||||
glNormal3d(0.0, 0.0, 1.0);
|
||||
|
||||
unsigned int horizontalTextureScale = glyph->face->size->metrics.x_ppem * 64;
|
||||
unsigned int verticalTextureScale = glyph->face->size->metrics.y_ppem * 64;
|
||||
|
||||
const FTMesh* mesh = vectoriser.GetMesh();
|
||||
for( tesselationIndex = 0; tesselationIndex < mesh->TesselationCount(); ++tesselationIndex)
|
||||
{
|
||||
const FTTesselation* subMesh = mesh->Tesselation( tesselationIndex);
|
||||
unsigned int polyonType = subMesh->PolygonType();
|
||||
|
||||
glBegin( polyonType);
|
||||
for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
|
||||
{
|
||||
FTPoint point = subMesh->Point(pointIndex);
|
||||
|
||||
glTexCoord2f( point.X() / horizontalTextureScale,
|
||||
point.Y() / verticalTextureScale);
|
||||
|
||||
glVertex3f( point.X() / 64.0f,
|
||||
point.Y() / 64.0f,
|
||||
0.0f);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
vectoriser.MakeMesh( -1.0);
|
||||
glNormal3d(0.0, 0.0, -1.0);
|
||||
|
||||
mesh = vectoriser.GetMesh();
|
||||
for( tesselationIndex = 0; tesselationIndex < mesh->TesselationCount(); ++tesselationIndex)
|
||||
{
|
||||
const FTTesselation* subMesh = mesh->Tesselation( tesselationIndex);
|
||||
unsigned int polyonType = subMesh->PolygonType();
|
||||
|
||||
glBegin( polyonType);
|
||||
for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
|
||||
{
|
||||
FTPoint point = subMesh->Point(pointIndex);
|
||||
|
||||
glTexCoord2f( subMesh->Point(pointIndex).X() / horizontalTextureScale,
|
||||
subMesh->Point(pointIndex).Y() / verticalTextureScale);
|
||||
|
||||
glVertex3f( subMesh->Point( pointIndex).X() / 64.0f,
|
||||
subMesh->Point( pointIndex).Y() / 64.0f,
|
||||
-depth);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
int contourFlag = vectoriser.ContourFlag();
|
||||
|
||||
for( size_t c = 0; c < vectoriser.ContourCount(); ++c)
|
||||
{
|
||||
const FTContour* contour = vectoriser.Contour(c);
|
||||
unsigned int numberOfPoints = contour->PointCount();
|
||||
|
||||
glBegin( GL_QUAD_STRIP);
|
||||
for( unsigned int j = 0; j <= numberOfPoints; ++j)
|
||||
{
|
||||
unsigned int pointIndex = ( j == numberOfPoints) ? 0 : j;
|
||||
unsigned int nextPointIndex = ( pointIndex == numberOfPoints - 1) ? 0 : pointIndex + 1;
|
||||
|
||||
FTPoint point = contour->Point(pointIndex);
|
||||
|
||||
FTPoint normal = GetNormal( point, contour->Point(nextPointIndex));
|
||||
if(normal != FTPoint( 0.0f, 0.0f, 0.0f))
|
||||
{
|
||||
glNormal3dv(static_cast<const FTGL_DOUBLE*>(normal));
|
||||
}
|
||||
|
||||
if( contourFlag & ft_outline_reverse_fill)
|
||||
{
|
||||
glTexCoord2f( point.X() / horizontalTextureScale,
|
||||
point.X() / verticalTextureScale);
|
||||
|
||||
glVertex3f( point.X() / 64.0f, point.Y() / 64.0f, 0.0f);
|
||||
glVertex3f( point.X() / 64.0f, point.Y() / 64.0f, -depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexCoord2f( point.X() / horizontalTextureScale,
|
||||
point.Y() / verticalTextureScale);
|
||||
|
||||
glVertex3f( point.X() / 64.0f, point.Y() / 64.0f, -depth);
|
||||
glVertex3f( point.X() / 64.0f, point.Y() / 64.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
if(useDisplayList)
|
||||
{
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTExtrdGlyph::~FTExtrdGlyph()
|
||||
{
|
||||
glDeleteLists( glList, 1);
|
||||
}
|
||||
|
||||
|
||||
const FTPoint& FTExtrdGlyph::Render( const FTPoint& pen)
|
||||
{
|
||||
glTranslatef( pen.X(), pen.Y(), 0);
|
||||
|
||||
if( glList)
|
||||
{
|
||||
glCallList( glList);
|
||||
}
|
||||
|
||||
return advance;
|
||||
}
|
||||
|
||||
|
||||
FTPoint FTExtrdGlyph::GetNormal( const FTPoint &a, const FTPoint &b)
|
||||
{
|
||||
float vectorX = a.X() - b.X();
|
||||
float vectorY = a.Y() - b.Y();
|
||||
|
||||
float length = sqrt( vectorX * vectorX + vectorY * vectorY );
|
||||
|
||||
if( length > 0.01f)
|
||||
{
|
||||
length = 1 / length;
|
||||
}
|
||||
else
|
||||
{
|
||||
length = 0.0f;
|
||||
}
|
||||
|
||||
return FTPoint( -vectorY * length,
|
||||
vectorX * length,
|
||||
0.0f);
|
||||
}
|
||||
|
||||
143
src/WinLibs/FTGL/src/FTFace.cpp
Normal file
143
src/WinLibs/FTGL/src/FTFace.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
#include "FTFace.h"
|
||||
#include "FTLibrary.h"
|
||||
|
||||
#include FT_TRUETYPE_TABLES_H
|
||||
|
||||
FTFace::FTFace( const char* fontFilePath)
|
||||
: numGlyphs(0),
|
||||
fontEncodingList(0),
|
||||
err(0)
|
||||
{
|
||||
const FT_Long DEFAULT_FACE_INDEX = 0;
|
||||
ftFace = new FT_Face;
|
||||
|
||||
err = FT_New_Face( *FTLibrary::Instance().GetLibrary(), fontFilePath, DEFAULT_FACE_INDEX, ftFace);
|
||||
|
||||
if( err)
|
||||
{
|
||||
delete ftFace;
|
||||
ftFace = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
numGlyphs = (*ftFace)->num_glyphs;
|
||||
hasKerningTable = FT_HAS_KERNING((*ftFace));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTFace::FTFace( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: numGlyphs(0),
|
||||
err(0)
|
||||
{
|
||||
const FT_Long DEFAULT_FACE_INDEX = 0;
|
||||
ftFace = new FT_Face;
|
||||
|
||||
err = FT_New_Memory_Face( *FTLibrary::Instance().GetLibrary(), (FT_Byte *)pBufferBytes, bufferSizeInBytes, DEFAULT_FACE_INDEX, ftFace);
|
||||
|
||||
if( err)
|
||||
{
|
||||
delete ftFace;
|
||||
ftFace = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
numGlyphs = (*ftFace)->num_glyphs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTFace::~FTFace()
|
||||
{
|
||||
if( ftFace)
|
||||
{
|
||||
FT_Done_Face( *ftFace);
|
||||
delete ftFace;
|
||||
ftFace = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FTFace::Attach( const char* fontFilePath)
|
||||
{
|
||||
err = FT_Attach_File( *ftFace, fontFilePath);
|
||||
return !err;
|
||||
}
|
||||
|
||||
|
||||
bool FTFace::Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
{
|
||||
FT_Open_Args open;
|
||||
|
||||
open.flags = FT_OPEN_MEMORY;
|
||||
open.memory_base = (FT_Byte *)pBufferBytes;
|
||||
open.memory_size = bufferSizeInBytes;
|
||||
|
||||
err = FT_Attach_Stream( *ftFace, &open);
|
||||
return !err;
|
||||
}
|
||||
|
||||
|
||||
const FTSize& FTFace::Size( const unsigned int size, const unsigned int res)
|
||||
{
|
||||
charSize.CharSize( ftFace, size, res, res);
|
||||
err = charSize.Error();
|
||||
|
||||
return charSize;
|
||||
}
|
||||
|
||||
|
||||
unsigned int FTFace::CharMapCount()
|
||||
{
|
||||
return (*ftFace)->num_charmaps;
|
||||
}
|
||||
|
||||
|
||||
FT_Encoding* FTFace::CharMapList()
|
||||
{
|
||||
if( 0 == fontEncodingList)
|
||||
{
|
||||
fontEncodingList = new FT_Encoding[CharMapCount()];
|
||||
for( size_t encodingIndex = 0; encodingIndex < CharMapCount(); ++encodingIndex)
|
||||
{
|
||||
fontEncodingList[encodingIndex] = (*ftFace)->charmaps[encodingIndex]->encoding;
|
||||
}
|
||||
}
|
||||
|
||||
return fontEncodingList;
|
||||
}
|
||||
|
||||
|
||||
FTPoint FTFace::KernAdvance( unsigned int index1, unsigned int index2)
|
||||
{
|
||||
float x, y;
|
||||
x = y = 0.0f;
|
||||
|
||||
if( hasKerningTable && index1 && index2)
|
||||
{
|
||||
FT_Vector kernAdvance;
|
||||
kernAdvance.x = kernAdvance.y = 0;
|
||||
|
||||
err = FT_Get_Kerning( *ftFace, index1, index2, ft_kerning_unfitted, &kernAdvance);
|
||||
if( !err)
|
||||
{
|
||||
x = static_cast<float>( kernAdvance.x) / 64.0f;
|
||||
y = static_cast<float>( kernAdvance.y) / 64.0f;
|
||||
}
|
||||
}
|
||||
|
||||
return FTPoint( x, y, 0.0);
|
||||
}
|
||||
|
||||
|
||||
FT_GlyphSlot FTFace::Glyph( unsigned int index, FT_Int load_flags)
|
||||
{
|
||||
err = FT_Load_Glyph( *ftFace, index, load_flags);
|
||||
if( err)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (*ftFace)->glyph;
|
||||
}
|
||||
|
||||
297
src/WinLibs/FTGL/src/FTFont.cpp
Normal file
297
src/WinLibs/FTGL/src/FTFont.cpp
Normal file
@ -0,0 +1,297 @@
|
||||
#include "FTFace.h"
|
||||
#include "FTFont.h"
|
||||
#include "FTGlyphContainer.h"
|
||||
#include "FTBBox.h"
|
||||
|
||||
|
||||
FTFont::FTFont( const char* fontFilePath)
|
||||
: face( fontFilePath),
|
||||
useDisplayLists(true),
|
||||
glyphList(0)
|
||||
{
|
||||
err = face.Error();
|
||||
if( err == 0)
|
||||
{
|
||||
glyphList = new FTGlyphContainer( &face);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTFont::FTFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: face( pBufferBytes, bufferSizeInBytes),
|
||||
glyphList(0)
|
||||
{
|
||||
err = face.Error();
|
||||
if( err == 0)
|
||||
{
|
||||
glyphList = new FTGlyphContainer( &face);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTFont::~FTFont()
|
||||
{
|
||||
delete glyphList;
|
||||
}
|
||||
|
||||
|
||||
bool FTFont::Attach( const char* fontFilePath)
|
||||
{
|
||||
if( face.Attach( fontFilePath))
|
||||
{
|
||||
err = 0;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = face.Error();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FTFont::Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
{
|
||||
if( face.Attach( pBufferBytes, bufferSizeInBytes))
|
||||
{
|
||||
err = 0;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = face.Error();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FTFont::FaceSize( const unsigned int size, const unsigned int res )
|
||||
{
|
||||
charSize = face.Size( size, res);
|
||||
err = face.Error();
|
||||
|
||||
if( err != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( glyphList != NULL)
|
||||
{
|
||||
delete glyphList;
|
||||
}
|
||||
|
||||
glyphList = new FTGlyphContainer( &face);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
unsigned int FTFont::FaceSize() const
|
||||
{
|
||||
return charSize.CharSize();
|
||||
}
|
||||
|
||||
|
||||
bool FTFont::CharMap( FT_Encoding encoding)
|
||||
{
|
||||
bool result = glyphList->CharMap( encoding);
|
||||
err = glyphList->Error();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
unsigned int FTFont::CharMapCount()
|
||||
{
|
||||
return face.CharMapCount();
|
||||
}
|
||||
|
||||
|
||||
FT_Encoding* FTFont::CharMapList()
|
||||
{
|
||||
return face.CharMapList();
|
||||
}
|
||||
|
||||
|
||||
void FTFont::UseDisplayList( bool useList)
|
||||
{
|
||||
useDisplayLists = useList;
|
||||
}
|
||||
|
||||
float FTFont::Ascender() const
|
||||
{
|
||||
return charSize.Ascender();
|
||||
}
|
||||
|
||||
|
||||
float FTFont::Descender() const
|
||||
{
|
||||
return charSize.Descender();
|
||||
}
|
||||
|
||||
float FTFont::LineHeight() const
|
||||
{
|
||||
return charSize.Height();
|
||||
}
|
||||
|
||||
void FTFont::BBox( const char* string,
|
||||
float& llx, float& lly, float& llz, float& urx, float& ury, float& urz)
|
||||
{
|
||||
FTBBox totalBBox;
|
||||
|
||||
if((NULL != string) && ('\0' != *string))
|
||||
{
|
||||
const unsigned char* c = (unsigned char*)string;
|
||||
float advance = 0;
|
||||
|
||||
if(CheckGlyph( *c))
|
||||
{
|
||||
totalBBox = glyphList->BBox( *c);
|
||||
advance = glyphList->Advance( *c, *(c + 1));
|
||||
}
|
||||
|
||||
while( *++c)
|
||||
{
|
||||
if(CheckGlyph( *c))
|
||||
{
|
||||
FTBBox tempBBox = glyphList->BBox( *c);
|
||||
tempBBox.Move( FTPoint( advance, 0.0f, 0.0f));
|
||||
totalBBox += tempBBox;
|
||||
advance += glyphList->Advance( *c, *(c + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
llx = totalBBox.lowerX;
|
||||
lly = totalBBox.lowerY;
|
||||
llz = totalBBox.lowerZ;
|
||||
urx = totalBBox.upperX;
|
||||
ury = totalBBox.upperY;
|
||||
urz = totalBBox.upperZ;
|
||||
}
|
||||
|
||||
|
||||
void FTFont::BBox( const wchar_t* string,
|
||||
float& llx, float& lly, float& llz, float& urx, float& ury, float& urz)
|
||||
{
|
||||
FTBBox totalBBox;
|
||||
|
||||
if((NULL != string) && ('\0' != *string))
|
||||
{
|
||||
const wchar_t* c = string;
|
||||
float advance = 0;
|
||||
|
||||
if(CheckGlyph( *c))
|
||||
{
|
||||
totalBBox = glyphList->BBox( *c);
|
||||
advance = glyphList->Advance( *c, *(c + 1));
|
||||
}
|
||||
|
||||
while( *++c)
|
||||
{
|
||||
if(CheckGlyph( *c))
|
||||
{
|
||||
FTBBox tempBBox = glyphList->BBox( *c);
|
||||
tempBBox.Move( FTPoint( advance, 0.0f, 0.0f));
|
||||
totalBBox += tempBBox;
|
||||
advance += glyphList->Advance( *c, *(c + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
llx = totalBBox.lowerX;
|
||||
lly = totalBBox.lowerY;
|
||||
llz = totalBBox.lowerZ;
|
||||
urx = totalBBox.upperX;
|
||||
ury = totalBBox.upperY;
|
||||
urz = totalBBox.upperZ;
|
||||
}
|
||||
|
||||
|
||||
float FTFont::Advance( const wchar_t* string)
|
||||
{
|
||||
const wchar_t* c = string;
|
||||
float width = 0.0f;
|
||||
|
||||
while( *c)
|
||||
{
|
||||
if(CheckGlyph( *c))
|
||||
{
|
||||
width += glyphList->Advance( *c, *(c + 1));
|
||||
}
|
||||
++c;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
float FTFont::Advance( const char* string)
|
||||
{
|
||||
const unsigned char* c = (unsigned char*)string;
|
||||
float width = 0.0f;
|
||||
|
||||
while( *c)
|
||||
{
|
||||
if(CheckGlyph( *c))
|
||||
{
|
||||
width += glyphList->Advance( *c, *(c + 1));
|
||||
}
|
||||
++c;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
void FTFont::Render( const char* string )
|
||||
{
|
||||
const unsigned char* c = (unsigned char*)string;
|
||||
pen.X(0); pen.Y(0);
|
||||
|
||||
while( *c)
|
||||
{
|
||||
if(CheckGlyph( *c))
|
||||
{
|
||||
pen = glyphList->Render( *c, *(c + 1), pen);
|
||||
}
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FTFont::Render( const wchar_t* string )
|
||||
{
|
||||
const wchar_t* c = string;
|
||||
pen.X(0); pen.Y(0);
|
||||
|
||||
while( *c)
|
||||
{
|
||||
if(CheckGlyph( *c))
|
||||
{
|
||||
pen = glyphList->Render( *c, *(c + 1), pen);
|
||||
}
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FTFont::CheckGlyph( const unsigned int characterCode)
|
||||
{
|
||||
if( NULL == glyphList->Glyph( characterCode))
|
||||
{
|
||||
unsigned int glyphIndex = glyphList->FontIndex( characterCode);
|
||||
FTGlyph* tempGlyph = MakeGlyph( glyphIndex);
|
||||
if( NULL == tempGlyph)
|
||||
{
|
||||
if( 0 == err)
|
||||
{
|
||||
err = 0x13;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
glyphList->Add( tempGlyph, characterCode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
66
src/WinLibs/FTGL/src/FTGLBitmapFont.cpp
Normal file
66
src/WinLibs/FTGL/src/FTGLBitmapFont.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include "FTGLBitmapFont.h"
|
||||
#include "FTBitmapGlyph.h"
|
||||
|
||||
|
||||
FTGLBitmapFont::FTGLBitmapFont( const char* fontFilePath)
|
||||
: FTFont( fontFilePath)
|
||||
{}
|
||||
|
||||
|
||||
FTGLBitmapFont::FTGLBitmapFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: FTFont( pBufferBytes, bufferSizeInBytes)
|
||||
{}
|
||||
|
||||
|
||||
FTGLBitmapFont::~FTGLBitmapFont()
|
||||
{}
|
||||
|
||||
|
||||
FTGlyph* FTGLBitmapFont::MakeGlyph( unsigned int g)
|
||||
{
|
||||
FT_GlyphSlot ftGlyph = face.Glyph( g, FT_LOAD_DEFAULT);
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTBitmapGlyph* tempGlyph = new FTBitmapGlyph( ftGlyph);
|
||||
return tempGlyph;
|
||||
}
|
||||
|
||||
err = face.Error();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void FTGLBitmapFont::Render( const char* string)
|
||||
{
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
|
||||
glPushAttrib( GL_ENABLE_BIT);
|
||||
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glDisable( GL_BLEND);
|
||||
|
||||
FTFont::Render( string);
|
||||
|
||||
glPopAttrib();
|
||||
glPopClientAttrib();
|
||||
}
|
||||
|
||||
|
||||
void FTGLBitmapFont::Render( const wchar_t* string)
|
||||
{
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
|
||||
glPushAttrib( GL_ENABLE_BIT);
|
||||
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glDisable( GL_BLEND);
|
||||
|
||||
FTFont::Render( string);
|
||||
|
||||
glPopAttrib();
|
||||
glPopClientAttrib();
|
||||
}
|
||||
|
||||
35
src/WinLibs/FTGL/src/FTGLExtrdFont.cpp
Normal file
35
src/WinLibs/FTGL/src/FTGLExtrdFont.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "FTGLExtrdFont.h"
|
||||
#include "FTExtrdGlyph.h"
|
||||
|
||||
|
||||
FTGLExtrdFont::FTGLExtrdFont( const char* fontFilePath)
|
||||
: FTFont( fontFilePath),
|
||||
depth( 0.0f)
|
||||
{}
|
||||
|
||||
|
||||
FTGLExtrdFont::FTGLExtrdFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: FTFont( pBufferBytes, bufferSizeInBytes),
|
||||
depth( 0.0f)
|
||||
{}
|
||||
|
||||
|
||||
FTGLExtrdFont::~FTGLExtrdFont()
|
||||
{}
|
||||
|
||||
|
||||
FTGlyph* FTGLExtrdFont::MakeGlyph( unsigned int glyphIndex)
|
||||
{
|
||||
FT_GlyphSlot ftGlyph = face.Glyph( glyphIndex, FT_LOAD_NO_HINTING);
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTExtrdGlyph* tempGlyph = new FTExtrdGlyph( ftGlyph, depth, useDisplayLists);
|
||||
return tempGlyph;
|
||||
}
|
||||
|
||||
err = face.Error();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
66
src/WinLibs/FTGL/src/FTGLOutlineFont.cpp
Normal file
66
src/WinLibs/FTGL/src/FTGLOutlineFont.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include "FTGLOutlineFont.h"
|
||||
#include "FTOutlineGlyph.h"
|
||||
|
||||
|
||||
FTGLOutlineFont::FTGLOutlineFont( const char* fontFilePath)
|
||||
: FTFont( fontFilePath)
|
||||
{}
|
||||
|
||||
|
||||
FTGLOutlineFont::FTGLOutlineFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: FTFont( pBufferBytes, bufferSizeInBytes)
|
||||
{}
|
||||
|
||||
|
||||
FTGLOutlineFont::~FTGLOutlineFont()
|
||||
{}
|
||||
|
||||
|
||||
FTGlyph* FTGLOutlineFont::MakeGlyph( unsigned int g)
|
||||
{
|
||||
FT_GlyphSlot ftGlyph = face.Glyph( g, FT_LOAD_NO_HINTING);
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTOutlineGlyph* tempGlyph = new FTOutlineGlyph( ftGlyph, useDisplayLists);
|
||||
return tempGlyph;
|
||||
}
|
||||
|
||||
err = face.Error();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void FTGLOutlineFont::Render( const char* string)
|
||||
{
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_HINT_BIT | GL_LINE_BIT | GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glDisable( GL_TEXTURE_2D);
|
||||
|
||||
glEnable( GL_LINE_SMOOTH);
|
||||
glHint( GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
|
||||
|
||||
FTFont::Render( string);
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
void FTGLOutlineFont::Render( const wchar_t* string)
|
||||
{
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_HINT_BIT | GL_LINE_BIT | GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glDisable( GL_TEXTURE_2D);
|
||||
|
||||
glEnable( GL_LINE_SMOOTH);
|
||||
glHint( GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
|
||||
|
||||
FTFont::Render( string);
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
83
src/WinLibs/FTGL/src/FTGLPixmapFont.cpp
Normal file
83
src/WinLibs/FTGL/src/FTGLPixmapFont.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include "FTGLPixmapFont.h"
|
||||
#include "FTPixmapGlyph.h"
|
||||
|
||||
|
||||
FTGLPixmapFont::FTGLPixmapFont( const char* fontFilePath)
|
||||
: FTFont( fontFilePath)
|
||||
{}
|
||||
|
||||
|
||||
FTGLPixmapFont::FTGLPixmapFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: FTFont( pBufferBytes, bufferSizeInBytes)
|
||||
{}
|
||||
|
||||
|
||||
FTGLPixmapFont::~FTGLPixmapFont()
|
||||
{}
|
||||
|
||||
|
||||
FTGlyph* FTGLPixmapFont::MakeGlyph( unsigned int g)
|
||||
{
|
||||
FT_GlyphSlot ftGlyph = face.Glyph( g, FT_LOAD_NO_HINTING);
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTPixmapGlyph* tempGlyph = new FTPixmapGlyph( ftGlyph);
|
||||
return tempGlyph;
|
||||
}
|
||||
|
||||
err = face.Error();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void FTGLPixmapFont::Render( const char* string)
|
||||
{
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_PIXEL_MODE_BIT | GL_COLOR_BUFFER_BIT);
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glDisable( GL_TEXTURE_2D);
|
||||
|
||||
GLfloat ftglColour[4];
|
||||
glGetFloatv( GL_CURRENT_RASTER_COLOR, ftglColour);
|
||||
|
||||
glPixelTransferf(GL_RED_SCALE, ftglColour[0]);
|
||||
glPixelTransferf(GL_GREEN_SCALE, ftglColour[1]);
|
||||
glPixelTransferf(GL_BLUE_SCALE, ftglColour[2]);
|
||||
glPixelTransferf(GL_ALPHA_SCALE, ftglColour[3]);
|
||||
|
||||
FTFont::Render( string);
|
||||
|
||||
glPopClientAttrib();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
void FTGLPixmapFont::Render( const wchar_t* string)
|
||||
{
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_PIXEL_MODE_BIT | GL_COLOR_BUFFER_BIT);
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glDisable( GL_TEXTURE_2D);
|
||||
|
||||
GLfloat ftglColour[4];
|
||||
glGetFloatv( GL_CURRENT_RASTER_COLOR, ftglColour);
|
||||
|
||||
glPixelTransferf(GL_RED_SCALE, ftglColour[0]);
|
||||
glPixelTransferf(GL_GREEN_SCALE, ftglColour[1]);
|
||||
glPixelTransferf(GL_BLUE_SCALE, ftglColour[2]);
|
||||
glPixelTransferf(GL_ALPHA_SCALE, ftglColour[3]);
|
||||
|
||||
FTFont::Render( string);
|
||||
|
||||
glPopClientAttrib();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
33
src/WinLibs/FTGL/src/FTGLPolygonFont.cpp
Normal file
33
src/WinLibs/FTGL/src/FTGLPolygonFont.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "FTGLPolygonFont.h"
|
||||
#include "FTPolyGlyph.h"
|
||||
|
||||
|
||||
FTGLPolygonFont::FTGLPolygonFont( const char* fontFilePath)
|
||||
: FTFont( fontFilePath)
|
||||
{}
|
||||
|
||||
|
||||
FTGLPolygonFont::FTGLPolygonFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: FTFont( pBufferBytes, bufferSizeInBytes)
|
||||
{}
|
||||
|
||||
|
||||
FTGLPolygonFont::~FTGLPolygonFont()
|
||||
{}
|
||||
|
||||
|
||||
FTGlyph* FTGLPolygonFont::MakeGlyph( unsigned int g)
|
||||
{
|
||||
FT_GlyphSlot ftGlyph = face.Glyph( g, FT_LOAD_NO_HINTING);
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTPolyGlyph* tempGlyph = new FTPolyGlyph( ftGlyph, useDisplayLists);
|
||||
return tempGlyph;
|
||||
}
|
||||
|
||||
err = face.Error();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
182
src/WinLibs/FTGL/src/FTGLTextureFont.cpp
Normal file
182
src/WinLibs/FTGL/src/FTGLTextureFont.cpp
Normal file
@ -0,0 +1,182 @@
|
||||
#include <cassert>
|
||||
#include <string> // For memset
|
||||
|
||||
#include "FTGLTextureFont.h"
|
||||
#include "FTTextureGlyph.h"
|
||||
|
||||
|
||||
inline GLuint NextPowerOf2( GLuint in)
|
||||
{
|
||||
in -= 1;
|
||||
|
||||
in |= in >> 16;
|
||||
in |= in >> 8;
|
||||
in |= in >> 4;
|
||||
in |= in >> 2;
|
||||
in |= in >> 1;
|
||||
|
||||
return in + 1;
|
||||
}
|
||||
|
||||
|
||||
FTGLTextureFont::FTGLTextureFont( const char* fontFilePath)
|
||||
: FTFont( fontFilePath),
|
||||
maximumGLTextureSize(0),
|
||||
textureWidth(0),
|
||||
textureHeight(0),
|
||||
glyphHeight(0),
|
||||
glyphWidth(0),
|
||||
padding(3),
|
||||
xOffset(0),
|
||||
yOffset(0)
|
||||
{
|
||||
remGlyphs = numGlyphs = face.GlyphCount();
|
||||
}
|
||||
|
||||
|
||||
FTGLTextureFont::FTGLTextureFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: FTFont( pBufferBytes, bufferSizeInBytes),
|
||||
maximumGLTextureSize(0),
|
||||
textureWidth(0),
|
||||
textureHeight(0),
|
||||
glyphHeight(0),
|
||||
glyphWidth(0),
|
||||
padding(3),
|
||||
xOffset(0),
|
||||
yOffset(0)
|
||||
{
|
||||
remGlyphs = numGlyphs = face.GlyphCount();
|
||||
}
|
||||
|
||||
|
||||
FTGLTextureFont::~FTGLTextureFont()
|
||||
{
|
||||
glDeleteTextures( textureIDList.size(), (const GLuint*)&textureIDList[0]);
|
||||
}
|
||||
|
||||
|
||||
FTGlyph* FTGLTextureFont::MakeGlyph( unsigned int glyphIndex)
|
||||
{
|
||||
FT_GlyphSlot ftGlyph = face.Glyph( glyphIndex, FT_LOAD_NO_HINTING);
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
glyphHeight = static_cast<int>( charSize.Height());
|
||||
glyphWidth = static_cast<int>( charSize.Width());
|
||||
|
||||
if( textureIDList.empty())
|
||||
{
|
||||
textureIDList.push_back( CreateTexture());
|
||||
xOffset = yOffset = padding;
|
||||
}
|
||||
|
||||
if( xOffset > ( textureWidth - glyphWidth))
|
||||
{
|
||||
xOffset = padding;
|
||||
yOffset += glyphHeight;
|
||||
|
||||
if( yOffset > ( textureHeight - glyphHeight))
|
||||
{
|
||||
textureIDList.push_back( CreateTexture());
|
||||
yOffset = padding;
|
||||
}
|
||||
}
|
||||
|
||||
FTTextureGlyph* tempGlyph = new FTTextureGlyph( ftGlyph, textureIDList[textureIDList.size() - 1],
|
||||
xOffset, yOffset, textureWidth, textureHeight);
|
||||
xOffset += static_cast<int>( tempGlyph->BBox().upperX - tempGlyph->BBox().lowerX + padding);
|
||||
|
||||
--remGlyphs;
|
||||
return tempGlyph;
|
||||
}
|
||||
|
||||
err = face.Error();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void FTGLTextureFont::CalculateTextureSize()
|
||||
{
|
||||
if( !maximumGLTextureSize)
|
||||
{
|
||||
glGetIntegerv( GL_MAX_TEXTURE_SIZE, (GLint*)&maximumGLTextureSize);
|
||||
assert(maximumGLTextureSize); // If you hit this then you have an invalid OpenGL context.
|
||||
}
|
||||
|
||||
textureWidth = NextPowerOf2( (remGlyphs * glyphWidth) + ( padding * 2));
|
||||
textureWidth = textureWidth > maximumGLTextureSize ? maximumGLTextureSize : textureWidth;
|
||||
|
||||
int h = static_cast<int>( (textureWidth - ( padding * 2)) / glyphWidth);
|
||||
|
||||
textureHeight = NextPowerOf2( (( numGlyphs / h) + 1) * glyphHeight);
|
||||
textureHeight = textureHeight > maximumGLTextureSize ? maximumGLTextureSize : textureHeight;
|
||||
}
|
||||
|
||||
|
||||
GLuint FTGLTextureFont::CreateTexture()
|
||||
{
|
||||
CalculateTextureSize();
|
||||
|
||||
int totalMemory = textureWidth * textureHeight;
|
||||
unsigned char* textureMemory = new unsigned char[totalMemory];
|
||||
memset( textureMemory, 0, totalMemory);
|
||||
|
||||
GLuint textID;
|
||||
glGenTextures( 1, (GLuint*)&textID);
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, textID);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA, textureWidth, textureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, textureMemory);
|
||||
|
||||
delete [] textureMemory;
|
||||
|
||||
return textID;
|
||||
}
|
||||
|
||||
|
||||
bool FTGLTextureFont::FaceSize( const unsigned int size, const unsigned int res)
|
||||
{
|
||||
if( !textureIDList.empty())
|
||||
{
|
||||
glDeleteTextures( textureIDList.size(), (const GLuint*)&textureIDList[0]);
|
||||
textureIDList.clear();
|
||||
remGlyphs = numGlyphs = face.GlyphCount();
|
||||
}
|
||||
|
||||
return FTFont::FaceSize( size, res);
|
||||
}
|
||||
|
||||
|
||||
void FTGLTextureFont::Render( const char* string)
|
||||
{
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
|
||||
|
||||
FTTextureGlyph::ResetActiveTexture();
|
||||
|
||||
FTFont::Render( string);
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
void FTGLTextureFont::Render( const wchar_t* string)
|
||||
{
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
|
||||
|
||||
FTTextureGlyph::ResetActiveTexture();
|
||||
|
||||
FTFont::Render( string);
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
17
src/WinLibs/FTGL/src/FTGlyph.cpp
Normal file
17
src/WinLibs/FTGL/src/FTGlyph.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "FTGlyph.h"
|
||||
|
||||
|
||||
FTGlyph::FTGlyph( FT_GlyphSlot glyph, bool useList)
|
||||
: useDisplayList(useList),
|
||||
err(0)
|
||||
{
|
||||
if( glyph)
|
||||
{
|
||||
bBox = FTBBox( glyph);
|
||||
advance = FTPoint( glyph->advance.x / 64.0f, glyph->advance.y / 64.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTGlyph::~FTGlyph()
|
||||
{}
|
||||
91
src/WinLibs/FTGL/src/FTGlyphContainer.cpp
Normal file
91
src/WinLibs/FTGL/src/FTGlyphContainer.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include "FTGlyphContainer.h"
|
||||
#include "FTGlyph.h"
|
||||
#include "FTFace.h"
|
||||
#include "FTCharmap.h"
|
||||
|
||||
|
||||
FTGlyphContainer::FTGlyphContainer( FTFace* f)
|
||||
: face(f),
|
||||
err(0)
|
||||
{
|
||||
glyphs.push_back( NULL);
|
||||
charMap = new FTCharmap( face);
|
||||
}
|
||||
|
||||
|
||||
FTGlyphContainer::~FTGlyphContainer()
|
||||
{
|
||||
GlyphVector::iterator glyphIterator;
|
||||
for( glyphIterator = glyphs.begin(); glyphIterator != glyphs.end(); ++glyphIterator)
|
||||
{
|
||||
delete *glyphIterator;
|
||||
}
|
||||
|
||||
glyphs.clear();
|
||||
delete charMap;
|
||||
}
|
||||
|
||||
|
||||
bool FTGlyphContainer::CharMap( FT_Encoding encoding)
|
||||
{
|
||||
bool result = charMap->CharMap( encoding);
|
||||
err = charMap->Error();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
unsigned int FTGlyphContainer::FontIndex( const unsigned int characterCode) const
|
||||
{
|
||||
return charMap->FontIndex( characterCode);
|
||||
}
|
||||
|
||||
|
||||
void FTGlyphContainer::Add( FTGlyph* tempGlyph, const unsigned int characterCode)
|
||||
{
|
||||
charMap->InsertIndex( characterCode, glyphs.size());
|
||||
glyphs.push_back( tempGlyph);
|
||||
}
|
||||
|
||||
|
||||
const FTGlyph* const FTGlyphContainer::Glyph( const unsigned int characterCode) const
|
||||
{
|
||||
signed int index = charMap->GlyphListIndex( characterCode);
|
||||
return glyphs[index];
|
||||
}
|
||||
|
||||
|
||||
FTBBox FTGlyphContainer::BBox( const unsigned int characterCode) const
|
||||
{
|
||||
return glyphs[charMap->GlyphListIndex( characterCode)]->BBox();
|
||||
}
|
||||
|
||||
|
||||
float FTGlyphContainer::Advance( const unsigned int characterCode, const unsigned int nextCharacterCode)
|
||||
{
|
||||
unsigned int left = charMap->FontIndex( characterCode);
|
||||
unsigned int right = charMap->FontIndex( nextCharacterCode);
|
||||
|
||||
float width = face->KernAdvance( left, right).X();
|
||||
width += glyphs[charMap->GlyphListIndex( characterCode)]->Advance().X();
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
FTPoint FTGlyphContainer::Render( const unsigned int characterCode, const unsigned int nextCharacterCode, FTPoint penPosition)
|
||||
{
|
||||
FTPoint kernAdvance, advance;
|
||||
|
||||
unsigned int left = charMap->FontIndex( characterCode);
|
||||
unsigned int right = charMap->FontIndex( nextCharacterCode);
|
||||
|
||||
kernAdvance = face->KernAdvance( left, right);
|
||||
|
||||
if( !face->Error())
|
||||
{
|
||||
advance = glyphs[charMap->GlyphListIndex( characterCode)]->Render( penPosition);
|
||||
}
|
||||
|
||||
kernAdvance += advance;
|
||||
return kernAdvance;
|
||||
}
|
||||
64
src/WinLibs/FTGL/src/FTLibrary.cpp
Normal file
64
src/WinLibs/FTGL/src/FTLibrary.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "FTLibrary.h"
|
||||
|
||||
|
||||
const FTLibrary& FTLibrary::Instance()
|
||||
{
|
||||
static FTLibrary ftlib;
|
||||
return ftlib;
|
||||
}
|
||||
|
||||
|
||||
FTLibrary::~FTLibrary()
|
||||
{
|
||||
if( library != 0)
|
||||
{
|
||||
FT_Done_FreeType( *library);
|
||||
|
||||
delete library;
|
||||
library= 0;
|
||||
}
|
||||
|
||||
// if( manager != 0)
|
||||
// {
|
||||
// FTC_Manager_Done( manager );
|
||||
//
|
||||
// delete manager;
|
||||
// manager= 0;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
FTLibrary::FTLibrary()
|
||||
: library(0),
|
||||
err(0)
|
||||
{
|
||||
Initialise();
|
||||
}
|
||||
|
||||
|
||||
bool FTLibrary::Initialise()
|
||||
{
|
||||
if( library != 0)
|
||||
return true;
|
||||
|
||||
library = new FT_Library;
|
||||
|
||||
err = FT_Init_FreeType( library);
|
||||
if( err)
|
||||
{
|
||||
delete library;
|
||||
library = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// FTC_Manager* manager;
|
||||
//
|
||||
// if( FTC_Manager_New( lib, 0, 0, 0, my_face_requester, 0, manager )
|
||||
// {
|
||||
// delete manager;
|
||||
// manager= 0;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
66
src/WinLibs/FTGL/src/FTOutlineGlyph.cpp
Normal file
66
src/WinLibs/FTGL/src/FTOutlineGlyph.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include "FTOutlineGlyph.h"
|
||||
#include "FTVectoriser.h"
|
||||
|
||||
|
||||
FTOutlineGlyph::FTOutlineGlyph( FT_GlyphSlot glyph, bool useDisplayList)
|
||||
: FTGlyph( glyph),
|
||||
glList(0)
|
||||
{
|
||||
if( ft_glyph_format_outline != glyph->format)
|
||||
{
|
||||
err = 0x14; // Invalid_Outline
|
||||
return;
|
||||
}
|
||||
|
||||
FTVectoriser vectoriser( glyph);
|
||||
|
||||
size_t numContours = vectoriser.ContourCount();
|
||||
if ( ( numContours < 1) || ( vectoriser.PointCount() < 3))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(useDisplayList)
|
||||
{
|
||||
glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
}
|
||||
|
||||
for( unsigned int c = 0; c < numContours; ++c)
|
||||
{
|
||||
const FTContour* contour = vectoriser.Contour(c);
|
||||
|
||||
glBegin( GL_LINE_LOOP);
|
||||
for( unsigned int pointIndex = 0; pointIndex < contour->PointCount(); ++pointIndex)
|
||||
{
|
||||
FTPoint point = contour->Point(pointIndex);
|
||||
glVertex2f( point.X() / 64.0f, point.Y() / 64.0f);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
if(useDisplayList)
|
||||
{
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTOutlineGlyph::~FTOutlineGlyph()
|
||||
{
|
||||
glDeleteLists( glList, 1);
|
||||
}
|
||||
|
||||
|
||||
const FTPoint& FTOutlineGlyph::Render( const FTPoint& pen)
|
||||
{
|
||||
glTranslatef( pen.X(), pen.Y(), 0.0f);
|
||||
|
||||
if( glList)
|
||||
{
|
||||
glCallList( glList);
|
||||
}
|
||||
|
||||
return advance;
|
||||
}
|
||||
|
||||
73
src/WinLibs/FTGL/src/FTPixmapGlyph.cpp
Normal file
73
src/WinLibs/FTGL/src/FTPixmapGlyph.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include "FTPixmapGlyph.h"
|
||||
|
||||
FTPixmapGlyph::FTPixmapGlyph( FT_GlyphSlot glyph)
|
||||
: FTGlyph( glyph),
|
||||
destWidth(0),
|
||||
destHeight(0),
|
||||
data(0)
|
||||
{
|
||||
err = FT_Render_Glyph( glyph, FT_RENDER_MODE_NORMAL);
|
||||
if( err || ft_glyph_format_bitmap != glyph->format)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FT_Bitmap bitmap = glyph->bitmap;
|
||||
|
||||
//check the pixel mode
|
||||
//ft_pixel_mode_grays
|
||||
|
||||
int srcWidth = bitmap.width;
|
||||
int srcHeight = bitmap.rows;
|
||||
|
||||
destWidth = srcWidth;
|
||||
destHeight = srcHeight;
|
||||
|
||||
if( destWidth && destHeight)
|
||||
{
|
||||
data = new unsigned char[destWidth * destHeight * 2];
|
||||
unsigned char* src = bitmap.buffer;
|
||||
|
||||
unsigned char* dest = data + ((destHeight - 1) * destWidth * 2);
|
||||
size_t destStep = destWidth * 2 * 2;
|
||||
|
||||
for( int y = 0; y < srcHeight; ++y)
|
||||
{
|
||||
for( int x = 0; x < srcWidth; ++x)
|
||||
{
|
||||
*dest++ = static_cast<unsigned char>(255);
|
||||
*dest++ = *src++;
|
||||
}
|
||||
dest -= destStep;
|
||||
}
|
||||
|
||||
destHeight = srcHeight;
|
||||
}
|
||||
|
||||
pos.X(glyph->bitmap_left);
|
||||
pos.Y(srcHeight - glyph->bitmap_top);
|
||||
}
|
||||
|
||||
|
||||
FTPixmapGlyph::~FTPixmapGlyph()
|
||||
{
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
|
||||
const FTPoint& FTPixmapGlyph::Render( const FTPoint& pen)
|
||||
{
|
||||
glBitmap( 0, 0, 0.0f, 0.0f, pen.X() + pos.X(), pen.Y() - pos.Y(), (const GLubyte*)0);
|
||||
|
||||
if( data)
|
||||
{
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 2);
|
||||
|
||||
glDrawPixels( destWidth, destHeight, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, (const GLvoid*)data);
|
||||
}
|
||||
|
||||
glBitmap( 0, 0, 0.0f, 0.0f, -pos.X(), pos.Y(), (const GLubyte*)0);
|
||||
|
||||
return advance;
|
||||
}
|
||||
19
src/WinLibs/FTGL/src/FTPoint.cpp
Normal file
19
src/WinLibs/FTGL/src/FTPoint.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "FTPoint.h"
|
||||
|
||||
|
||||
bool operator == ( const FTPoint &a, const FTPoint &b)
|
||||
{
|
||||
return((a.values[0] == b.values[0]) && (a.values[1] == b.values[1]) && (a.values[2] == b.values[2]));
|
||||
}
|
||||
|
||||
bool operator != ( const FTPoint &a, const FTPoint &b)
|
||||
{
|
||||
return((a.values[0] != b.values[0]) || (a.values[1] != b.values[1]) || (a.values[2] != b.values[2]));
|
||||
}
|
||||
|
||||
|
||||
FTPoint operator*( double multiplier, FTPoint& point)
|
||||
{
|
||||
return point * multiplier;
|
||||
}
|
||||
|
||||
77
src/WinLibs/FTGL/src/FTPolyGlyph.cpp
Normal file
77
src/WinLibs/FTGL/src/FTPolyGlyph.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#include "FTPolyGlyph.h"
|
||||
#include "FTVectoriser.h"
|
||||
|
||||
|
||||
FTPolyGlyph::FTPolyGlyph( FT_GlyphSlot glyph, bool useDisplayList)
|
||||
: FTGlyph( glyph),
|
||||
glList(0)
|
||||
{
|
||||
if( ft_glyph_format_outline != glyph->format)
|
||||
{
|
||||
err = 0x14; // Invalid_Outline
|
||||
return;
|
||||
}
|
||||
|
||||
FTVectoriser vectoriser( glyph);
|
||||
|
||||
if(( vectoriser.ContourCount() < 1) || ( vectoriser.PointCount() < 3))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int horizontalTextureScale = glyph->face->size->metrics.x_ppem * 64;
|
||||
unsigned int verticalTextureScale = glyph->face->size->metrics.y_ppem * 64;
|
||||
|
||||
vectoriser.MakeMesh( 1.0);
|
||||
|
||||
if( useDisplayList)
|
||||
{
|
||||
glList = glGenLists( 1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
}
|
||||
|
||||
const FTMesh* mesh = vectoriser.GetMesh();
|
||||
for( unsigned int index = 0; index < mesh->TesselationCount(); ++index)
|
||||
{
|
||||
const FTTesselation* subMesh = mesh->Tesselation( index);
|
||||
unsigned int polyonType = subMesh->PolygonType();
|
||||
|
||||
glBegin( polyonType);
|
||||
for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
|
||||
{
|
||||
FTPoint point = subMesh->Point(pointIndex);
|
||||
|
||||
glTexCoord2f( point.X() / horizontalTextureScale,
|
||||
point.Y() / verticalTextureScale);
|
||||
|
||||
glVertex3f( point.X() / 64.0f,
|
||||
point.Y() / 64.0f,
|
||||
0.0f);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
if(useDisplayList)
|
||||
{
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTPolyGlyph::~FTPolyGlyph()
|
||||
{
|
||||
glDeleteLists( glList, 1);
|
||||
}
|
||||
|
||||
|
||||
const FTPoint& FTPolyGlyph::Render( const FTPoint& pen)
|
||||
{
|
||||
glTranslatef( pen.X(), pen.Y(), 0.0f);
|
||||
|
||||
if( glList)
|
||||
{
|
||||
glCallList( glList);
|
||||
}
|
||||
|
||||
return advance;
|
||||
}
|
||||
104
src/WinLibs/FTGL/src/FTSize.cpp
Normal file
104
src/WinLibs/FTGL/src/FTSize.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include "FTSize.h"
|
||||
|
||||
|
||||
FTSize::FTSize()
|
||||
: ftFace(0),
|
||||
ftSize(0),
|
||||
size(0),
|
||||
xResolution(0),
|
||||
yResolution(0),
|
||||
err(0)
|
||||
{}
|
||||
|
||||
|
||||
FTSize::~FTSize()
|
||||
{}
|
||||
|
||||
|
||||
bool FTSize::CharSize( FT_Face* face, unsigned int pointSize, unsigned int xRes, unsigned int yRes )
|
||||
{
|
||||
if( size != pointSize || xResolution != xRes || yResolution != yRes)
|
||||
{
|
||||
err = FT_Set_Char_Size( *face, 0L, pointSize * 64, xResolution, yResolution);
|
||||
|
||||
if( !err)
|
||||
{
|
||||
ftFace = face;
|
||||
size = pointSize;
|
||||
xResolution = xRes;
|
||||
yResolution = yRes;
|
||||
ftSize = (*ftFace)->size;
|
||||
}
|
||||
else
|
||||
{
|
||||
ftFace = 0;
|
||||
size = 0;
|
||||
xResolution = 0;
|
||||
yResolution = 0;
|
||||
ftSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return !err;
|
||||
}
|
||||
|
||||
|
||||
unsigned int FTSize::CharSize() const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
float FTSize::Ascender() const
|
||||
{
|
||||
return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.ascender) / 64.0f;
|
||||
}
|
||||
|
||||
|
||||
float FTSize::Descender() const
|
||||
{
|
||||
return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.descender) / 64.0f;
|
||||
}
|
||||
|
||||
|
||||
float FTSize::Height() const
|
||||
{
|
||||
if( 0 == ftSize)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if( FT_IS_SCALABLE((*ftFace)))
|
||||
{
|
||||
return ( (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin) * ( (float)ftSize->metrics.y_ppem / (float)(*ftFace)->units_per_EM);
|
||||
}
|
||||
else
|
||||
{
|
||||
return static_cast<float>( ftSize->metrics.height) / 64.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float FTSize::Width() const
|
||||
{
|
||||
if( 0 == ftSize)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if( FT_IS_SCALABLE((*ftFace)))
|
||||
{
|
||||
return ( (*ftFace)->bbox.xMax - (*ftFace)->bbox.xMin) * ( static_cast<float>(ftSize->metrics.x_ppem) / static_cast<float>((*ftFace)->units_per_EM));
|
||||
}
|
||||
else
|
||||
{
|
||||
return static_cast<float>( ftSize->metrics.max_advance) / 64.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float FTSize::Underline() const
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
84
src/WinLibs/FTGL/src/FTTextureGlyph.cpp
Normal file
84
src/WinLibs/FTGL/src/FTTextureGlyph.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include "FTTextureGlyph.h"
|
||||
|
||||
GLint FTTextureGlyph::activeTextureID = 0;
|
||||
|
||||
FTTextureGlyph::FTTextureGlyph( FT_GlyphSlot glyph, int id, int xOffset, int yOffset, GLsizei width, GLsizei height)
|
||||
: FTGlyph( glyph),
|
||||
destWidth(0),
|
||||
destHeight(0),
|
||||
glTextureID(id)
|
||||
{
|
||||
err = FT_Render_Glyph( glyph, FT_RENDER_MODE_NORMAL);
|
||||
if( err || glyph->format != ft_glyph_format_bitmap)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FT_Bitmap bitmap = glyph->bitmap;
|
||||
|
||||
destWidth = bitmap.width;
|
||||
destHeight = bitmap.rows;
|
||||
|
||||
if( destWidth && destHeight)
|
||||
{
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, glTextureID);
|
||||
glTexSubImage2D( GL_TEXTURE_2D, 0, xOffset, yOffset, destWidth, destHeight, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.buffer);
|
||||
|
||||
glPopClientAttrib();
|
||||
}
|
||||
|
||||
|
||||
// 0
|
||||
// +----+
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
// +----+
|
||||
// 1
|
||||
|
||||
uv[0].X( static_cast<float>(xOffset) / static_cast<float>(width));
|
||||
uv[0].Y( static_cast<float>(yOffset) / static_cast<float>(height));
|
||||
uv[1].X( static_cast<float>( xOffset + destWidth) / static_cast<float>(width));
|
||||
uv[1].Y( static_cast<float>( yOffset + destHeight) / static_cast<float>(height));
|
||||
|
||||
pos.X( glyph->bitmap_left);
|
||||
pos.Y( glyph->bitmap_top);
|
||||
}
|
||||
|
||||
|
||||
FTTextureGlyph::~FTTextureGlyph()
|
||||
{}
|
||||
|
||||
|
||||
const FTPoint& FTTextureGlyph::Render( const FTPoint& pen)
|
||||
{
|
||||
if( activeTextureID != glTextureID)
|
||||
{
|
||||
glBindTexture( GL_TEXTURE_2D, (GLuint)glTextureID);
|
||||
activeTextureID = glTextureID;
|
||||
}
|
||||
|
||||
glTranslatef( pen.X(), pen.Y(), 0.0f);
|
||||
|
||||
glBegin( GL_QUADS);
|
||||
glTexCoord2f( uv[0].X(), uv[0].Y());
|
||||
glVertex2f( pos.X(), pos.Y());
|
||||
|
||||
glTexCoord2f( uv[0].X(), uv[1].Y());
|
||||
glVertex2f( pos.X(), pos.Y() - destHeight);
|
||||
|
||||
glTexCoord2f( uv[1].X(), uv[1].Y());
|
||||
glVertex2f( destWidth + pos.X(), pos.Y() - destHeight);
|
||||
|
||||
glTexCoord2f( uv[1].X(), uv[0].Y());
|
||||
glVertex2f( destWidth + pos.X(), pos.Y());
|
||||
glEnd();
|
||||
|
||||
return advance;
|
||||
}
|
||||
|
||||
225
src/WinLibs/FTGL/src/FTVectoriser.cpp
Normal file
225
src/WinLibs/FTGL/src/FTVectoriser.cpp
Normal file
@ -0,0 +1,225 @@
|
||||
#include "FTVectoriser.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
#ifndef CALLBACK
|
||||
#define CALLBACK
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE_CC__
|
||||
typedef GLvoid (*GLUTesselatorFunction)(...);
|
||||
#elif defined( __mips ) || defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __sun ) || defined (__CYGWIN__)
|
||||
typedef GLvoid (*GLUTesselatorFunction)();
|
||||
#elif defined ( WIN32)
|
||||
typedef GLvoid (CALLBACK *GLUTesselatorFunction)( );
|
||||
#else
|
||||
#error "Error - need to define type GLUTesselatorFunction for this platform/compiler"
|
||||
#endif
|
||||
|
||||
|
||||
void CALLBACK ftglError( GLenum errCode, FTMesh* mesh)
|
||||
{
|
||||
mesh->Error( errCode);
|
||||
}
|
||||
|
||||
|
||||
void CALLBACK ftglVertex( void* data, FTMesh* mesh)
|
||||
{
|
||||
FTGL_DOUBLE* vertex = static_cast<FTGL_DOUBLE*>(data);
|
||||
mesh->AddPoint( vertex[0], vertex[1], vertex[2]);
|
||||
}
|
||||
|
||||
|
||||
void CALLBACK ftglCombine( FTGL_DOUBLE coords[3], void* vertex_data[4], GLfloat weight[4], void** outData, FTMesh* mesh)
|
||||
{
|
||||
const FTGL_DOUBLE* vertex = static_cast<const FTGL_DOUBLE*>(coords);
|
||||
*outData = const_cast<FTGL_DOUBLE*>(mesh->Combine( vertex[0], vertex[1], vertex[2]));
|
||||
}
|
||||
|
||||
|
||||
void CALLBACK ftglBegin( GLenum type, FTMesh* mesh)
|
||||
{
|
||||
mesh->Begin( type);
|
||||
}
|
||||
|
||||
|
||||
void CALLBACK ftglEnd( FTMesh* mesh)
|
||||
{
|
||||
mesh->End();
|
||||
}
|
||||
|
||||
|
||||
FTMesh::FTMesh()
|
||||
: currentTesselation(0),
|
||||
err(0)
|
||||
{
|
||||
tesselationList.reserve( 16);
|
||||
}
|
||||
|
||||
|
||||
FTMesh::~FTMesh()
|
||||
{
|
||||
for( size_t t = 0; t < tesselationList.size(); ++t)
|
||||
{
|
||||
delete tesselationList[t];
|
||||
}
|
||||
|
||||
tesselationList.clear();
|
||||
}
|
||||
|
||||
|
||||
void FTMesh::AddPoint( const FTGL_DOUBLE x, const FTGL_DOUBLE y, const FTGL_DOUBLE z)
|
||||
{
|
||||
currentTesselation->AddPoint( x, y, z);
|
||||
}
|
||||
|
||||
|
||||
const FTGL_DOUBLE* FTMesh::Combine( const FTGL_DOUBLE x, const FTGL_DOUBLE y, const FTGL_DOUBLE z)
|
||||
{
|
||||
tempPointList.push_back( FTPoint( x, y,z));
|
||||
return static_cast<const FTGL_DOUBLE*>(tempPointList.back());
|
||||
}
|
||||
|
||||
|
||||
void FTMesh::Begin( GLenum meshType)
|
||||
{
|
||||
currentTesselation = new FTTesselation( meshType);
|
||||
}
|
||||
|
||||
|
||||
void FTMesh::End()
|
||||
{
|
||||
tesselationList.push_back( currentTesselation);
|
||||
}
|
||||
|
||||
|
||||
const FTTesselation* const FTMesh::Tesselation( unsigned int index) const
|
||||
{
|
||||
return ( index < tesselationList.size()) ? tesselationList[index] : NULL;
|
||||
}
|
||||
|
||||
|
||||
FTVectoriser::FTVectoriser( const FT_GlyphSlot glyph)
|
||||
: contourList(0),
|
||||
mesh(0),
|
||||
ftContourCount(0),
|
||||
contourFlag(0)
|
||||
{
|
||||
if( glyph)
|
||||
{
|
||||
outline = glyph->outline;
|
||||
|
||||
ftContourCount = outline.n_contours;
|
||||
contourList = 0;
|
||||
contourFlag = outline.flags;
|
||||
|
||||
ProcessContours();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FTVectoriser::~FTVectoriser()
|
||||
{
|
||||
for( size_t c = 0; c < ContourCount(); ++c)
|
||||
{
|
||||
delete contourList[c];
|
||||
}
|
||||
|
||||
delete [] contourList;
|
||||
delete mesh;
|
||||
}
|
||||
|
||||
|
||||
void FTVectoriser::ProcessContours()
|
||||
{
|
||||
short contourLength = 0;
|
||||
short startIndex = 0;
|
||||
short endIndex = 0;
|
||||
|
||||
contourList = new FTContour*[ftContourCount];
|
||||
|
||||
for( short contourIndex = 0; contourIndex < ftContourCount; ++contourIndex)
|
||||
{
|
||||
FT_Vector* pointList = &outline.points[startIndex];
|
||||
char* tagList = &outline.tags[startIndex];
|
||||
|
||||
endIndex = outline.contours[contourIndex];
|
||||
contourLength = ( endIndex - startIndex) + 1;
|
||||
|
||||
FTContour* contour = new FTContour( pointList, tagList, contourLength);
|
||||
|
||||
contourList[contourIndex] = contour;
|
||||
|
||||
startIndex = endIndex + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
size_t FTVectoriser::PointCount()
|
||||
{
|
||||
size_t s = 0;
|
||||
for( size_t c = 0; c < ContourCount(); ++c)
|
||||
{
|
||||
s += contourList[c]->PointCount();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
const FTContour* const FTVectoriser::Contour( unsigned int index) const
|
||||
{
|
||||
return ( index < ContourCount()) ? contourList[index] : NULL;
|
||||
}
|
||||
|
||||
|
||||
void FTVectoriser::MakeMesh( FTGL_DOUBLE zNormal)
|
||||
{
|
||||
if( mesh)
|
||||
{
|
||||
delete mesh;
|
||||
}
|
||||
|
||||
mesh = new FTMesh;
|
||||
|
||||
GLUtesselator* tobj = gluNewTess();
|
||||
|
||||
gluTessCallback( tobj, GLU_TESS_BEGIN_DATA, (GLUTesselatorFunction)ftglBegin);
|
||||
gluTessCallback( tobj, GLU_TESS_VERTEX_DATA, (GLUTesselatorFunction)ftglVertex);
|
||||
gluTessCallback( tobj, GLU_TESS_COMBINE_DATA, (GLUTesselatorFunction)ftglCombine);
|
||||
gluTessCallback( tobj, GLU_TESS_END_DATA, (GLUTesselatorFunction)ftglEnd);
|
||||
gluTessCallback( tobj, GLU_TESS_ERROR_DATA, (GLUTesselatorFunction)ftglError);
|
||||
|
||||
if( contourFlag & ft_outline_even_odd_fill) // ft_outline_reverse_fill
|
||||
{
|
||||
gluTessProperty( tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
|
||||
}
|
||||
else
|
||||
{
|
||||
gluTessProperty( tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO);
|
||||
}
|
||||
|
||||
|
||||
gluTessProperty( tobj, GLU_TESS_TOLERANCE, 0);
|
||||
gluTessNormal( tobj, 0.0f, 0.0f, zNormal);
|
||||
gluTessBeginPolygon( tobj, mesh);
|
||||
|
||||
for( size_t c = 0; c < ContourCount(); ++c)
|
||||
{
|
||||
const FTContour* contour = contourList[c];
|
||||
|
||||
gluTessBeginContour( tobj);
|
||||
|
||||
for( size_t p = 0; p < contour->PointCount(); ++p)
|
||||
{
|
||||
const FTGL_DOUBLE* d = contour->Point(p);
|
||||
gluTessVertex( tobj, (GLdouble*)d, (GLdouble*)d);
|
||||
}
|
||||
|
||||
gluTessEndContour( tobj);
|
||||
}
|
||||
|
||||
gluTessEndPolygon( tobj);
|
||||
|
||||
gluDeleteTess( tobj);
|
||||
}
|
||||
|
||||
154
src/WinLibs/FTGL/test/FTBBox-Test.cpp
Normal file
154
src/WinLibs/FTGL/test/FTBBox-Test.cpp
Normal file
@ -0,0 +1,154 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTBBox.h"
|
||||
|
||||
|
||||
class FTBBoxTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTBBoxTest);
|
||||
CPPUNIT_TEST( testDefaultConstructor);
|
||||
CPPUNIT_TEST( testGlyphConstructor);
|
||||
CPPUNIT_TEST( testMoveBBox);
|
||||
CPPUNIT_TEST( testPlusEquals);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTBBoxTest() : CppUnit::TestCase( "FTBBox Test")
|
||||
{}
|
||||
|
||||
FTBBoxTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testDefaultConstructor()
|
||||
{
|
||||
FTBBox boundingBox;
|
||||
|
||||
CPPUNIT_ASSERT( boundingBox.lowerX == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.lowerY == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.lowerZ == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperX == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperY == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperZ == 0.0f);
|
||||
}
|
||||
|
||||
|
||||
void testGlyphConstructor()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
FTBBox boundingBox( face->glyph);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 2, boundingBox.lowerX, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, boundingBox.lowerY, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, boundingBox.lowerZ, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 35, boundingBox.upperX, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 38, boundingBox.upperY, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, boundingBox.upperZ, 0.01);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void testMoveBBox()
|
||||
{
|
||||
FTBBox boundingBox;
|
||||
FTPoint firstMove( 3.5f, 1.0f, -2.5f);
|
||||
FTPoint secondMove( -3.5f, -1.0f, 2.5f);
|
||||
|
||||
boundingBox.Move( firstMove);
|
||||
|
||||
CPPUNIT_ASSERT( boundingBox.lowerX == 3.5f);
|
||||
CPPUNIT_ASSERT( boundingBox.lowerY == 1.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.lowerZ == -2.5f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperX == 3.5f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperY == 1.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperZ == -2.5f);
|
||||
|
||||
boundingBox.Move( secondMove);
|
||||
|
||||
CPPUNIT_ASSERT( boundingBox.lowerX == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.lowerY == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.lowerZ == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperX == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperY == 0.0f);
|
||||
CPPUNIT_ASSERT( boundingBox.upperZ == 0.0f);
|
||||
}
|
||||
|
||||
void testPlusEquals()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
FTBBox boundingBox1;
|
||||
FTBBox boundingBox2( face->glyph);
|
||||
|
||||
boundingBox1 += boundingBox2;
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 2, boundingBox2.lowerX, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, boundingBox2.lowerY, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, boundingBox2.lowerZ, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 35, boundingBox2.upperX, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 38, boundingBox2.upperY, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, boundingBox2.upperZ, 0.01);
|
||||
|
||||
float advance = 40;
|
||||
|
||||
boundingBox2.Move( FTPoint( advance, 0, 0));
|
||||
boundingBox1 += boundingBox2;
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 42, boundingBox2.lowerX, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, boundingBox2.lowerY, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, boundingBox2.lowerZ, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 75, boundingBox2.upperX, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 38, boundingBox2.upperY, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, boundingBox2.upperZ, 0.01);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
FT_Glyph glyph;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
CPPUNIT_ASSERT(!error);
|
||||
error = FT_New_Face( library, GOOD_FONT_FILE, 0, &face);
|
||||
CPPUNIT_ASSERT(!error);
|
||||
|
||||
long glyphIndex = FT_Get_Char_Index( face, CHARACTER_CODE_G);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
error = FT_Load_Glyph( face, glyphIndex, FT_LOAD_DEFAULT);
|
||||
CPPUNIT_ASSERT(!error);
|
||||
error = FT_Get_Glyph( face->glyph, &glyph);
|
||||
CPPUNIT_ASSERT(!error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Glyph( glyph);
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTBBoxTest);
|
||||
|
||||
84
src/WinLibs/FTGL/test/FTBitmapGlyph-Test.cpp
Normal file
84
src/WinLibs/FTGL/test/FTBitmapGlyph-Test.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTBitmapGlyph.h"
|
||||
|
||||
class FTBitmapGlyphTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTBitmapGlyphTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTBitmapGlyphTest() : CppUnit::TestCase( "FTBitmapGlyph Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTBitmapGlyphTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTBitmapGlyphTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
FTBitmapGlyph* bitmapGlyph = new FTBitmapGlyph( face->glyph);
|
||||
CPPUNIT_ASSERT( bitmapGlyph->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
FTBitmapGlyph* bitmapGlyph = new FTBitmapGlyph( face->glyph);
|
||||
CPPUNIT_ASSERT( bitmapGlyph->Error() == 0);
|
||||
bitmapGlyph->Render(FTPoint( 0, 0, 0));
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
error = FT_Load_Char( face, CHARACTER_CODE_A, FT_LOAD_DEFAULT);
|
||||
assert( !error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTBitmapGlyphTest);
|
||||
|
||||
64
src/WinLibs/FTGL/test/FTCharToGlyphIndexMap-Test.cpp
Normal file
64
src/WinLibs/FTGL/test/FTCharToGlyphIndexMap-Test.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "FTCharToGlyphIndexMap.h"
|
||||
|
||||
|
||||
class FTCharToGlyphIndexMapTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTCharToGlyphIndexMapTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testInsert);
|
||||
CPPUNIT_TEST( testClear);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTCharToGlyphIndexMapTest() : CppUnit::TestCase( "FTCharToGlyphIndexMap Test")
|
||||
{}
|
||||
|
||||
FTCharToGlyphIndexMapTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
FTCharToGlyphIndexMap testMap;
|
||||
|
||||
CPPUNIT_ASSERT( testMap.find( 2) == 0);
|
||||
CPPUNIT_ASSERT( testMap.find( 5) == 0);
|
||||
}
|
||||
|
||||
void testInsert()
|
||||
{
|
||||
FTCharToGlyphIndexMap testMap;
|
||||
|
||||
testMap.insert( 2, 37);
|
||||
|
||||
CPPUNIT_ASSERT( testMap.find( 2) == 37);
|
||||
CPPUNIT_ASSERT( testMap.find( 5) == 0);
|
||||
}
|
||||
|
||||
void testClear()
|
||||
{
|
||||
FTCharToGlyphIndexMap testMap;
|
||||
|
||||
testMap.insert( 2, 37);
|
||||
testMap.clear();
|
||||
|
||||
CPPUNIT_ASSERT( testMap.find( 2) == 0);
|
||||
CPPUNIT_ASSERT( testMap.find( 5) == 0);
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTCharToGlyphIndexMapTest);
|
||||
|
||||
143
src/WinLibs/FTGL/test/FTCharmap-Test.cpp
Normal file
143
src/WinLibs/FTGL/test/FTCharmap-Test.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTFace.h"
|
||||
#include "FTCharmap.h"
|
||||
|
||||
|
||||
class FTCharmapTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTCharmapTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testSetEncoding);
|
||||
CPPUNIT_TEST( testGetGlyphListIndex);
|
||||
CPPUNIT_TEST( testGetFontIndex);
|
||||
CPPUNIT_TEST( testInsertCharacterIndex);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTCharmapTest() : CppUnit::TestCase( "FTCharmap Test")
|
||||
{
|
||||
setUpFreetype();
|
||||
}
|
||||
|
||||
FTCharmapTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTCharmapTest()
|
||||
{
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
CPPUNIT_ASSERT( charmap->Error() == 0);
|
||||
CPPUNIT_ASSERT( charmap->Encoding() == ft_encoding_unicode);
|
||||
}
|
||||
|
||||
|
||||
void testSetEncoding()
|
||||
{
|
||||
CPPUNIT_ASSERT( charmap->CharMap( ft_encoding_unicode));
|
||||
|
||||
CPPUNIT_ASSERT( charmap->Error() == 0);
|
||||
CPPUNIT_ASSERT( charmap->Encoding() == ft_encoding_unicode);
|
||||
|
||||
CPPUNIT_ASSERT( !charmap->CharMap( ft_encoding_johab));
|
||||
|
||||
CPPUNIT_ASSERT( charmap->Error() == 0x06); // invalid argument
|
||||
CPPUNIT_ASSERT( charmap->Encoding() == ft_encoding_none);
|
||||
}
|
||||
|
||||
|
||||
void testGetGlyphListIndex()
|
||||
{
|
||||
charmap->CharMap( ft_encoding_johab);
|
||||
|
||||
CPPUNIT_ASSERT( charmap->Error() == 0x06); // invalid argument
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_A) == 0);
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( BIG_CHARACTER_CODE) == 0);
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( NULL_CHARACTER_CODE) == 0);
|
||||
|
||||
charmap->CharMap( ft_encoding_unicode);
|
||||
|
||||
CPPUNIT_ASSERT( charmap->Error() == 0);
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_A) == 0);
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( BIG_CHARACTER_CODE) == 0);
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( NULL_CHARACTER_CODE) == 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testGetFontIndex()
|
||||
{
|
||||
charmap->CharMap( ft_encoding_johab);
|
||||
|
||||
CPPUNIT_ASSERT( charmap->Error() == 0x06); // invalid argument
|
||||
CPPUNIT_ASSERT( charmap->FontIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
|
||||
CPPUNIT_ASSERT( charmap->FontIndex( BIG_CHARACTER_CODE) == BIG_FONT_INDEX);
|
||||
CPPUNIT_ASSERT( charmap->FontIndex( NULL_CHARACTER_CODE) == NULL_FONT_INDEX);
|
||||
charmap->CharMap( ft_encoding_unicode);
|
||||
|
||||
CPPUNIT_ASSERT( charmap->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( charmap->FontIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
|
||||
CPPUNIT_ASSERT( charmap->FontIndex( BIG_CHARACTER_CODE) == BIG_FONT_INDEX);
|
||||
CPPUNIT_ASSERT( charmap->FontIndex( NULL_CHARACTER_CODE) == NULL_FONT_INDEX);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testInsertCharacterIndex()
|
||||
{
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_A) == 0);
|
||||
CPPUNIT_ASSERT( charmap->FontIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
|
||||
|
||||
charmap->InsertIndex( CHARACTER_CODE_A, 69);
|
||||
CPPUNIT_ASSERT( charmap->FontIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_A) == 69);
|
||||
|
||||
charmap->InsertIndex( CHARACTER_CODE_G, 999);
|
||||
CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_G) == 999);
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
charmap = new FTCharmap( face);
|
||||
}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
delete charmap;
|
||||
}
|
||||
|
||||
private:
|
||||
FTFace* face;
|
||||
FTCharmap* charmap;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
face = new FTFace( GOOD_FONT_FILE);
|
||||
CPPUNIT_ASSERT( !face->Error());
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
delete face;
|
||||
}
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTCharmapTest);
|
||||
|
||||
226
src/WinLibs/FTGL/test/FTContour-Test.cpp
Normal file
226
src/WinLibs/FTGL/test/FTContour-Test.cpp
Normal file
@ -0,0 +1,226 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "FTContour.h"
|
||||
|
||||
// FT_Curve_Tag_On 1
|
||||
// FT_Curve_Tag_Conic 0
|
||||
// FT_Curve_Tag_Cubic 2
|
||||
|
||||
static FT_Vector shortLine[2] =
|
||||
{
|
||||
{ 1, 1},
|
||||
{ 2, 2},
|
||||
};
|
||||
|
||||
static FT_Vector straightLinePoints[3] =
|
||||
{
|
||||
{ 0, 0},
|
||||
{ 6, 7},
|
||||
{ 9, -2}
|
||||
};
|
||||
|
||||
static char straightLineTags[3] =
|
||||
{
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On
|
||||
};
|
||||
|
||||
static char brokenTags[3] =
|
||||
{
|
||||
FT_Curve_Tag_Conic,
|
||||
69,
|
||||
FT_Curve_Tag_On
|
||||
};
|
||||
|
||||
static FT_Vector simpleConicPoints[3] =
|
||||
{
|
||||
{ 0, 0},
|
||||
{ 6, 7},
|
||||
{ 9, -2}
|
||||
};
|
||||
|
||||
static FT_Vector brokenPoints[3] =
|
||||
{
|
||||
{ 0, 0},
|
||||
{ 0, 0},
|
||||
{ 0, 0}
|
||||
};
|
||||
|
||||
static char simpleConicTags[3] =
|
||||
{
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On
|
||||
};
|
||||
|
||||
static FT_Vector doubleConicPoints[4] =
|
||||
{
|
||||
{ 0, 0},
|
||||
{ 6, 7},
|
||||
{ 9, -2},
|
||||
{ 4, 0}
|
||||
};
|
||||
|
||||
static char doubleConicTags[4] =
|
||||
{
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_Conic
|
||||
};
|
||||
|
||||
static FT_Vector cubicPoints[4] =
|
||||
{
|
||||
{ 0, 0},
|
||||
{ 6, 7},
|
||||
{ 9, -2},
|
||||
{ 4, 0}
|
||||
};
|
||||
|
||||
static char cubicTags[4] =
|
||||
{
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_Cubic,
|
||||
FT_Curve_Tag_Cubic
|
||||
};
|
||||
|
||||
|
||||
// ARIAl 'd'
|
||||
static FT_Vector compositePoints[18] =
|
||||
{
|
||||
{ 1856, 0},
|
||||
{ 1856, 279},
|
||||
{ 1625, -64},
|
||||
{ 1175, -64},
|
||||
{ 884, -64},
|
||||
{ 396, 251},
|
||||
{ 128, 815},
|
||||
{ 128, 1182},
|
||||
{ 128, 1539},
|
||||
{ 370, 2121},
|
||||
{ 855, 2432},
|
||||
{ 1156, 2432},
|
||||
{ 1375, 2432},
|
||||
{ 1718, 2257},
|
||||
{ 1826, 2118},
|
||||
{ 1826, 3264},
|
||||
{ 2240, 3264},
|
||||
{ 2240, 0},
|
||||
};
|
||||
|
||||
static char compositeTags[18] =
|
||||
{
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_Conic,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On,
|
||||
FT_Curve_Tag_On
|
||||
};
|
||||
|
||||
class FTContourTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTContourTest);
|
||||
CPPUNIT_TEST( testNullCurve);
|
||||
CPPUNIT_TEST( testBrokenCurve);
|
||||
CPPUNIT_TEST( testStraightLine);
|
||||
CPPUNIT_TEST( testConicCurve);
|
||||
CPPUNIT_TEST( testDoubleConicCurve);
|
||||
CPPUNIT_TEST( testCubicCurve);
|
||||
CPPUNIT_TEST( testCompositeCurve);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTContourTest() : CppUnit::TestCase( "FTContour Test")
|
||||
{}
|
||||
|
||||
FTContourTest( const std::string& name) : CppUnit::TestCase(name)
|
||||
{}
|
||||
|
||||
void testNullCurve()
|
||||
{
|
||||
FTContour contour( NULL, NULL, 0);
|
||||
CPPUNIT_ASSERT( contour.PointCount() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testBrokenCurve()
|
||||
{
|
||||
FTContour contour( brokenPoints, simpleConicTags, 3);
|
||||
CPPUNIT_ASSERT( contour.PointCount() == 1);
|
||||
|
||||
FTContour shortContour( shortLine, simpleConicTags, 2);
|
||||
CPPUNIT_ASSERT( shortContour.PointCount() == 6);
|
||||
|
||||
FTContour reallyShortContour( shortLine, simpleConicTags, 1);
|
||||
CPPUNIT_ASSERT( reallyShortContour.PointCount() == 1);
|
||||
|
||||
FTContour brokenTagtContour( shortLine, brokenTags, 3);
|
||||
CPPUNIT_ASSERT( brokenTagtContour.PointCount() == 7);
|
||||
}
|
||||
|
||||
|
||||
void testStraightLine()
|
||||
{
|
||||
FTContour contour( straightLinePoints, straightLineTags, 3);
|
||||
CPPUNIT_ASSERT( contour.PointCount() == 3);
|
||||
}
|
||||
|
||||
|
||||
void testConicCurve()
|
||||
{
|
||||
FTContour contour( simpleConicPoints, simpleConicTags, 3);
|
||||
CPPUNIT_ASSERT( contour.PointCount() == 7);
|
||||
}
|
||||
|
||||
|
||||
void testDoubleConicCurve()
|
||||
{
|
||||
FTContour contour( doubleConicPoints, doubleConicTags, 4);
|
||||
CPPUNIT_ASSERT( contour.PointCount() == 12);
|
||||
}
|
||||
|
||||
|
||||
void testCubicCurve()
|
||||
{
|
||||
FTContour contour( cubicPoints, cubicTags, 4);
|
||||
CPPUNIT_ASSERT( contour.PointCount() == 7);
|
||||
}
|
||||
|
||||
|
||||
void testCompositeCurve()
|
||||
{
|
||||
FTContour contour( compositePoints, compositeTags, 18);
|
||||
CPPUNIT_ASSERT( contour.PointCount() == 50);
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTContourTest);
|
||||
|
||||
91
src/WinLibs/FTGL/test/FTExtrdGlyph-Test.cpp
Normal file
91
src/WinLibs/FTGL/test/FTExtrdGlyph-Test.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTExtrdGlyph.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTExtrdGlyphTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTExtrdGlyphTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTExtrdGlyphTest() : CppUnit::TestCase( "FTExtrdGlyph Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTExtrdGlyphTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTExtrdGlyphTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
FTExtrdGlyph* extrudedGlyph = new FTExtrdGlyph( face->glyph, 0.0f, true);
|
||||
CPPUNIT_ASSERT( extrudedGlyph->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
FTExtrdGlyph* extrudedGlyph = new FTExtrdGlyph( face->glyph, 0.0f, true);
|
||||
CPPUNIT_ASSERT( extrudedGlyph->Error() == 0);
|
||||
extrudedGlyph->Render(FTPoint(0, 0, 0));
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
error = FT_Load_Char( face, CHARACTER_CODE_A, FT_LOAD_DEFAULT);
|
||||
assert( !error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTExtrdGlyphTest);
|
||||
|
||||
130
src/WinLibs/FTGL/test/FTFace-Test.cpp
Normal file
130
src/WinLibs/FTGL/test/FTFace-Test.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
#include "cppunit/extensions/HelperMacros.h"
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include "cppunit/TestCase.h"
|
||||
#include "cppunit/TestSuite.h"
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTFace.h"
|
||||
|
||||
|
||||
class FTFaceTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTFaceTest);
|
||||
CPPUNIT_TEST( testOpenFace);
|
||||
CPPUNIT_TEST( testOpenFaceFromMemory);
|
||||
CPPUNIT_TEST( testAttachFile);
|
||||
CPPUNIT_TEST( testAttachMemoryData);
|
||||
CPPUNIT_TEST( testGlyphCount);
|
||||
CPPUNIT_TEST( testSetFontSize);
|
||||
CPPUNIT_TEST( testGetCharmapList);
|
||||
CPPUNIT_TEST( testKerning);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTFaceTest() : CppUnit::TestCase( "FTFace test") {};
|
||||
FTFaceTest( const std::string& name) : CppUnit::TestCase(name) {};
|
||||
|
||||
|
||||
void testOpenFace()
|
||||
{
|
||||
FTFace face1( BAD_FONT_FILE);
|
||||
CPPUNIT_ASSERT( face1.Error() == 0x06);
|
||||
|
||||
FTFace face2( GOOD_FONT_FILE);
|
||||
CPPUNIT_ASSERT( face2.Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testOpenFaceFromMemory()
|
||||
{
|
||||
FTFace face1( (unsigned char*)100, 0);
|
||||
CPPUNIT_ASSERT( face1.Error() == 0x02);
|
||||
|
||||
FTFace face2( HPGCalc_pfb.dataBytes, HPGCalc_pfb.numBytes);
|
||||
CPPUNIT_ASSERT( face2.Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testAttachFile()
|
||||
{
|
||||
CPPUNIT_ASSERT( !testFace->Attach( TYPE1_AFM_FILE));
|
||||
CPPUNIT_ASSERT( testFace->Error() == 0x07); // unimplemented feature
|
||||
|
||||
FTFace test( TYPE1_FONT_FILE);
|
||||
CPPUNIT_ASSERT( test.Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( test.Attach( TYPE1_AFM_FILE));
|
||||
CPPUNIT_ASSERT( test.Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testAttachMemoryData()
|
||||
{
|
||||
CPPUNIT_ASSERT( !testFace->Attach((unsigned char*)100, 0));
|
||||
CPPUNIT_ASSERT( testFace->Error() == 0x07); // unimplemented feature
|
||||
|
||||
FTFace test( TYPE1_FONT_FILE);
|
||||
CPPUNIT_ASSERT( test.Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( test.Attach( HPGCalc_afm.dataBytes, HPGCalc_afm.numBytes));
|
||||
CPPUNIT_ASSERT( test.Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testGlyphCount()
|
||||
{
|
||||
CPPUNIT_ASSERT( testFace->GlyphCount() == 14099);
|
||||
}
|
||||
|
||||
|
||||
void testSetFontSize()
|
||||
{
|
||||
FTSize size = testFace->Size( FONT_POINT_SIZE, RESOLUTION);
|
||||
CPPUNIT_ASSERT( testFace->Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testGetCharmapList()
|
||||
{
|
||||
CPPUNIT_ASSERT( testFace->CharMapCount() == 2);
|
||||
|
||||
FT_Encoding* charmapList = testFace->CharMapList();
|
||||
|
||||
CPPUNIT_ASSERT( charmapList[0] == ft_encoding_unicode);
|
||||
CPPUNIT_ASSERT( charmapList[1] == ft_encoding_adobe_standard);
|
||||
}
|
||||
|
||||
|
||||
void testKerning()
|
||||
{
|
||||
FTFace test(ARIAL_FONT_FILE);
|
||||
FTPoint kerningVector = test.KernAdvance( 'A', 'A');
|
||||
CPPUNIT_ASSERT( kerningVector.X() == 0);
|
||||
CPPUNIT_ASSERT( kerningVector.Y() == 0);
|
||||
CPPUNIT_ASSERT( kerningVector.Z() == 0);
|
||||
|
||||
kerningVector = test.KernAdvance( 0x6FB3, 0x9580);
|
||||
CPPUNIT_ASSERT( kerningVector.X() == 0);
|
||||
CPPUNIT_ASSERT( kerningVector.Y() == 0);
|
||||
CPPUNIT_ASSERT( kerningVector.Z() == 0);
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{
|
||||
testFace = new FTFace( GOOD_FONT_FILE);
|
||||
}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
delete testFace;
|
||||
}
|
||||
|
||||
private:
|
||||
FTFace* testFace;
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTFaceTest);
|
||||
|
||||
294
src/WinLibs/FTGL/test/FTFont-Test.cpp
Normal file
294
src/WinLibs/FTGL/test/FTFont-Test.cpp
Normal file
@ -0,0 +1,294 @@
|
||||
#include "cppunit/extensions/HelperMacros.h"
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include "cppunit/TestCase.h"
|
||||
#include "cppunit/TestSuite.h"
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTGlyph.h"
|
||||
#include "FTFont.h"
|
||||
|
||||
|
||||
class TestGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
TestGlyph( FT_GlyphSlot glyph)
|
||||
: FTGlyph( glyph)
|
||||
{}
|
||||
|
||||
const FTPoint& Render( const FTPoint& pen){ return advance;}
|
||||
};
|
||||
|
||||
|
||||
class TestFont : public FTFont
|
||||
{
|
||||
public:
|
||||
TestFont( const char* fontFilePath)
|
||||
: FTFont( fontFilePath)
|
||||
{}
|
||||
|
||||
TestFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
|
||||
: FTFont( pBufferBytes, bufferSizeInBytes)
|
||||
{}
|
||||
|
||||
FTGlyph* MakeGlyph( unsigned int g)
|
||||
{
|
||||
FT_GlyphSlot ftGlyph = face.Glyph( g, FT_LOAD_NO_HINTING);
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
TestGlyph* tempGlyph = new TestGlyph( ftGlyph);
|
||||
return tempGlyph;
|
||||
}
|
||||
|
||||
err = face.Error();
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class BadGlyphTestFont : public FTFont
|
||||
{
|
||||
public:
|
||||
BadGlyphTestFont( const char* fontFilePath)
|
||||
: FTFont( fontFilePath)
|
||||
{}
|
||||
|
||||
FTGlyph* MakeGlyph( unsigned int g)
|
||||
{
|
||||
FT_GlyphSlot ftGlyph = face.Glyph( g, FT_LOAD_NO_HINTING);
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
TestGlyph* tempGlyph = new TestGlyph( ftGlyph);
|
||||
return tempGlyph;
|
||||
}
|
||||
|
||||
err = face.Error();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
bool CheckGlyph( const unsigned int chr)
|
||||
{
|
||||
static bool succeed = false;
|
||||
|
||||
if( succeed == false)
|
||||
{
|
||||
succeed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class FTFontTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTFontTest);
|
||||
CPPUNIT_TEST( testOpenFont);
|
||||
CPPUNIT_TEST( testOpenFontFromMemory);
|
||||
CPPUNIT_TEST( testAttachFile);
|
||||
CPPUNIT_TEST( testAttachData);
|
||||
CPPUNIT_TEST( testSetFontSize);
|
||||
CPPUNIT_TEST( testSetCharMap);
|
||||
CPPUNIT_TEST( testGetCharmapList);
|
||||
CPPUNIT_TEST( testBoundingBox);
|
||||
CPPUNIT_TEST( testCheckGlyphFailure);
|
||||
CPPUNIT_TEST( testAdvance);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTFontTest() : CppUnit::TestCase( "FTFont test") {};
|
||||
FTFontTest( const std::string& name) : CppUnit::TestCase(name) {};
|
||||
|
||||
|
||||
void testOpenFont()
|
||||
{
|
||||
TestFont badFont( BAD_FONT_FILE);
|
||||
CPPUNIT_ASSERT( badFont.Error() == 0x06); // invalid argument
|
||||
|
||||
TestFont goodFont( GOOD_FONT_FILE);
|
||||
CPPUNIT_ASSERT( goodFont.Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testOpenFontFromMemory()
|
||||
{
|
||||
TestFont badFont( (unsigned char*)100, 0);
|
||||
CPPUNIT_ASSERT( badFont.Error() == 0x02);
|
||||
|
||||
TestFont goodFont( HPGCalc_pfb.dataBytes, HPGCalc_pfb.numBytes);
|
||||
CPPUNIT_ASSERT( goodFont.Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testAttachFile()
|
||||
{
|
||||
testFont->Attach( TYPE1_AFM_FILE);
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0x07); // unimplemented feature
|
||||
}
|
||||
|
||||
|
||||
void testAttachData()
|
||||
{
|
||||
testFont->Attach( (unsigned char*)100, 0);
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0x07); // unimplemented feature
|
||||
}
|
||||
|
||||
|
||||
void testSetFontSize()
|
||||
{
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, testFont->Ascender(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, testFont->Descender(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, testFont->LineHeight(), 0.01);
|
||||
|
||||
float advance = testFont->Advance( GOOD_UNICODE_TEST_STRING);
|
||||
CPPUNIT_ASSERT( advance == 0);
|
||||
|
||||
CPPUNIT_ASSERT( testFont->FaceSize( FONT_POINT_SIZE));
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( testFont->FaceSize() == FONT_POINT_SIZE);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 52, testFont->Ascender(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, testFont->Descender(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 81.86, testFont->LineHeight(), 0.01);
|
||||
|
||||
CPPUNIT_ASSERT( testFont->FaceSize( FONT_POINT_SIZE * 2));
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( testFont->FaceSize() == FONT_POINT_SIZE * 2);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 104, testFont->Ascender(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( -29, testFont->Descender(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 163.72, testFont->LineHeight(), 0.01);
|
||||
}
|
||||
|
||||
|
||||
void testSetCharMap()
|
||||
{
|
||||
CPPUNIT_ASSERT( true == testFont->CharMap( ft_encoding_unicode));
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( false == testFont->CharMap( ft_encoding_johab));
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0x06); // invalid argument
|
||||
}
|
||||
|
||||
|
||||
void testGetCharmapList()
|
||||
{
|
||||
CPPUNIT_ASSERT( testFont->CharMapCount() == 2);
|
||||
|
||||
FT_Encoding* charmapList = testFont->CharMapList();
|
||||
|
||||
CPPUNIT_ASSERT( charmapList[0] == ft_encoding_unicode);
|
||||
CPPUNIT_ASSERT( charmapList[1] == ft_encoding_adobe_standard);
|
||||
}
|
||||
|
||||
|
||||
void testBoundingBox()
|
||||
{
|
||||
CPPUNIT_ASSERT( testFont->FaceSize( FONT_POINT_SIZE));
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0);
|
||||
|
||||
float llx, lly, llz, urx, ury, urz;
|
||||
|
||||
testFont->BBox( GOOD_ASCII_TEST_STRING, llx, lly, llz, urx, ury, urz);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.21, llx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( -15.12, lly, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00, llz, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 307.43, urx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 51.54, ury, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00, urz, 0.01);
|
||||
|
||||
testFont->BBox( BAD_ASCII_TEST_STRING, llx, lly, llz, urx, ury, urz);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lly, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llz, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, ury, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urz, 0.01);
|
||||
|
||||
testFont->BBox( GOOD_UNICODE_TEST_STRING, llx, lly, llz, urx, ury, urz);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.15, llx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( -6.12, lly, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00, llz, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 134.28, urx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 61.12, ury, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00, urz, 0.01);
|
||||
|
||||
testFont->BBox( BAD_UNICODE_TEST_STRING, llx, lly, llz, urx, ury, urz);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lly, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llz, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, ury, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urz, 0.01);
|
||||
|
||||
testFont->BBox( (char*)0, llx, lly, llz, urx, ury, urz);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lly, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llz, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urx, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, ury, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urz, 0.01);
|
||||
}
|
||||
|
||||
void testCheckGlyphFailure()
|
||||
{
|
||||
BadGlyphTestFont* testFont = new BadGlyphTestFont(GOOD_FONT_FILE);
|
||||
|
||||
float advance = testFont->Advance( GOOD_ASCII_TEST_STRING);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, advance, 0.01);
|
||||
}
|
||||
|
||||
void testAdvance()
|
||||
{
|
||||
CPPUNIT_ASSERT( testFont->FaceSize( FONT_POINT_SIZE));
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0);
|
||||
|
||||
float advance = testFont->Advance( GOOD_ASCII_TEST_STRING);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 312.10, advance, 0.01);
|
||||
|
||||
advance = testFont->Advance( BAD_ASCII_TEST_STRING);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, advance, 0.01);
|
||||
|
||||
advance = testFont->Advance( GOOD_UNICODE_TEST_STRING);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 144, advance, 0.01);
|
||||
|
||||
advance = testFont->Advance( BAD_UNICODE_TEST_STRING);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, advance, 0.01);
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
testFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
CPPUNIT_ASSERT( testFont->Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{
|
||||
testFont = new TestFont( GOOD_FONT_FILE);
|
||||
}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
delete testFont;
|
||||
}
|
||||
|
||||
private:
|
||||
TestFont* testFont;
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTFontTest);
|
||||
|
||||
109
src/WinLibs/FTGL/test/FTGLBitmapFont-Test.cpp
Normal file
109
src/WinLibs/FTGL/test/FTGLBitmapFont-Test.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTGLBitmapFont.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTGLBitmapFontTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTGLBitmapFontTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST( testPenPosition);
|
||||
CPPUNIT_TEST( testDisplayList);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTGLBitmapFontTest() : CppUnit::TestCase( "FTGLBitmapFont Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTGLBitmapFontTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTGLBitmapFontTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLBitmapFont* bitmapFont = new FTGLBitmapFont( FONT_FILE);
|
||||
CPPUNIT_ASSERT( bitmapFont->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLBitmapFont* bitmapFont = new FTGLBitmapFont( FONT_FILE);
|
||||
bitmapFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( bitmapFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
bitmapFont->FaceSize(18);
|
||||
bitmapFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( bitmapFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
void testPenPosition()
|
||||
{
|
||||
buildGLContext();
|
||||
float rasterPosition[4];
|
||||
|
||||
glRasterPos2f(0.0f,0.0f);
|
||||
|
||||
glGetFloatv(GL_CURRENT_RASTER_POSITION, rasterPosition);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, rasterPosition[0], 0.01);
|
||||
|
||||
FTGLBitmapFont* bitmapFont = new FTGLBitmapFont( FONT_FILE);
|
||||
bitmapFont->FaceSize(18);
|
||||
|
||||
bitmapFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
bitmapFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glGetFloatv(GL_CURRENT_RASTER_POSITION, rasterPosition);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 122, rasterPosition[0], 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, rasterPosition[1], 0.01);
|
||||
}
|
||||
|
||||
|
||||
void testDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLBitmapFont* bitmapFont = new FTGLBitmapFont( FONT_FILE);
|
||||
bitmapFont->FaceSize(18);
|
||||
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
bitmapFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTGLBitmapFontTest);
|
||||
|
||||
104
src/WinLibs/FTGL/test/FTGLExtrdFont.cpp-Test.cpp
Normal file
104
src/WinLibs/FTGL/test/FTGLExtrdFont.cpp-Test.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTGLExtrdFont.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTGLExtrdFontTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTGLExtrdFontTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST( testBadDisplayList);
|
||||
CPPUNIT_TEST( testGoodDisplayList);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTGLExtrdFontTest() : CppUnit::TestCase( "FTGLExtrdFont Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTGLExtrdFontTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTGLExtrdFontTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);
|
||||
CPPUNIT_ASSERT( extrudedFont->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);
|
||||
extrudedFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( extrudedFont->Error() == 0x97); // Invalid pixels per em
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
extrudedFont->FaceSize(18);
|
||||
extrudedFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( extrudedFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testBadDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);
|
||||
extrudedFont->FaceSize(18);
|
||||
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
extrudedFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
void testGoodDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);
|
||||
extrudedFont->FaceSize(18);
|
||||
|
||||
extrudedFont->UseDisplayList(false);
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
extrudedFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTGLExtrdFontTest);
|
||||
|
||||
104
src/WinLibs/FTGL/test/FTGLOutlineFont-Test.cpp
Normal file
104
src/WinLibs/FTGL/test/FTGLOutlineFont-Test.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTGLOutlineFont.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTGLOutlineFontTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTGLOutlineFontTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST( testBadDisplayList);
|
||||
CPPUNIT_TEST( testGoodDisplayList);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTGLOutlineFontTest() : CppUnit::TestCase( "FTGLOutlineFont Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTGLOutlineFontTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTGLOutlineFontTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLOutlineFont* outlineFont = new FTGLOutlineFont( FONT_FILE);
|
||||
CPPUNIT_ASSERT( outlineFont->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLOutlineFont* outlineFont = new FTGLOutlineFont( FONT_FILE);
|
||||
outlineFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( outlineFont->Error() == 0x97); // Invalid pixels per em
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
outlineFont->FaceSize(18);
|
||||
outlineFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( outlineFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testBadDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLOutlineFont* outlineFont = new FTGLOutlineFont( FONT_FILE);
|
||||
outlineFont->FaceSize(18);
|
||||
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
outlineFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
void testGoodDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLOutlineFont* outlineFont = new FTGLOutlineFont( FONT_FILE);
|
||||
outlineFont->FaceSize(18);
|
||||
|
||||
outlineFont->UseDisplayList(false);
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
outlineFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTGLOutlineFontTest);
|
||||
|
||||
85
src/WinLibs/FTGL/test/FTGLPixmapFont-Test.cpp
Normal file
85
src/WinLibs/FTGL/test/FTGLPixmapFont-Test.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTGLPixmapFont.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTGLPixmapFontTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTGLPixmapFontTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST( testDisplayList);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTGLPixmapFontTest() : CppUnit::TestCase( "FTGLPixmapFont Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTGLPixmapFontTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTGLPixmapFontTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLPixmapFont* pixmapFont = new FTGLPixmapFont( FONT_FILE);
|
||||
CPPUNIT_ASSERT( pixmapFont->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLPixmapFont* pixmapFont = new FTGLPixmapFont( FONT_FILE);
|
||||
|
||||
pixmapFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
CPPUNIT_ASSERT( pixmapFont->Error() == 0x97); // Invalid pixels per em
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
pixmapFont->FaceSize(18);
|
||||
pixmapFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( pixmapFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLPixmapFont* pixmapFont = new FTGLPixmapFont( FONT_FILE);
|
||||
pixmapFont->FaceSize(18);
|
||||
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
pixmapFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTGLPixmapFontTest);
|
||||
|
||||
105
src/WinLibs/FTGL/test/FTGLPolygonFont-Test.cpp
Normal file
105
src/WinLibs/FTGL/test/FTGLPolygonFont-Test.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTGLPolygonFont.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTGLPolygonFontTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTGLPolygonFontTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST( testBadDisplayList);
|
||||
CPPUNIT_TEST( testGoodDisplayList);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTGLPolygonFontTest() : CppUnit::TestCase( "FTGLPolygonFont Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTGLPolygonFontTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTGLPolygonFontTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLPolygonFont* polygonFont = new FTGLPolygonFont( FONT_FILE);
|
||||
CPPUNIT_ASSERT( polygonFont->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLPolygonFont* polygonFont = new FTGLPolygonFont( FONT_FILE);
|
||||
|
||||
polygonFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( polygonFont->Error() == 0x97); // Invalid pixels per em
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
polygonFont->FaceSize(18);
|
||||
polygonFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( polygonFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testBadDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLPolygonFont* polygonFont = new FTGLPolygonFont( FONT_FILE);
|
||||
polygonFont->FaceSize(18);
|
||||
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
polygonFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
void testGoodDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLPolygonFont* polygonFont = new FTGLPolygonFont( FONT_FILE);
|
||||
polygonFont->FaceSize(18);
|
||||
|
||||
polygonFont->UseDisplayList(false);
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
polygonFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTGLPolygonFontTest);
|
||||
|
||||
101
src/WinLibs/FTGL/test/FTGLTextureFont-Test.cpp
Normal file
101
src/WinLibs/FTGL/test/FTGLTextureFont-Test.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTGLTextureFont.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTGLTextureFontTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTGLTextureFontTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testResizeBug);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST( testDisplayList);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTGLTextureFontTest() : CppUnit::TestCase( "FTGLTextureFontTest Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTGLTextureFontTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTGLTextureFontTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLTextureFont* textureFont = new FTGLTextureFont( FONT_FILE);
|
||||
CPPUNIT_ASSERT( textureFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testResizeBug()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLTextureFont* textureFont = new FTGLTextureFont( FONT_FILE);
|
||||
CPPUNIT_ASSERT( textureFont->Error() == 0);
|
||||
|
||||
textureFont->FaceSize(18);
|
||||
textureFont->Render("first");
|
||||
|
||||
textureFont->FaceSize(38);
|
||||
textureFont->Render("second");
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLTextureFont* textureFont = new FTGLTextureFont( FONT_FILE);
|
||||
|
||||
textureFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
CPPUNIT_ASSERT( textureFont->Error() == 0x97); // Invalid pixels per em
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
textureFont->FaceSize(18);
|
||||
textureFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
CPPUNIT_ASSERT( textureFont->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void testDisplayList()
|
||||
{
|
||||
buildGLContext();
|
||||
|
||||
FTGLTextureFont* textureFont = new FTGLTextureFont( FONT_FILE);
|
||||
textureFont->FaceSize(18);
|
||||
|
||||
int glList = glGenLists(1);
|
||||
glNewList( glList, GL_COMPILE);
|
||||
|
||||
textureFont->Render(GOOD_ASCII_TEST_STRING);
|
||||
|
||||
glEndList();
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTGLTextureFontTest);
|
||||
|
||||
104
src/WinLibs/FTGL/test/FTGlyph-Test.cpp
Normal file
104
src/WinLibs/FTGL/test/FTGlyph-Test.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTGlyph.h"
|
||||
|
||||
class TestGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
TestGlyph( FT_GlyphSlot glyph)
|
||||
: FTGlyph(glyph)
|
||||
{}
|
||||
|
||||
const FTPoint& Render( const FTPoint& pen) { return advance;};
|
||||
};
|
||||
|
||||
|
||||
class FTGlyphTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTGlyphTest);
|
||||
CPPUNIT_TEST( testBadConstructor);
|
||||
CPPUNIT_TEST( testGoodConstructor);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTGlyphTest() : CppUnit::TestCase( "FTGlyph Test")
|
||||
{}
|
||||
|
||||
FTGlyphTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testBadConstructor()
|
||||
{
|
||||
TestGlyph testGlyph(0);
|
||||
|
||||
FTPoint testPoint;
|
||||
|
||||
CPPUNIT_ASSERT( testPoint == testGlyph.Advance());
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, testGlyph.BBox().upperY, 0.01);
|
||||
|
||||
CPPUNIT_ASSERT( testGlyph.Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testGoodConstructor()
|
||||
{
|
||||
setUpFreetype( CHARACTER_CODE_A);
|
||||
TestGlyph testGlyph(face->glyph);
|
||||
|
||||
FTPoint testPoint(47.0f, 0.0f, 0.0f);
|
||||
|
||||
CPPUNIT_ASSERT( testPoint == testGlyph.Advance());
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 51.39, testGlyph.BBox().upperY, 0.01);
|
||||
|
||||
CPPUNIT_ASSERT( testGlyph.Error() == 0);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype( unsigned int characterIndex)
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, ARIAL_FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
|
||||
loadGlyph( characterIndex);
|
||||
}
|
||||
|
||||
void loadGlyph( unsigned int characterIndex)
|
||||
{
|
||||
long glyphIndex = FT_Get_Char_Index( face, characterIndex);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
FT_Error error = FT_Load_Glyph( face, glyphIndex, FT_LOAD_DEFAULT);
|
||||
assert(!error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTGlyphTest);
|
||||
|
||||
122
src/WinLibs/FTGL/test/FTGlyphContainer-Test.cpp
Normal file
122
src/WinLibs/FTGL/test/FTGlyphContainer-Test.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTFace.h"
|
||||
#include "FTGlyph.h"
|
||||
#include "FTGlyphContainer.h"
|
||||
|
||||
|
||||
class TestGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
TestGlyph()
|
||||
: FTGlyph(0)
|
||||
{
|
||||
advance = FTPoint(50.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
virtual const FTPoint& Render( const FTPoint& pen){ return advance;}
|
||||
};
|
||||
|
||||
|
||||
class FTGlyphContainerTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTGlyphContainerTest);
|
||||
CPPUNIT_TEST( testAdd);
|
||||
CPPUNIT_TEST( testSetCharMap);
|
||||
CPPUNIT_TEST( testGlyphIndex);
|
||||
CPPUNIT_TEST( testAdvance);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTGlyphContainerTest() : CppUnit::TestCase( "FTGlyphContainer Test")
|
||||
{
|
||||
face = new FTFace( GOOD_FONT_FILE);
|
||||
face->Size( 72, 72);
|
||||
}
|
||||
|
||||
FTGlyphContainerTest( const std::string& name) : CppUnit::TestCase(name)
|
||||
{
|
||||
delete face;
|
||||
}
|
||||
|
||||
void testAdd()
|
||||
{
|
||||
TestGlyph* glyph = new TestGlyph();
|
||||
CPPUNIT_ASSERT( glyphContainer->Glyph( CHARACTER_CODE_A) == NULL);
|
||||
|
||||
glyphContainer->Add( glyph, CHARACTER_CODE_A);
|
||||
glyphContainer->Add( NULL, 0);
|
||||
|
||||
CPPUNIT_ASSERT( glyphContainer->Glyph( 0) == NULL);
|
||||
CPPUNIT_ASSERT( glyphContainer->Glyph( 999) == NULL);
|
||||
CPPUNIT_ASSERT( glyphContainer->Glyph( CHARACTER_CODE_A) == glyph);
|
||||
}
|
||||
|
||||
|
||||
void testSetCharMap()
|
||||
{
|
||||
CPPUNIT_ASSERT( glyphContainer->CharMap( ft_encoding_unicode));
|
||||
CPPUNIT_ASSERT( glyphContainer->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( !glyphContainer->CharMap( ft_encoding_johab));
|
||||
CPPUNIT_ASSERT( glyphContainer->Error() == 0x06); // invalid argument
|
||||
}
|
||||
|
||||
|
||||
void testGlyphIndex()
|
||||
{
|
||||
CPPUNIT_ASSERT( glyphContainer->FontIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
|
||||
CPPUNIT_ASSERT( glyphContainer->FontIndex( BIG_CHARACTER_CODE) == BIG_FONT_INDEX);
|
||||
}
|
||||
|
||||
|
||||
void testAdvance()
|
||||
{
|
||||
TestGlyph* glyph = new TestGlyph();
|
||||
|
||||
glyphContainer->Add( glyph, CHARACTER_CODE_A);
|
||||
float advance = glyphContainer->Advance( CHARACTER_CODE_A, 0);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 50, advance, 0.01);
|
||||
}
|
||||
|
||||
|
||||
void testRender()
|
||||
{
|
||||
TestGlyph* glyph = new TestGlyph();
|
||||
|
||||
glyphContainer->Add( glyph, 'A');
|
||||
|
||||
FTPoint pen;
|
||||
|
||||
float advance = glyphContainer->Render( 'A', 0, pen).X();
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 50, advance, 0.01);
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{
|
||||
glyphContainer = new FTGlyphContainer( face);
|
||||
}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
delete glyphContainer;
|
||||
}
|
||||
|
||||
private:
|
||||
FTFace* face;
|
||||
FTGlyphContainer* glyphContainer;
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTGlyphContainerTest);
|
||||
|
||||
51
src/WinLibs/FTGL/test/FTLibrary-Test.cpp
Normal file
51
src/WinLibs/FTGL/test/FTLibrary-Test.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "FTLibrary.h"
|
||||
|
||||
class FTLibraryTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTLibraryTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testError);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTLibraryTest() : CppUnit::TestCase( "FTLibrary Test")
|
||||
{}
|
||||
|
||||
FTLibraryTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
const FTLibrary& libraryOne = FTLibrary::Instance();
|
||||
const FTLibrary& libraryTwo = FTLibrary::Instance();
|
||||
|
||||
CPPUNIT_ASSERT( &libraryOne == &libraryTwo);
|
||||
CPPUNIT_ASSERT( &libraryOne == &FTLibrary::Instance());
|
||||
}
|
||||
|
||||
|
||||
void testError()
|
||||
{
|
||||
const FTLibrary& library = FTLibrary::Instance();
|
||||
|
||||
CPPUNIT_ASSERT( library.Error() == 0);
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTLibraryTest);
|
||||
|
||||
81
src/WinLibs/FTGL/test/FTList-Test.cpp
Normal file
81
src/WinLibs/FTGL/test/FTList-Test.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "FTList.h"
|
||||
|
||||
|
||||
class FTListTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTListTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testPushBack);
|
||||
CPPUNIT_TEST( testGetBack);
|
||||
CPPUNIT_TEST( testGetFront);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTListTest() : CppUnit::TestCase( "FTList Test")
|
||||
{}
|
||||
|
||||
FTListTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
FTList<float> listOfFloats;
|
||||
|
||||
CPPUNIT_ASSERT( listOfFloats.size() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testPushBack()
|
||||
{
|
||||
FTList<float> listOfFloats;
|
||||
|
||||
CPPUNIT_ASSERT( listOfFloats.size() == 0);
|
||||
|
||||
listOfFloats.push_back( 0.1);
|
||||
listOfFloats.push_back( 1.2);
|
||||
listOfFloats.push_back( 2.3);
|
||||
|
||||
CPPUNIT_ASSERT( listOfFloats.size() == 3);
|
||||
}
|
||||
|
||||
|
||||
void testGetBack()
|
||||
{
|
||||
FTList<int> listOfIntegers;
|
||||
|
||||
listOfIntegers.push_back( 0);
|
||||
listOfIntegers.push_back( 1);
|
||||
listOfIntegers.push_back( 2);
|
||||
|
||||
CPPUNIT_ASSERT( listOfIntegers.back() == 2);
|
||||
}
|
||||
|
||||
|
||||
void testGetFront()
|
||||
{
|
||||
FTList<char> listOfChars;
|
||||
|
||||
listOfChars.push_back( 'a');
|
||||
listOfChars.push_back( 'b');
|
||||
listOfChars.push_back( 'c');
|
||||
|
||||
CPPUNIT_ASSERT( listOfChars.front() == 'a');
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTListTest);
|
||||
|
||||
142
src/WinLibs/FTGL/test/FTMesh-Test.cpp
Normal file
142
src/WinLibs/FTGL/test/FTMesh-Test.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "FTVectoriser.h"
|
||||
|
||||
|
||||
void CALLBACK ftglError( GLenum errCode, FTMesh* mesh);
|
||||
void CALLBACK ftglVertex( void* data, FTMesh* mesh);
|
||||
void CALLBACK ftglBegin( GLenum type, FTMesh* mesh);
|
||||
void CALLBACK ftglEnd( FTMesh* mesh);
|
||||
void CALLBACK ftglCombine( FTGL_DOUBLE coords[3], void* vertex_data[4], GLfloat weight[4], void** outData, FTMesh* mesh);
|
||||
|
||||
|
||||
static float POINT_DATA[] =
|
||||
{
|
||||
10, 3, 0.7,
|
||||
-53, 2000, 23,
|
||||
77, -2.4, 765,
|
||||
117.5, 0.02, -99,
|
||||
10, 3, -0.87,
|
||||
117.5, 0.02, 34.76,
|
||||
0.27, 44.4, 3000,
|
||||
10, 3, 0
|
||||
};
|
||||
|
||||
class FTMeshTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTMeshTest);
|
||||
CPPUNIT_TEST( testGetTesselation);
|
||||
CPPUNIT_TEST( testAddPoint);
|
||||
CPPUNIT_TEST( testTooManyPoints);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTMeshTest() : CppUnit::TestCase( "FTMesh Test")
|
||||
{}
|
||||
|
||||
FTMeshTest( const std::string& name) : CppUnit::TestCase(name)
|
||||
{}
|
||||
|
||||
void testGetTesselation()
|
||||
{
|
||||
FTMesh mesh;
|
||||
|
||||
CPPUNIT_ASSERT( mesh.Tesselation(0) == NULL);
|
||||
|
||||
ftglBegin( GL_TRIANGLES, &mesh);
|
||||
ftglVertex( &POINT_DATA[0], &mesh);
|
||||
ftglVertex( &POINT_DATA[3], &mesh);
|
||||
ftglVertex( &POINT_DATA[6], &mesh);
|
||||
ftglVertex( &POINT_DATA[9], &mesh);
|
||||
ftglEnd( &mesh);
|
||||
|
||||
CPPUNIT_ASSERT( mesh.Tesselation(0));
|
||||
CPPUNIT_ASSERT( mesh.Tesselation(10) == NULL);
|
||||
}
|
||||
|
||||
|
||||
void testAddPoint()
|
||||
{
|
||||
FTGL_DOUBLE testPoint[3] = { 1, 2, 3};
|
||||
FTGL_DOUBLE* hole[] = { 0, 0, 0, 0};
|
||||
|
||||
FTMesh mesh;
|
||||
CPPUNIT_ASSERT( mesh.TesselationCount() == 0);
|
||||
|
||||
ftglBegin( GL_TRIANGLES, &mesh);
|
||||
ftglVertex( &POINT_DATA[0], &mesh);
|
||||
ftglVertex( &POINT_DATA[3], &mesh);
|
||||
ftglVertex( &POINT_DATA[6], &mesh);
|
||||
ftglVertex( &POINT_DATA[9], &mesh);
|
||||
ftglEnd( &mesh);
|
||||
|
||||
CPPUNIT_ASSERT( mesh.TesselationCount() == 1);
|
||||
CPPUNIT_ASSERT( mesh.Tesselation(0)->PolygonType() == GL_TRIANGLES);
|
||||
CPPUNIT_ASSERT( mesh.Tesselation(0)->PointCount() == 4);
|
||||
CPPUNIT_ASSERT( mesh.Error() == 0);
|
||||
|
||||
ftglBegin( GL_QUADS, &mesh);
|
||||
ftglVertex( &POINT_DATA[12], &mesh);
|
||||
ftglVertex( &POINT_DATA[15], &mesh);
|
||||
ftglError( 2, &mesh);
|
||||
ftglVertex( &POINT_DATA[18], &mesh);
|
||||
ftglCombine( testPoint, NULL, NULL, (void**)hole, &mesh);
|
||||
ftglVertex( &POINT_DATA[21], &mesh);
|
||||
ftglError( 3, &mesh);
|
||||
ftglEnd( &mesh);
|
||||
|
||||
CPPUNIT_ASSERT( mesh.TesselationCount() == 2);
|
||||
CPPUNIT_ASSERT( mesh.Tesselation(0)->PointCount() == 4);
|
||||
CPPUNIT_ASSERT( mesh.Tesselation(1)->PolygonType() == GL_QUADS);
|
||||
CPPUNIT_ASSERT( mesh.Tesselation(1)->PointCount() == 4);
|
||||
CPPUNIT_ASSERT( mesh.Error() == 3);
|
||||
|
||||
CPPUNIT_ASSERT( mesh.TesselationCount() == 2);
|
||||
}
|
||||
|
||||
|
||||
void testTooManyPoints()
|
||||
{
|
||||
FTGL_DOUBLE testPoint[3] = { 1, 2, 3};
|
||||
|
||||
FTGL_DOUBLE* testOutput[] = { 0, 0, 0, 0};
|
||||
FTGL_DOUBLE* hole[] = { 0, 0, 0, 0};
|
||||
|
||||
FTMesh mesh;
|
||||
unsigned int x;
|
||||
|
||||
ftglBegin( GL_TRIANGLES, &mesh);
|
||||
ftglCombine( testPoint, NULL, NULL, (void**)testOutput, &mesh);
|
||||
|
||||
for( x = 0; x < 200; ++x)
|
||||
{
|
||||
ftglCombine( testPoint, NULL, NULL, (void**)hole, &mesh);
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT( *testOutput == static_cast<const FTGL_DOUBLE*>(mesh.TempPointList().front()));
|
||||
|
||||
for( x = 201; x < 300; ++x)
|
||||
{
|
||||
ftglCombine( testPoint, NULL, NULL, (void**)hole, &mesh);
|
||||
}
|
||||
|
||||
ftglEnd( &mesh);
|
||||
|
||||
CPPUNIT_ASSERT( *testOutput == static_cast<const FTGL_DOUBLE*>(mesh.TempPointList().front()));
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTMeshTest);
|
||||
|
||||
89
src/WinLibs/FTGL/test/FTOutlineGlyph-Test.cpp
Normal file
89
src/WinLibs/FTGL/test/FTOutlineGlyph-Test.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTOutlineGlyph.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTOutlineGlyphTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTOutlineGlyphTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTOutlineGlyphTest() : CppUnit::TestCase( "FTOutlineGlyph Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTOutlineGlyphTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTOutlineGlyphTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
FTOutlineGlyph* outlineGlyph = new FTOutlineGlyph( face->glyph, true);
|
||||
CPPUNIT_ASSERT( outlineGlyph->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
FTOutlineGlyph* outlineGlyph = new FTOutlineGlyph( face->glyph, true);
|
||||
outlineGlyph->Render(FTPoint( 0, 0, 0));
|
||||
CPPUNIT_ASSERT( outlineGlyph->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
error = FT_Load_Char( face, CHARACTER_CODE_A, FT_LOAD_DEFAULT);
|
||||
assert( !error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTOutlineGlyphTest);
|
||||
|
||||
97
src/WinLibs/FTGL/test/FTPixmapGlyph-Test.cpp
Normal file
97
src/WinLibs/FTGL/test/FTPixmapGlyph-Test.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTPixmapGlyph.h"
|
||||
|
||||
#define GL_ASSERT() {GLenum sci_err; while ((sci_err = glGetError()) != GL_NO_ERROR) \
|
||||
std::cerr << "OpenGL error: " << (char *)gluErrorString(sci_err) << " at " << __FILE__ <<":" << __LINE__ << std::endl;}
|
||||
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTPixmapGlyphTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTPixmapGlyphTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTPixmapGlyphTest() : CppUnit::TestCase( "FTPixmapGlyph Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTPixmapGlyphTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTPixmapGlyphTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
FTPixmapGlyph* PixmapGlyph = new FTPixmapGlyph( face->glyph);
|
||||
CPPUNIT_ASSERT( PixmapGlyph->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
FTPixmapGlyph* pixmapGlyph = new FTPixmapGlyph( face->glyph);
|
||||
CPPUNIT_ASSERT( pixmapGlyph->Error() == 0);
|
||||
pixmapGlyph->Render(FTPoint( 0, 0, 0));
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
error = FT_Load_Char( face, CHARACTER_CODE_A, FT_LOAD_DEFAULT);
|
||||
assert( !error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTPixmapGlyphTest);
|
||||
|
||||
162
src/WinLibs/FTGL/test/FTPoint-Test.cpp
Normal file
162
src/WinLibs/FTGL/test/FTPoint-Test.cpp
Normal file
@ -0,0 +1,162 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "FTPoint.h"
|
||||
|
||||
|
||||
class FTPointTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTPointTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testOperatorEqual);
|
||||
CPPUNIT_TEST( testOperatorPlus);
|
||||
CPPUNIT_TEST( testOperatorMultiply);
|
||||
CPPUNIT_TEST( testOperatorNotEqual);
|
||||
CPPUNIT_TEST( testOperatorPlusEquals);
|
||||
CPPUNIT_TEST( testOperatorDouble);
|
||||
CPPUNIT_TEST( testSetters);
|
||||
CPPUNIT_TEST( testGetters);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTPointTest() : CppUnit::TestCase( "FTPoint Test")
|
||||
{}
|
||||
|
||||
FTPointTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
FTPoint point1;
|
||||
|
||||
CPPUNIT_ASSERT( point1.X() == 0.0f);
|
||||
CPPUNIT_ASSERT( point1.Y() == 0.0f);
|
||||
CPPUNIT_ASSERT( point1.Z() == 0.0f);
|
||||
|
||||
FTPoint point2( 1.0f, 2.0f, 3.0f);
|
||||
|
||||
CPPUNIT_ASSERT( point2.X() == 1.0f);
|
||||
CPPUNIT_ASSERT( point2.Y() == 2.0f);
|
||||
CPPUNIT_ASSERT( point2.Z() == 3.0f);
|
||||
|
||||
FT_Vector ftVector;
|
||||
ftVector.x = 4;
|
||||
ftVector.y = 23;
|
||||
|
||||
FTPoint point3( ftVector);
|
||||
|
||||
CPPUNIT_ASSERT( point3.X() == 4.0f);
|
||||
CPPUNIT_ASSERT( point3.Y() == 23.0f);
|
||||
CPPUNIT_ASSERT( point3.Z() == 0.0f);
|
||||
}
|
||||
|
||||
|
||||
void testOperatorEqual()
|
||||
{
|
||||
FTPoint point1( 1.0f, 2.0f, 3.0f);
|
||||
FTPoint point2( 1.0f, 2.0f, 3.0f);
|
||||
FTPoint point3( -1.0f, 2.3f, 23.0f);
|
||||
|
||||
CPPUNIT_ASSERT( point1 == point1);
|
||||
CPPUNIT_ASSERT( point1 == point2);
|
||||
CPPUNIT_ASSERT( !(point1 == point3));
|
||||
}
|
||||
|
||||
|
||||
void testOperatorNotEqual()
|
||||
{
|
||||
FTPoint point1( 1.0f, 2.0f, 3.0f);
|
||||
FTPoint point2( 1.0f, 2.0f, 3.0f);
|
||||
FTPoint point3( -1.0f, 2.3f, 23.0f);
|
||||
|
||||
CPPUNIT_ASSERT( !(point1 != point1));
|
||||
CPPUNIT_ASSERT( !(point1 != point2));
|
||||
CPPUNIT_ASSERT( point1 != point3);
|
||||
}
|
||||
|
||||
|
||||
void testOperatorPlus()
|
||||
{
|
||||
FTPoint point1( 1.0f, 2.0f, 3.0f);
|
||||
FTPoint point2( 1.0f, 2.0f, 3.0f);
|
||||
|
||||
FTPoint point3( 2.0f, 4.0f, 6.0f);
|
||||
FTPoint point4 = point1 + point2;
|
||||
|
||||
CPPUNIT_ASSERT( point4 == point3);
|
||||
}
|
||||
|
||||
|
||||
void testOperatorMultiply()
|
||||
{
|
||||
FTPoint point1( 1.0f, 2.0f, 3.0f);
|
||||
FTPoint point2( 1.0f, 2.0f, 3.0f);
|
||||
|
||||
FTPoint point3( 2.0f, 4.0f, 6.0f);
|
||||
FTPoint point4 = point1 * 2.0;
|
||||
|
||||
CPPUNIT_ASSERT( point4 == point3);
|
||||
|
||||
point4 = 2.0 * point2;
|
||||
|
||||
CPPUNIT_ASSERT( point4 == point3);
|
||||
}
|
||||
|
||||
|
||||
void testOperatorPlusEquals()
|
||||
{
|
||||
FTPoint point1( 1.0f, 2.0f, 3.0f);
|
||||
FTPoint point2( -2.0f, 21.0f, 0.0f);
|
||||
FTPoint point3( -1.0f, 23.0f, 3.0f);
|
||||
|
||||
point1 += point2;
|
||||
|
||||
CPPUNIT_ASSERT( point1 == point3);
|
||||
}
|
||||
|
||||
|
||||
void testOperatorDouble()
|
||||
{
|
||||
FTPoint point1( 1.0f, 2.0f, 3.0f);
|
||||
|
||||
const double* pointer = static_cast<const double*>(point1);
|
||||
CPPUNIT_ASSERT(pointer[0] == 1.0f);
|
||||
CPPUNIT_ASSERT(pointer[1] == 2.0f);
|
||||
CPPUNIT_ASSERT(pointer[2] == 3.0f);
|
||||
}
|
||||
|
||||
void testSetters()
|
||||
{
|
||||
FTPoint point;
|
||||
FTPoint point1( 1, 2, 3);
|
||||
|
||||
point.X(1);
|
||||
point.Y(2);
|
||||
point.Z(3);
|
||||
|
||||
CPPUNIT_ASSERT(point == point1);
|
||||
}
|
||||
|
||||
void testGetters()
|
||||
{
|
||||
FTPoint point( 1.0f, 2.0f, 3.0f);
|
||||
|
||||
CPPUNIT_ASSERT(point.X() == 1.0);
|
||||
CPPUNIT_ASSERT(point.Y() == 2.0);
|
||||
CPPUNIT_ASSERT(point.Z() == 3.0);
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTPointTest);
|
||||
|
||||
91
src/WinLibs/FTGL/test/FTPolyGlyph-Test.cpp
Normal file
91
src/WinLibs/FTGL/test/FTPolyGlyph-Test.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTPolyGlyph.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTPolyGlyphTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTPolyGlyphTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTPolyGlyphTest() : CppUnit::TestCase( "FTPolyGlyph Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTPolyGlyphTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTPolyGlyphTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
FTPolyGlyph* polyGlyph = new FTPolyGlyph( face->glyph, true);
|
||||
CPPUNIT_ASSERT( polyGlyph->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
FTPolyGlyph* polyGlyph = new FTPolyGlyph( face->glyph, true);
|
||||
polyGlyph->Render(FTPoint( 0, 0, 0));
|
||||
CPPUNIT_ASSERT( polyGlyph->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
error = FT_Load_Char( face, CHARACTER_CODE_A, FT_LOAD_DEFAULT);
|
||||
assert( !error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTPolyGlyphTest);
|
||||
|
||||
94
src/WinLibs/FTGL/test/FTSize-Test.cpp
Normal file
94
src/WinLibs/FTGL/test/FTSize-Test.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTSize.h"
|
||||
|
||||
|
||||
class FTSizeTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTSizeTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testSetCharSize);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTSizeTest() : CppUnit::TestCase( "FTSize Test")
|
||||
{}
|
||||
|
||||
FTSizeTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
FTSize size;
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, size.CharSize(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, size.Ascender(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, size.Descender(), 0.01);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, size.Height(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, size.Width(), 0.01);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, size.Underline(), 0.01);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testSetCharSize()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
FTSize size;
|
||||
|
||||
CPPUNIT_ASSERT( size.CharSize( &face, FONT_POINT_SIZE, RESOLUTION, RESOLUTION));
|
||||
CPPUNIT_ASSERT( size.Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 72, size.CharSize(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 52, size.Ascender(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, size.Descender(), 0.01);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 81.86, size.Height(), 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 76.32, size.Width(), 0.01);
|
||||
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, size.Underline(), 0.01);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, GOOD_FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTSizeTest);
|
||||
|
||||
73
src/WinLibs/FTGL/test/FTTesselation-Test.cpp
Normal file
73
src/WinLibs/FTGL/test/FTTesselation-Test.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "FTVectoriser.h"
|
||||
|
||||
|
||||
class FTTesselationTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTTesselationTest);
|
||||
CPPUNIT_TEST( testAddPoint);
|
||||
CPPUNIT_TEST( testGetPoint);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTTesselationTest() : CppUnit::TestCase( "FTTesselation Test")
|
||||
{}
|
||||
|
||||
FTTesselationTest( const std::string& name) : CppUnit::TestCase(name)
|
||||
{}
|
||||
|
||||
void testAddPoint()
|
||||
{
|
||||
FTTesselation tesselation( 1);
|
||||
|
||||
CPPUNIT_ASSERT( tesselation.PointCount() == 0);
|
||||
|
||||
tesselation.AddPoint( 10, 3, 0.7);
|
||||
tesselation.AddPoint( -53, 2000, 23);
|
||||
tesselation.AddPoint( 77, -2.4, 765);
|
||||
tesselation.AddPoint( 117.5, 0.02, -99);
|
||||
|
||||
CPPUNIT_ASSERT( tesselation.PointCount() == 4);
|
||||
|
||||
tesselation.AddPoint( 10, 3, -0.87);
|
||||
tesselation.AddPoint( 117.5, 0.02, 34.76);
|
||||
tesselation.AddPoint( 0.27, 44.4, 3000);
|
||||
tesselation.AddPoint( 10, 3, 0);
|
||||
|
||||
CPPUNIT_ASSERT( tesselation.PointCount() == 8);
|
||||
}
|
||||
|
||||
|
||||
void testGetPoint()
|
||||
{
|
||||
FTTesselation tesselation(1);
|
||||
|
||||
CPPUNIT_ASSERT( tesselation.PointCount() == 0);
|
||||
|
||||
tesselation.AddPoint( 10, 3, 0.7);
|
||||
tesselation.AddPoint( -53, 2000, 23);
|
||||
tesselation.AddPoint( 77, -2.4, 765);
|
||||
tesselation.AddPoint( 117.5, 0.02, -99);
|
||||
|
||||
CPPUNIT_ASSERT( tesselation.PointCount() == 4);
|
||||
CPPUNIT_ASSERT( tesselation.Point(2) == FTPoint( 77, -2.4, 765));
|
||||
CPPUNIT_ASSERT( tesselation.Point(20) != FTPoint( 77, -2.4, 765));
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTTesselationTest);
|
||||
|
||||
117
src/WinLibs/FTGL/test/FTTextureGlyph-Test.cpp
Normal file
117
src/WinLibs/FTGL/test/FTTextureGlyph-Test.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTTextureGlyph.h"
|
||||
|
||||
extern void buildGLContext();
|
||||
|
||||
class FTTextureGlyphTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTTextureGlyphTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testRender);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTTextureGlyphTest() : CppUnit::TestCase( "FTTextureGlyph Test")
|
||||
{
|
||||
}
|
||||
|
||||
FTTextureGlyphTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
~FTTextureGlyphTest()
|
||||
{
|
||||
}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
GLuint textureID;
|
||||
glGenTextures(1, &textureID);
|
||||
|
||||
char* texture[64*64];
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, textureID);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA, 64, 64, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texture);
|
||||
|
||||
FTTextureGlyph* textureGlyph = new FTTextureGlyph( face->glyph, textureID, 0, 0, 64, 64);
|
||||
|
||||
CPPUNIT_ASSERT( textureGlyph->Error() == 0);
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void testRender()
|
||||
{
|
||||
setUpFreetype();
|
||||
|
||||
buildGLContext();
|
||||
|
||||
GLuint textureID;
|
||||
glGenTextures(1, &textureID);
|
||||
|
||||
char* texture[64*64];
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, textureID);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA, 64, 64, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texture);
|
||||
|
||||
FTTextureGlyph* textureGlyph = new FTTextureGlyph( face->glyph, textureID, 0, 0, 64, 64);
|
||||
textureGlyph->Render(FTPoint( 0, 0, 0));
|
||||
CPPUNIT_ASSERT( textureGlyph->Error() == 0);
|
||||
|
||||
CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
error = FT_Load_Char( face, CHARACTER_CODE_A, FT_LOAD_DEFAULT);
|
||||
assert( !error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTTextureGlyphTest);
|
||||
|
||||
86
src/WinLibs/FTGL/test/FTVector-Test.cpp
Normal file
86
src/WinLibs/FTGL/test/FTVector-Test.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "FTVector.h"
|
||||
|
||||
|
||||
class FTVectorTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTVectorTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST( testReserve);
|
||||
CPPUNIT_TEST( testPushBack);
|
||||
CPPUNIT_TEST( testOperatorSquareBrackets);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTVectorTest() : CppUnit::TestCase( "FTVector Test")
|
||||
{}
|
||||
|
||||
FTVectorTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
FTVector<float> floatVector;
|
||||
|
||||
CPPUNIT_ASSERT( floatVector.size() == 0);
|
||||
CPPUNIT_ASSERT( floatVector.empty());
|
||||
CPPUNIT_ASSERT( floatVector.capacity() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testReserve()
|
||||
{
|
||||
FTVector<float> floatVector;
|
||||
|
||||
floatVector.reserve(128);
|
||||
CPPUNIT_ASSERT( floatVector.capacity() == 256);
|
||||
CPPUNIT_ASSERT( floatVector.empty());
|
||||
CPPUNIT_ASSERT( floatVector.size() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testPushBack()
|
||||
{
|
||||
FTVector<int> integerVector;
|
||||
|
||||
CPPUNIT_ASSERT( integerVector.size() == 0);
|
||||
|
||||
integerVector.push_back(0);
|
||||
integerVector.push_back(1);
|
||||
integerVector.push_back(2);
|
||||
integerVector.push_back(3);
|
||||
|
||||
CPPUNIT_ASSERT( !integerVector.empty());
|
||||
CPPUNIT_ASSERT( integerVector.size() == 4);
|
||||
}
|
||||
|
||||
|
||||
void testOperatorSquareBrackets()
|
||||
{
|
||||
FTVector<int> integerVector;
|
||||
|
||||
integerVector.push_back(1);
|
||||
integerVector.push_back(2);
|
||||
integerVector.push_back(4);
|
||||
integerVector.push_back(8);
|
||||
|
||||
CPPUNIT_ASSERT( integerVector[0] == 1);
|
||||
CPPUNIT_ASSERT( integerVector[2] == 4);
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTVectorTest);
|
||||
|
||||
465
src/WinLibs/FTGL/test/FTVectoriser-Test.cpp
Normal file
465
src/WinLibs/FTGL/test/FTVectoriser-Test.cpp
Normal file
@ -0,0 +1,465 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "FTVectoriser.h"
|
||||
|
||||
|
||||
static double testOutline[] =
|
||||
{
|
||||
28, 0, 0.0,
|
||||
28, 4.53125, 0.0,
|
||||
26.4756, 2.54, 0.0,
|
||||
24.69, 0.99125, 0.0,
|
||||
22.6431, -0.115, 0.0,
|
||||
20.335, -0.77875, 0.0,
|
||||
17.7656, -1, 0.0,
|
||||
16.0434, -0.901563, 0.0,
|
||||
14.3769, -0.60625, 0.0,
|
||||
12.7659, -0.114062, 0.0,
|
||||
11.2106, 0.575, 0.0,
|
||||
9.71094, 1.46094, 0.0,
|
||||
8.30562, 2.52344, 0.0,
|
||||
7.03344, 3.74219, 0.0,
|
||||
5.89437, 5.11719, 0.0,
|
||||
4.88844, 6.64844, 0.0,
|
||||
4.01562, 8.33594, 0.0,
|
||||
3.29, 10.1538, 0.0,
|
||||
2.72563, 12.0759, 0.0,
|
||||
2.3225, 14.1025, 0.0,
|
||||
2.08063, 16.2334, 0.0,
|
||||
2, 18.4688, 0.0,
|
||||
2.07312, 20.6591, 0.0,
|
||||
2.2925, 22.7675, 0.0,
|
||||
2.65812, 24.7941, 0.0,
|
||||
3.17, 26.7388, 0.0,
|
||||
3.82812, 28.6016, 0.0,
|
||||
4.6325, 30.3381, 0.0,
|
||||
5.58313, 31.9041, 0.0,
|
||||
6.68, 33.2994, 0.0,
|
||||
7.92313, 34.5241, 0.0,
|
||||
9.3125, 35.5781, 0.0,
|
||||
10.8088, 36.45, 0.0,
|
||||
12.3725, 37.1281, 0.0,
|
||||
14.0038, 37.6125, 0.0,
|
||||
15.7025, 37.9031, 0.0,
|
||||
17.4688, 38, 0.0,
|
||||
18.7647, 37.9438, 0.0,
|
||||
20.0025, 37.775, 0.0,
|
||||
21.1822, 37.4938, 0.0,
|
||||
22.3038, 37.1, 0.0,
|
||||
23.3672, 36.5938, 0.0,
|
||||
24.3631, 35.9975, 0.0,
|
||||
25.2822, 35.3338, 0.0,
|
||||
26.1244, 34.6025, 0.0,
|
||||
26.8897, 33.8037, 0.0,
|
||||
27.5781, 32.9375, 0.0,
|
||||
27.5781, 51, 0.0,
|
||||
34, 51, 0.0,
|
||||
34, 0, 0.0,
|
||||
8.375, 18.4844, 0.0,
|
||||
8.49312, 15.7491, 0.0,
|
||||
8.8475, 13.3056, 0.0,
|
||||
9.43813, 11.1541, 0.0,
|
||||
10.265, 9.29437, 0.0,
|
||||
11.3281, 7.72656, 0.0,
|
||||
12.5519, 6.44688, 0.0,
|
||||
13.8606, 5.45156, 0.0,
|
||||
15.2544, 4.74062, 0.0,
|
||||
16.7331, 4.31406, 0.0,
|
||||
18.2969, 4.17188, 0.0,
|
||||
19.8669, 4.30781, 0.0,
|
||||
21.3394, 4.71563, 0.0,
|
||||
22.7144, 5.39531, 0.0,
|
||||
23.9919, 6.34688, 0.0,
|
||||
25.1719, 7.57031, 0.0,
|
||||
26.19, 9.07312, 0.0,
|
||||
26.9819, 10.8628, 0.0,
|
||||
27.5475, 12.9394, 0.0,
|
||||
27.8869, 15.3028, 0.0,
|
||||
28, 17.9531, 0.0,
|
||||
27.8847, 20.8591, 0.0,
|
||||
27.5388, 23.4394, 0.0,
|
||||
26.9622, 25.6941, 0.0,
|
||||
26.155, 27.6231, 0.0,
|
||||
25.1172, 29.2266, 0.0,
|
||||
23.9106, 30.5231, 0.0,
|
||||
22.5972, 31.5316, 0.0,
|
||||
21.1769, 32.2519, 0.0,
|
||||
19.6497, 32.6841, 0.0,
|
||||
18.0156, 32.8281, 0.0,
|
||||
16.4203, 32.69, 0.0,
|
||||
14.9344, 32.2756, 0.0,
|
||||
13.5578, 31.585, 0.0,
|
||||
12.2906, 30.6181, 0.0,
|
||||
11.1328, 29.375, 0.0,
|
||||
10.14, 27.8344, 0.0,
|
||||
9.36781, 25.975, 0.0,
|
||||
8.81625, 23.7969, 0.0,
|
||||
8.48531, 21.3, 0.0,
|
||||
8.375, 18.4844, 0.0
|
||||
};
|
||||
|
||||
|
||||
static GLenum testMeshPolygonTypes[] =
|
||||
{
|
||||
GL_TRIANGLE_FAN,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLE_FAN,
|
||||
GL_TRIANGLE_FAN,
|
||||
GL_TRIANGLE_FAN,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLE_FAN,
|
||||
GL_TRIANGLE_STRIP,
|
||||
GL_TRIANGLES
|
||||
};
|
||||
|
||||
|
||||
static unsigned int testMeshPointCount[] =
|
||||
{
|
||||
8, 7, 7, 11, 7, 9, 5, 6, 6, 7, 17, 6, 19, 3,
|
||||
};
|
||||
|
||||
|
||||
static double testMesh[] =
|
||||
{
|
||||
28, 4.53125, 0.0,
|
||||
28, 0, 0.0,
|
||||
34, 0, 0.0,
|
||||
28, 17.9531, 0.0,
|
||||
27.8869, 15.3028, 0.0,
|
||||
27.5475, 12.9394, 0.0,
|
||||
26.9819, 10.8628, 0.0,
|
||||
26.4756, 2.54, 0.0,
|
||||
26.9819, 10.8628, 0.0,
|
||||
26.19, 9.07312, 0.0,
|
||||
26.4756, 2.54, 0.0,
|
||||
25.1719, 7.57031, 0.0,
|
||||
24.69, 0.99125, 0.0,
|
||||
23.9919, 6.34688, 0.0,
|
||||
22.7144, 5.39531, 0.0,
|
||||
24.69, 0.99125, 0.0,
|
||||
22.7144, 5.39531, 0.0,
|
||||
22.6431, -0.115, 0.0,
|
||||
21.3394, 4.71563, 0.0,
|
||||
20.335, -0.77875, 0.0,
|
||||
19.8669, 4.30781, 0.0,
|
||||
18.2969, 4.17188, 0.0,
|
||||
20.335, -0.77875, 0.0,
|
||||
18.2969, 4.17188, 0.0,
|
||||
17.7656, -1, 0.0,
|
||||
16.7331, 4.31406, 0.0,
|
||||
16.0434, -0.901563, 0.0,
|
||||
15.2544, 4.74062, 0.0,
|
||||
14.3769, -0.60625, 0.0,
|
||||
13.8606, 5.45156, 0.0,
|
||||
12.7659, -0.114062, 0.0,
|
||||
12.5519, 6.44688, 0.0,
|
||||
11.3281, 7.72656, 0.0,
|
||||
12.7659, -0.114062, 0.0,
|
||||
11.3281, 7.72656, 0.0,
|
||||
11.2106, 0.575, 0.0,
|
||||
10.265, 9.29437, 0.0,
|
||||
9.71094, 1.46094, 0.0,
|
||||
9.43813, 11.1541, 0.0,
|
||||
8.8475, 13.3056, 0.0,
|
||||
8.81625, 23.7969, 0.0,
|
||||
9.3125, 35.5781, 0.0,
|
||||
8.48531, 21.3, 0.0,
|
||||
7.92313, 34.5241, 0.0,
|
||||
8.375, 18.4844, 0.0,
|
||||
8.30562, 2.52344, 0.0,
|
||||
8.49312, 15.7491, 0.0,
|
||||
9.71094, 1.46094, 0.0,
|
||||
8.8475, 13.3056, 0.0,
|
||||
34, 51, 0.0,
|
||||
27.5781, 51, 0.0,
|
||||
27.8847, 20.8591, 0.0,
|
||||
28, 17.9531, 0.0,
|
||||
34, 0, 0.0,
|
||||
27.5781, 32.9375, 0.0,
|
||||
26.8897, 33.8037, 0.0,
|
||||
26.9622, 25.6941, 0.0,
|
||||
27.5388, 23.4394, 0.0,
|
||||
27.8847, 20.8591, 0.0,
|
||||
27.5781, 51, 0.0,
|
||||
26.155, 27.6231, 0.0,
|
||||
26.9622, 25.6941, 0.0,
|
||||
26.8897, 33.8037, 0.0,
|
||||
26.1244, 34.6025, 0.0,
|
||||
25.2822, 35.3338, 0.0,
|
||||
25.1172, 29.2266, 0.0,
|
||||
22.3038, 37.1, 0.0,
|
||||
22.5972, 31.5316, 0.0,
|
||||
23.3672, 36.5938, 0.0,
|
||||
23.9106, 30.5231, 0.0,
|
||||
24.3631, 35.9975, 0.0,
|
||||
25.1172, 29.2266, 0.0,
|
||||
25.2822, 35.3338, 0.0,
|
||||
11.1328, 29.375, 0.0,
|
||||
12.2906, 30.6181, 0.0,
|
||||
12.3725, 37.1281, 0.0,
|
||||
13.5578, 31.585, 0.0,
|
||||
14.0038, 37.6125, 0.0,
|
||||
14.9344, 32.2756, 0.0,
|
||||
15.7025, 37.9031, 0.0,
|
||||
16.4203, 32.69, 0.0,
|
||||
17.4688, 38, 0.0,
|
||||
18.0156, 32.8281, 0.0,
|
||||
18.7647, 37.9438, 0.0,
|
||||
19.6497, 32.6841, 0.0,
|
||||
20.0025, 37.775, 0.0,
|
||||
21.1769, 32.2519, 0.0,
|
||||
21.1822, 37.4938, 0.0,
|
||||
22.5972, 31.5316, 0.0,
|
||||
22.3038, 37.1, 0.0,
|
||||
10.8088, 36.45, 0.0,
|
||||
9.3125, 35.5781, 0.0,
|
||||
9.36781, 25.975, 0.0,
|
||||
10.14, 27.8344, 0.0,
|
||||
11.1328, 29.375, 0.0,
|
||||
12.3725, 37.1281, 0.0,
|
||||
8.30562, 2.52344, 0.0,
|
||||
7.92313, 34.5241, 0.0,
|
||||
7.03344, 3.74219, 0.0,
|
||||
6.68, 33.2994, 0.0,
|
||||
5.89437, 5.11719, 0.0,
|
||||
5.58313, 31.9041, 0.0,
|
||||
4.88844, 6.64844, 0.0,
|
||||
4.6325, 30.3381, 0.0,
|
||||
4.01562, 8.33594, 0.0,
|
||||
3.82812, 28.6016, 0.0,
|
||||
3.29, 10.1538, 0.0,
|
||||
3.17, 26.7388, 0.0,
|
||||
2.72563, 12.0759, 0.0,
|
||||
2.65812, 24.7941, 0.0,
|
||||
2.3225, 14.1025, 0.0,
|
||||
2.2925, 22.7675, 0.0,
|
||||
2.08063, 16.2334, 0.0,
|
||||
2.07312, 20.6591, 0.0,
|
||||
2, 18.4688, 0.0,
|
||||
9.3125, 35.5781, 0.0,
|
||||
8.81625, 23.7969, 0.0,
|
||||
9.36781, 25.975, 0.0
|
||||
};
|
||||
|
||||
|
||||
class FTVectoriserTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTVectoriserTest);
|
||||
CPPUNIT_TEST( testFreetypeVersion);
|
||||
CPPUNIT_TEST( testNullGlyphProcess);
|
||||
CPPUNIT_TEST( testBadGlyphProcess);
|
||||
CPPUNIT_TEST( testSimpleGlyphProcess);
|
||||
CPPUNIT_TEST( testComplexGlyphProcess);
|
||||
CPPUNIT_TEST( testGetContour);
|
||||
CPPUNIT_TEST( testGetOutline);
|
||||
CPPUNIT_TEST( testGetMesh);
|
||||
CPPUNIT_TEST( testMakeMesh);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTVectoriserTest() : CppUnit::TestCase( "FTVectoriser Test")
|
||||
{}
|
||||
|
||||
FTVectoriserTest( const std::string& name) : CppUnit::TestCase(name)
|
||||
{}
|
||||
|
||||
|
||||
void testFreetypeVersion()
|
||||
{
|
||||
setUpFreetype( NULL_CHARACTER_INDEX);
|
||||
|
||||
FT_Int major;
|
||||
FT_Int minor;
|
||||
FT_Int patch;
|
||||
|
||||
FT_Library_Version( library, &major, &minor, &patch);
|
||||
|
||||
// If you hit these asserts then you have the wrong library version to run the tests.
|
||||
// You can still run the tests but some will fail because the hinter changed in 2.1.4
|
||||
CPPUNIT_ASSERT( major == 2);
|
||||
CPPUNIT_ASSERT( minor == 1);
|
||||
CPPUNIT_ASSERT( patch >= 4);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void testNullGlyphProcess()
|
||||
{
|
||||
FTVectoriser vectoriser( NULL);
|
||||
CPPUNIT_ASSERT( vectoriser.ContourCount() == 0);
|
||||
}
|
||||
|
||||
|
||||
void testBadGlyphProcess()
|
||||
{
|
||||
setUpFreetype( NULL_CHARACTER_INDEX);
|
||||
|
||||
FTVectoriser vectoriser( face->glyph);
|
||||
CPPUNIT_ASSERT( vectoriser.ContourCount() == 0);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void testSimpleGlyphProcess()
|
||||
{
|
||||
setUpFreetype( SIMPLE_CHARACTER_INDEX);
|
||||
|
||||
FTVectoriser vectoriser( face->glyph);
|
||||
|
||||
CPPUNIT_ASSERT( vectoriser.ContourCount() == 2);
|
||||
CPPUNIT_ASSERT( vectoriser.PointCount() == 8);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void testComplexGlyphProcess()
|
||||
{
|
||||
setUpFreetype( COMPLEX_CHARACTER_INDEX);
|
||||
|
||||
FTVectoriser vectoriser( face->glyph);
|
||||
|
||||
CPPUNIT_ASSERT( vectoriser.ContourCount() == 2);
|
||||
CPPUNIT_ASSERT( vectoriser.PointCount() == 91);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void testGetContour()
|
||||
{
|
||||
setUpFreetype( SIMPLE_CHARACTER_INDEX);
|
||||
|
||||
FTVectoriser vectoriser( face->glyph);
|
||||
|
||||
CPPUNIT_ASSERT( vectoriser.Contour(1));
|
||||
CPPUNIT_ASSERT( vectoriser.Contour(99) == NULL);
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void testGetOutline()
|
||||
{
|
||||
setUpFreetype( COMPLEX_CHARACTER_INDEX);
|
||||
|
||||
FTVectoriser vectoriser( face->glyph);
|
||||
|
||||
unsigned int d = 0;
|
||||
for( size_t c = 0; c < vectoriser.ContourCount(); ++c)
|
||||
{
|
||||
const FTContour* contour = vectoriser.Contour(c);
|
||||
|
||||
for( size_t p = 0; p < contour->PointCount(); ++p)
|
||||
{
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( *(testOutline + d), contour->Point(p).X() / 64.0f, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( *(testOutline + d + 1), contour->Point(p).Y() / 64.0f, 0.01);
|
||||
d += 3;
|
||||
}
|
||||
}
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void testGetMesh()
|
||||
{
|
||||
setUpFreetype( SIMPLE_CHARACTER_INDEX);
|
||||
|
||||
FTVectoriser vectoriser( face->glyph);
|
||||
CPPUNIT_ASSERT( vectoriser.GetMesh() == NULL);
|
||||
|
||||
vectoriser.MakeMesh( FTGL_FRONT_FACING);
|
||||
|
||||
CPPUNIT_ASSERT( vectoriser.GetMesh());
|
||||
}
|
||||
|
||||
|
||||
void testMakeMesh()
|
||||
{
|
||||
setUpFreetype( COMPLEX_CHARACTER_INDEX);
|
||||
|
||||
FTVectoriser vectoriser( face->glyph);
|
||||
|
||||
vectoriser.MakeMesh( FTGL_FRONT_FACING);
|
||||
|
||||
int d = 0;
|
||||
const FTMesh* mesh = vectoriser.GetMesh();
|
||||
unsigned int tesselations = mesh->TesselationCount();
|
||||
CPPUNIT_ASSERT( tesselations == 14);
|
||||
|
||||
for( unsigned int index = 0; index < tesselations; ++index)
|
||||
{
|
||||
const FTTesselation* subMesh = mesh->Tesselation( index);
|
||||
|
||||
unsigned int polyType = subMesh->PolygonType();
|
||||
CPPUNIT_ASSERT( testMeshPolygonTypes[index] == polyType);
|
||||
|
||||
unsigned int numberOfVertices = subMesh->PointCount();
|
||||
CPPUNIT_ASSERT( testMeshPointCount[index] == numberOfVertices);
|
||||
|
||||
for( unsigned int x = 0; x < numberOfVertices; ++x)
|
||||
{
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( *(testMesh + d), subMesh->Point(x).X() / 64, 0.01);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL( *(testMesh + d + 1), subMesh->Point(x).Y() / 64, 0.01);
|
||||
d += 3;
|
||||
}
|
||||
}
|
||||
|
||||
tearDownFreetype();
|
||||
}
|
||||
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
||||
void setUpFreetype( unsigned int characterIndex)
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &library);
|
||||
assert(!error);
|
||||
error = FT_New_Face( library, ARIAL_FONT_FILE, 0, &face);
|
||||
assert(!error);
|
||||
|
||||
loadGlyph( characterIndex);
|
||||
}
|
||||
|
||||
void loadGlyph( unsigned int characterIndex)
|
||||
{
|
||||
long glyphIndex = FT_Get_Char_Index( face, characterIndex);
|
||||
|
||||
FT_Set_Char_Size( face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION);
|
||||
|
||||
FT_Error error = FT_Load_Glyph( face, glyphIndex, FT_LOAD_DEFAULT);
|
||||
assert(!error);
|
||||
}
|
||||
|
||||
void tearDownFreetype()
|
||||
{
|
||||
FT_Done_Face( face);
|
||||
FT_Done_FreeType( library);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTVectoriserTest);
|
||||
|
||||
40
src/WinLibs/FTGL/test/FTlayout-Test.cpp
Normal file
40
src/WinLibs/FTGL/test/FTlayout-Test.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
|
||||
#include "Fontdefs.h"
|
||||
#include "layout/FTLayoutFont.h"
|
||||
|
||||
static const int SCRIPT = 2; // arabic
|
||||
|
||||
class FTLayoutTest : public CppUnit::TestCase
|
||||
{
|
||||
CPPUNIT_TEST_SUITE( FTLayoutTest);
|
||||
CPPUNIT_TEST( testConstructor);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
FTLayoutTest() : CppUnit::TestCase( "FTLayout Test")
|
||||
{}
|
||||
|
||||
FTLayoutTest( const std::string& name) : CppUnit::TestCase(name) {}
|
||||
|
||||
void testConstructor()
|
||||
{
|
||||
FTLayoutFont font( FONT_FILE, SCRIPT);
|
||||
CPPUNIT_ASSERT( font.Error() == 0);
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FTLayoutTest);
|
||||
|
||||
39
src/WinLibs/FTGL/test/Fontdefs.h
Normal file
39
src/WinLibs/FTGL/test/Fontdefs.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef __Font_defs__
|
||||
#define __Font_defs__
|
||||
|
||||
|
||||
const char* const BAD_FONT_FILE = "missing_font.ttf";
|
||||
const char* const GOOD_FONT_FILE = "../../test/font_pack/MHei-Medium-Acro";
|
||||
const char* const ARIAL_FONT_FILE = "../../test/font_pack/arial.ttf";
|
||||
const char* const FONT_FILE = "../../test/font_pack/times.ttf";
|
||||
const char* const TYPE1_FONT_FILE = "../../test/font_pack/HPGCalc.pfb";
|
||||
const char* const TYPE1_AFM_FILE = "../../test/font_pack/HPGCalc.afm";
|
||||
|
||||
const char* const GOOD_ASCII_TEST_STRING = "test string";
|
||||
const char* const BAD_ASCII_TEST_STRING = "";
|
||||
const wchar_t GOOD_UNICODE_TEST_STRING[4] = { 0x6FB3, 0x9580, 0x0};
|
||||
const wchar_t* const BAD_UNICODE_TEST_STRING = L"";
|
||||
|
||||
const unsigned int FONT_POINT_SIZE = 72;
|
||||
const unsigned int RESOLUTION = 72;
|
||||
|
||||
const unsigned int CHARACTER_CODE_A = 'A';
|
||||
const unsigned int CHARACTER_CODE_G = 'g';
|
||||
const unsigned int BIG_CHARACTER_CODE = 0x6FB3;
|
||||
const unsigned int NULL_CHARACTER_CODE = 512;
|
||||
const unsigned int NULL_CHARACTER_INDEX = ' ';
|
||||
const unsigned int SIMPLE_CHARACTER_INDEX = 'i';
|
||||
const unsigned int COMPLEX_CHARACTER_INDEX = 'd';
|
||||
|
||||
const unsigned int FONT_INDEX_OF_A = 34;
|
||||
const unsigned int BIG_FONT_INDEX = 4838;
|
||||
const unsigned int NULL_FONT_INDEX = 0;
|
||||
|
||||
const unsigned int NUMBER_OF_GLYPHS = 50;
|
||||
const unsigned int TOO_MANY_GLYPHS = 14100; // MHei-Medium-Acro has 14099
|
||||
|
||||
|
||||
#include "HPGCalc_pfb.cpp"
|
||||
#include "HPGCalc_afm.cpp"
|
||||
|
||||
#endif // __Font_defs__
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user