1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0031087: Configuration - make FreeType dependency optional

Added option USE_FREETYPE to CMake configuration, enabled by default.
Added handling of HAVE_FREETYPE macros.

genproj now overrides env.bat/env.sh on template change.
This commit is contained in:
kgv 2021-04-06 22:25:38 +03:00
parent 5e4f263d1c
commit 5c9493b348
15 changed files with 228 additions and 80 deletions

View File

@ -364,6 +364,14 @@ if (MSVC)
endif()
# whether use optional 3rdparty or not
set (USE_FREETYPE ON CACHE BOOL "${USE_FREETYPE_DESCR}")
set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
set (USE_FFMPEG OFF CACHE BOOL "${USE_FFMPEG_DESCR}")
set (USE_OPENVR OFF CACHE BOOL "${USE_OPENVR_DESCR}")
set (USE_RAPIDJSON OFF CACHE BOOL "${USE_RAPIDJSON_DESCR}")
set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
set (USE_EIGEN OFF CACHE BOOL "${USE_EIGEN_DESCR}")
if (APPLE)
set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}")
else()
@ -493,7 +501,7 @@ endif()
# search for CSF variable in EXTERNLIB of each being used toolkit
OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE)
OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE USE_FREETYPE)
OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE CAN_USE_FREETYPE)
OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_OPENGL)
OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlesLibs CAN_USE_GLES2)
OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB)
@ -516,13 +524,21 @@ else()
OCCT_CHECK_AND_UNSET ("INSTALL_TK")
endif()
if (USE_FREETYPE)
message (STATUS "Info: Freetype is used by OCCT")
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
# FreeType
if (CAN_USE_FREETYPE)
if (USE_FREETYPE)
message (STATUS "Info: FreeType is used by OCCT")
add_definitions (-DHAVE_FREETYPE)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
endif()
else()
OCCT_CHECK_AND_UNSET ("USE_FREETYPE")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE")
endif()
@ -550,8 +566,6 @@ endif()
# FREEIMAGE
if (CAN_USE_FREEIMAGE)
set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}")
if (USE_FREEIMAGE)
add_definitions (-DHAVE_FREEIMAGE)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
@ -570,8 +584,6 @@ endif()
# search for CSF_OpenVR variable in EXTERNLIB of each being used toolkit
OCCT_IS_PRODUCT_REQUIRED (CSF_OpenVR CAN_USE_OPENVR)
if (CAN_USE_OPENVR)
set (USE_OPENVR OFF CACHE BOOL "${USE_OPENVR_DESCR}")
if (USE_OPENVR)
add_definitions (-DHAVE_OPENVR)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/openvr")
@ -591,8 +603,6 @@ endif()
OCCT_IS_PRODUCT_REQUIRED (CSF_FFmpeg CAN_USE_FFMPEG)
if (CAN_USE_FFMPEG)
set (USE_FFMPEG OFF CACHE BOOL "${USE_FFMPEG_DESCR}")
if (USE_FFMPEG)
add_definitions (-DHAVE_FFMPEG)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/ffmpeg")
@ -655,8 +665,6 @@ endif()
# TBB
if (NOT DEFINED ANDROID AND CAN_USE_TBB)
set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}")
if (USE_TBB)
add_definitions (-DHAVE_TBB)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
@ -677,8 +685,6 @@ endif()
# search for CSF_RapidJSON variable in EXTERNLIB of each being used toolkit
OCCT_IS_PRODUCT_REQUIRED (CSF_RapidJSON CAN_USE_RAPIDJSON)
if (CAN_USE_RAPIDJSON)
set (USE_RAPIDJSON OFF CACHE BOOL "${USE_RAPIDJSON_DESCR}")
if (USE_RAPIDJSON)
add_definitions (-DHAVE_RAPIDJSON)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/rapidjson")
@ -695,8 +701,6 @@ endif()
# EIGEN
if (CAN_USE_EIGEN)
set (USE_EIGEN OFF CACHE BOOL "${USE_EIGEN_DESCR}")
if (USE_EIGEN)
add_definitions (-DHAVE_EIGEN)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/eigen")

View File

@ -118,6 +118,8 @@ else()
set (CSF_OpenGlesLibs "EGL GLESv2")
set (CSF_XwLibs "X11 Xext Xmu Xi")
set (CSF_dl "dl")
set (CSF_fontconfig "fontconfig")
if (USE_FREETYPE)
set (CSF_fontconfig "fontconfig")
endif()
endif()
endif()

View File

@ -155,12 +155,15 @@ set (3RDPARTY_DIR_DESCR
third-party product have been found - corresponding CMake variables will be specified
(VTK: 3RDPARTY_VTK_DIR, 3RDPARTY_VTK_INCLUDE_DIR, 3RDPARTY_VTK_LIBRARY_DIR)")
set (USE_FREETYPE_DESCR
"Indicates whether FreeType product should be used in OCCT for text rendering using external font files")
set (USE_FFMPEG_DESCR
"Indicates whether FFmpeg framework is used or not. FFmpeg stands for
multimedia data handling, open-source software libraries used for video encoding and decoding.")
set (USE_FREEIMAGE_DESCR
"Indicates whether Freeimage product should be used in OCCT visualization
"Indicates whether FreeImage product should be used in OCCT visualization
module for support of popular graphics image formats (PNG, BMP etc)")
set (USE_OPENVR_DESCR

View File

@ -175,7 +175,9 @@ proc wokdep:gui:UpdateList {} {
set anBin32Errs {}
set anBin64Errs {}
wokdep:SearchTclTk anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
wokdep:SearchFreeType anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
if { "$::HAVE_FREETYPE" == "true" } {
wokdep:SearchFreeType anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
}
wokdep:SearchX11 anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
if { "$::HAVE_GLES2" == "true" } {
wokdep:SearchEGL anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
@ -471,6 +473,8 @@ ttk::label .myFrame.myHxxChecks.myScutsLbl -text "Strategy for filling he
ttk::label .myFrame.mySrchLbl -text "3rd-parties search path:" -padding {5 5 80 5}
entry .myFrame.mySrchEntry -textvariable PRODUCTS_PATH_INPUT -width 80
ttk::button .myFrame.mySrchBrowseBtn -text "Browse" -command wokdep:gui:BrowsePartiesRoot
checkbutton .myFrame.myChecks.myFreeTypeCheck -offvalue "false" -onvalue "true" -variable HAVE_FREETYPE -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myFreeTypeLbl -text "Use FreeType"
checkbutton .myFrame.myChecks.myFImageCheck -offvalue "false" -onvalue "true" -variable HAVE_FREEIMAGE -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myFImageLbl -text "Use FreeImage"
checkbutton .myFrame.myChecks.myTbbCheck -offvalue "false" -onvalue "true" -variable HAVE_TBB -command wokdep:gui:UpdateList
@ -604,10 +608,10 @@ incr aRowIter
grid .myFrame.myChecks -row $aRowIter -column 0 -columnspan 10 -sticky w
incr aRowIter
grid .myFrame.myChecks.myFImageCheck -row $aCheckRowIter -column 0 -sticky e
grid .myFrame.myChecks.myFImageLbl -row $aCheckRowIter -column 1 -sticky w
grid .myFrame.myChecks.myTbbCheck -row $aCheckRowIter -column 2 -sticky e
grid .myFrame.myChecks.myTbbLbl -row $aCheckRowIter -column 3 -sticky w
grid .myFrame.myChecks.myFreeTypeCheck -row $aCheckRowIter -column 0 -sticky e
grid .myFrame.myChecks.myFreeTypeLbl -row $aCheckRowIter -column 1 -sticky w
grid .myFrame.myChecks.myRapidJsonCheck -row $aCheckRowIter -column 2 -sticky e
grid .myFrame.myChecks.myRapidJsonLbl -row $aCheckRowIter -column 3 -sticky w
if { "$::tcl_platform(os)" != "Darwin" } {
grid .myFrame.myChecks.myGlesCheck -row $aCheckRowIter -column 4 -sticky e
grid .myFrame.myChecks.myGlesLbl -row $aCheckRowIter -column 5 -sticky w
@ -621,10 +625,10 @@ grid .myFrame.myChecks.myQtCheck -row $aCheckRowIter -column 12 -sticky e
grid .myFrame.myChecks.myQtLbl -row $aCheckRowIter -column 13 -sticky w
incr aCheckRowIter
grid .myFrame.myChecks.myFFmpegCheck -row $aCheckRowIter -column 0 -sticky e
grid .myFrame.myChecks.myFFmpegLbl -row $aCheckRowIter -column 1 -sticky w
grid .myFrame.myChecks.myVtkCheck -row $aCheckRowIter -column 2 -sticky e
grid .myFrame.myChecks.myVtkLbl -row $aCheckRowIter -column 3 -sticky w
grid .myFrame.myChecks.myFImageCheck -row $aCheckRowIter -column 0 -sticky e
grid .myFrame.myChecks.myFImageLbl -row $aCheckRowIter -column 1 -sticky w
grid .myFrame.myChecks.myTbbCheck -row $aCheckRowIter -column 2 -sticky e
grid .myFrame.myChecks.myTbbLbl -row $aCheckRowIter -column 3 -sticky w
if { "$::tcl_platform(platform)" == "windows" } {
grid .myFrame.myChecks.myD3dCheck -row $aCheckRowIter -column 4 -sticky e
grid .myFrame.myChecks.myD3dLbl -row $aCheckRowIter -column 5 -sticky w
@ -638,8 +642,10 @@ grid .myFrame.myChecks.myJDKCheck -row $aCheckRowIter -column 12 -sticky e
grid .myFrame.myChecks.myJDKLbl -row $aCheckRowIter -column 13 -sticky w
incr aCheckRowIter
grid .myFrame.myChecks.myRapidJsonCheck -row $aCheckRowIter -column 0 -sticky e
grid .myFrame.myChecks.myRapidJsonLbl -row $aCheckRowIter -column 1 -sticky w
grid .myFrame.myChecks.myFFmpegCheck -row $aCheckRowIter -column 0 -sticky e
grid .myFrame.myChecks.myFFmpegLbl -row $aCheckRowIter -column 1 -sticky w
grid .myFrame.myChecks.myVtkCheck -row $aCheckRowIter -column 2 -sticky e
grid .myFrame.myChecks.myVtkLbl -row $aCheckRowIter -column 3 -sticky w
grid .myFrame.myChecks.myOpenVrCheck -row $aCheckRowIter -column 4 -sticky e
grid .myFrame.myChecks.myOpenVrLbl -row $aCheckRowIter -column 5 -sticky w
grid .myFrame.myChecks.myE57Check -row $aCheckRowIter -column 6 -sticky e

View File

@ -68,9 +68,10 @@ if { [info exists ::env(SHORTCUT_HEADERS)] } {
}
# fetch environment variables (e.g. set by custom.sh or custom.bat) and set them as tcl variables with the same name
set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENVR HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo BUILD_Inspector}
set THE_ENV_VARIABLES {HAVE_FREETYPE HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENVR HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo BUILD_Inspector}
foreach anEnvIter $THE_ENV_VARIABLES { set ${anEnvIter} "false" }
set HAVE_FREETYPE "true"
foreach anEnvIter $THE_ENV_VARIABLES {
set ${anEnvIter} "false"
if { [info exists ::env(${anEnvIter})] } {
set ${anEnvIter} "$::env(${anEnvIter})"
}

View File

@ -129,7 +129,7 @@ proc osutils:isEqualContent { theContent1 theContent2 } {
# Auxiliary function for writing new file content only if it has been actually changed
# (e.g. to preserve file timestamp on no change).
# Useful for automatically (re)generated files.
proc osutils:writeTextFile { theFile theContent {theEol lf} } {
proc osutils:writeTextFile { theFile theContent {theEol lf} {theToBackup false} } {
if {[file exists "${theFile}"]} {
set aFileOld [open "${theFile}" rb]
fconfigure $aFileOld -translation crlf
@ -143,6 +143,10 @@ proc osutils:writeTextFile { theFile theContent {theEol lf} } {
return false
}
if { $theToBackup == true } {
puts "Warning: file ${theFile} is updated. Old content is saved to ${theFile}.bak"
file copy -force -- "${theFile}" "${theFile}.bak"
}
file delete -force "${theFile}"
}
@ -373,29 +377,28 @@ proc copy_with_warning {from to} {
# Generate auxiliary scripts for launching IDE.
proc genprojbat {theFormat thePlatform theSolution} {
set aTargetPlatformExt sh
set aTargetEol lf
if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
set aTargetPlatformExt bat
set aTargetEol crlf
}
if {"$theFormat" != "cmake"} {
# copy env.bat/sh only if not yet present
if { ! [file exists "$::path/env.${aTargetPlatformExt}"] } {
set anEnvTmplFile [open "$::THE_CASROOT/adm/templates/env.${aTargetPlatformExt}" "r"]
set anEnvTmpl [read $anEnvTmplFile]
close $anEnvTmplFile
# generate env.bat/sh
set anEnvTmplFilePath "$::THE_CASROOT/adm/templates/env.${aTargetPlatformExt}"
set anEnvTmplFile [open "$anEnvTmplFilePath" "r"]
set anEnvTmpl [read $anEnvTmplFile]
close $anEnvTmplFile
set aCasRoot ""
if { [file normalize "$::path"] != [file normalize "$::THE_CASROOT"] } {
set aCasRoot [relativePath "$::path" "$::THE_CASROOT"]
}
regsub -all -- {__CASROOT__} $anEnvTmpl "$aCasRoot" anEnvTmpl
set anEnvFile [open "$::path/env.${aTargetPlatformExt}" "w"]
puts $anEnvFile $anEnvTmpl
close $anEnvFile
set aCasRoot ""
if { [file normalize "$::path"] != [file normalize "$::THE_CASROOT"] } {
set aCasRoot [relativePath "$::path" "$::THE_CASROOT"]
}
regsub -all -- {__CASROOT__} $anEnvTmpl "$aCasRoot" anEnvTmpl
set aLineList [split $anEnvTmpl "\n"]
osutils:writeTextFile "$::path/env.${aTargetPlatformExt}" $aLineList $aTargetEol true
copy_with_warning "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
if { "$::BUILD_Inspector" == "true" } {
@ -1409,7 +1412,9 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
unset theCsfLibsMap
unset theCsfFrmsMap
set aLibsMap(CSF_FREETYPE) "freetype"
if { "$::HAVE_FREETYPE" == "true" } {
set aLibsMap(CSF_FREETYPE) "freetype"
}
set aLibsMap(CSF_TclLibs) "tcl8.6"
set aLibsMap(CSF_TclTkLibs) "tk8.6"
if { "$::HAVE_FREEIMAGE" == "true" } {
@ -1504,7 +1509,9 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
} elseif { "$theOS" == "android" } {
set aLibsMap(CSF_androidlog) "log"
} else {
set aLibsMap(CSF_fontconfig) "fontconfig"
if { "$::HAVE_FREETYPE" == "true" } {
set aLibsMap(CSF_fontconfig) "fontconfig"
}
if { "$theOS" == "qnx" } {
# CSF_ThreadLibs - pthread API is part of libc on QNX
} else {

View File

@ -18,7 +18,7 @@ aHxxRoot = $$OccGitRoot/inc
INCLUDEPATH += $$aHxxRoot
# CSF variables
CSF_FREETYPE = -lfreetype
HAVE_FREETYPE { CSF_FREETYPE = -lfreetype }
CSF_TclLibs = -ltcl8.6
CSF_TclTkLibs = -ltk8.6
HAVE_FREEIMAGE { CSF_FreeImagePlus = -lfreeimage } else:win32 { CSF_FreeImagePlus = -lwindowscodecs -lole32 }
@ -64,7 +64,7 @@ win32 {
CSF_TclTkLibs = -lX11 -ltk8.6
CSF_XwLibs = -lX11 -lXext -lXmu -lXi
CSF_MotifLibs = -lX11
CSF_fontconfig = -lfontconfig
HAVE_FREETYPE { CSF_fontconfig = -lfontconfig }
}
for (aCfgIter, CONFIG) {

View File

@ -17,6 +17,7 @@ set "ARCH=64"
set "VCVARS="
set "HAVE_TBB=false"
set "HAVE_OPENCL=false"
set "HAVE_FREETYPE=true"
set "HAVE_FREEIMAGE=false"
set "HAVE_FFMPEG=false"
set "HAVE_VTK=false"
@ -56,9 +57,9 @@ rem Decode VCVER variable and define related ones:
rem
rem VCFMT - "vc" followed by full version number of Visual Studio toolset
rem (same as VCVER without optional suffix "-uwp")
rem VCLIB - name of folder contining binaries
rem VCLIB - name of folder containing binaries
rem (same as VCVER except without third version in number)
rem VCPROP - name of required Visual Studion Workload (starting with VS 2017)
rem VCPROP - name of required Visual Studio Workload (starting with VS 2017)
rem
rem Note that for VS before 2015 (vc14) always
rem VCFMT=VCLIB=VCVER and VCPROP=NativeDesktop
@ -182,6 +183,7 @@ set "CSF_OPT_CMPL="
set "PRODUCTS_DEFINES="
if ["%HAVE_TBB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TBB" & set "CSF_DEFINES=HAVE_TBB;%CSF_DEFINES%"
if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENCL" & set "CSF_DEFINES=HAVE_OPENCL;%CSF_DEFINES%"
if ["%HAVE_FREETYPE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREETYPE;%CSF_DEFINES%"
if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%"
if ["%HAVE_FFMPEG%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FFMPEG" & set "CSF_DEFINES=HAVE_FFMPEG;%CSF_DEFINES%"
if ["%HAVE_VTK%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_VTK" & set "CSF_DEFINES=HAVE_VTK;%CSF_DEFINES%"
@ -199,20 +201,20 @@ if ["%CSF_DEFINES%"] == [""] set "CSF_DEFINES=;"
rem ----- Optional 3rd-parties should be enabled by HAVE macros -----
if not ["%PRODUCTS_DEFINES%"] == [""] set "CSF_OPT_CMPL=%CSF_OPT_CMPL% %PRODUCTS_DEFINES%"
rem ----- Colect 3rd-parties additional include paths into compiler options -----
rem ----- Collect 3rd-parties additional include paths into compiler options -----
for %%a in ("%CSF_OPT_INC:;=";"%") do (
set "anItem=%%~a"
if not ["%%~a"] == [""] call :concatCmplInc %%~a
)
rem ----- Colect 3rd-parties additional library paths (32-bit) into linker options -----
rem ----- Collect 3rd-parties additional library paths (32-bit) into linker options -----
set "OPT_LIB32="
for %%a in ("%CSF_OPT_LIB32:;=";"%") do (
set "anItem=%%~a"
if not ["%%~a"] == [""] call :concatLib32 %%~a
)
rem ----- Colect 3rd-parties additional library paths (64-bit) into linker options -----
rem ----- Collect 3rd-parties additional library paths (64-bit) into linker options -----
set "OPT_LIB64="
for %%a in ("%CSF_OPT_LIB64:;=";"%") do (
set "anItem=%%~a"
@ -244,7 +246,7 @@ if ["%CASDEB%"] == ["d"] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64D%;%PAT
if ["%CASDEB%"] == ["i"] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32I%;%PATH%"
if ["%CASDEB%"] == ["i"] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64I%;%PATH%"
rem ----- Set envoronment variables used by OCCT -----
rem ----- Set environment variables used by OCCT -----
set CSF_LANGUAGE=us
set MMGT_CLEAR=1
set "CSF_SHMessage=%CSF_OCCTResourcePath%\SHMessage"

View File

@ -9,6 +9,7 @@ export CASDEB=""
export PRJFMT="";
export HAVE_TBB="false";
export HAVE_OPENCL="false";
export HAVE_FREETYPE="true";
export HAVE_FREEIMAGE="false";
export HAVE_FFMPEG="false";
export HAVE_VTK="false";
@ -100,6 +101,7 @@ export CSF_OPT_CMPL=""
# Optiona 3rd-parties should be enabled by HAVE macros
if [ "$HAVE_TBB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_TBB"; fi
if [ "$HAVE_OPENCL" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENCL"; fi
if [ "$HAVE_FREETYPE" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREETYPE"; fi
if [ "$HAVE_FREEIMAGE" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREEIMAGE"; fi
if [ "$HAVE_FFMPEG" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FFMPEG"; fi
if [ "$HAVE_GLES2" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_GLES2_EXT"; fi

View File

@ -471,7 +471,7 @@ The environment is defined in the file *custom.sh* which can be edited directly:
* "HardLink* - hard links to headers located in *src* will be created.
* For optional third-party libraries, set corresponding environment variable <i>HAVE_<LIBRARY_NAME></i> to either *false*, e.g.:
~~~~~
export HAVE_GL2PS=false
export HAVE_FREEIMAGE=false
~~~~~
Alternatively, or when *custom.sh* does not exist, you can launch *genconf.sh* to configure environment interactively:
@ -544,7 +544,7 @@ directly:
* "HardLink* - hard links to headers located in *src* will be created.
* For optional third-party libraries, set corresponding environment variable <i>HAVE_<LIBRARY_NAME></i> to either *false*, e.g.:
~~~~~
export HAVE_GL2PS=false
export HAVE_FREEIMAGE=false
~~~~~
Alternatively, or when *custom.sh* or *custom.bat* does not exist, you can launch **genconf** tool to configure

View File

@ -348,6 +348,11 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c
#else
di << "TBB disabled\n";
#endif
#ifdef HAVE_FREETYPE
di << "FreeType enabled (HAVE_FREETYPE)\n";
#else
di << "FreeType disabled\n";
#endif
#ifdef HAVE_FREEIMAGE
di << "FreeImage enabled (HAVE_FREEIMAGE)\n";
#else

View File

@ -23,8 +23,10 @@
#include <algorithm>
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef HAVE_FREETYPE
#include <ft2build.h>
#include FT_FREETYPE_H
#endif
IMPLEMENT_STANDARD_RTTIEXT(Font_FTFont,Standard_Transient)
@ -38,7 +40,11 @@ Font_FTFont::Font_FTFont (const Handle(Font_FTLibrary)& theFTLib)
myActiveFTFace(NULL),
myFontAspect (Font_FontAspect_Regular),
myWidthScaling(1.0),
#ifdef HAVE_FREETYPE
myLoadFlags (FT_LOAD_NO_HINTING | FT_LOAD_TARGET_NORMAL),
#else
myLoadFlags (0),
#endif
myUChar (0U),
myToUseUnicodeSubsetFallback (Font_FontMgr::ToUseUnicodeSubsetFallback())
{
@ -68,7 +74,9 @@ void Font_FTFont::Release()
myUChar = 0;
if (myFTFace != NULL)
{
#ifdef HAVE_FREETYPE
FT_Done_Face (myFTFace);
#endif
myFTFace = NULL;
}
myActiveFTFace = NULL;
@ -95,6 +103,7 @@ bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData,
return false;
}
#ifdef HAVE_FREETYPE
if (!theData.IsNull())
{
if (FT_New_Memory_Face (myFTLib->Instance(), theData->Data(), (FT_Long )theData->Size(), (FT_Long )theFaceId, &myFTFace) != 0)
@ -144,6 +153,10 @@ bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData,
}
myActiveFTFace = myFTFace;
return true;
#else
(void )theFaceId;
return false;
#endif
}
// =======================================================================
@ -174,6 +187,7 @@ Handle(Font_FTFont) Font_FTFont::FindAndCreate (const TCollection_AsciiString& t
return aFont;
}
}
#ifdef HAVE_FREETYPE
else if (theStrictLevel == Font_StrictLevel_Any)
{
switch (theFontAspect)
@ -196,6 +210,7 @@ Handle(Font_FTFont) Font_FTFont::FindAndCreate (const TCollection_AsciiString& t
return aFont;
}
}
#endif
return Handle(Font_FTFont)();
}
@ -222,6 +237,7 @@ bool Font_FTFont::FindAndInit (const TCollection_AsciiString& theFontName,
const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (myFontAspect, aParams.ToSynthesizeItalic, aFaceId);
return Init (aPath, aParams, aFaceId);
}
#ifdef HAVE_FREETYPE
else if (theStrictLevel == Font_StrictLevel_Any)
{
if (theFontAspect == Font_FontAspect_Italic
@ -231,6 +247,7 @@ bool Font_FTFont::FindAndInit (const TCollection_AsciiString& theFontName,
}
return Init (Font_FontMgr::EmbedFallbackFont(), "Embed Fallback Font", aParams, 0);
}
#endif
Release();
return false;
}
@ -246,6 +263,7 @@ bool Font_FTFont::findAndInitFallback (Font_UnicodeSubset theSubset)
return myFallbackFaces[theSubset]->IsValid();
}
#ifdef HAVE_FREETYPE
myFallbackFaces[theSubset] = new Font_FTFont (myFTLib);
myFallbackFaces[theSubset]->myToUseUnicodeSubsetFallback = false; // no recursion
@ -263,6 +281,7 @@ bool Font_FTFont::findAndInitFallback (Font_UnicodeSubset theSubset)
+ " for symbols unsupported by '" + myFTFace->family_name + "'");
}
}
#endif
return myFallbackFaces[theSubset]->IsValid();
}
@ -272,7 +291,12 @@ bool Font_FTFont::findAndInitFallback (Font_UnicodeSubset theSubset)
// =======================================================================
bool Font_FTFont::HasSymbol (Standard_Utf32Char theUChar) const
{
#ifdef HAVE_FREETYPE
return FT_Get_Char_Index (myFTFace, theUChar) != 0;
#else
(void )theUChar;
return false;
#endif
}
// =======================================================================
@ -286,6 +310,7 @@ bool Font_FTFont::loadGlyph (const Standard_Utf32Char theUChar)
return myUChar != 0;
}
#ifdef HAVE_FREETYPE
myGlyphImg.Clear();
myUChar = 0;
myActiveFTFace = myFTFace;
@ -314,6 +339,9 @@ bool Font_FTFont::loadGlyph (const Standard_Utf32Char theUChar)
myUChar = theUChar;
return true;
#else
return false;
#endif
}
// =======================================================================
@ -326,6 +354,7 @@ bool Font_FTFont::RenderGlyph (const Standard_Utf32Char theUChar)
myUChar = 0;
myActiveFTFace = myFTFace;
#ifdef HAVE_FREETYPE
if (theUChar != 0
&& myToUseUnicodeSubsetFallback
&& !HasSymbol (theUChar))
@ -387,6 +416,10 @@ bool Font_FTFont::RenderGlyph (const Standard_Utf32Char theUChar)
myUChar = theUChar;
return true;
#else
(void )theUChar;
return false;
#endif
}
// =======================================================================
@ -395,6 +428,7 @@ bool Font_FTFont::RenderGlyph (const Standard_Utf32Char theUChar)
// =======================================================================
unsigned int Font_FTFont::GlyphMaxSizeX (bool theToIncludeFallback) const
{
#ifdef HAVE_FREETYPE
if (!theToIncludeFallback)
{
float aWidth = (FT_IS_SCALABLE(myFTFace) != 0)
@ -416,6 +450,10 @@ unsigned int Font_FTFont::GlyphMaxSizeX (bool theToIncludeFallback) const
}
}
return aWidth;
#else
(void )theToIncludeFallback;
return 0;
#endif
}
// =======================================================================
@ -424,6 +462,7 @@ unsigned int Font_FTFont::GlyphMaxSizeX (bool theToIncludeFallback) const
// =======================================================================
unsigned int Font_FTFont::GlyphMaxSizeY (bool theToIncludeFallback) const
{
#ifdef HAVE_FREETYPE
if (!theToIncludeFallback)
{
float aHeight = (FT_IS_SCALABLE(myFTFace) != 0)
@ -445,6 +484,10 @@ unsigned int Font_FTFont::GlyphMaxSizeY (bool theToIncludeFallback) const
}
}
return aHeight;
#else
(void )theToIncludeFallback;
return 0;
#endif
}
// =======================================================================
@ -453,7 +496,11 @@ unsigned int Font_FTFont::GlyphMaxSizeY (bool theToIncludeFallback) const
// =======================================================================
float Font_FTFont::Ascender() const
{
#ifdef HAVE_FREETYPE
return float(myFTFace->ascender) * (float(myFTFace->size->metrics.y_ppem) / float(myFTFace->units_per_EM));
#else
return 0.0f;
#endif
}
// =======================================================================
@ -462,7 +509,11 @@ float Font_FTFont::Ascender() const
// =======================================================================
float Font_FTFont::Descender() const
{
#ifdef HAVE_FREETYPE
return float(myFTFace->descender) * (float(myFTFace->size->metrics.y_ppem) / float(myFTFace->units_per_EM));
#else
return 0.0f;
#endif
}
// =======================================================================
@ -471,7 +522,11 @@ float Font_FTFont::Descender() const
// =======================================================================
float Font_FTFont::LineSpacing() const
{
#ifdef HAVE_FREETYPE
return float(myFTFace->height) * (float(myFTFace->size->metrics.y_ppem) / float(myFTFace->units_per_EM));
#else
return 0.0f;
#endif
}
// =======================================================================
@ -504,6 +559,7 @@ bool Font_FTFont::getKerning (FT_Vector& theKern,
Standard_Utf32Char theUCharCurr,
Standard_Utf32Char theUCharNext) const
{
#ifdef HAVE_FREETYPE
theKern.x = 0;
theKern.y = 0;
if (theUCharNext != 0 && FT_HAS_KERNING(myActiveFTFace) != 0)
@ -519,6 +575,11 @@ bool Font_FTFont::getKerning (FT_Vector& theKern,
}
return true;
}
#else
(void )theKern;
(void )theUCharCurr;
(void )theUCharNext;
#endif
return false;
}
@ -533,9 +594,14 @@ float Font_FTFont::AdvanceX (Standard_Utf32Char theUCharNext) const
return 0.0f;
}
#ifdef HAVE_FREETYPE
FT_Vector aKern;
getKerning (aKern, myUChar, theUCharNext);
return myWidthScaling * fromFTPoints<float> (myActiveFTFace->glyph->advance.x + aKern.x);
#else
(void )theUCharNext;
return 0.0f;
#endif
}
// =======================================================================
@ -549,9 +615,14 @@ float Font_FTFont::AdvanceY (Standard_Utf32Char theUCharNext) const
return 0.0f;
}
#ifdef HAVE_FREETYPE
FT_Vector aKern;
getKerning (aKern, myUChar, theUCharNext);
return fromFTPoints<float> (myActiveFTFace->glyph->advance.y + aKern.y);
#else
(void )theUCharNext;
return 0.0f;
#endif
}
// =======================================================================
@ -560,6 +631,7 @@ float Font_FTFont::AdvanceY (Standard_Utf32Char theUCharNext) const
// =======================================================================
Standard_Integer Font_FTFont::GlyphsNumber (bool theToIncludeFallback) const
{
#ifdef HAVE_FREETYPE
Standard_Integer aNbGlyphs = myFTFace->num_glyphs;
if (theToIncludeFallback)
{
@ -573,6 +645,10 @@ Standard_Integer Font_FTFont::GlyphsNumber (bool theToIncludeFallback) const
}
}
return aNbGlyphs;
#else
(void )theToIncludeFallback;
return 0;
#endif
}
// =======================================================================
@ -581,11 +657,15 @@ Standard_Integer Font_FTFont::GlyphsNumber (bool theToIncludeFallback) const
// =======================================================================
void Font_FTFont::GlyphRect (Font_Rect& theRect) const
{
#ifdef HAVE_FREETYPE
const FT_Bitmap& aBitmap = myActiveFTFace->glyph->bitmap;
theRect.Left = float(myActiveFTFace->glyph->bitmap_left);
theRect.Top = float(myActiveFTFace->glyph->bitmap_top);
theRect.Right = float(myActiveFTFace->glyph->bitmap_left + (int )aBitmap.width);
theRect.Bottom = float(myActiveFTFace->glyph->bitmap_top - (int )aBitmap.rows);
#else
(void )theRect;
#endif
}
// =======================================================================
@ -614,10 +694,15 @@ Font_Rect Font_FTFont::BoundingBox (const NCollection_String& theS
// =======================================================================
const FT_Outline* Font_FTFont::renderGlyphOutline (const Standard_Utf32Char theChar)
{
#ifdef HAVE_FREETYPE
if (!loadGlyph (theChar)
|| myActiveFTFace->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
{
return 0;
}
return &myActiveFTFace->glyph->outline;
#else
(void )theChar;
return 0;
#endif
}

View File

@ -15,8 +15,10 @@
#include <Font_FTLibrary.hxx>
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef HAVE_FREETYPE
#include <ft2build.h>
#include FT_FREETYPE_H
#endif
IMPLEMENT_STANDARD_RTTIEXT(Font_FTLibrary,Standard_Transient)
@ -27,10 +29,12 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FTLibrary,Standard_Transient)
Font_FTLibrary::Font_FTLibrary()
: myFTLib (NULL)
{
#ifdef HAVE_FREETYPE
if (FT_Init_FreeType (&myFTLib) != 0)
{
myFTLib = NULL;
}
#endif
}
// =======================================================================
@ -41,6 +45,8 @@ Font_FTLibrary::~Font_FTLibrary()
{
if (IsValid())
{
#ifdef HAVE_FREETYPE
FT_Done_FreeType (myFTLib);
#endif
}
}

View File

@ -28,10 +28,12 @@
#include <Standard_Type.hxx>
#include <TCollection_HAsciiString.hxx>
#include "Font_DejavuSans_Latin_woff.pxx"
#ifdef HAVE_FREETYPE
#include "Font_DejavuSans_Latin_woff.pxx"
#include <ft2build.h>
#include FT_FREETYPE_H
#include <ft2build.h>
#include FT_FREETYPE_H
#endif
IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient)
#if defined(_WIN32)
@ -39,7 +41,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient)
#include <windows.h>
#include <stdlib.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && defined(HAVE_FREETYPE)
#pragma comment (lib, "freetype.lib")
#endif
@ -82,7 +84,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient)
NULL
};
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
#if defined(HAVE_FREETYPE) && !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
// X11 configuration file in plain text format (obsolete - doesn't exists in modern distributives)
static Standard_CString myFontServiceConf[] = {"/etc/X11/fs/config",
"/usr/X11R6/lib/X11/fs/config",
@ -149,8 +151,9 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient)
static bool checkFont (NCollection_Sequence<Handle(Font_SystemFont)>& theFonts,
const Handle(Font_FTLibrary)& theFTLib,
const TCollection_AsciiString& theFontPath,
FT_Long theFaceId = -1)
signed long theFaceId = -1) // FT_Long
{
#ifdef HAVE_FREETYPE
const FT_Long aFaceId = theFaceId != -1 ? theFaceId : 0;
FT_Face aFontFace;
FT_Error aFaceError = FT_New_Face (theFTLib->Instance(), theFontPath.ToCString(), aFaceId, &aFontFace);
@ -283,6 +286,13 @@ static bool checkFont (NCollection_Sequence<Handle(Font_SystemFont)>& theFonts,
FT_Done_Face (aFontFace);
return true;
#else
(void )theFonts;
(void )theFTLib;
(void )theFontPath;
(void )theFaceId;
return false;
#endif
}
// =======================================================================
@ -712,7 +722,7 @@ void Font_FontMgr::InitFontDataBase()
#else
NCollection_Map<TCollection_AsciiString> aMapOfFontsDirs;
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
#if defined(HAVE_FREETYPE) && !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
if (FcConfig* aFcCfg = FcInitLoadConfig())
{
if (FcStrList* aFcFontDir = FcConfigGetFontDirs (aFcCfg))
@ -815,7 +825,7 @@ void Font_FontMgr::InitFontDataBase()
for (NCollection_Map<TCollection_AsciiString>::Iterator anIter (aMapOfFontsDirs);
anIter.More(); anIter.Next())
{
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
#if defined(HAVE_FREETYPE) && !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
OSD_File aReadFile (anIter.Value() + "/fonts.dir");
if (!aReadFile.Exists())
{
@ -835,7 +845,7 @@ void Font_FontMgr::InitFontDataBase()
RegisterFonts (aFonts, false);
}
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
#if defined(HAVE_FREETYPE) && !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
continue;
}
@ -1154,7 +1164,11 @@ Handle(Font_SystemFont) Font_FontMgr::Font_FontMap::Find (const TCollection_Asci
// =======================================================================
Handle(NCollection_Buffer) Font_FontMgr::EmbedFallbackFont()
{
#ifdef HAVE_FREETYPE
return new NCollection_Buffer (Handle(NCollection_BaseAllocator)(),
Font_DejavuSans_Latin_woff_size,
const_cast<Standard_Byte*>(Font_DejavuSans_Latin_woff));
#else
return Handle(NCollection_Buffer)();
#endif
}

View File

@ -47,9 +47,11 @@
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfShapeSequenceOfShape.hxx>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H
#ifdef HAVE_FREETYPE
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H
#endif
IMPLEMENT_STANDARD_RTTIEXT(StdPrs_BRepFont, Standard_Transient)
@ -66,6 +68,7 @@ namespace
return theSize / Standard_Real(THE_FONT_SIZE) * 72.0 / Standard_Real(THE_RESOLUTION_DPI);
}
#ifdef HAVE_FREETYPE
//! Auxiliary method to convert FT_Vector to gp_XY
static gp_XY readFTVec (const FT_Vector& theVec,
const Standard_Real theScaleUnits,
@ -113,7 +116,7 @@ namespace
}
return aRes;
}
#endif
}
// =======================================================================
@ -308,6 +311,7 @@ bool StdPrs_BRepFont::to3d (const Handle(Geom2d_Curve)& theCurve2d,
Standard_Boolean StdPrs_BRepFont::buildFaces (const NCollection_Sequence<TopoDS_Wire>& theWires,
TopoDS_Shape& theRes)
{
#ifdef HAVE_FREETYPE
// classify wires
NCollection_DataMap<TopoDS_Shape, NCollection_Sequence<TopoDS_Wire>, TopTools_ShapeMapHasher> aMapOutInts;
TopTools_DataMapOfShapeInteger aMapNbOuts;
@ -419,6 +423,11 @@ Standard_Boolean StdPrs_BRepFont::buildFaces (const NCollection_Sequence<TopoDS_
theRes = aFaceComp;
}
return Standard_True;
#else
(void )theWires;
(void )theRes;
return Standard_False;
#endif
}
// =======================================================================
@ -429,7 +438,7 @@ Standard_Boolean StdPrs_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
TopoDS_Shape& theShape)
{
theShape.Nullify();
#ifdef HAVE_FREETYPE
const FT_Outline* anOutline = myFTFont->renderGlyphOutline (theChar);
if (!anOutline)
{
@ -666,7 +675,9 @@ Standard_Boolean StdPrs_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
{
theShape = aFaceCompDraft;
}
#else
(void )theChar;
#endif
myCache.Bind (theChar, theShape);
return !theShape.IsNull();
}