added polygon extraction
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..adc842d
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,60 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+PROJECT(FTGL)
+SET(CMAKE_MODULE_PATH ${FTGL_SOURCE_DIR})
+
+SET(VERSION_SERIES 2)
+SET(VERSION_MAJOR 1)
+SET(VERSION_MINOR 3)
+SET(FTGL_SOVERSION 1)
+
+FIND_PACKAGE(Freetype REQUIRED) # if it fails, check this: https://bugs.launchpad.net/ubuntu/+source/cmake/+bug/826988
+FIND_PACKAGE(OpenGL REQUIRED)
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/FTFont)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/FTGL)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/FTGlyph)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/FTLayout)
+INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
+
+IF(NOT CMAKE_BUILD_TYPE)
+ SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
+ENDIF(NOT CMAKE_BUILD_TYPE)
+
+# Allow the developer to select if Dynamic or Static libraries are built
+OPTION(BUILD_SHARED_LIBS "Build Shared Libraries" ON)
+IF(BUILD_SHARED_LIBS)
+ SET(LIB_TYPE SHARED)
+ELSE(BUILD_SHARED_LIBS)
+ SET(LIB_TYPE STATIC)
+ ADD_DEFINITIONS(-DFTGL_LIBRARY_STATIC)
+ENDIF(BUILD_SHARED_LIBS)
+
+ADD_CUSTOM_TARGET(doc)
+
+FIND_PACKAGE(Doxygen)
+IF(DOXYGEN_FOUND)
+ ADD_CUSTOM_TARGET(doxygen
+ ${DOXYGEN_EXECUTABLE}
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ COMMENT "Doxygen ...")
+ ADD_DEPENDENCIES(doc doxygen)
+
+ENDIF(DOXYGEN_FOUND)
+
+SUBDIRS(src)
+
+OPTION(BUILD_TESTS "Build Unit Tests" OFF)
+IF(BUILD_TESTS)
+ SUBDIRS(test)
+ENDIF(BUILD_TESTS)
+
+IF(NOT DEFINED FTGL_CMAKE_FINDER_INSTALL_DIR)
+ SET(FTGL_CMAKE_FINDER_INSTALL_DIR "share/cmake-2.8/Modules")
+ENDIF( NOT DEFINED FTGL_CMAKE_FINDER_INSTALL_DIR)
+
+INSTALL(FILES ${PROJECT_SOURCE_DIR}/cmake/FindFTGL.cmake DESTINATION
+ ${CMAKE_INSTALL_PREFIX}/${FTGL_CMAKE_FINDER_INSTALL_DIR})
+
diff --git a/ppa_upload.sh b/ppa_upload.sh
new file mode 100755
index 0000000..dc4a1b2
--- /dev/null
+++ b/ppa_upload.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# build a debian sourcepackage and upload it to the launchpad ppa
+export GPGKEY=DA94BB53
+export DEBEMAIL="richi@paraeasy.ch"
+export DEBFULLNAME="Richard Ulrich"
+rm -r builddeb
+mkdir builddeb
+cd builddeb
+for DISTRIBUTION in precise # oneiric natty maverick
+do
+ FTGLVERSIONSTR=2.1.3~rc5-6polyextr~${DISTRIBUTION}
+ sed -i -e "s/maverick/${DISTRIBUTION}/g" -e "s/natty/${DISTRIBUTION}/g" -e "s/oneiric/${DISTRIBUTION}/g" -e "s/precise/${DISTRIBUTION}/g" debian/changelog
+# rm -rf debian/source
+ dpkg-buildpackage -rfakeroot -S
+ dput ppa:richi-paraeasy/ppa ../ftgl_${FTGLVERSIONSTR}_source.changes
+done
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..9298dfe
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,145 @@
+
+
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/cmake)
+
+
+ADD_DEFINITIONS(-DPACKAGE_VERSION="${VERSION_SERIES}.${VERSION_MAJOR}.${VERSION_MINOR}")
+
+IF(WIN32)
+ ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
+ENDIF()
+
+SET(libftgl_la_SOURCES
+ FTBuffer.cpp
+ FTCharmap.cpp
+ FTCharmap.h
+ FTCharToGlyphIndexMap.h
+ FTCleanup.cpp
+ FTCleanup.h
+ FTContour.cpp
+ FTContour.h
+ FTFace.cpp
+ FTFace.h
+ FTGL.cpp
+ FTGlyphContainer.cpp
+ FTGlyphContainer.h
+ FTInternals.h
+ FTLibrary.cpp
+ FTLibrary.h
+ FTList.h
+ FTPoint.cpp
+ FTSize.cpp
+ FTSize.h
+ FTVector.h
+ FTVectoriser.cpp
+ FTVectoriser.h
+ FTUnicode.h
+)
+
+SET(ftgl_headers
+ FTGL/ftgl.h
+ FTGL/FTBBox.h
+ FTGL/FTBuffer.h
+ FTGL/FTPoint.h
+ FTGL/FTGlyph.h
+ FTGL/FTBitmapGlyph.h
+ FTGL/FTBufferGlyph.h
+ FTGL/FTExtrdGlyph.h
+ FTGL/FTOutlineGlyph.h
+ FTGL/FTPixmapGlyph.h
+ FTGL/FTPolyGlyph.h
+ FTGL/FTTextureGlyph.h
+ FTGL/FTFont.h
+ FTGL/FTGLBitmapFont.h
+ FTGL/FTBufferFont.h
+ FTGL/FTGLExtrdFont.h
+ FTGL/FTGLOutlineFont.h
+ FTGL/FTGLPixmapFont.h
+ FTGL/FTGLPolygonFont.h
+ FTGL/FTGLTextureFont.h
+ FTGL/FTGLTriangleExtractorFont.h
+ FTGL/FTLayout.h
+ FTGL/FTSimpleLayout.h
+)
+
+SET(ftglyph_sources
+ FTGlyph/FTGlyph.cpp
+ FTGlyph/FTGlyphImpl.h
+ FTGlyph/FTGlyphGlue.cpp
+ FTGlyph/FTBitmapGlyph.cpp
+ FTGlyph/FTBitmapGlyphImpl.h
+ FTGlyph/FTBufferGlyph.cpp
+ FTGlyph/FTBufferGlyphImpl.h
+ FTGlyph/FTExtrudeGlyph.cpp
+ FTGlyph/FTExtrudeGlyphImpl.h
+ FTGlyph/FTOutlineGlyph.cpp
+ FTGlyph/FTOutlineGlyphImpl.h
+ FTGlyph/FTPixmapGlyph.cpp
+ FTGlyph/FTPixmapGlyphImpl.h
+ FTGlyph/FTPolygonGlyph.cpp
+ FTGlyph/FTPolygonGlyphImpl.h
+ FTGlyph/FTTextureGlyph.cpp
+ FTGlyph/FTTextureGlyphImpl.h
+ FTGlyph/FTTriangleExtractorGlyph.cpp
+ FTGlyph/FTTriangleExtractorGlyphImpl.h
+)
+
+SET(ftfont_sources
+ FTFont/FTFont.cpp
+ FTFont/FTFontImpl.h
+ FTFont/FTFontGlue.cpp
+ FTFont/FTBitmapFont.cpp
+ FTFont/FTBitmapFontImpl.h
+ FTFont/FTBufferFont.cpp
+ FTFont/FTBufferFontImpl.h
+ FTFont/FTExtrudeFont.cpp
+ FTFont/FTExtrudeFontImpl.h
+ FTFont/FTOutlineFont.cpp
+ FTFont/FTOutlineFontImpl.h
+ FTFont/FTPixmapFont.cpp
+ FTFont/FTPixmapFontImpl.h
+ FTFont/FTPolygonFont.cpp
+ FTFont/FTPolygonFontImpl.h
+ FTFont/FTTextureFont.cpp
+ FTFont/FTTextureFontImpl.h
+ FTFont/FTTriangleExtractorFont.cpp
+ FTFont/FTTriangleExtractorFontImpl.h
+)
+
+SET(ftlayout_sources
+ FTLayout/FTLayout.cpp
+ FTLayout/FTLayoutImpl.h
+ FTLayout/FTLayoutGlue.cpp
+ FTLayout/FTSimpleLayout.cpp
+ FTLayout/FTSimpleLayoutImpl.h
+)
+
+
+ADD_LIBRARY(ftgl ${libftgl_la_SOURCES} ${ftgl_headers} ${ftglyph_sources} ${ftfont_sources} ${ftlayout_sources})
+TARGET_LINK_LIBRARIES(ftgl
+ ${FREETYPE_LIBRARIES}
+ ${OPENGL_LIBRARIES}
+)
+
+IF(NOT BUILD_SHARED_LIBS)
+ TARGET_LINK_LIBRARIES(ftgl ${OPENGL_LIBRARIES})
+ENDIF()
+
+SET_TARGET_PROPERTIES(
+ ftgl
+ PROPERTIES
+ VERSION ${VERSION_SERIES}.${VERSION_MAJOR}.${VERSION_MINOR}
+ SOVERSION ${FTGL_SOVERSION}
+ DEBUG_POSTFIX "d"
+)
+
+INSTALL(TARGETS ftgl
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+
+FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/FTGL/*.h")
+INSTALL(FILES ${files} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/FTGL)
+
diff --git a/src/FTFont/FTPolygonFontImpl.h b/src/FTFont/FTPolygonFontImpl.h
index 3f4f1e2..fc8f13a 100644
--- a/src/FTFont/FTPolygonFontImpl.h
+++ b/src/FTFont/FTPolygonFontImpl.h
@@ -28,6 +28,8 @@
#define __FTPolygonFontImpl__
#include "FTFontImpl.h"
+// std lib
+#include <vector>
class FTGlyph;
@@ -57,6 +59,7 @@ class FTPolygonFontImpl : public FTFontImpl
FTPoint position, FTPoint spacing,
int renderMode);
+
private:
/**
* The outset distance for the font.
diff --git a/src/FTFont/FTTriangleExtractorFont.cpp b/src/FTFont/FTTriangleExtractorFont.cpp
new file mode 100644
index 0000000..e7f6147
--- /dev/null
+++ b/src/FTFont/FTTriangleExtractorFont.cpp
@@ -0,0 +1,118 @@
+/*
+ * FTGL - OpenGL font library
+ *
+ * Copyright (c) 2011 Richard Ulrich <richi@paraeasy.ch>
+ *
+ * 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.
+ */
+
+#include "config.h"
+
+#include "FTGL/ftgl.h"
+
+#include "FTInternals.h"
+#include "FTTriangleExtractorFontImpl.h"
+
+
+//
+// FTTriangleExtractorFont
+//
+
+
+FTTriangleExtractorFont::FTTriangleExtractorFont(char const *fontFilePath, std::vector<float>& triangles) :
+ FTFont(new FTTriangleExtractorFontImpl(this, fontFilePath, triangles))
+{}
+
+
+FTTriangleExtractorFont::FTTriangleExtractorFont(const unsigned char *pBufferBytes,
+ size_t bufferSizeInBytes, std::vector<float>& triangles) :
+ FTFont(new FTTriangleExtractorFontImpl(this, pBufferBytes, bufferSizeInBytes, triangles))
+{}
+
+
+FTTriangleExtractorFont::~FTTriangleExtractorFont()
+{}
+
+
+FTGlyph* FTTriangleExtractorFont::MakeGlyph(FT_GlyphSlot ftGlyph)
+{
+ FTTriangleExtractorFontImpl *myimpl = dynamic_cast<FTTriangleExtractorFontImpl*>(impl);
+ if(!myimpl)
+ {
+ return NULL;
+ }
+
+ return new FTTriangleExtractorGlyph(ftGlyph, myimpl->outset,
+ myimpl->triangles_);
+}
+
+//
+// FTTriangleExtractorFontImpl
+//
+
+
+FTTriangleExtractorFontImpl::FTTriangleExtractorFontImpl(FTFont *ftFont, const char* fontFilePath, std::vector<float>& triangles)
+: FTFontImpl(ftFont, fontFilePath),
+ outset(0.0f),
+ triangles_(triangles)
+{
+ load_flags = FT_LOAD_NO_HINTING;
+}
+
+
+FTTriangleExtractorFontImpl::FTTriangleExtractorFontImpl(FTFont *ftFont,
+ const unsigned char *pBufferBytes,
+ size_t bufferSizeInBytes, std::vector<float>& triangles)
+: FTFontImpl(ftFont, pBufferBytes, bufferSizeInBytes),
+ outset(0.0f),
+ triangles_(triangles)
+{
+ load_flags = FT_LOAD_NO_HINTING;
+}
+
+
+template <typename T>
+inline FTPoint FTTriangleExtractorFontImpl::RenderI(const T* string, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode)
+{
+ FTPoint tmp = FTFontImpl::Render(string, len,
+ position, spacing, renderMode);
+
+ return tmp;
+}
+
+
+FTPoint FTTriangleExtractorFontImpl::Render(const char * string, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode)
+{
+ return RenderI(string, len, position, spacing, renderMode);
+}
+
+
+FTPoint FTTriangleExtractorFontImpl::Render(const wchar_t * string, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode)
+{
+ return RenderI(string, len, position, spacing, renderMode);
+}
+
+
diff --git a/src/FTFont/FTTriangleExtractorFontImpl.h b/src/FTFont/FTTriangleExtractorFontImpl.h
new file mode 100644
index 0000000..0ba8070
--- /dev/null
+++ b/src/FTFont/FTTriangleExtractorFontImpl.h
@@ -0,0 +1,77 @@
+/*
+ * FTGL - OpenGL font library
+ *
+ * Copyright (c) 2011 Richard Ulrich <richi@paraeasy.ch>
+ *
+ * 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.
+ */
+
+#ifndef __FTTriangleExtractorFontImpl__
+#define __FTTriangleExtractorFontImpl__
+
+#include "FTFontImpl.h"
+// std lib
+#include <vector>
+
+class FTGlyph;
+
+class FTTriangleExtractorFontImpl : public FTFontImpl
+{
+ friend class FTTriangleExtractorFont;
+
+ protected:
+ FTTriangleExtractorFontImpl(FTFont *ftFont, const char* fontFilePath, std::vector<float>& triangles);
+
+ FTTriangleExtractorFontImpl(FTFont *ftFont, const unsigned char *pBufferBytes,
+ size_t bufferSizeInBytes, std::vector<float>& triangles);
+
+ /**
+ * Set the outset distance for the font. Only implemented by
+ * FTOutlineFont, FTPolygonFont and FTExtrudeFont
+ *
+ * @param outset The outset distance.
+ */
+ virtual void Outset(float o) { outset = o; }
+
+ virtual FTPoint Render(const char *s, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode);
+
+ virtual FTPoint Render(const wchar_t *s, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode);
+
+
+ private:
+ /**
+ * The outset distance for the font.
+ */
+ float outset;
+
+ std::vector<float>& triangles_;
+
+ /* Internal generic Render() implementation */
+ template <typename T>
+ inline FTPoint RenderI(const T *s, const int len,
+ FTPoint position, FTPoint spacing, int mode);
+};
+
+#endif // __FTPolygonFontImpl__
+
diff --git a/src/FTGL/FTFont.h b/src/FTGL/FTFont.h
index 72480aa..7328410 100644
--- a/src/FTGL/FTFont.h
+++ b/src/FTGL/FTFont.h
@@ -82,6 +82,7 @@ class FTGL_EXPORT FTFont
friend class FTPixmapFont;
friend class FTPolygonFont;
friend class FTTextureFont;
+ friend class FTTriangleExtractorFont;
/**
* Internal FTGL FTFont constructor. For private use only.
diff --git a/src/FTGL/FTGLPolygonFont.h b/src/FTGL/FTGLPolygonFont.h
index 6b6d3b1..b79a923 100644
--- a/src/FTGL/FTGLPolygonFont.h
+++ b/src/FTGL/FTGLPolygonFont.h
@@ -35,6 +35,7 @@
#ifdef __cplusplus
+#include <vector>
/**
* FTPolygonFont is a specialisation of the FTFont class for handling
@@ -68,6 +69,7 @@ class FTGL_EXPORT FTPolygonFont : public FTFont
*/
~FTPolygonFont();
+
protected:
/**
* Construct a glyph of the correct type.
diff --git a/src/FTGL/FTGLTriangleExtractorFont.h b/src/FTGL/FTGLTriangleExtractorFont.h
new file mode 100644
index 0000000..05c2c5b
--- /dev/null
+++ b/src/FTGL/FTGLTriangleExtractorFont.h
@@ -0,0 +1,118 @@
+/*
+ * FTGL - OpenGL font library
+ *
+ * Copyright (c) 2011 Richard Ulrich <richi@paraeasy.ch>
+ *
+ * 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.
+ */
+
+#ifndef __ftgl__
+# warning This header is deprecated. Please use <FTGL/ftgl.h> from now.
+# include <FTGL/ftgl.h>
+#endif
+
+#ifndef __FTTriangleExtractorFont__
+#define __FTTriangleExtractorFont__
+
+#ifdef __cplusplus
+
+#include <vector>
+
+/**
+ * FTPolygonFont is a specialisation of the FTFont class for handling
+ * tesselated Polygon Mesh fonts
+ *
+ * @see FTFont
+ */
+class FTGL_EXPORT FTTriangleExtractorFont : public FTFont
+{
+ public:
+ /**
+ * Open and read a font file. Sets Error flag.
+ *
+ * @param fontFilePath font file path.
+ * @param triangles the container to store the triangle data.
+ */
+ FTTriangleExtractorFont(const char* fontFilePath, std::vector<float>& triangles);
+
+ /**
+ * 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
+ * @param triangles the container to store the triangle data.
+ */
+ FTTriangleExtractorFont(const unsigned char *pBufferBytes,
+ size_t bufferSizeInBytes, std::vector<float>& triangles);
+
+ /**
+ * Destructor
+ */
+ ~FTTriangleExtractorFont();
+
+ protected:
+ /**
+ * Construct a glyph of the correct type.
+ *
+ * Clients must override the function and return their specialised
+ * FTGlyph.
+ *
+ * @param slot A FreeType glyph slot.
+ * @return An FT****Glyph or <code>null</code> on failure.
+ */
+ virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot);
+};
+
+#define FTGLTriangleExtractorFont FTTriangleExtractorFont
+
+#endif //__cplusplus
+
+FTGL_BEGIN_C_DECLS
+
+/**
+ * Create a specialised FTGLfont object for handling tesselated polygon
+ * mesh fonts.
+ *
+ * @param file The font file name.
+ * @return An FTGLfont* object.
+ *
+ * @see FTGLfont
+ */
+FTGL_EXPORT FTGLfont *ftglCreateTriangleExtractorFont(const char *file);
+
+/**
+ * Create a specialised FTGLfont object for handling tesselated polygon
+ * mesh fonts 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 bytes the in-memory buffer
+ * @param len the length of the buffer in bytes
+ * @return An FTGLfont* object.
+ */
+FTGL_EXPORT FTGLfont *ftglCreateTriangleExtractorFontFromMem(const unsigned char *bytes,
+ size_t len);
+
+FTGL_END_C_DECLS
+
+#endif // __FTTriangleExtractorFont__
+
diff --git a/src/FTGL/FTGlyph.h b/src/FTGL/FTGlyph.h
index 855ff70..525a1fe 100644
--- a/src/FTGL/FTGlyph.h
+++ b/src/FTGL/FTGlyph.h
@@ -74,6 +74,7 @@ class FTGL_EXPORT FTGlyph
friend class FTPixmapGlyph;
friend class FTPolygonGlyph;
friend class FTTextureGlyph;
+ friend class FTTriangleExtractorGlyph;
public:
/**
diff --git a/src/FTGL/FTTriangleExtractorGlyph.h b/src/FTGL/FTTriangleExtractorGlyph.h
new file mode 100644
index 0000000..e07d753
--- /dev/null
+++ b/src/FTGL/FTTriangleExtractorGlyph.h
@@ -0,0 +1,97 @@
+/*
+ * FTGL - OpenGL font library
+ *
+ * Copyright (c) 2011 Richard Ulrich <richi@paraeasy.ch>
+ *
+ * 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.
+ */
+
+#ifndef __ftgl__
+# warning This header is deprecated. Please use <FTGL/ftgl.h> from now.
+# include <FTGL/ftgl.h>
+#endif
+
+#ifndef __FTTriangleExtractorGlyph__
+#define __FTTriangleExtractorGlyph__
+
+#ifdef __cplusplus
+
+#include <vector>
+
+/**
+ * FTPolygonGlyph is a specialisation of FTGlyph for creating tessellated
+ * polygon glyphs.
+ */
+class FTGL_EXPORT FTTriangleExtractorGlyph : 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 outset The outset distance
+ * @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.
+ */
+ FTTriangleExtractorGlyph(FT_GlyphSlot glyph, float outset, std::vector<float>& triangles);
+
+ /**
+ * Destructor
+ */
+ virtual ~FTTriangleExtractorGlyph();
+
+ /**
+ * Render this glyph at the current pen position.
+ *
+ * @param pen The current pen position.
+ * @param renderMode Render mode to display
+ * @return The advance distance for this glyph.
+ */
+ virtual const FTPoint& Render(const FTPoint& pen, int renderMode);
+};
+
+#define FTPolyGlyph FTPolygonGlyph
+
+#endif //__cplusplus
+
+FTGL_BEGIN_C_DECLS
+
+/**
+ * Create a specialisation of FTGLglyph for creating tessellated
+ * polygon glyphs.
+ *
+ * @param glyph The Freetype glyph to be processed
+ * @param outset outset contour size
+ * @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.
+ * @return An FTGLglyph* object.
+ */
+FTGL_EXPORT FTGLglyph *ftglCreateTriangleExtractorGlyph(FT_GlyphSlot glyph, float outset,
+ int useDisplayList);
+
+FTGL_END_C_DECLS
+
+#endif // __FTTriangleExtractorGlyph__
+
diff --git a/src/FTGL/ftgl.h b/src/FTGL/ftgl.h
index cb1318f..97bb0e2 100644
--- a/src/FTGL/ftgl.h
+++ b/src/FTGL/ftgl.h
@@ -146,6 +146,7 @@ namespace FTGL
#include <FTGL/FTPixmapGlyph.h>
#include <FTGL/FTPolyGlyph.h>
#include <FTGL/FTTextureGlyph.h>
+#include <FTGL/FTTriangleExtractorGlyph.h>
#include <FTGL/FTFont.h>
#include <FTGL/FTGLBitmapFont.h>
@@ -155,6 +156,7 @@ namespace FTGL
#include <FTGL/FTGLPixmapFont.h>
#include <FTGL/FTGLPolygonFont.h>
#include <FTGL/FTGLTextureFont.h>
+#include <FTGL/FTGLTriangleExtractorFont.h>
#include <FTGL/FTLayout.h>
#include <FTGL/FTSimpleLayout.h>
diff --git a/src/FTGlyph/FTTriangleExtractorGlyph.cpp b/src/FTGlyph/FTTriangleExtractorGlyph.cpp
new file mode 100644
index 0000000..1807a16
--- /dev/null
+++ b/src/FTGlyph/FTTriangleExtractorGlyph.cpp
@@ -0,0 +1,165 @@
+/*
+ * FTGL - OpenGL font library
+ *
+ * Copyright (c) 2011 Richard Ulrich <richi@paraeasy.ch>
+ *
+ * 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.
+ */
+
+#include "config.h"
+
+#include "FTGL/ftgl.h"
+
+#include "FTInternals.h"
+#include "FTTriangleExtractorGlyphImpl.h"
+#include "FTVectoriser.h"
+// std lib
+#include <cassert>
+
+//
+// FTGLTriangleExtractorGlyph
+//
+
+
+FTTriangleExtractorGlyph::FTTriangleExtractorGlyph(FT_GlyphSlot glyph, float outset,
+ std::vector<float>& triangles) :
+ FTGlyph(new FTTriangleExtractorGlyphImpl(glyph, outset, triangles))
+{}
+
+
+FTTriangleExtractorGlyph::~FTTriangleExtractorGlyph()
+{}
+
+
+const FTPoint& FTTriangleExtractorGlyph::Render(const FTPoint& pen, int renderMode)
+{
+ FTTriangleExtractorGlyphImpl *myimpl = dynamic_cast<FTTriangleExtractorGlyphImpl *>(impl);
+ return myimpl->RenderImpl(pen, renderMode);
+}
+
+
+//
+// FTGLTriangleExtractorGlyphImpl
+//
+
+
+FTTriangleExtractorGlyphImpl::FTTriangleExtractorGlyphImpl(FT_GlyphSlot glyph, float _outset,
+ std::vector<float>& triangles)
+: FTGlyphImpl(glyph),
+ triangles_(triangles)
+{
+ if(ft_glyph_format_outline != glyph->format)
+ {
+ err = 0x14; // Invalid_Outline
+ return;
+ }
+
+ vectoriser = new FTVectoriser(glyph);
+
+ if((vectoriser->ContourCount() < 1) || (vectoriser->PointCount() < 3))
+ {
+ delete vectoriser;
+ vectoriser = NULL;
+ return;
+ }
+
+
+ hscale = glyph->face->size->metrics.x_ppem * 64;
+ vscale = glyph->face->size->metrics.y_ppem * 64;
+ outset = _outset;
+}
+
+
+FTTriangleExtractorGlyphImpl::~FTTriangleExtractorGlyphImpl()
+{
+ delete vectoriser;
+}
+
+
+const FTPoint& FTTriangleExtractorGlyphImpl::RenderImpl(const FTPoint& pen,
+ int renderMode)
+{
+ (void)renderMode;
+
+ if(NULL == vectoriser)
+ return advance;
+
+ vectoriser->MakeMesh(1.0, 1, outset);
+ const FTMesh *mesh = vectoriser->GetMesh();
+
+ for(unsigned int t = 0; t < mesh->TesselationCount(); ++t)
+ {
+ const FTTesselation* subMesh = mesh->Tesselation(t);
+ const unsigned int polygonType = subMesh->PolygonType();
+
+ // convert everything to a single triangle strip.
+ // In some cases we have to insert invalid triangles to make a valid strip
+ switch(polygonType)
+ {
+ case GL_TRIANGLE_STRIP:
+ AddVertex(pen, subMesh->Point(0));
+ for(unsigned int i = 0; i < subMesh->PointCount(); ++i)
+ AddVertex(pen, subMesh->Point(i));
+ AddVertex(pen, subMesh->Point(subMesh->PointCount() - 1));
+ break;
+ case GL_TRIANGLES:
+ assert(subMesh->PointCount() % 3 == 0);
+ for(unsigned int i = 0; i < subMesh->PointCount(); i += 3)
+ {
+ AddVertex(pen, subMesh->Point(i));
+ AddVertex(pen, subMesh->Point(i));
+ AddVertex(pen, subMesh->Point(i+1));
+ AddVertex(pen, subMesh->Point(i+2));
+ AddVertex(pen, subMesh->Point(i+2));
+ }
+ break;
+ case GL_TRIANGLE_FAN:
+ {
+ const FTPoint& centerPoint = subMesh->Point(0);
+ AddVertex(pen, centerPoint);
+
+ for(unsigned int i = 1; i < subMesh->PointCount()-1; ++i)
+ {
+ AddVertex(pen, centerPoint);
+ AddVertex(pen, subMesh->Point(i));
+ AddVertex(pen, subMesh->Point(i+1));
+ AddVertex(pen, centerPoint);
+ }
+ AddVertex(pen, centerPoint);
+ break;
+ }
+ default:
+ assert(!"please implement...");
+ ;
+ }
+
+
+ }
+
+ return advance;
+}
+
+void FTTriangleExtractorGlyphImpl::AddVertex(const FTPoint& pen, const FTPoint& point)
+{
+ triangles_.push_back(pen.Xf() + point.Xf() / 64.0);
+ triangles_.push_back(pen.Yf() + point.Yf() / 64.0);
+ triangles_.push_back(pen.Zf());
+}
+
diff --git a/src/FTGlyph/FTTriangleExtractorGlyphImpl.h b/src/FTGlyph/FTTriangleExtractorGlyphImpl.h
new file mode 100644
index 0000000..aede27d
--- /dev/null
+++ b/src/FTGlyph/FTTriangleExtractorGlyphImpl.h
@@ -0,0 +1,59 @@
+/*
+ * FTGL - OpenGL font library
+ *
+ * Copyright (c) 2011 Richard Ulrich <richi@paraeasy.ch>
+ *
+ * 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.
+ */
+
+#ifndef __FTTriangleExtractorGlyphImpl__
+#define __FTTriangleExtractorGlyphImpl__
+
+#include "FTGlyphImpl.h"
+
+class FTVectoriser;
+
+class FTTriangleExtractorGlyphImpl : public FTGlyphImpl
+{
+ friend class FTTriangleExtractorGlyph;
+
+ public:
+ FTTriangleExtractorGlyphImpl(FT_GlyphSlot glyph, float outset,
+ std::vector<float>& triangles);
+
+ virtual ~FTTriangleExtractorGlyphImpl();
+
+ virtual const FTPoint& RenderImpl(const FTPoint& pen, int renderMode);
+
+ private:
+
+ void AddVertex(const FTPoint& pen, const FTPoint& point);
+
+ /**
+ * Private rendering variables.
+ */
+ unsigned int hscale, vscale;
+ FTVectoriser *vectoriser;
+ float outset;
+ std::vector<float>& triangles_;
+};
+
+#endif // __FTTriangleExtractorGlyphImpl__
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..ab10f1a
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,62 @@
+
+FIND_PACKAGE(CxxTest REQUIRED)
+
+INCLUDE_DIRECTORIES(${CXXTEST_INCLUDE_DIRS})
+
+SET(CXXTest_SOURCES
+ $(DEACTIVATED)
+ CXXTest.cpp
+ Fontdefs.h
+ FTBBox-Test.cpp
+ FTBitmapFont-Test.cpp
+ FTBitmapGlyph-Test.cpp
+ FTCharmap-Test.cpp
+ FTCharToGlyphIndexMap-Test.cpp
+ FTContour-Test.cpp
+ FTExtrudeFont-Test.cpp
+ FTExtrudeGlyph-Test.cpp
+ FTFace-Test.cpp
+ FTFont-Test.cpp
+ FTGlyph-Test.cpp
+ FTGlyphContainer-Test.cpp
+ FTlayout-Test.cpp
+ FTLibrary-Test.cpp
+ FTList-Test.cpp
+ FTMesh-Test.cpp
+ FTOutlineFont-Test.cpp
+ FTOutlineGlyph-Test.cpp
+ FTPixmapFont-Test.cpp
+ FTPixmapGlyph-Test.cpp
+ FTPoint-Test.cpp
+ FTPolygonFont-Test.cpp
+ FTPolygonGlyph-Test.cpp
+ FTSize-Test.cpp
+ FTTesselation-Test.cpp
+ FTTextureFont-Test.cpp
+ FTTextureGlyph-Test.cpp
+ FTVectoriser-Test.cpp
+ FTVector-Test.cpp
+ HPGCalc_afm.cpp
+ HPGCalc_pfb.cpp
+)
+
+
+ADD_EXECUTABLE(CXXTest ${CXXTest_SOURCES})
+TARGET_LINK_LIBRARIES(CXXTest
+ ftgl
+ cppunit
+ ${FREETYPE_LIBRARIES}
+ ${OPENGL_LIBRARIES}
+)
+
+SET_TARGET_PROPERTIES(
+ CXXTest
+ PROPERTIES
+ VERSION ${VERSION_SERIES}.${VERSION_MAJOR}.${VERSION_MINOR}
+ SOVERSION ${FTGL_SOVERSION}
+ DEBUG_POSTFIX "d"
+)
+
+
+
+