diff --git a/entry/libs/x86_64/libTKBO.so.8.0 b/entry/libs/x86_64/libTKBO.so.8.0 index 9f264bdb..0b3a012f 100644 Binary files a/entry/libs/x86_64/libTKBO.so.8.0 and b/entry/libs/x86_64/libTKBO.so.8.0 differ diff --git a/entry/libs/x86_64/libTKBRep.so.8.0 b/entry/libs/x86_64/libTKBRep.so.8.0 index 2d1cff12..09198e71 100644 Binary files a/entry/libs/x86_64/libTKBRep.so.8.0 and b/entry/libs/x86_64/libTKBRep.so.8.0 differ diff --git a/entry/libs/x86_64/libTKBin.so.8.0 b/entry/libs/x86_64/libTKBin.so.8.0 index fff84092..89aa0e40 100644 Binary files a/entry/libs/x86_64/libTKBin.so.8.0 and b/entry/libs/x86_64/libTKBin.so.8.0 differ diff --git a/entry/libs/x86_64/libTKBinL.so.8.0 b/entry/libs/x86_64/libTKBinL.so.8.0 index c6166224..8eded1f2 100644 Binary files a/entry/libs/x86_64/libTKBinL.so.8.0 and b/entry/libs/x86_64/libTKBinL.so.8.0 differ diff --git a/entry/libs/x86_64/libTKBinTObj.so.8.0 b/entry/libs/x86_64/libTKBinTObj.so.8.0 index 67728b23..13037cf9 100644 Binary files a/entry/libs/x86_64/libTKBinTObj.so.8.0 and b/entry/libs/x86_64/libTKBinTObj.so.8.0 differ diff --git a/entry/libs/x86_64/libTKBinXCAF.so.8.0 b/entry/libs/x86_64/libTKBinXCAF.so.8.0 index 76a30ad3..c71aa049 100644 Binary files a/entry/libs/x86_64/libTKBinXCAF.so.8.0 and b/entry/libs/x86_64/libTKBinXCAF.so.8.0 differ diff --git a/entry/libs/x86_64/libTKBool.so.8.0 b/entry/libs/x86_64/libTKBool.so.8.0 index 34302ae0..c3ca470b 100644 Binary files a/entry/libs/x86_64/libTKBool.so.8.0 and b/entry/libs/x86_64/libTKBool.so.8.0 differ diff --git a/entry/libs/x86_64/libTKCAF.so.8.0 b/entry/libs/x86_64/libTKCAF.so.8.0 index 09d747ee..7c8b72f4 100644 Binary files a/entry/libs/x86_64/libTKCAF.so.8.0 and b/entry/libs/x86_64/libTKCAF.so.8.0 differ diff --git a/entry/libs/x86_64/libTKCDF.so.8.0 b/entry/libs/x86_64/libTKCDF.so.8.0 index 0c73eb45..277acf98 100644 Binary files a/entry/libs/x86_64/libTKCDF.so.8.0 and b/entry/libs/x86_64/libTKCDF.so.8.0 differ diff --git a/entry/libs/x86_64/libTKDE.so.8.0 b/entry/libs/x86_64/libTKDE.so.8.0 index 37e599b1..45ee2ba5 100644 Binary files a/entry/libs/x86_64/libTKDE.so.8.0 and b/entry/libs/x86_64/libTKDE.so.8.0 differ diff --git a/entry/libs/x86_64/libTKDECascade.so.8.0 b/entry/libs/x86_64/libTKDECascade.so.8.0 index 17e99989..0e5b384a 100644 Binary files a/entry/libs/x86_64/libTKDECascade.so.8.0 and b/entry/libs/x86_64/libTKDECascade.so.8.0 differ diff --git a/entry/libs/x86_64/libTKDEIGES.so.8.0 b/entry/libs/x86_64/libTKDEIGES.so.8.0 index 277bf52a..7ab14e79 100644 Binary files a/entry/libs/x86_64/libTKDEIGES.so.8.0 and b/entry/libs/x86_64/libTKDEIGES.so.8.0 differ diff --git a/entry/libs/x86_64/libTKDEOBJ.so.8.0 b/entry/libs/x86_64/libTKDEOBJ.so.8.0 index cb3f9fc0..c7bfb4f2 100644 Binary files a/entry/libs/x86_64/libTKDEOBJ.so.8.0 and b/entry/libs/x86_64/libTKDEOBJ.so.8.0 differ diff --git a/entry/libs/x86_64/libTKDEPLY.so.8.0 b/entry/libs/x86_64/libTKDEPLY.so.8.0 index fb9d91af..4ad29cf1 100644 Binary files a/entry/libs/x86_64/libTKDEPLY.so.8.0 and b/entry/libs/x86_64/libTKDEPLY.so.8.0 differ diff --git a/entry/libs/x86_64/libTKDESTEP.so.8.0 b/entry/libs/x86_64/libTKDESTEP.so.8.0 index 7f614e4c..955a5429 100644 Binary files a/entry/libs/x86_64/libTKDESTEP.so.8.0 and b/entry/libs/x86_64/libTKDESTEP.so.8.0 differ diff --git a/entry/libs/x86_64/libTKDESTL.so.8.0 b/entry/libs/x86_64/libTKDESTL.so.8.0 index 586e49ae..a7c8c7e7 100644 Binary files a/entry/libs/x86_64/libTKDESTL.so.8.0 and b/entry/libs/x86_64/libTKDESTL.so.8.0 differ diff --git a/entry/libs/x86_64/libTKDEVRML.so.8.0 b/entry/libs/x86_64/libTKDEVRML.so.8.0 index 2e333c8a..fb40cf0a 100644 Binary files a/entry/libs/x86_64/libTKDEVRML.so.8.0 and b/entry/libs/x86_64/libTKDEVRML.so.8.0 differ diff --git a/entry/libs/x86_64/libTKExpress.so.8.0 b/entry/libs/x86_64/libTKExpress.so.8.0 index 86d6080b..245cba2e 100644 Binary files a/entry/libs/x86_64/libTKExpress.so.8.0 and b/entry/libs/x86_64/libTKExpress.so.8.0 differ diff --git a/entry/libs/x86_64/libTKFeat.so.8.0 b/entry/libs/x86_64/libTKFeat.so.8.0 index 0582f7ba..9b495ff2 100644 Binary files a/entry/libs/x86_64/libTKFeat.so.8.0 and b/entry/libs/x86_64/libTKFeat.so.8.0 differ diff --git a/entry/libs/x86_64/libTKFillet.so.8.0 b/entry/libs/x86_64/libTKFillet.so.8.0 index b158d466..53fb4ab8 100644 Binary files a/entry/libs/x86_64/libTKFillet.so.8.0 and b/entry/libs/x86_64/libTKFillet.so.8.0 differ diff --git a/entry/libs/x86_64/libTKG2d.so.8.0 b/entry/libs/x86_64/libTKG2d.so.8.0 index f0924711..740b842d 100644 Binary files a/entry/libs/x86_64/libTKG2d.so.8.0 and b/entry/libs/x86_64/libTKG2d.so.8.0 differ diff --git a/entry/libs/x86_64/libTKG3d.so.8.0 b/entry/libs/x86_64/libTKG3d.so.8.0 index 0553e321..74775083 100644 Binary files a/entry/libs/x86_64/libTKG3d.so.8.0 and b/entry/libs/x86_64/libTKG3d.so.8.0 differ diff --git a/entry/libs/x86_64/libTKGeomAlgo.so.8.0 b/entry/libs/x86_64/libTKGeomAlgo.so.8.0 index 62d1ffef..643e9830 100644 Binary files a/entry/libs/x86_64/libTKGeomAlgo.so.8.0 and b/entry/libs/x86_64/libTKGeomAlgo.so.8.0 differ diff --git a/entry/libs/x86_64/libTKGeomBase.so.8.0 b/entry/libs/x86_64/libTKGeomBase.so.8.0 index c9d0bfa7..ae9e95b2 100644 Binary files a/entry/libs/x86_64/libTKGeomBase.so.8.0 and b/entry/libs/x86_64/libTKGeomBase.so.8.0 differ diff --git a/entry/libs/x86_64/libTKHLR.so.8.0 b/entry/libs/x86_64/libTKHLR.so.8.0 index 6efd7b11..e048b79b 100644 Binary files a/entry/libs/x86_64/libTKHLR.so.8.0 and b/entry/libs/x86_64/libTKHLR.so.8.0 differ diff --git a/entry/libs/x86_64/libTKHelix.so.8.0 b/entry/libs/x86_64/libTKHelix.so.8.0 index 1264dea2..1c9f1b10 100644 Binary files a/entry/libs/x86_64/libTKHelix.so.8.0 and b/entry/libs/x86_64/libTKHelix.so.8.0 differ diff --git a/entry/libs/x86_64/libTKLCAF.so.8.0 b/entry/libs/x86_64/libTKLCAF.so.8.0 index 495ea621..6b13bd87 100644 Binary files a/entry/libs/x86_64/libTKLCAF.so.8.0 and b/entry/libs/x86_64/libTKLCAF.so.8.0 differ diff --git a/entry/libs/x86_64/libTKMath.so.8.0 b/entry/libs/x86_64/libTKMath.so.8.0 index 80f5e5d5..d408e58a 100644 Binary files a/entry/libs/x86_64/libTKMath.so.8.0 and b/entry/libs/x86_64/libTKMath.so.8.0 differ diff --git a/entry/libs/x86_64/libTKMesh.so.8.0 b/entry/libs/x86_64/libTKMesh.so.8.0 index 31148275..feae569b 100644 Binary files a/entry/libs/x86_64/libTKMesh.so.8.0 and b/entry/libs/x86_64/libTKMesh.so.8.0 differ diff --git a/entry/libs/x86_64/libTKMeshVS.so.8.0 b/entry/libs/x86_64/libTKMeshVS.so.8.0 index ccb0c936..cb6c5387 100644 Binary files a/entry/libs/x86_64/libTKMeshVS.so.8.0 and b/entry/libs/x86_64/libTKMeshVS.so.8.0 differ diff --git a/entry/libs/x86_64/libTKOffset.so.8.0 b/entry/libs/x86_64/libTKOffset.so.8.0 index 8259ab2b..5060b854 100644 Binary files a/entry/libs/x86_64/libTKOffset.so.8.0 and b/entry/libs/x86_64/libTKOffset.so.8.0 differ diff --git a/entry/libs/x86_64/libTKOpenGles.so.8.0 b/entry/libs/x86_64/libTKOpenGles.so.8.0 index 3c0c179c..5a720a9f 100644 Binary files a/entry/libs/x86_64/libTKOpenGles.so.8.0 and b/entry/libs/x86_64/libTKOpenGles.so.8.0 differ diff --git a/entry/libs/x86_64/libTKPrim.so.8.0 b/entry/libs/x86_64/libTKPrim.so.8.0 index 50487161..d99e1a53 100644 Binary files a/entry/libs/x86_64/libTKPrim.so.8.0 and b/entry/libs/x86_64/libTKPrim.so.8.0 differ diff --git a/entry/libs/x86_64/libTKRWMesh.so.8.0 b/entry/libs/x86_64/libTKRWMesh.so.8.0 index 09bfff59..ad5228ba 100644 Binary files a/entry/libs/x86_64/libTKRWMesh.so.8.0 and b/entry/libs/x86_64/libTKRWMesh.so.8.0 differ diff --git a/entry/libs/x86_64/libTKService.so.8.0 b/entry/libs/x86_64/libTKService.so.8.0 index 222d60d7..d4e35304 100644 Binary files a/entry/libs/x86_64/libTKService.so.8.0 and b/entry/libs/x86_64/libTKService.so.8.0 differ diff --git a/entry/libs/x86_64/libTKShHealing.so.8.0 b/entry/libs/x86_64/libTKShHealing.so.8.0 index 548b2858..728de65b 100644 Binary files a/entry/libs/x86_64/libTKShHealing.so.8.0 and b/entry/libs/x86_64/libTKShHealing.so.8.0 differ diff --git a/entry/libs/x86_64/libTKStd.so.8.0 b/entry/libs/x86_64/libTKStd.so.8.0 index d8b11694..e6560560 100644 Binary files a/entry/libs/x86_64/libTKStd.so.8.0 and b/entry/libs/x86_64/libTKStd.so.8.0 differ diff --git a/entry/libs/x86_64/libTKStdL.so.8.0 b/entry/libs/x86_64/libTKStdL.so.8.0 index 680a93e9..065891a5 100644 Binary files a/entry/libs/x86_64/libTKStdL.so.8.0 and b/entry/libs/x86_64/libTKStdL.so.8.0 differ diff --git a/entry/libs/x86_64/libTKTObj.so.8.0 b/entry/libs/x86_64/libTKTObj.so.8.0 index 81a69bd1..df871269 100644 Binary files a/entry/libs/x86_64/libTKTObj.so.8.0 and b/entry/libs/x86_64/libTKTObj.so.8.0 differ diff --git a/entry/libs/x86_64/libTKTopAlgo.so.8.0 b/entry/libs/x86_64/libTKTopAlgo.so.8.0 index 8e6ac50b..ed8f48fb 100644 Binary files a/entry/libs/x86_64/libTKTopAlgo.so.8.0 and b/entry/libs/x86_64/libTKTopAlgo.so.8.0 differ diff --git a/entry/libs/x86_64/libTKV3d.so.8.0 b/entry/libs/x86_64/libTKV3d.so.8.0 index 3376e63f..b61af16e 100644 Binary files a/entry/libs/x86_64/libTKV3d.so.8.0 and b/entry/libs/x86_64/libTKV3d.so.8.0 differ diff --git a/entry/libs/x86_64/libTKVCAF.so.8.0 b/entry/libs/x86_64/libTKVCAF.so.8.0 index 248f94e3..16511e8a 100644 Binary files a/entry/libs/x86_64/libTKVCAF.so.8.0 and b/entry/libs/x86_64/libTKVCAF.so.8.0 differ diff --git a/entry/libs/x86_64/libTKXCAF.so.8.0 b/entry/libs/x86_64/libTKXCAF.so.8.0 index 77ef09bf..1dfedd26 100644 Binary files a/entry/libs/x86_64/libTKXCAF.so.8.0 and b/entry/libs/x86_64/libTKXCAF.so.8.0 differ diff --git a/entry/libs/x86_64/libTKXMesh.so.8.0 b/entry/libs/x86_64/libTKXMesh.so.8.0 index d175394e..cd814c41 100644 Binary files a/entry/libs/x86_64/libTKXMesh.so.8.0 and b/entry/libs/x86_64/libTKXMesh.so.8.0 differ diff --git a/entry/libs/x86_64/libTKXSBase.so.8.0 b/entry/libs/x86_64/libTKXSBase.so.8.0 index 1bd47adf..fa5f96af 100644 Binary files a/entry/libs/x86_64/libTKXSBase.so.8.0 and b/entry/libs/x86_64/libTKXSBase.so.8.0 differ diff --git a/entry/libs/x86_64/libTKXml.so.8.0 b/entry/libs/x86_64/libTKXml.so.8.0 index 4e6c3c63..f644c8d0 100644 Binary files a/entry/libs/x86_64/libTKXml.so.8.0 and b/entry/libs/x86_64/libTKXml.so.8.0 differ diff --git a/entry/libs/x86_64/libTKXmlL.so.8.0 b/entry/libs/x86_64/libTKXmlL.so.8.0 index 8b5cadf7..b776166a 100644 Binary files a/entry/libs/x86_64/libTKXmlL.so.8.0 and b/entry/libs/x86_64/libTKXmlL.so.8.0 differ diff --git a/entry/libs/x86_64/libTKXmlTObj.so.8.0 b/entry/libs/x86_64/libTKXmlTObj.so.8.0 index 173d99b4..5bd11a6a 100644 Binary files a/entry/libs/x86_64/libTKXmlTObj.so.8.0 and b/entry/libs/x86_64/libTKXmlTObj.so.8.0 differ diff --git a/entry/libs/x86_64/libTKXmlXCAF.so.8.0 b/entry/libs/x86_64/libTKXmlXCAF.so.8.0 index 9c64d25c..ee3ed1d7 100644 Binary files a/entry/libs/x86_64/libTKXmlXCAF.so.8.0 and b/entry/libs/x86_64/libTKXmlXCAF.so.8.0 differ diff --git a/entry/libs/x86_64/libTKernel.so.8.0 b/entry/libs/x86_64/libTKernel.so.8.0 index bd83daea..9c639a67 100644 Binary files a/entry/libs/x86_64/libTKernel.so.8.0 and b/entry/libs/x86_64/libTKernel.so.8.0 differ diff --git a/entry/libs/x86_64/libbrotlicommon.so.1 b/entry/libs/x86_64/libbrotlicommon.so.1 new file mode 100644 index 00000000..9f2309d7 Binary files /dev/null and b/entry/libs/x86_64/libbrotlicommon.so.1 differ diff --git a/entry/libs/x86_64/libbrotlidec.so.1 b/entry/libs/x86_64/libbrotlidec.so.1 new file mode 100644 index 00000000..906b3921 Binary files /dev/null and b/entry/libs/x86_64/libbrotlidec.so.1 differ diff --git a/entry/libs/x86_64/libbrotlienc.so.1 b/entry/libs/x86_64/libbrotlienc.so.1 new file mode 100644 index 00000000..0b7af231 Binary files /dev/null and b/entry/libs/x86_64/libbrotlienc.so.1 differ diff --git a/entry/libs/x86_64/libbz2.so b/entry/libs/x86_64/libbz2.so new file mode 100644 index 00000000..7bda725e Binary files /dev/null and b/entry/libs/x86_64/libbz2.so differ diff --git a/entry/libs/x86_64/libfreetype.so.6 b/entry/libs/x86_64/libfreetype.so.6 index 9a26ba1d..095d8269 100644 Binary files a/entry/libs/x86_64/libfreetype.so.6 and b/entry/libs/x86_64/libfreetype.so.6 differ diff --git a/entry/libs/x86_64/libharfbuzz.so b/entry/libs/x86_64/libharfbuzz.so new file mode 100644 index 00000000..5eb1c5a8 Binary files /dev/null and b/entry/libs/x86_64/libharfbuzz.so differ diff --git a/entry/libs/x86_64/libpng16.so.16 b/entry/libs/x86_64/libpng16.so.16 new file mode 100644 index 00000000..8850f36b Binary files /dev/null and b/entry/libs/x86_64/libpng16.so.16 differ diff --git a/entry/src/main/cpp/CMakeLists.txt b/entry/src/main/cpp/CMakeLists.txt index 319f7f66..7b31db1d 100644 --- a/entry/src/main/cpp/CMakeLists.txt +++ b/entry/src/main/cpp/CMakeLists.txt @@ -4,6 +4,7 @@ project(opencax) set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) add_definitions(-DOHOS_PLATFORM) +add_definitions (-DHAVE_FREETYPE) set(CMAKE_CXX_STANDARD 17) # 添加 NAPI 头文件 @@ -23,7 +24,10 @@ set(OCCT_CORE_LIBS TKDESTEP TKShHealing TKHLR TKVCAF TKBO TKPrim TKBool TKDE TKXSBase ) -set(OCCT_3RD_LIBS libfreetype.so.6) +set(OCCT_3RD_LIBS + libfreetype.so.6 libharfbuzz.so libbz2.so libbrotlienc.so.1 + libbrotlidec.so.1 libbrotlicommon.so.1 libpng16.so.16 +) foreach(LIB_NAME ${OCCT_CORE_LIBS}) list(APPEND OCCT_IMPORTED_LIBS ${OCCT_LIB_DIR}/lib${LIB_NAME}.so.${OCCT_VERSION}) diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp index 367c2e9c..2bc4caf6 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.cpp @@ -15,9 +15,7 @@ NativeRender::NativeRender(int w, int h) ogd(new OpenGlGraphicDriver), ts(new TextStyle), vw(new View), vr(new Viewer), win(new Window) { width = w; height = h; - ftMgr=Font_FontMgr::GetInstance(); - ftMgr->SetPrintErrors(true); - ftMgr->SetTraceAliases(true); + } NativeRender::~NativeRender() { shapes_.clear(); } @@ -231,18 +229,32 @@ void NativeRender::fontDev() { // // } //OCCT字体管理信息获取 -// auto mgr=Font_FontMgr::GetInstance(); +// auto mgr=Font_FontMgr::GetInstance(); +// Handle(Font_SystemFont) sysFont=new Font_SystemFont("HarmonyOS_Sans_Regular"); +// sysFont->SetFontPath(Font_FontAspect_Regular, "/data/storage/el1/bundle/entry/resources/rawfile/fonts/HarmonyOS_Sans_Regular.ttf"); +// TCollection_ExtendedString aFontName("HarmonyOS_Sans_Regular"); // 为你自定义的字体起一个名称,后续绘制时会用到 +// +// // 注册字体。第二个参数如果是 Standard_True,表示强制注册,即使同名也覆盖。 +// bool isRegistered = mgr->RegisterFont(sysFont, Standard_True); +// +// if (!isRegistered) { +// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","Error: Cannot register font: %{public}s",sysFont->FontName().ToCString()); +// return; // 或者进行错误处理 +// } else { +// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","Successfully registered font: %{public}s",sysFont->FontName().ToCString()); +// } +// mgr->InitFontDataBase(); +// mgr->AddFontAlias("HarmonyOS-Sans", "HarmonyOS-Sans"); // Font_FontAspect aspect = Font_FA_Regular; // // 查找sans别名,优先匹配HarmonyOS Sans -// Handle(Font_SystemFont) font = mgr->FindFont("HarmonyOS-Sans", aspect); +// Handle(Font_SystemFont) font = mgr->FindFont("HarmonyOS_Sans_Regular", aspect); // if (!font.IsNull()) { // // 打印实际匹配到的字体名,若为HarmonyOS Sans则生效 // OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","SO库匹配到的字体名:%{public}s",font->FontName().ToCString()); // } -// mgr->InitFontDataBase(); // Handle(Font_SystemFont) sysFont=new Font_SystemFont("HarmonyOS-Sans"); -// sysFont->SetFontPath(Font_FontAspect_Regular, "/system/fonts/"); -// bool err=mgr->RegisterFont(sysFont,false); +// sysFont->SetFontPath(Font_FontAspect_Regular, "/data/storage/el1/bundle/entry/resources/rawfile/fonts"); +// bool err=mgr->RegisterFont(sysFont,true); // if(err){ // OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT RegisterFont Done"); // } @@ -251,9 +263,10 @@ void NativeRender::fontDev() { // for(auto ft:theAliases){ // OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Aliases: %{public}s", ft->ToCString()); // } -// Handle(Font_SystemFont)sFont = mgr->GetFont("HarmonyOS-Sans"); -// OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT sysFont: %{public}s", sFont->FontName().ToCString()); -// //查找指定的字体 + + //Handle(Font_SystemFont)sFont = mgr->GetFont("HarmonyOS-Sans"); + //OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT sysFont: %{public}s", sFont->FontName().ToCString()); + //查找指定的字体 // const TCollection_AsciiString theFontName='HarmonyOS-Sans'; // Font_FontAspect theFontAspect; // mgr->FindFont(theFontName, theFontAspect); @@ -261,14 +274,16 @@ void NativeRender::fontDev() { //字体示例 Handle(AIS_TextLabel) aTextLabel = new AIS_TextLabel(); - aTextLabel->SetText(TCollection_ExtendedString(u8"共产主义接班人")); - Handle(Prs3d_TextAspect) textAspect = aTextLabel->Attributes()->TextAspect(); - textAspect->SetFont("HarmonyOS Sans"); - textAspect->SetHeight(10000.0); - textAspect->SetColor(Quantity_Color(Quantity_NOC_YELLOW)); + //TCollection_ExtendedString tostr; + //const char* str = "\xC4\xE3\xBA\xC3"; + //Resource_Unicode::ConvertGBToUnicode(str, tostr); + const char16_t chinese_array[] = u"新时代社会主义新中国接班人"; + aTextLabel->SetText(chinese_array); + aTextLabel->Attributes()->SetTextAspect(ts->text); gp_Pnt position(0.0, 0.0, 0.0); // 例如,在原点 aTextLabel->SetPosition(position); ctx->context->Display(aTextLabel, Standard_True); - vw->ResetView(); + HILOG_ERROR(NATIVE_TAG, "aTextLabel字体名字:%{public}s", aTextLabel->FontName().ToCString()); + HILOG_ERROR(NATIVE_TAG, "aTextLabel字体名字:%{public}s", aTextLabel->Attributes()->TextAspect()->Aspect()->Font().ToCString()); } } // namespace NativeOpenCAX \ No newline at end of file diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h index 0be0e963..c36b0343 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRender.h @@ -73,7 +73,6 @@ private: View* vw; Viewer* vr; Window* win; - Handle(Font_FontMgr) ftMgr ; std::vector shapes_; }; } // namespace NativeRender diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp index 848fea0c..9a28a50a 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.cpp @@ -1,4 +1,5 @@ #include "NativeRenderThread.h" +#include "Font_FontAspect.hxx" #include "NativeEGLOCCT/common.h" #include #include @@ -56,6 +57,39 @@ void NativeRenderThread::renderLoop() { if (!eglCore_->init(nativeWindow_)) { OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "EGLCoreInit","Failed to initialize EGL"); } + ftMgr=Font_FontMgr::GetInstance(); + ftMgr->InitFontDataBase(); + ftMgr->SetPrintErrors(true); + ftMgr->SetTraceAliases(true); + Handle(Font_SystemFont) sysFont=new Font_SystemFont("HarmonyOS_Sans_Medium"); + sysFont->SetFontPath(Font_FontAspect_Regular, "/data/storage/el2/base/haps/entry/files/fonts/"); + // 注册字体。第二个参数如果是 Standard_True,表示强制注册,即使同名也覆盖。 + bool isRegistered = ftMgr->RegisterFont(sysFont, Standard_True); + + if (!isRegistered) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","Error: Cannot register font: %{public}s",sysFont->FontName().ToCString()); + return; // 或者进行错误处理 + } else { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","Successfully registered font: %{public}s",sysFont->FontName().ToCString()); + } + + Handle(Font_SystemFont) fsf; + fsf=ftMgr->GetFont("HarmonyOS_Sans_Medium"); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Path: %{public}s", fsf->FontPath(Font_FontAspect_Regular).ToCString()); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT GetFont: %{public}s", fsf->FontName().ToCString()); + //输出所有字体 + NCollection_Sequence> theAliases; + ftMgr->GetAllAliases(theAliases); + for(auto ft:theAliases){ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Aliases: %{public}s", ft->ToCString()); + } + //checkfont + NCollection_List> fsfs; + fsfs=ftMgr->GetAvailableFonts(); + for(auto fta:fsfs){ + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Font: %{public}s", fta->FontName().ToCString()); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "OCCT","OCCT Font Path: %{public}s", fta->FontPath(Font_FontAspect_Regular).ToCString()); + } // 初始化OCCT渲染器 if (!renderer_->init(*eglCore_)) { OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NativeRenderInit","Failed to initialize OCCT renderer"); diff --git a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h index c49879be..55eaf8b3 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h +++ b/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h @@ -10,6 +10,10 @@ #include "EGLCore.h" #include "NativeRender.h" +#include +#include +#include + namespace NativeOpenCAX { class NativeRenderThread { @@ -68,7 +72,7 @@ private: std::mutex callbackMutex_; Callback renderCompleteCallback_; - + Handle(Font_FontMgr) ftMgr ; int windowWidth_; int windowHeight_; }; diff --git a/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.cpp b/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.cpp index 3a1a5fae..62dee5b5 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.cpp +++ b/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.cpp @@ -10,6 +10,7 @@ #define NATIVE_TAG "TEXTSTYLE" #endif +//该类型主要用于全局字体,样式设置.包含字体.大小.颜色.渲染方式 namespace NativeOpenCAX { @@ -20,7 +21,7 @@ bool TextStyle::InitTextStyle() { try { text = new Prs3d_TextAspect(); text->SetFont("HarmonyOS Sans"); - text->SetHeight(12); + text->SetHeight(5000); text->Aspect()->SetColor(Quantity_NOC_GRAY95); text->Aspect()->SetColorSubTitle(Quantity_NOC_BLACK); text->Aspect()->SetDisplayType(Aspect_TODT_SHADOW); diff --git a/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.h b/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.h index 9b7dae2f..a8e3fb14 100644 --- a/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.h +++ b/entry/src/main/cpp/NativeEGLOCCT/TextStyle/TextStyle.h @@ -7,10 +7,16 @@ #ifndef OPENCAX_TEXTSTYLE_H #define OPENCAX_TEXTSTYLE_H +#include #include "NativeEGLOCCT/common.h" #include "Font_NameOfFont.hxx" #include +//字体样式类型.主要用于区别该样式用于何处 +enum FONT_STYLE_TYPE{ + STYLE_AXIS, + STYLE_FACE, +}; namespace NativeOpenCAX{ class TextStyle{ public: @@ -19,6 +25,8 @@ public: bool InitTextStyle(); public: Handle(Prs3d_TextAspect) text; + //一个字体管理样式对象管理.主要负责对字体样式的归一化集中管理 + std::map fontStyle; }; } diff --git a/entry/src/main/cpp/include/opencascade/Font_FontMgr.hxx b/entry/src/main/cpp/include/opencascade/Font_FontMgr.hxx index 2b076458..70ac336b 100644 --- a/entry/src/main/cpp/include/opencascade/Font_FontMgr.hxx +++ b/entry/src/main/cpp/include/opencascade/Font_FontMgr.hxx @@ -31,6 +31,45 @@ class TCollection_HAsciiString; class NCollection_Buffer; +// list of supported extensions +static const char* Font_FontMgr_Extensions[] = {"ttf", + "otf", + "ttc", + "pfa", + "pfb", + #ifdef __APPLE__ + // Datafork TrueType (OS X), obsolete + //"dfont", + #endif + nullptr}; + + #if defined(HAVE_FREETYPE_OHOS) && !defined(__ANDROID__) && !defined(__APPLE__) \ + && !defined(__EMSCRIPTEN__) +// X11 configuration file in plain text format (obsolete - doesn't exists in modern distributives) +static const char* myFontServiceConf[] = {"/etc/X11/fs/config", + "/usr/X11R6/lib/X11/fs/config", + "/usr/X11/lib/X11/fs/config", + nullptr}; + + // Although fontconfig library can be built for various platforms, + // practically it is useful only on desktop Linux distributions, where it is always packaged. + //Harmony OS not + #include + #endif + + #ifdef __APPLE__ +// default fonts paths in Mac OS X +static const char* myDefaultFontsDirs[] = {"/System/Library/Fonts", "/Library/Fonts", nullptr}; + #else +// default fonts paths in most Unix systems (Linux and others) +// static const char* myDefaultFontsDirs[] = {"/system/fonts", // Android +// "/usr/share/fonts", +// "/usr/local/share/fonts", +// nullptr}; +static const char* myDefaultFontsDirs[] = {"/data/storage/el2/base/haps/entry/files/fonts", // Harmony OS + nullptr}; + #endif + //! Collects and provides information about available fonts in system. class Font_FontMgr : public Standard_Transient { diff --git a/entry/src/main/cpp/include/opencascade/Standard_Version.hxx b/entry/src/main/cpp/include/opencascade/Standard_Version.hxx index 7332f3a1..d8593d56 100644 --- a/entry/src/main/cpp/include/opencascade/Standard_Version.hxx +++ b/entry/src/main/cpp/include/opencascade/Standard_Version.hxx @@ -1,4 +1,4 @@ -// Created on: 2026-03-25 +// Created on: 2026-03-27 // Copyright (c) 2002-2025 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 4e87a049..812dedee 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -6,8 +6,6 @@ import { ModelViewTab } from './modelViewTab' import { TitleColumnSub } from './TitleLayout/TitleColumnSub' import { mwInfo } from './AppStorageV2Class' import fs from '@ohos.file.fs'; -import resourceManager from '@ohos.resourceManager'; -import fileIO from '@ohos.fileio'; const DOMAIN = 0x0000; @@ -29,50 +27,80 @@ struct Index { @Provider('panelWidth') panelWidth:number=mwInfo.mainWindowWidth * 0.15; //列出资源管理器指定目录下的所有问题件 - async HilogToDirFile(dir: string){ - const context = getContext(this); + HilogToDirFile(){ + const context = this.getUIContext().getHostContext(); // 获取资源管理器 - const rm = context.resourceManager; - - // 列出 rawfile/fonts/ - const fontFiles: string[] = await rm.getRawFileList(dir); - console.info(dir+'目录下文件:', JSON.stringify(fontFiles)); - - if (fontFiles.length === 0) { - console.warn(dir +':目录为空'); - return; - } + const rm = context?.filesDir+'/fonts/'; + fs.listFile(rm).then((filenames: Array) => { + console.info('沙箱文件信息'); // 打印成功日志 + console.info('目录路径:'+rm); // 打印成功日志 + console.log('指定目录文件数: ' + filenames.length) // 打印文件数量 + // 遍历打印所有文件名到控制台 + for (let i = 0; i < filenames.length; i++) { + console.log('文件名:', filenames[i]); + } + }).catch((err: BusinessError) => { + // 捕获并打印文件列表获取失败的错误信息 + console.error('list file failed with error message: ' + err.message + ', error code: ' + err.code); + }); } //复制字体到沙盒指定目录 //SandBoxFontDir:"/data/storage/el2/base/haps/entry/files/fonts" - async CopyFontToSandbox(fontFiles: Array) { - try { - const context = getContext(this); - let srcPath = context.resourceDir+'/fonts/'; - let destPath = context.filesDir + '/fonts/'; - // 判断文件夹是否存在 - if (!fs.accessSync(destPath)) { - fs.mkdirSync(destPath); - console.info('创建沙箱目录成功:', destPath); - } - console.info('srcPath:', srcPath); - console.info('destPath:', destPath); - fs.copyDirSync(srcPath, destPath, 0) - } catch (err) { - let msg = 'Unknown error'; - if (err instanceof Error) { - msg = err.message; - } else if (typeof err === 'string') { - msg = err; - } - console.error(`Copy failed: ${msg}`); - throw new Error(`Failed to copy ${fontFiles} to sandbox: ${msg}`); + CopyFontToSandbox() { + try { + const context = this.getUIContext().getHostContext(); + let srcPath = context?.resourceDir+ '/fonts/'; + let destPath = context?.filesDir + '/fonts/'; + + if (!srcPath || !destPath) { + throw new Error('Resource or files directory is not available.'); } + + console.info('srcPath:', srcPath); + console.info('destPath:', destPath); + + // 1. 检查源目录是否存在 + try { + fs.access(srcPath); + } catch (error) { + console.error('Source directory does not exist:', srcPath); + return; // 或者抛出错误 + } + + // 2. 创建目标目录 + // 使用 mkdir 同步或异步版本,并处理已存在的异常 + try { + fs.mkdir(destPath); + console.info('Created sandbox directory successfully:', destPath); + } catch (mkdirErr) { + // 如果目录已存在,mkdir 会失败,这通常是无害的 + console.info('Sandbox directory already exists:', destPath); + } + + // 3. 复制目录 + // 关键修改点:移除第三个参数 '1',该参数是无效的。 + // 可以选择性地添加一个空的 flags 对象 {} + fs.copyDir(srcPath, destPath); + + console.info('Fonts copied to sandbox successfully.'); + + } catch (err) { + let msg = 'Unknown error'; + if (err instanceof Error) { + msg = err.message; + } else if (typeof err === 'string') { + msg = err; + } + console.error(`Copy failed: ${msg}`); + // 注意:模板字符串需要反引号 ``,您原代码中的单引号 '' 会直接输出变量名 + throw new Error(`Failed to copy to sandbox: ${msg}`); + } } //Copy Font File to Sandbox aboutToAppear() { - this.HilogToDirFile('fonts/'); - this.CopyFontToSandbox(Fonts); + this.CopyFontToSandbox(); + //输出沙盘下得文件名 + this.HilogToDirFile(); } build() { diff --git a/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets b/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets index 9d70b6b2..8722ee1c 100644 --- a/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets +++ b/entry/src/main/ets/pages/TitleLayout/TitleColumnSub.ets @@ -8,6 +8,7 @@ import { LayoutSwitch } from "../LayoutInterface/Layout/LayoutSwitch"; import { FileMenuData } from "../LayoutInterface/Layout/FileMenuData"; import { mwInfo } from "../AppStorageV2Class"; import { SubColumnMenu} from "../CustomStyle/Button"; +import { fileIo } from "@kit.CoreFileKit"; @ComponentV2 diff --git a/entry/src/main/ets/pages/modelView.ets b/entry/src/main/ets/pages/modelView.ets index deae0a66..125de0d1 100644 --- a/entry/src/main/ets/pages/modelView.ets +++ b/entry/src/main/ets/pages/modelView.ets @@ -24,9 +24,35 @@ export struct ModelView { private nodeContent: NodeContent = new NodeContent(); aboutToAppear() { - const context = getContext(this); - modelPath = `${context.filesDir}/${this.modelName}` NativeOpenCAX.createNativeNode(this.nodeContent); + this.copyRawFileToSandbox(); + } + async copyRawFileToSandbox() { + try { + const context = getContext(this); + modelPath = `${context.filesDir}/${this.modelName}`; + const arrayBuffer:Uint8Array = await context.resourceManager.getRawFileContent(this.modelName); + const buffer = arrayBuffer.buffer; + console.log('Raw file size:', arrayBuffer.byteLength); + if (fs.accessSync(modelPath)) { + fs.unlinkSync(modelPath); + } + const fd = fileIO.openSync(modelPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE,0o666); + const bytesWritten = fileIO.writeSync(fd, buffer); + console.log('Bytes written:', bytesWritten); + fileIO.closeSync(fd); + console.log('SanBox File:', arrayBuffer.byteLength); + console.log('WriteModelPath:', modelPath); + } catch (err) { + let msg = 'Unknown error'; + if (err instanceof Error) { + msg = err.message; + } else if (typeof err === 'string') { + msg = err; + } + console.error(`Copy failed: ${msg}`); + throw new Error(`Failed to copy ${this.modelName} to sandbox: ${msg}`); + } } build() { diff --git a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Black.ttf b/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Black.ttf deleted file mode 100644 index e551ec32..00000000 Binary files a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Black.ttf and /dev/null differ diff --git a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Bold.ttf b/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Bold.ttf deleted file mode 100644 index d4a5771d..00000000 Binary files a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Bold.ttf and /dev/null differ diff --git a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Light.ttf b/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Light.ttf deleted file mode 100644 index ca84eb11..00000000 Binary files a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Light.ttf and /dev/null differ diff --git a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Medium.ttf b/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Medium.ttf deleted file mode 100644 index c71de848..00000000 Binary files a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Medium.ttf and /dev/null differ diff --git a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Regular.ttf b/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Regular.ttf deleted file mode 100644 index 830b2afa..00000000 Binary files a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Regular.ttf and /dev/null differ diff --git a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Semibold.ttf b/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Semibold.ttf deleted file mode 100644 index 27551a39..00000000 Binary files a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Semibold.ttf and /dev/null differ diff --git a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Thin.ttf b/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Thin.ttf deleted file mode 100644 index 56c5ae59..00000000 Binary files a/entry/src/main/resources/rawfile/fonts/HarmonyOS_Sans_Thin.ttf and /dev/null differ diff --git a/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Black.ttf b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Black.ttf new file mode 100644 index 00000000..184e791a Binary files /dev/null and b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Black.ttf differ diff --git a/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Bold.ttf b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Bold.ttf new file mode 100644 index 00000000..2a3791fc Binary files /dev/null and b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Bold.ttf differ diff --git a/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Light.ttf b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Light.ttf new file mode 100644 index 00000000..c376b15c Binary files /dev/null and b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Light.ttf differ diff --git a/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Medium.ttf b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Medium.ttf new file mode 100644 index 00000000..527457d8 Binary files /dev/null and b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Medium.ttf differ diff --git a/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Regular.ttf b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Regular.ttf new file mode 100644 index 00000000..02456d27 Binary files /dev/null and b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Regular.ttf differ diff --git a/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Semibold.ttf b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Semibold.ttf new file mode 100644 index 00000000..b2c59ca8 Binary files /dev/null and b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Semibold.ttf differ diff --git a/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Thin.ttf b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Thin.ttf new file mode 100644 index 00000000..0420a61a Binary files /dev/null and b/entry/src/main/resources/resfile/fonts/HarmonyOS_SansSC_Thin.ttf differ diff --git a/entry/src/main/resources/resfile/fonts/simhei.ttf b/entry/src/main/resources/resfile/fonts/simhei.ttf new file mode 100644 index 00000000..c5030aea Binary files /dev/null and b/entry/src/main/resources/resfile/fonts/simhei.ttf differ