From 70491687c6f3be021791d0f52d5e899069338829 Mon Sep 17 00:00:00 2001 From: HEYAHONG <2229388563@qq.com> Date: Tue, 10 Dec 2024 17:25:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hbox/gui/tools/dotfontscan/.gitignore | 2 + hbox/gui/tools/dotfontscan/CMakeLists.txt | 26 +++ hbox/gui/tools/dotfontscan/fs/banner | 6 + hbox/gui/tools/dotfontscan/main.cpp | 238 ++++++++++++++++++++++ 4 files changed, 272 insertions(+) create mode 100644 hbox/gui/tools/dotfontscan/.gitignore create mode 100644 hbox/gui/tools/dotfontscan/CMakeLists.txt create mode 100644 hbox/gui/tools/dotfontscan/fs/banner create mode 100644 hbox/gui/tools/dotfontscan/main.cpp diff --git a/hbox/gui/tools/dotfontscan/.gitignore b/hbox/gui/tools/dotfontscan/.gitignore new file mode 100644 index 0000000..2b522c3 --- /dev/null +++ b/hbox/gui/tools/dotfontscan/.gitignore @@ -0,0 +1,2 @@ +build +*.exe diff --git a/hbox/gui/tools/dotfontscan/CMakeLists.txt b/hbox/gui/tools/dotfontscan/CMakeLists.txt new file mode 100644 index 0000000..0da68be --- /dev/null +++ b/hbox/gui/tools/dotfontscan/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.20) +set(PROJECT_NAME dotfontscan) +project(${PROJECT_NAME} + VERSION 1.0.0.0 + LANGUAGES C CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_C_STANDARD 99) +file(GLOB C_CXX_FILES *.h *.cpp *.c *.hpp *.cxx) +add_executable(${PROJECT_NAME} ${C_CXX_FILES}) +#添加线程库 +find_package(Threads REQUIRED) +target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT}) +#设定HRC文件系统目录为fs +set(HRC_FS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fs/) +#添加3rdparty/HCppBox +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../../ HCppBox EXCLUDE_FROM_ALL) +#启用HCppBox、HRC +hcppbox_enable(${PROJECT_NAME}) +hrc_enable(${PROJECT_NAME}) + +include(FindPkgConfig) +#添加FreeType +pkg_check_modules(FREETYPE2 IMPORTED_TARGET REQUIRED freetype2) +target_link_libraries(${PROJECT_NAME} PkgConfig::FREETYPE2) + diff --git a/hbox/gui/tools/dotfontscan/fs/banner b/hbox/gui/tools/dotfontscan/fs/banner new file mode 100644 index 0000000..80a4ba2 --- /dev/null +++ b/hbox/gui/tools/dotfontscan/fs/banner @@ -0,0 +1,6 @@ + _ _ __ _ + __| | ___ | |_ / _| ___ _ __ | |_ ___ ___ __ _ _ __ + / _` |/ _ \| __| |_ / _ \| '_ \| __/ __|/ __/ _` | '_ \ +| (_| | (_) | |_| _| (_) | | | | |_\__ \ (_| (_| | | | | + \__,_|\___/ \__|_| \___/|_| |_|\__|___/\___\__,_|_| |_| + diff --git a/hbox/gui/tools/dotfontscan/main.cpp b/hbox/gui/tools/dotfontscan/main.cpp new file mode 100644 index 0000000..4d3bf13 --- /dev/null +++ b/hbox/gui/tools/dotfontscan/main.cpp @@ -0,0 +1,238 @@ +#include "HCPPBox.h" +#include "hbox.h" +#include "hrc.h" +#include +#include FT_FREETYPE_H +#include "stdlib.h" +#include "stdio.h" +#include + + +static class ft_lib +{ + FT_Library library; +public: + operator FT_Library() + { + return library; + } + ft_lib():library(NULL) + { + FT_Init_FreeType(&library); + } + ~ft_lib() + { + FT_Done_FreeType(library); + } +} g_ft_lib; + + +static int cmd_help(int argc,const char *argv[]); +static int cmd_font(int argc,const char *argv[]); +static struct +{ + const char * cmd; + const char * cmd_short; + int (*cmd_entry)(int argc,const char *argv[]); + const char * usage; + const char * help; +} cmd_list[]= +{ + { + "--help", + "-h", + cmd_help, + "--help / -h ", + "get help" + }, + { + "--font", + "-f", + cmd_help, + "--font=[font_file_path] / -f [font_file_path] ", + "fontfile path" + } +}; + +static int cmd_help(int argc,const char *argv[]) +{ + const size_t cmd_max_len=16; + const size_t usage_max_len=50; + { + //打印banner + const char *banner=(const char *)RCGetHandle("banner"); + if(banner!=NULL) + { + printf("%s",banner); + } + } + { + printf("\r\n%s [options]\r\n",argv[0]); + } + { + //打印标题栏 + for(size_t i=0; i 0) + { + for(size_t i=0; i 0) + { + for(size_t i=0; i