diff --git a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt index 1ecdd6500b5d4..0ec53c0c880e1 100644 --- a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt +++ b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt @@ -2,6 +2,7 @@ CMAKE_C_COMPILER=clang CMAKE_CXX_COMPILER=clang++ CMAKE_GENERATOR=Ninja builtin_freetype=ON +builtin_ftgl=ON builtin_gif=ON builtin_gl2ps=ON builtin_jpeg=ON diff --git a/builtins/freetype/CMakeLists.txt b/builtins/freetype/CMakeLists.txt index 92a5ba374782c..a9647571bee9a 100644 --- a/builtins/freetype/CMakeLists.txt +++ b/builtins/freetype/CMakeLists.txt @@ -6,8 +6,8 @@ # **PLEASE UPDATE ALSO THE FOLLOWING LINE WHEN UPDATING THE VERSION** # 22 Mar 2026, https://github.com/freetype/freetype/releases/tag/VER-2-14-3 -set(FREETYPE_VERSION 2.14.3) -set(FREETYPE_HASH "e61b31ab26358b946e767ed7eb7f4bb2e507da1cfefeb7a8861ace7fd5c899a1") +set(ROOT_FREETYPE_VERSION 2.14.3) +set(ROOT_FREETYPE_HASH "e61b31ab26358b946e767ed7eb7f4bb2e507da1cfefeb7a8861ace7fd5c899a1") set(FREETYPE_PREFIX ${CMAKE_BINARY_DIR}/builtins/FREETYPE-prefix) @@ -34,8 +34,8 @@ set(FREETYPE_LIBRARY ${FREETYPE_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}freety ExternalProject_Add( BUILTIN_FREETYPE - URL ${lcgpackages}/freetype-${FREETYPE_VERSION}.tar.gz - URL_HASH SHA256=${FREETYPE_HASH} + URL ${lcgpackages}/freetype-${ROOT_FREETYPE_VERSION}.tar.gz + URL_HASH SHA256=${ROOT_FREETYPE_HASH} PREFIX ${FREETYPE_PREFIX} CMAKE_ARGS -G ${CMAKE_GENERATOR} -DCMAKE_POLICY_VERSION_MINIMUM=3.5 @@ -77,7 +77,11 @@ endif() # Set the canonical output of find_package according to # https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names -set(FREETYPE_INCLUDE_DIRS ${incdir} PARENT_SCOPE) -set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY} PARENT_SCOPE) -set(Freetype_FOUND TRUE PARENT_SCOPE) -set(Freetype_VERSION ${FREETYPE_VERSION} PARENT_SCOPE) +# FindFreetype seems quite hacky (non-standard) https://github.com/Kitware/CMake/blob/0ea36ddcf68fc52c0a0cb6035b612817551ca8d7/Modules/FindFreetype.cmake#L120 +set(FREETYPE_INCLUDE_DIRS ${incdir} PARENT_SCOPE) # FindFreetype.cmake seems to define capital (non-standard) +set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY} PARENT_SCOPE) # FindFreetype.cmake seems to define capital (non-standard) +set(FREETYPE_LIBRARY ${FREETYPE_LIBRARY} PARENT_SCOPE) # FindFreetype.cmake seems to read this as HINT (non-standard) +set(Freetype_FOUND TRUE PARENT_SCOPE) # FindFreetype.cmake added with standard case in CMake 3.3 +set(FREETYPE_FOUND TRUE PARENT_SCOPE) # FindFreetype.cmake historical (non-standard, deprecated with 4.2) +set(Freetype_VERSION ${ROOT_FREETYPE_VERSION} PARENT_SCOPE) # FindFreetype.cmake added with standard case in CMake 4.2 +set(FREETYPE_VERSION_STRING ${ROOT_FREETYPE_VERSION} PARENT_SCOPE) # FindFreetype.cmake historical (non-standard, deprecated with 4.2) diff --git a/builtins/ftgl/0001-src-CMakeLists.txt-remove-FTLibrary.h-from-libftgl_l.patch b/builtins/ftgl/0001-src-CMakeLists.txt-remove-FTLibrary.h-from-libftgl_l.patch new file mode 100644 index 0000000000000..4ece6e5eccf75 --- /dev/null +++ b/builtins/ftgl/0001-src-CMakeLists.txt-remove-FTLibrary.h-from-libftgl_l.patch @@ -0,0 +1,25 @@ +From b043877060efafcfa00f1d07c264d69e32e5d3a9 Mon Sep 17 00:00:00 2001 +From: Frank Heckenbach +Date: Tue, 21 May 2019 23:09:18 +0200 +Subject: [PATCH] src/CMakeLists.txt: remove FTLibrary.h from + libftgl_la_SOURCES (it's only in ftgl_headers) + +--- + src/CMakeLists.txt | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 693e49f..b0f26f6 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -26,7 +26,6 @@ SET(libftgl_la_SOURCES + FTGlyphContainer.h + FTInternals.h + FTLibrary.cpp +- FTLibrary.h + FTList.h + FTPoint.cpp + FTSize.cpp +-- +2.34.1 + diff --git a/builtins/ftgl/0002-fix-type-error.patch b/builtins/ftgl/0002-fix-type-error.patch new file mode 100644 index 0000000000000..3ba314b33b884 --- /dev/null +++ b/builtins/ftgl/0002-fix-type-error.patch @@ -0,0 +1,39 @@ +diff --git a/src/FTContour.cpp b/src/FTContour.cpp +index c668d32..ef13576 100644 +--- a/src/FTContour.cpp ++++ b/src/FTContour.cpp +@@ -174,7 +174,7 @@ void FTContour::SetParity(int parity) + } + + +-FTContour::FTContour(FT_Vector* contour, char* tags, unsigned int n) ++FTContour::FTContour(FT_Vector* contour, unsigned char* tags, unsigned int n) + { + FTPoint prev, cur(contour[(n - 1) % n]), next(contour[0]); + double olddir, dir = atan2((next - cur).Y(), (next - cur).X()); +diff --git a/src/FTContour.h b/src/FTContour.h +index d2d187c..dc64e3a 100644 +--- a/src/FTContour.h ++++ b/src/FTContour.h +@@ -52,7 +52,7 @@ class FTContour + * @param pointTags + * @param numberOfPoints + */ +- FTContour(FT_Vector* contour, char* pointTags, unsigned int numberOfPoints); ++ FTContour(FT_Vector* contour, unsigned char* pointTags, unsigned int numberOfPoints); + + /** + * Destructor +diff --git a/src/FTVectoriser.cpp b/src/FTVectoriser.cpp +index 26e7da8..53d738e 100644 +--- a/src/FTVectoriser.cpp ++++ b/src/FTVectoriser.cpp +@@ -168,7 +168,7 @@ void FTVectoriser::ProcessContours() + for(int i = 0; i < ftContourCount; ++i) + { + FT_Vector* pointList = &outline.points[startIndex]; +- char* tagList = &outline.tags[startIndex]; ++ unsigned char* tagList = (unsigned char*)&outline.tags[startIndex]; + + endIndex = outline.contours[i]; + contourLength = (endIndex - startIndex) + 1; diff --git a/builtins/ftgl/CMakeLists.txt b/builtins/ftgl/CMakeLists.txt new file mode 100644 index 0000000000000..c630590fbdcdd --- /dev/null +++ b/builtins/ftgl/CMakeLists.txt @@ -0,0 +1,85 @@ +# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. +# All rights reserved. +# +# For the licensing terms see $ROOTSYS/LICENSE. +# For the list of contributors see $ROOTSYS/README/CREDITS. + +# **PLEASE UPDATE ALSO THE FOLLOWING LINE WHEN UPDATING THE VERSION** +# 7 Feb 2019, https://github.com/frankheckenbach/ftgl/releases/tag/v2.4.0 +set(ROOT_FTGL_VERSION 2.4.0) +set(ROOT_FTGL_HASH "aa97da1c3442a8fd3941037655df18016d70b5266381c81d81e8b5335f196ea8") +# Cherry-pick https://github.com/frankheckenbach/ftgl/commit/835f2ba7911a6c15a1a314d5e3267fa089b5a319 : +set(ROOT_FTGL_PATCH_FILE_1 "${CMAKE_CURRENT_SOURCE_DIR}/0001-src-CMakeLists.txt-remove-FTLibrary.h-from-libftgl_l.patch") +# From https://github.com/frankheckenbach/ftgl/issues/22, see also https://github.com/xmake-io/xmake-repo/pull/9040/changes and https://github.com/root-project/root/commit/a028d13255f0c2d0c84f2e1b99ccb6a112598e0c +set(ROOT_FTGL_PATCH_FILE_2 "${CMAKE_CURRENT_SOURCE_DIR}/0002-fix-type-error.patch") +set(ROOT_FTGL_PREFIX ${CMAKE_BINARY_DIR}/builtins/FTGL-prefix) +set(ROOT_FTGL_LIBRARY ${ROOT_FTGL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}ftgl${CMAKE_STATIC_LIBRARY_SUFFIX}) + +include(ExternalProject) + +# Clear cache variables set by find_package(FTGL) +# to ensure that we use the builtin version +foreach(var FTGL_LIBRARIES FTGL_LIBRARY FTGL_LIBRARY_DEBUG FTGL_LIBRARY_RELEASE FTGL_FOUND FTGL_VERSION FTGL_INCLUDE_DIR FTGL_LIBRARY FTGL_LIBRARIES) + unset(${var}) + unset(${var} CACHE) +endforeach() + +if(WIN32 AND NOT CMAKE_GENERATOR MATCHES Ninja) + if(winrtdebug) + set(ROOT_FTGL_BUILD_COMMAND_FLAGS "--config Debug") + else() + set(ROOT_FTGL_BUILD_COMMAND_FLAGS "--config $,RelWithDebInfo,Release>") + endif() +endif() + +ExternalProject_Add(BUILTIN_FTGL + PREFIX ${ROOT_FTGL_PREFIX} + URL ${lcgpackages}/ftgl-${ROOT_FTGL_VERSION}.tar.gz + URL_HASH SHA256=${ROOT_FTGL_HASH} + PATCH_COMMAND git apply ${ROOT_FTGL_PATCH_FILE_1} ${ROOT_FTGL_PATCH_FILE_2} + + LOG_DOWNLOAD TRUE + LOG_CONFIGURE TRUE + LOG_BUILD TRUE + LOG_INSTALL TRUE + LOG_OUTPUT_ON_FAILURE TRUE + + CMAKE_ARGS -G ${CMAKE_GENERATOR} + -DCMAKE_INSTALL_PREFIX:PATH= + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} + -DBUILD_SHARED_LIBS:BOOL=FALSE + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DFREETYPE_LIBRARY=${FREETYPE_LIBRARY} # Seems to be needed for Win32 (CMake 3.30 Freetype.cmake) + -DFREETYPE_INCLUDE_DIRS=${FREETYPE_INCLUDE_DIRS} # Seems to be needed for Win32 (CMake 3.30 Freetype.cmake) + -DFREETYPE_DIR=${FREETYPE_INCLUDE_DIRS}/../ # Seems to be needed for Win32 (CMake 3.30 Freetype.cmake) + BUILD_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_FTGL_BUILD_COMMAND_FLAGS} + INSTALL_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_FTGL_BUILD_COMMAND_FLAGS} --target install + BUILD_BYPRODUCTS + ${ROOT_FTGL_LIBRARY} + TIMEOUT 600 +) + +file(MAKE_DIRECTORY ${ROOT_FTGL_PREFIX}/include) +add_library(FTGL::FTGL IMPORTED STATIC GLOBAL) +add_dependencies(FTGL::FTGL BUILTIN_FTGL) +set_target_properties(FTGL::FTGL PROPERTIES + IMPORTED_LOCATION ${ROOT_FTGL_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${ROOT_FTGL_PREFIX}/include) +target_compile_definitions(FTGL::FTGL INTERFACE FTGL_LIBRARY_STATIC) # needed for Win32 since public flag is not correctly propagated to parent scope (BUILD_SHARED_LIBS works fine for building but when installing, flag info is lost) +if(builtin_freetype) + add_dependencies(BUILTIN_FTGL BUILTIN_FREETYPE) +endif() +if(builin_zlib) + add_dependencies(BUILTIN_FTGL BUILTIN_ZLIB) +endif() +target_link_libraries(FTGL::FTGL INTERFACE Freetype::Freetype) # private: OpenGL::GL OpenGL::GLU ZLIB::ZLIB + +# Set the canonical output of find_package according to +# https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names +set(FTGL_INCLUDE_DIRS ${ROOT_FTGL_PREFIX}/include PARENT_SCOPE) +set(FTGL_LIBRARIES ${ROOT_FTGL_LIBRARY} PARENT_SCOPE) +set(FTGL_FOUND TRUE PARENT_SCOPE) +set(FTGL_VERSION ${ROOT_FTGL_VERSION} PARENT_SCOPE) diff --git a/cmake/modules/FindFTGL.cmake b/cmake/modules/FindFTGL.cmake index 2b95f826c0909..8f2afc4877fde 100644 --- a/cmake/modules/FindFTGL.cmake +++ b/cmake/modules/FindFTGL.cmake @@ -25,3 +25,12 @@ set(FTGL_LIBRARIES ${FTGL_LIBRARY}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(FTGL DEFAULT_MSG FTGL_INCLUDE_DIR FTGL_LIBRARY) mark_as_advanced(FTGL_FOUND FTGL_INCLUDE_DIR FTGL_LIBRARY) + +if(FTGL_FOUND) + if(NOT TARGET FTGL::FTGL) + add_library(FTGL::FTGL UNKNOWN IMPORTED) + set_target_properties(FTGL::FTGL PROPERTIES + IMPORTED_LOCATION "${FTGL_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${FTGL_INCLUDE_DIRS}") + endif() +endif() diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index ec812855ad905..a3efe5b59ef09 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -818,29 +818,14 @@ if(dcache) endif() #---Check for ftgl if needed---------------------------------------------------------- -if(opengl AND NOT builtin_ftgl) - find_package(FTGL) - if(NOT FTGL_FOUND) - if(fail-on-missing) - message(SEND_ERROR "ftgl library not found and is required ('builtin_ftgl' is OFF). Set variable FTGL_ROOT_DIR to installation location") - else() - message(STATUS "ftgl library not found. Set variable FTGL_ROOT_DIR to point to your installation") - message(STATUS "For the time being switching ON 'builtin_ftgl' option") - set(builtin_ftgl ON CACHE BOOL "Enabled because ftgl not found but opengl requested (${builtin_ftgl_description})" FORCE) - endif() +if(opengl) + ROOT_FIND_REQUIRED_DEP(FTGL builtin_ftgl) + if (builtin_ftgl) + add_subdirectory(builtins/ftgl) + list(APPEND ROOT_BUILTINS BUILTIN_FTGL) endif() -endif() - -if(builtin_ftgl) - # clear variables set to NOTFOUND to allow builtin FTGL to override them - foreach(var FTGL_LIBRARIES FTGL_LIBRARY FTGL_LIBRARY_DEBUG FTGL_LIBRARY_RELEASE) - unset(${var}) - unset(${var} CACHE) - endforeach() - set(FTGL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/graf3d/ftgl/inc) - set(FTGL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/graf3d/ftgl/inc) - set(FTGL_CFLAGS -DBUILTIN_FTGL) - set(FTGL_LIBRARIES FTGL) +elseif(builtin_ftgl) + message(SEND_ERROR "FTGL features enabled with \"builtin_ftgl=ON\" require \"opengl=ON\"") endif() #---Check for R/Rcpp/RInside-------------------------------------------------------------------- diff --git a/graf2d/asimage/CMakeLists.txt b/graf2d/asimage/CMakeLists.txt index 3b5188c126edb..5c45f2bc1ee4d 100644 --- a/graf2d/asimage/CMakeLists.txt +++ b/graf2d/asimage/CMakeLists.txt @@ -26,9 +26,11 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImage -writeEmptyRootPCM LIBRARIES libAfterImage - ${ASEXTRA_LIBRARIES} - ${FREETYPE_LIBRARIES} - ${X11_LIBRARIES} + JPEG::JPEG + PNG::PNG + GIF::GIF + libAfterImage + Freetype::Freetype ZLIB::ZLIB DEPENDENCIES Core @@ -36,7 +38,6 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImage Postscript ) -target_link_libraries(ASImage PRIVATE JPEG::JPEG PNG::PNG GIF::GIF libAfterImage Freetype::Freetype) if (x11) target_link_libraries(ASImage PRIVATE X11::X11) endif() diff --git a/graf3d/CMakeLists.txt b/graf3d/CMakeLists.txt index 983db1dad4713..a3dbf992200d3 100644 --- a/graf3d/CMakeLists.txt +++ b/graf3d/CMakeLists.txt @@ -12,9 +12,6 @@ endif() add_subdirectory(csg) # special CMakeLists.txt if (opengl) - if(builtin_ftgl) - add_subdirectory(ftgl) - endif() if(geom) add_subdirectory(eve) add_subdirectory(gviz3d) diff --git a/graf3d/ftgl/CMakeLists.txt b/graf3d/ftgl/CMakeLists.txt deleted file mode 100644 index 2aeb51f5d7ab3..0000000000000 --- a/graf3d/ftgl/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. -# All rights reserved. -# -# For the licensing terms see $ROOTSYS/LICENSE. -# For the list of contributors see $ROOTSYS/README/CREDITS. - -############################################################################ -# CMakeLists.txt file for building ROOT graf3d/ftgl package -############################################################################ - -if(MACOSX_GLU_DEPRECATED) - add_definitions(-Wno-deprecated-declarations) -endif() - -ROOT_LINKER_LIBRARY(FTGL - src/FTBitmapGlyph.cxx - src/FTCharmap.cxx - src/FTContour.cxx - src/FTExtrdGlyph.cxx - src/FTFace.cxx - src/FTFont.cxx - src/FTGLBitmapFont.cxx - src/FTGLExtrdFont.cxx - src/FTGLOutlineFont.cxx - src/FTGLPixmapFont.cxx - src/FTGLPolygonFont.cxx - src/FTGLTextureFont.cxx - src/FTGlyphContainer.cxx - src/FTGlyph.cxx - src/FTLibrary.cxx - src/FTOutlineGlyph.cxx - src/FTPixmapGlyph.cxx - src/FTPoint.cxx - src/FTPolyGlyph.cxx - src/FTSize.cxx - src/FTTextureGlyph.cxx - src/FTVectoriser.cxx - LIBRARIES - OpenGL::GL - OpenGL::GLU - Freetype::Freetype - ZLIB::ZLIB - BUILTINS - FREETYPE -) - -target_include_directories(FTGL PRIVATE - ${OPENGL_INCLUDE_DIR} - ${CMAKE_SOURCE_DIR}/graf3d/gl/inc -) - -if(builtin_freetype) - add_dependencies(FTGL BUILTIN_FREETYPE) -endif() - -ROOT_INSTALL_HEADERS() diff --git a/graf3d/ftgl/inc/FTBBox.h b/graf3d/ftgl/inc/FTBBox.h deleted file mode 100644 index 64b5d6942e491..0000000000000 --- a/graf3d/ftgl/inc/FTBBox.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef __FTBBox__ -#define __FTBBox__ - -#include -#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. FT_Glyph_Get_CBox() - * - * @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( bbox.xMin) / 64.0f; - lowerY = static_cast( bbox.yMin) / 64.0f; - lowerZ = 0.0f; - upperX = static_cast( bbox.xMax) / 64.0f; - upperY = static_cast( 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__ - diff --git a/graf3d/ftgl/inc/FTBitmapGlyph.h b/graf3d/ftgl/inc/FTBitmapGlyph.h deleted file mode 100644 index a9ee3ccaced97..0000000000000 --- a/graf3d/ftgl/inc/FTBitmapGlyph.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef __FTBitmapGlyph__ -#define __FTBitmapGlyph__ - - -#include -#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 Render 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) override; - - 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__ - diff --git a/graf3d/ftgl/inc/FTCharToGlyphIndexMap.h b/graf3d/ftgl/inc/FTCharToGlyphIndexMap.h deleted file mode 100644 index baff7628049e3..0000000000000 --- a/graf3d/ftgl/inc/FTCharToGlyphIndexMap.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef __FTCharToGlyphIndexMap__ -#define __FTCharToGlyphIndexMap__ - -#include -#include - -#include "FTGL.h" - -/** - * Provides a non-STL alternative to the STL std::map - * 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 = nullptr; - } - - virtual ~FTCharToGlyphIndexMap() - { - if( this->Indices) - { - // Free all buckets - this->clear(); - - // Free main structure - delete [] this->Indices; - this->Indices = nullptr; - } - } - - void clear() - { - if(this->Indices) - { - for( int i = 0; i < FTCharToGlyphIndexMap::NumberOfBuckets; i++) - { - if( this->Indices[i]) - { - delete [] this->Indices[i]; - this->Indices[i] = nullptr; - } - } - } - } - - 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] = nullptr; - } - } - - // 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__ diff --git a/graf3d/ftgl/inc/FTCharmap.h b/graf3d/ftgl/inc/FTCharmap.h deleted file mode 100644 index d83ac58f3c01f..0000000000000 --- a/graf3d/ftgl/inc/FTCharmap.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef __FTCharmap__ -#define __FTCharmap__ - - -#include -#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 true 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__ diff --git a/graf3d/ftgl/inc/FTContour.h b/graf3d/ftgl/inc/FTContour.h deleted file mode 100644 index 15d7e0ccc42c7..0000000000000 --- a/graf3d/ftgl/inc/FTContour.h +++ /dev/null @@ -1,97 +0,0 @@ -#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: - #define FREETYPE_VER_HEX ((FREETYPE_MAJOR << 16) | (FREETYPE_MINOR << 8) | (FREETYPE_PATCH)) - #if FREETYPE_VER_HEX >= 0x20d03 - // enabled from 2.13.3 - using PointTag_t = unsigned char; - #else - using PointTag_t = char; - #endif - #undef FREETYPE_VER_HEX - - /** - * Constructor - * - * @param contour - * @param pointTags - * @param numberOfPoints - */ - FTContour( FT_Vector* contour, PointTag_t* 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 PointVector; - PointVector pointList; - - /** - * 2D array storing values of de Casteljau algorithm. - */ - float controlPoints[4][2]; -}; - -#endif // __FTContour__ diff --git a/graf3d/ftgl/inc/FTExtrdGlyph.h b/graf3d/ftgl/inc/FTExtrdGlyph.h deleted file mode 100644 index 1d77f5d4cc4ff..0000000000000 --- a/graf3d/ftgl/inc/FTExtrdGlyph.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __FTExtrdGlyph__ -#define __FTExtrdGlyph__ - -#include -#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 - * true turns ON display lists. - * false 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) override; - - 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__ - diff --git a/graf3d/ftgl/inc/FTFace.h b/graf3d/ftgl/inc/FTFace.h deleted file mode 100644 index 74ad3d2e1a94d..0000000000000 --- a/graf3d/ftgl/inc/FTFace.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef __FTFace__ -#define __FTFace__ - -#include -#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 auxiliary file to font (e.g., font metrics). - * - * @param fontFilePath auxiliary font file path. - * @return true if file has opened - * successfully. - */ - bool Attach( const char* fontFilePath); - - /** - * Attach auxiliary 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 true 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 FTSize 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__ diff --git a/graf3d/ftgl/inc/FTFont.h b/graf3d/ftgl/inc/FTFont.h deleted file mode 100644 index 8e9f453f29c99..0000000000000 --- a/graf3d/ftgl/inc/FTFont.h +++ /dev/null @@ -1,301 +0,0 @@ -#ifndef __FTFont__ -#define __FTFont__ - -#include -#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 - * MakeGlyph function to create glyphs of the - * appropriate type. - * - * It is good practice after using these functions to test the error - * code returned. FT_Error Error(). 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 auxiliary file to font e.g font metrics. - * - * Note: not all font formats implement this function. - * - * @param fontFilePath auxiliary font file path. - * @return true if file has been attached - * successfully. - */ - bool Attach( const char* fontFilePath); - - /** - * Attach auxiliary 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 true 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 true 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 true 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 true turns ON display lists. - * false 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); - - /** - * Prepare for rendering - */ - virtual void PreRender() { preRenderCalled = true; } - - /** - * Cleanup after rendering - */ - virtual void PostRender() { preRenderCalled = false; } - - /** - * 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 'C' style string to be output. - * @param w_max maximum width of text - * @param w_fade width at which text starts to fade - */ - virtual void Render( const char* string, float w_max, float w_fade ); - - /** - * 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 null 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 - * true turns ON display lists. - * false turns OFF display lists. - */ - bool useDisplayLists; - - /** - * Current error code. Zero means no error. - */ - FT_Error err; - - private: - /** - * Check that the glyph at chr exist. If not load it. - * - * @param chr character index - * @return true if the glyph can be created. - */ - inline bool CheckGlyph( const unsigned int chr); - - /** - * PreRender() was called from outside. Do not call it again - * from Render(), nor call PostRender(). - * User has to call it themselves. - */ - bool preRenderCalled; - - /** - * An object that holds a list of glyphs - */ - FTGlyphContainer* glyphList; - - /** - * Current pen or cursor position; - */ - FTPoint pen; -}; - - -#endif // __FTFont__ - diff --git a/graf3d/ftgl/inc/FTGL.h b/graf3d/ftgl/inc/FTGL.h deleted file mode 100644 index 70bcf1beac47b..0000000000000 --- a/graf3d/ftgl/inc/FTGL.h +++ /dev/null @@ -1,68 +0,0 @@ -#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 -#include "Windows4Root.h" -#endif - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifndef WIN32 - // 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__ diff --git a/graf3d/ftgl/inc/FTGLBitmapFont.h b/graf3d/ftgl/inc/FTGLBitmapFont.h deleted file mode 100644 index 6048d8a5c202e..0000000000000 --- a/graf3d/ftgl/inc/FTGLBitmapFont.h +++ /dev/null @@ -1,59 +0,0 @@ -#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(); - - /** - * Prepare for rendering - */ - virtual void PreRender() override; - - /** - * Cleanup after rendering - */ - virtual void PostRender() override; - - private: - /** - * Construct a FTBitmapGlyph. - * - * @param g The glyph index NOT the char code. - * @return An FTBitmapGlyph or null on failure. - */ - inline virtual FTGlyph* MakeGlyph( unsigned int g) override; - -}; -#endif // __FTGLBitmapFont__ diff --git a/graf3d/ftgl/inc/FTGLExtrdFont.h b/graf3d/ftgl/inc/FTGLExtrdFont.h deleted file mode 100644 index b6f5dcaba6be7..0000000000000 --- a/graf3d/ftgl/inc/FTGLExtrdFont.h +++ /dev/null @@ -1,63 +0,0 @@ -#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) override { depth = d;} - - private: - /** - * Construct a FTPolyGlyph. - * - * @param glyphIndex The glyph index NOT the char code. - * @return An FTExtrdGlyph or null on failure. - */ - inline virtual FTGlyph* MakeGlyph( unsigned int glyphIndex) override; - - /** - * The extrusion distance for the font. - */ - float depth; -}; - - -#endif // __FTGLExtrdFont__ - diff --git a/graf3d/ftgl/inc/FTGLOutlineFont.h b/graf3d/ftgl/inc/FTGLOutlineFont.h deleted file mode 100644 index 843c1b70180ad..0000000000000 --- a/graf3d/ftgl/inc/FTGLOutlineFont.h +++ /dev/null @@ -1,60 +0,0 @@ -#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(); - - /** - * Prepare for rendering - */ - virtual void PreRender() override; - - /** - * Cleanup after rendering - */ - virtual void PostRender() override; - - private: - /** - * Construct a FTOutlineGlyph. - * - * @param g The glyph index NOT the char code. - * @return An FTOutlineGlyph or null on failure. - */ - inline virtual FTGlyph* MakeGlyph( unsigned int g) override; - -}; -#endif // __FTGLOutlineFont__ diff --git a/graf3d/ftgl/inc/FTGLPixmapFont.h b/graf3d/ftgl/inc/FTGLPixmapFont.h deleted file mode 100644 index 319b5230c1aff..0000000000000 --- a/graf3d/ftgl/inc/FTGLPixmapFont.h +++ /dev/null @@ -1,64 +0,0 @@ -#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(); - - /** - * Prepare for rendering - */ - virtual void PreRender() override; - - /** - * Cleanup after rendering - */ - virtual void PostRender() override; - - private: - /** - * Construct a FTPixmapGlyph. - * - * @param g The glyph index NOT the char code. - * @return An FTPixmapGlyph or null on failure. - */ - inline virtual FTGlyph* MakeGlyph( unsigned int g) override; - -}; - - -#endif // __FTGLPixmapFont__ - diff --git a/graf3d/ftgl/inc/FTGLPolygonFont.h b/graf3d/ftgl/inc/FTGLPolygonFont.h deleted file mode 100644 index 0adaf289d7667..0000000000000 --- a/graf3d/ftgl/inc/FTGLPolygonFont.h +++ /dev/null @@ -1,53 +0,0 @@ -#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 null on failure. - */ - inline virtual FTGlyph* MakeGlyph( unsigned int g) override; - -}; - - -#endif // __FTGLPolygonFont__ - diff --git a/graf3d/ftgl/inc/FTGLTextureFont.h b/graf3d/ftgl/inc/FTGLTextureFont.h deleted file mode 100644 index 502a2df6b2466..0000000000000 --- a/graf3d/ftgl/inc/FTGLTextureFont.h +++ /dev/null @@ -1,146 +0,0 @@ -#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 true if size was set correctly - */ - virtual bool FaceSize( const unsigned int size, const unsigned int res = 72) override; - - /** - * Prepare for rendering - */ - virtual void PreRender() override; - - /** - * Cleanup after rendering - */ - virtual void PostRender() override; - - private: - /** - * Construct a FTTextureGlyph. - * - * @param glyphIndex The glyph index NOT the char code. - * @return An FTTextureGlyph or null on failure. - */ - inline virtual FTGlyph* MakeGlyph( unsigned int glyphIndex) override; - - /** - * 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 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__ - - diff --git a/graf3d/ftgl/inc/FTGlyph.h b/graf3d/ftgl/inc/FTGlyph.h deleted file mode 100644 index a13343033c5b7..0000000000000 --- a/graf3d/ftgl/inc/FTGlyph.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef __FTGlyph__ -#define __FTGlyph__ - -#include -#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 render 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 - * true turns ON display lists. - * false 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 - * true turns ON display lists. - * false turns OFF display lists. - */ - bool useDisplayList; - - /** - * Current error code. Zero means no error. - */ - FT_Error err; - - private: - -}; - - -#endif // __FTGlyph__ - diff --git a/graf3d/ftgl/inc/FTGlyphContainer.h b/graf3d/ftgl/inc/FTGlyphContainer.h deleted file mode 100644 index b7994fb09bba4..0000000000000 --- a/graf3d/ftgl/inc/FTGlyphContainer.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef __FTGlyphContainer__ -#define __FTGlyphContainer__ - -#include -#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 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 true 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 null is it hasn't been - * loaded. - */ - FTGlyph* 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__ diff --git a/graf3d/ftgl/inc/FTLibrary.h b/graf3d/ftgl/inc/FTLibrary.h deleted file mode 100644 index 07b0ba759f5e7..0000000000000 --- a/graf3d/ftgl/inc/FTLibrary.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef __FTLibrary__ -#define __FTLibrary__ - -#include -#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 FTLibrary::Instance() function. - * - * Just because this class returns a valid FTLibrary 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... - * err = FTLibrary::Instance().Error(); - * - * @see "Freetype 2 Documentation" - * - */ -class FTGL_EXPORT FTLibrary -{ - public: - /** - * Global acces point to the single FTLibrary object. - * - * @return The global FTLibrary object. - */ - static const FTLibrary& Instance(); - - /** - * Gets a pointer to the native Freetype library. - * - * @return A handle to a FreeType library instance. - */ - const FT_Library* 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 true if the Freetype library was - * successfully initialised, false - * otherwise. - */ - bool Initialise(); - - /** - * Freetype library handle. - */ - FT_Library* library; -// FTC_Manager* manager; - - /** - * Current error code. Zero means no error. - */ - FT_Error err; - -}; - -#endif // __FTLibrary__ diff --git a/graf3d/ftgl/inc/FTList.h b/graf3d/ftgl/inc/FTList.h deleted file mode 100644 index 2a07150fc380b..0000000000000 --- a/graf3d/ftgl/inc/FTList.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef __FTList__ -#define __FTList__ - -#include "FTGL.h" - -/** -* Provides a non-STL alternative to the STL list - */ -template -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(nullptr) - { - tail = nullptr; - 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 == nullptr) - { - 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(nullptr) - {} - - Node( const value_type& item) - : next(nullptr) - { - payload = item; - } - - Node* next; - - value_type payload; - }; - - size_type listSize; - - Node* head; - Node* tail; -}; - -#endif // __FTList__ - diff --git a/graf3d/ftgl/inc/FTOutlineGlyph.h b/graf3d/ftgl/inc/FTOutlineGlyph.h deleted file mode 100644 index 8061fdae370ef..0000000000000 --- a/graf3d/ftgl/inc/FTOutlineGlyph.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __FTOutlineGlyph__ -#define __FTOutlineGlyph__ - -#include -#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 - * true turns ON display lists. - * false 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) override; - - private: - /** - * OpenGL display list - */ - GLuint glList; - -}; - - -#endif // __FTOutlineGlyph__ - diff --git a/graf3d/ftgl/inc/FTPixmapGlyph.h b/graf3d/ftgl/inc/FTPixmapGlyph.h deleted file mode 100644 index e5b3cb5017380..0000000000000 --- a/graf3d/ftgl/inc/FTPixmapGlyph.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __FTPixmapGlyph__ -#define __FTPixmapGlyph__ - - -#include -#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) override; - - // 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__ diff --git a/graf3d/ftgl/inc/FTPoint.h b/graf3d/ftgl/inc/FTPoint.h deleted file mode 100644 index ccd6b29cf0972..0000000000000 --- a/graf3d/ftgl/inc/FTPoint.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef __FTPoint__ -#define __FTPoint__ - -#include -#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 this multiplied by multiplier. - */ - 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 multiplier multiplied by point. - */ - 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__ - diff --git a/graf3d/ftgl/inc/FTPolyGlyph.h b/graf3d/ftgl/inc/FTPolyGlyph.h deleted file mode 100644 index 4692959012a72..0000000000000 --- a/graf3d/ftgl/inc/FTPolyGlyph.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __FTPolyGlyph__ -#define __FTPolyGlyph__ - - -#include -#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 useDisplayList Enable or disable the use of Display Lists for this glyph - * true turns ON display lists. - * false 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) override; - - private: - /** - * OpenGL display list - */ - GLuint glList; - -}; - - -#endif // __FTPolyGlyph__ - diff --git a/graf3d/ftgl/inc/FTSize.h b/graf3d/ftgl/inc/FTSize.h deleted file mode 100644 index c1ca2253e5b28..0000000000000 --- a/graf3d/ftgl/inc/FTSize.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef __FTSize__ -#define __FTSize__ - - -#include -#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 true 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__ - diff --git a/graf3d/ftgl/inc/FTTextureGlyph.h b/graf3d/ftgl/inc/FTTextureGlyph.h deleted file mode 100644 index cb5dcee403d71..0000000000000 --- a/graf3d/ftgl/inc/FTTextureGlyph.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef __FTTextureGlyph__ -#define __FTTextureGlyph__ - - -#include -#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) override; - - /** - * 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 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__ diff --git a/graf3d/ftgl/inc/FTVector.h b/graf3d/ftgl/inc/FTVector.h deleted file mode 100644 index 9bb8fdf184db3..0000000000000 --- a/graf3d/ftgl/inc/FTVector.h +++ /dev/null @@ -1,190 +0,0 @@ -#ifndef __FTVector__ -#define __FTVector__ - -#include "FTGL.h" - -/** - * Provides a non-STL alternative to the STL vector - */ -template -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 = nullptr; - } - - - 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 = nullptr; - } - } - - 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 begin1, end1; - - if( n >= Size) - { - begin1 = this->end(); - end1 = this->begin() + n; - } - else - { - begin1 = this->begin() + n; - end1 = this->end(); - } - - while( begin1 != end1) - { - *begin1++ = 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 begin2 = this->begin(); - iterator end2 = this->end(); - value_type *ptr = new_items; - - while( begin2 != end2) - { - *ptr++ = *begin2++; - } - - if( Capacity) - { - delete [] Items; - } - - Items = new_items; - Capacity = new_capacity; - } - - size_type Capacity; - size_type Size; - value_type* Items; -}; - -#endif // __FTVector__ diff --git a/graf3d/ftgl/inc/FTVectoriser.h b/graf3d/ftgl/inc/FTVectoriser.h deleted file mode 100644 index d93cb880d2cf1..0000000000000 --- a/graf3d/ftgl/inc/FTVectoriser.h +++ /dev/null @@ -1,275 +0,0 @@ -#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 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 TesselationVector; - typedef FTList 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* 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* 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* 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__ diff --git a/graf3d/ftgl/src/FTBitmapGlyph.cxx b/graf3d/ftgl/src/FTBitmapGlyph.cxx deleted file mode 100644 index 22cba13005d8c..0000000000000 --- a/graf3d/ftgl/src/FTBitmapGlyph.cxx +++ /dev/null @@ -1,65 +0,0 @@ -#include - -#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(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; -} diff --git a/graf3d/ftgl/src/FTCharmap.cxx b/graf3d/ftgl/src/FTCharmap.cxx deleted file mode 100644 index c4ca147eaf2cd..0000000000000 --- a/graf3d/ftgl/src/FTCharmap.cxx +++ /dev/null @@ -1,62 +0,0 @@ -#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); -} diff --git a/graf3d/ftgl/src/FTContour.cxx b/graf3d/ftgl/src/FTContour.cxx deleted file mode 100644 index 4234cdebe336b..0000000000000 --- a/graf3d/ftgl/src/FTContour.cxx +++ /dev/null @@ -1,147 +0,0 @@ -#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(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(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, PointTag_t* pointTags, unsigned int numberOfPoints) -{ - for( unsigned int pointIndex = 0; pointIndex < numberOfPoints; ++ pointIndex) - { - PointTag_t 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) - { - PointTag_t 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 nextPoint1 = ( 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] = nextPoint1.X(); controlPoints[3][1] = nextPoint1.Y(); - - evaluateCubicCurve(); - ++pointIndex; - continue; - } - } -} diff --git a/graf3d/ftgl/src/FTExtrdGlyph.cxx b/graf3d/ftgl/src/FTExtrdGlyph.cxx deleted file mode 100644 index 82fefb4b885b0..0000000000000 --- a/graf3d/ftgl/src/FTExtrdGlyph.cxx +++ /dev/null @@ -1,173 +0,0 @@ -#include - -#include - -#include "FTExtrdGlyph.h" -#include "FTVectoriser.h" - - -FTExtrdGlyph::FTExtrdGlyph( FT_GlyphSlot glyph, float depth, bool useDisplayList1) -: 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(useDisplayList1) - { - 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(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(useDisplayList1) - { - 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); -} - diff --git a/graf3d/ftgl/src/FTFace.cxx b/graf3d/ftgl/src/FTFace.cxx deleted file mode 100644 index 166207ca05b90..0000000000000 --- a/graf3d/ftgl/src/FTFace.cxx +++ /dev/null @@ -1,126 +0,0 @@ -#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( kernAdvance.x) / 64.0f; - y = static_cast( 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; -} diff --git a/graf3d/ftgl/src/FTFont.cxx b/graf3d/ftgl/src/FTFont.cxx deleted file mode 100644 index 880d7ad6b16a0..0000000000000 --- a/graf3d/ftgl/src/FTFont.cxx +++ /dev/null @@ -1,342 +0,0 @@ -#include "FTFace.h" -#include "FTFont.h" -#include "FTGlyphContainer.h" -#include "FTBBox.h" - - -FTFont::FTFont( const char* fontFilePath) -: face( fontFilePath), - useDisplayLists(true), - preRenderCalled(false), - 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 ) -{ - bool pre_post = ! preRenderCalled; - if (pre_post) PreRender(); - - 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; - } - - if (pre_post) PostRender(); -} - - -void FTFont::Render( const char* string, float w_max, float w_fade ) -{ - bool pre_post = ! preRenderCalled; - if (pre_post) PreRender(); - - float col[4]; - glGetFloatv(GL_CURRENT_COLOR, col); - float alpha_fac = col[3] / (w_max - w_fade); - float w = 0; - - 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); - w += pen.X(); - if(w > w_max) - break; - if(w > w_fade) - { - col[3] = alpha_fac * (w_max - w); - glColor4fv(col); - } - } - ++c; - } - - if (pre_post) PostRender(); -} - - -void FTFont::Render( const wchar_t* string ) -{ - bool pre_post = ! preRenderCalled; - if (pre_post) PreRender(); - - const wchar_t* c = string; - pen.X(0); pen.Y(0); - - while( *c) - { - if(CheckGlyph( *c)) - { - pen = glyphList->Render( *c, *(c + 1), pen); - } - ++c; - } - - if (pre_post) PostRender(); -} - - -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; -} - diff --git a/graf3d/ftgl/src/FTGLBitmapFont.cxx b/graf3d/ftgl/src/FTGLBitmapFont.cxx deleted file mode 100644 index 1e19dbf26ce98..0000000000000 --- a/graf3d/ftgl/src/FTGLBitmapFont.cxx +++ /dev/null @@ -1,52 +0,0 @@ -#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::PreRender() -{ - FTFont::PreRender(); - 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); -} - - -void FTGLBitmapFont::PostRender() -{ - glPopAttrib(); - glPopClientAttrib(); - FTFont::PostRender(); -} diff --git a/graf3d/ftgl/src/FTGLExtrdFont.cxx b/graf3d/ftgl/src/FTGLExtrdFont.cxx deleted file mode 100644 index 7bd0ff7851fa6..0000000000000 --- a/graf3d/ftgl/src/FTGLExtrdFont.cxx +++ /dev/null @@ -1,35 +0,0 @@ -#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; -} - - diff --git a/graf3d/ftgl/src/FTGLOutlineFont.cxx b/graf3d/ftgl/src/FTGLOutlineFont.cxx deleted file mode 100644 index 5863a339f7d1d..0000000000000 --- a/graf3d/ftgl/src/FTGLOutlineFont.cxx +++ /dev/null @@ -1,52 +0,0 @@ -#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::PreRender() -{ - FTFont::PreRender(); - 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 -} - - -void FTGLOutlineFont::PostRender() -{ - glPopAttrib(); - FTFont::PostRender(); -} diff --git a/graf3d/ftgl/src/FTGLPixmapFont.cxx b/graf3d/ftgl/src/FTGLPixmapFont.cxx deleted file mode 100644 index 605a68ae0700a..0000000000000 --- a/graf3d/ftgl/src/FTGLPixmapFont.cxx +++ /dev/null @@ -1,62 +0,0 @@ -#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::PreRender() -{ - FTFont::PreRender(); - 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); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GEQUAL, 0.0625); - - 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]); -} - - -void FTGLPixmapFont::PostRender() -{ - glPopClientAttrib(); - glPopAttrib(); - FTFont::PostRender(); -} diff --git a/graf3d/ftgl/src/FTGLPolygonFont.cxx b/graf3d/ftgl/src/FTGLPolygonFont.cxx deleted file mode 100644 index 47a8af41a1bf7..0000000000000 --- a/graf3d/ftgl/src/FTGLPolygonFont.cxx +++ /dev/null @@ -1,33 +0,0 @@ -#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; -} - - diff --git a/graf3d/ftgl/src/FTGLTextureFont.cxx b/graf3d/ftgl/src/FTGLTextureFont.cxx deleted file mode 100644 index 24924024b55a6..0000000000000 --- a/graf3d/ftgl/src/FTGLTextureFont.cxx +++ /dev/null @@ -1,172 +0,0 @@ -#include -#include // 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( charSize.Height()); - glyphWidth = static_cast( 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( 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( (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::PreRender() -{ - FTFont::PreRender(); - glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GEQUAL, 0.0625); - - FTTextureGlyph::ResetActiveTexture(); -} - - -void FTGLTextureFont::PostRender() -{ - glPopAttrib(); - FTFont::PostRender(); -} diff --git a/graf3d/ftgl/src/FTGlyph.cxx b/graf3d/ftgl/src/FTGlyph.cxx deleted file mode 100644 index d9925a8350a87..0000000000000 --- a/graf3d/ftgl/src/FTGlyph.cxx +++ /dev/null @@ -1,17 +0,0 @@ -#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() -{} diff --git a/graf3d/ftgl/src/FTGlyphContainer.cxx b/graf3d/ftgl/src/FTGlyphContainer.cxx deleted file mode 100644 index 19d49830eaf45..0000000000000 --- a/graf3d/ftgl/src/FTGlyphContainer.cxx +++ /dev/null @@ -1,91 +0,0 @@ -#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); -} - - -FTGlyph* 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; -} diff --git a/graf3d/ftgl/src/FTLibrary.cxx b/graf3d/ftgl/src/FTLibrary.cxx deleted file mode 100644 index 9d886a431eb2e..0000000000000 --- a/graf3d/ftgl/src/FTLibrary.cxx +++ /dev/null @@ -1,64 +0,0 @@ -#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; -} diff --git a/graf3d/ftgl/src/FTOutlineGlyph.cxx b/graf3d/ftgl/src/FTOutlineGlyph.cxx deleted file mode 100644 index 936649b7b03ae..0000000000000 --- a/graf3d/ftgl/src/FTOutlineGlyph.cxx +++ /dev/null @@ -1,66 +0,0 @@ -#include "FTOutlineGlyph.h" -#include "FTVectoriser.h" - - -FTOutlineGlyph::FTOutlineGlyph( FT_GlyphSlot glyph, bool useDisplayList1) -: 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(useDisplayList1) - { - 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(useDisplayList1) - { - 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; -} - diff --git a/graf3d/ftgl/src/FTPixmapGlyph.cxx b/graf3d/ftgl/src/FTPixmapGlyph.cxx deleted file mode 100644 index 9139af426c294..0000000000000 --- a/graf3d/ftgl/src/FTPixmapGlyph.cxx +++ /dev/null @@ -1,73 +0,0 @@ -#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(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; -} diff --git a/graf3d/ftgl/src/FTPoint.cxx b/graf3d/ftgl/src/FTPoint.cxx deleted file mode 100644 index 674e2b01b4295..0000000000000 --- a/graf3d/ftgl/src/FTPoint.cxx +++ /dev/null @@ -1,19 +0,0 @@ -#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; -} - diff --git a/graf3d/ftgl/src/FTPolyGlyph.cxx b/graf3d/ftgl/src/FTPolyGlyph.cxx deleted file mode 100644 index abf26851a7124..0000000000000 --- a/graf3d/ftgl/src/FTPolyGlyph.cxx +++ /dev/null @@ -1,77 +0,0 @@ -#include "FTPolyGlyph.h" -#include "FTVectoriser.h" - - -FTPolyGlyph::FTPolyGlyph( FT_GlyphSlot glyph, bool useDisplayList1) -: 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( useDisplayList1) - { - 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(useDisplayList1) - { - 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; -} diff --git a/graf3d/ftgl/src/FTSize.cxx b/graf3d/ftgl/src/FTSize.cxx deleted file mode 100644 index 44b121d9a1ae8..0000000000000 --- a/graf3d/ftgl/src/FTSize.cxx +++ /dev/null @@ -1,87 +0,0 @@ -#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( ftSize->metrics.ascender) / 64.0f; -} - - -float FTSize::Descender() const -{ - return ftSize == 0 ? 0.0f : static_cast( 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( 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(ftSize->metrics.x_ppem) / static_cast((*ftFace)->units_per_EM)); - } else { - return static_cast( ftSize->metrics.max_advance) / 64.0f; - } -} - - -float FTSize::Underline() const -{ - return 0.0f; -} diff --git a/graf3d/ftgl/src/FTTextureGlyph.cxx b/graf3d/ftgl/src/FTTextureGlyph.cxx deleted file mode 100644 index 4cf2fcdd2f8d6..0000000000000 --- a/graf3d/ftgl/src/FTTextureGlyph.cxx +++ /dev/null @@ -1,84 +0,0 @@ -#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(xOffset) / static_cast(width)); - uv[0].Y( static_cast(yOffset) / static_cast(height)); - uv[1].X( static_cast( xOffset + destWidth) / static_cast(width)); - uv[1].Y( static_cast( yOffset + destHeight) / static_cast(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; -} - diff --git a/graf3d/ftgl/src/FTVectoriser.cxx b/graf3d/ftgl/src/FTVectoriser.cxx deleted file mode 100644 index 0b1f3c0fd3aca..0000000000000 --- a/graf3d/ftgl/src/FTVectoriser.cxx +++ /dev/null @@ -1,233 +0,0 @@ -#include "FTVectoriser.h" -#include "FTGL.h" - -#ifndef CALLBACK -#define CALLBACK -#endif - -#if defined(__APPLE_CC__) && __APPLE_CC__ > 4000 && __APPLE_CC__ < 5450 && !defined(__INTEL_COMPILER) - typedef GLvoid (*GLUTesselatorFunction)(...); -#elif defined( __mips ) || defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __sun ) || defined (__CYGWIN__) || defined (__APPLE__) - 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(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(coords); - *outData = const_cast(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(tempPointList.back()); -} - - -void FTMesh::Begin( GLenum meshType) -{ - currentTesselation = new FTTesselation( meshType); -} - - -void FTMesh::End() -{ - tesselationList.push_back( currentTesselation); -} - - -const FTTesselation* 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]; - auto* 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* 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(); - -#if defined(__GNUC__) && __GNUC__ >= 8 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-function-type" -#endif - - 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 defined(__GNUC__) && __GNUC__ >= 8 -#pragma GCC diagnostic pop -#endif - - 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); -} diff --git a/graf3d/gl/CMakeLists.txt b/graf3d/gl/CMakeLists.txt index 8fa7eec0c9bbd..3dea9b2558ccc 100644 --- a/graf3d/gl/CMakeLists.txt +++ b/graf3d/gl/CMakeLists.txt @@ -17,9 +17,6 @@ if(x11) set(RGL_EXTRA_SOURCES TX11GL.cxx) endif() -set_source_files_properties(src/TGLFontManager.cxx PROPERTIES COMPILE_FLAGS "${FTGL_CFLAGS}") -set_source_files_properties(src/TGLText.cxx PROPERTIES COMPILE_FLAGS "${FTGL_CFLAGS}") - ROOT_STANDARD_LIBRARY_PACKAGE(RGL HEADERS TArcBall.h @@ -202,7 +199,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RGL LIBRARIES OpenGL::GL OpenGL::GLU - ${FTGL_LIBRARIES} + FTGL::FTGL gl2ps::gl2ps Freetype::Freetype ZLIB::ZLIB @@ -214,6 +211,8 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RGL Ged RCsg ASImage + BUILTINS + BUILTIN_FTGL INSTALL_OPTIONS ${installoptions} ) @@ -221,7 +220,6 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RGL target_include_directories(RGL PRIVATE ${OPENGL_INCLUDE_DIR} - ${FTGL_INCLUDE_DIR} ) if(MACOSX_GLU_DEPRECATED) diff --git a/graf3d/gl/src/TGLFontManager.cxx b/graf3d/gl/src/TGLFontManager.cxx index 0cf76e2d95579..ac05e4c744ff0 100644 --- a/graf3d/gl/src/TGLFontManager.cxx +++ b/graf3d/gl/src/TGLFontManager.cxx @@ -22,19 +22,8 @@ #include "TGLUtil.h" #include "TGLIncludes.h" -// Direct inclusion of FTGL headers is deprecated in ftgl-2.1.3 while -// ftgl-2.1.2 shipped with ROOT requires manual inclusion. -#ifndef BUILTIN_FTGL # include -#else -# include "FTFont.h" -# include "FTGLExtrdFont.h" -# include "FTGLOutlineFont.h" -# include "FTGLPolygonFont.h" -# include "FTGLTextureFont.h" -# include "FTGLPixmapFont.h" -# include "FTGLBitmapFont.h" -#endif + /** \class TGLFont diff --git a/graf3d/gl/src/TGLText.cxx b/graf3d/gl/src/TGLText.cxx index 2ed3ee0917ab1..2644f6e564758 100644 --- a/graf3d/gl/src/TGLText.cxx +++ b/graf3d/gl/src/TGLText.cxx @@ -18,19 +18,7 @@ #include "TEnv.h" #include "TGLIncludes.h" -// Direct inclusion of FTGL headers is deprecated in ftgl-2.1.3 while -// ftgl-2.1.2 shipped with ROOT requires manual inclusion. -#ifndef BUILTIN_FTGL # include -#else -# include "FTFont.h" -# include "FTGLExtrdFont.h" -# include "FTGLOutlineFont.h" -# include "FTGLPolygonFont.h" -# include "FTGLTextureFont.h" -# include "FTGLPixmapFont.h" -# include "FTGLBitmapFont.h" -#endif #define FTGL_BITMAP 0 #define FTGL_PIXMAP 1