├── .gitignore ├── .idea ├── Falcom.iml ├── misc.xml ├── modules.xml ├── vcs.xml └── workspace.xml ├── CMakeLists.txt ├── README.md ├── common ├── include │ ├── asuka.h │ ├── freetype │ │ ├── config │ │ │ ├── ftconfig.h │ │ │ ├── ftheader.h │ │ │ ├── ftmodule.h │ │ │ ├── ftoption.h │ │ │ └── ftstdlib.h │ │ ├── freetype.h │ │ ├── ftadvanc.h │ │ ├── ftautoh.h │ │ ├── ftbbox.h │ │ ├── ftbdf.h │ │ ├── ftbitmap.h │ │ ├── ftbzip2.h │ │ ├── ftcache.h │ │ ├── ftcffdrv.h │ │ ├── ftchapters.h │ │ ├── ftcid.h │ │ ├── fterrdef.h │ │ ├── fterrors.h │ │ ├── ftfntfmt.h │ │ ├── ftgasp.h │ │ ├── ftglyph.h │ │ ├── ftgxval.h │ │ ├── ftgzip.h │ │ ├── ftimage.h │ │ ├── ftincrem.h │ │ ├── ftlcdfil.h │ │ ├── ftlist.h │ │ ├── ftlzw.h │ │ ├── ftmac.h │ │ ├── ftmm.h │ │ ├── ftmodapi.h │ │ ├── ftmoderr.h │ │ ├── ftotval.h │ │ ├── ftoutln.h │ │ ├── ftpcfdrv.h │ │ ├── ftpfr.h │ │ ├── ftrender.h │ │ ├── ftsizes.h │ │ ├── ftsnames.h │ │ ├── ftstroke.h │ │ ├── ftsynth.h │ │ ├── ftsystem.h │ │ ├── fttrigon.h │ │ ├── ftttdrv.h │ │ ├── fttypes.h │ │ ├── ftwinfnt.h │ │ ├── t1tables.h │ │ ├── ttnameid.h │ │ ├── tttables.h │ │ ├── tttags.h │ │ └── ttunpat.h │ ├── ft2build.h │ ├── iconv.h │ ├── kvec.h │ ├── png.h │ ├── pngconf.h │ ├── pnglibconf.h │ ├── zconf.h │ └── zlib.h └── lib │ ├── libfreetype.a │ ├── libiconv.a │ ├── libpng.a │ └── libz.a ├── edao-patch ├── PCSG00246.txt └── src │ ├── .clang_complete │ ├── Makefile │ ├── hook.c │ ├── hook.h │ ├── hook_stub.s │ ├── khash.h │ ├── log.c │ ├── log.h │ ├── main.c │ ├── memcpy_asm.S │ ├── tools.c │ ├── tools.h │ ├── translator.c │ └── translator.h ├── font2png └── src │ ├── Makefile │ └── font2png.c ├── makefont └── src │ ├── Makefile │ ├── codeconvert.c │ ├── codeconvert.h │ ├── easyfont.c │ ├── easyfont.h │ ├── makefont.c │ └── makefont.h └── scripts ├── CheckCNJPMatch.py ├── Common.py ├── CompareLength.py ├── ExtractNotTranslate.py ├── GenSJISCodeTable.py ├── GenUTF8CodeTable.py ├── ImportCodeTable.TBL ├── MakeCodeTable.py ├── MakeJPCNMap.py ├── MoveExtra.py ├── MoveOutput.bat ├── PackJPCNMap.py ├── ProcessEbootText.py ├── ReportDiff.py ├── ReportNotMatch.py ├── ShiftJisCodeTable.png ├── nidformat.py └── vitadump.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.la 22 | *.lo 23 | 24 | # Shared objects (inc. Windows DLLs) 25 | *.dll 26 | *.so 27 | *.so.* 28 | *.dylib 29 | 30 | # Executables 31 | *.exe 32 | *.out 33 | *.app 34 | *.i*86 35 | *.x86_64 36 | *.hex 37 | 38 | # Debug files 39 | *.dSYM/ 40 | *.su 41 | *.idb 42 | *.pdb 43 | 44 | # Kernel Module Compile Results 45 | *.mod* 46 | *.cmd 47 | .tmp_versions/ 48 | modules.order 49 | Module.symvers 50 | Mkfile.old 51 | dkms.conf 52 | 53 | 54 | #CMake 55 | cmake-build-* 56 | 57 | 58 | #PS Vita 59 | *.velf 60 | *.suprx 61 | *.skprx 62 | *.bin 63 | *.swp 64 | *.fnt 65 | *.dat 66 | *.new 67 | -------------------------------------------------------------------------------- /.idea/Falcom.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | project(Falcom C) 3 | 4 | 5 | include_directories(common/include) 6 | include_directories(/opt/local/include) 7 | #include_directories(/Users/asuka/local/vitasdk/arm-vita-eabi/include) 8 | #link_directories(common/lib) 9 | link_directories(/opt/local/lib) 10 | 11 | set(CMAKE_C_FLAGS "-Wl, -Wall -std=gnu11 -g") 12 | 13 | 14 | 15 | set(FONT2PNG_SOURCE_FILES 16 | font2png/src/font2png.c) 17 | 18 | add_executable(font2png ${FONT2PNG_SOURCE_FILES}) 19 | target_link_libraries(font2png png z m) 20 | 21 | 22 | set (MAKEFONT_SOURCE_FILES 23 | makefont/src/easyfont.c 24 | makefont/src/easyfont.h 25 | makefont/src/makefont.c 26 | makefont/src/makefont.h makefont/src/codeconvert.h makefont/src/codeconvert.c) 27 | 28 | add_executable(makefont ${MAKEFONT_SOURCE_FILES}) 29 | target_link_libraries(makefont freetype png z iconv) 30 | 31 | 32 | 33 | set(EDAOPATCH_SOURCE_FILES 34 | edao-patch/src/hook.c 35 | edao-patch/src/log.c 36 | edao-patch/src/main.c 37 | edao-patch/src/tools.c 38 | edao-patch/src/translator.c edao-patch/src/memcpy_asm.S) 39 | 40 | 41 | add_executable(edao-patch ${EDAOPATCH_SOURCE_FILES}) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Falcom 2 | 3 | PSV 碧之轨迹EVO 汉化程序源码 4 | 5 | 发布地址:https://tieba.baidu.com/p/6302452900 6 | 7 | 汉化使用PC版文本,查字典方式 8 | 9 | 即先做一个 PC日文-PC中文的字典,当PSV游戏显示日文时,Hook相关函数,获取日文原文做为Key,去字典里查Value,查到了就显示出来 10 | 11 | 目前的汉化测试补丁还很不完整,EVO和老版之间有差异的文本没有汉化,新增剧情没有汉化,图片也没有汉化 12 | 13 | 我自己大概是没什么时间继续下去了 14 | 15 | 如果你想继续汉化碧轨EVO或者零轨EVO,可以提个Issue联系我,我会看到的 16 | -------------------------------------------------------------------------------- /common/include/asuka.h: -------------------------------------------------------------------------------- 1 | #ifndef ASUKA_H 2 | #define ASUKA_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | //macros 10 | 11 | #define IN 12 | #define OUT 13 | #define OPT 14 | 15 | #define GET_VALUE(buff, index, type) (*(type*)((unsigned char*)buff + index)) 16 | 17 | #define ALIGN(x, align) (((x) + ((align) - 1)) & ~((align) - 1)) 18 | 19 | 20 | //tool functions 21 | static inline 22 | void* load_file(const char* filename, uint32_t* size) 23 | { 24 | if (!filename) 25 | { 26 | return NULL; 27 | } 28 | 29 | FILE* fp_src = fopen(filename, "rb"); 30 | if (fp_src == NULL) 31 | { 32 | return NULL; 33 | } 34 | 35 | uint32_t filesize = 0; 36 | 37 | fseek(fp_src, 0, SEEK_END); 38 | filesize = ftell(fp_src); 39 | fseek(fp_src, 0, SEEK_SET); 40 | 41 | void* buffer = malloc(filesize); 42 | if (!buffer) 43 | { 44 | fclose(fp_src); 45 | return NULL; 46 | } 47 | 48 | fread(buffer, filesize, 1, fp_src); 49 | fclose(fp_src); 50 | 51 | if (size) 52 | { 53 | *size = filesize; 54 | } 55 | return buffer; 56 | } 57 | 58 | static inline 59 | void free_file(void* file_buff) 60 | { 61 | if(!file_buff) 62 | { 63 | return; 64 | } 65 | free(file_buff); 66 | } 67 | 68 | 69 | static inline 70 | int write_new_file(const char* filename, uint8_t* buffer, uint32_t len) 71 | { 72 | if (!filename || !buffer) 73 | { 74 | return -1; 75 | } 76 | 77 | FILE* fdst = fopen(filename, "wb"); 78 | if (!fdst) 79 | { 80 | return -1; 81 | } 82 | fwrite(buffer, len, 1, fdst); 83 | fclose(fdst); 84 | } 85 | 86 | 87 | 88 | #endif //ASUKA_H -------------------------------------------------------------------------------- /common/include/freetype/config/ftmodule.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file. */ 2 | FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) 3 | FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) 4 | FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) 5 | FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) 6 | FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) 7 | FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) 8 | FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) 9 | FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) 10 | FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) 11 | FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) 12 | FT_USE_MODULE( FT_Module_Class, autofit_module_class ) 13 | FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) 14 | FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) 15 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) 16 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) 17 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) 18 | FT_USE_MODULE( FT_Module_Class, psaux_module_class ) 19 | FT_USE_MODULE( FT_Module_Class, psnames_module_class ) 20 | /* EOF */ 21 | -------------------------------------------------------------------------------- /common/include/freetype/config/ftstdlib.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftstdlib.h */ 4 | /* */ 5 | /* ANSI-specific library and header configuration file (specification */ 6 | /* only). */ 7 | /* */ 8 | /* Copyright 2002-2017 by */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* This file is part of the FreeType project, and may only be used, */ 12 | /* modified, and distributed under the terms of the FreeType project */ 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 | /* this file you indicate that you have read the license and */ 15 | /* understand and accept it fully. */ 16 | /* */ 17 | /***************************************************************************/ 18 | 19 | 20 | /*************************************************************************/ 21 | /* */ 22 | /* This file is used to group all #includes to the ANSI C library that */ 23 | /* FreeType normally requires. It also defines macros to rename the */ 24 | /* standard functions within the FreeType source code. */ 25 | /* */ 26 | /* Load a file which defines FTSTDLIB_H_ before this one to override it. */ 27 | /* */ 28 | /*************************************************************************/ 29 | 30 | 31 | #ifndef FTSTDLIB_H_ 32 | #define FTSTDLIB_H_ 33 | 34 | 35 | #include 36 | 37 | #define ft_ptrdiff_t ptrdiff_t 38 | 39 | 40 | /**********************************************************************/ 41 | /* */ 42 | /* integer limits */ 43 | /* */ 44 | /* UINT_MAX and ULONG_MAX are used to automatically compute the size */ 45 | /* of `int' and `long' in bytes at compile-time. So far, this works */ 46 | /* for all platforms the library has been tested on. */ 47 | /* */ 48 | /* Note that on the extremely rare platforms that do not provide */ 49 | /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */ 50 | /* old Crays where `int' is 36 bits), we do not make any guarantee */ 51 | /* about the correct behaviour of FT2 with all fonts. */ 52 | /* */ 53 | /* In these case, `ftconfig.h' will refuse to compile anyway with a */ 54 | /* message like `couldn't find 32-bit type' or something similar. */ 55 | /* */ 56 | /**********************************************************************/ 57 | 58 | 59 | #include 60 | 61 | #define FT_CHAR_BIT CHAR_BIT 62 | #define FT_USHORT_MAX USHRT_MAX 63 | #define FT_INT_MAX INT_MAX 64 | #define FT_INT_MIN INT_MIN 65 | #define FT_UINT_MAX UINT_MAX 66 | #define FT_LONG_MIN LONG_MIN 67 | #define FT_LONG_MAX LONG_MAX 68 | #define FT_ULONG_MAX ULONG_MAX 69 | 70 | 71 | /**********************************************************************/ 72 | /* */ 73 | /* character and string processing */ 74 | /* */ 75 | /**********************************************************************/ 76 | 77 | 78 | #include 79 | 80 | #define ft_memchr memchr 81 | #define ft_memcmp memcmp 82 | #define ft_memcpy memcpy 83 | #define ft_memmove memmove 84 | #define ft_memset memset 85 | #define ft_strcat strcat 86 | #define ft_strcmp strcmp 87 | #define ft_strcpy strcpy 88 | #define ft_strlen strlen 89 | #define ft_strncmp strncmp 90 | #define ft_strncpy strncpy 91 | #define ft_strrchr strrchr 92 | #define ft_strstr strstr 93 | 94 | 95 | /**********************************************************************/ 96 | /* */ 97 | /* file handling */ 98 | /* */ 99 | /**********************************************************************/ 100 | 101 | 102 | #include 103 | 104 | #define FT_FILE FILE 105 | #define ft_fclose fclose 106 | #define ft_fopen fopen 107 | #define ft_fread fread 108 | #define ft_fseek fseek 109 | #define ft_ftell ftell 110 | #define ft_sprintf sprintf 111 | 112 | 113 | /**********************************************************************/ 114 | /* */ 115 | /* sorting */ 116 | /* */ 117 | /**********************************************************************/ 118 | 119 | 120 | #include 121 | 122 | #define ft_qsort qsort 123 | 124 | 125 | /**********************************************************************/ 126 | /* */ 127 | /* memory allocation */ 128 | /* */ 129 | /**********************************************************************/ 130 | 131 | 132 | #define ft_scalloc calloc 133 | #define ft_sfree free 134 | #define ft_smalloc malloc 135 | #define ft_srealloc realloc 136 | 137 | 138 | /**********************************************************************/ 139 | /* */ 140 | /* miscellaneous */ 141 | /* */ 142 | /**********************************************************************/ 143 | 144 | 145 | #define ft_strtol strtol 146 | #define ft_getenv getenv 147 | 148 | 149 | /**********************************************************************/ 150 | /* */ 151 | /* execution control */ 152 | /* */ 153 | /**********************************************************************/ 154 | 155 | 156 | #include 157 | 158 | #define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ 159 | /* jmp_buf is defined as a macro */ 160 | /* on certain platforms */ 161 | 162 | #define ft_longjmp longjmp 163 | #define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ 164 | 165 | 166 | /* the following is only used for debugging purposes, i.e., if */ 167 | /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ 168 | 169 | #include 170 | 171 | 172 | #endif /* FTSTDLIB_H_ */ 173 | 174 | 175 | /* END */ 176 | -------------------------------------------------------------------------------- /common/include/freetype/ftbbox.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftbbox.h */ 4 | /* */ 5 | /* FreeType exact bbox computation (specification). */ 6 | /* */ 7 | /* Copyright 1996-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /*************************************************************************/ 20 | /* */ 21 | /* This component has a _single_ role: to compute exact outline bounding */ 22 | /* boxes. */ 23 | /* */ 24 | /* It is separated from the rest of the engine for various technical */ 25 | /* reasons. It may well be integrated in `ftoutln' later. */ 26 | /* */ 27 | /*************************************************************************/ 28 | 29 | 30 | #ifndef FTBBOX_H_ 31 | #define FTBBOX_H_ 32 | 33 | 34 | #include 35 | #include FT_FREETYPE_H 36 | 37 | #ifdef FREETYPE_H 38 | #error "freetype.h of FreeType 1 has been loaded!" 39 | #error "Please fix the directory search order for header files" 40 | #error "so that freetype.h of FreeType 2 is found first." 41 | #endif 42 | 43 | 44 | FT_BEGIN_HEADER 45 | 46 | 47 | /*************************************************************************/ 48 | /* */ 49 | /*
*/ 50 | /* outline_processing */ 51 | /* */ 52 | /*************************************************************************/ 53 | 54 | 55 | /*************************************************************************/ 56 | /* */ 57 | /* */ 58 | /* FT_Outline_Get_BBox */ 59 | /* */ 60 | /* */ 61 | /* Compute the exact bounding box of an outline. This is slower */ 62 | /* than computing the control box. However, it uses an advanced */ 63 | /* algorithm that returns _very_ quickly when the two boxes */ 64 | /* coincide. Otherwise, the outline Bézier arcs are traversed to */ 65 | /* extract their extrema. */ 66 | /* */ 67 | /* */ 68 | /* outline :: A pointer to the source outline. */ 69 | /* */ 70 | /* */ 71 | /* abbox :: The outline's exact bounding box. */ 72 | /* */ 73 | /* */ 74 | /* FreeType error code. 0~means success. */ 75 | /* */ 76 | /* */ 77 | /* If the font is tricky and the glyph has been loaded with */ 78 | /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */ 79 | /* reasonable values for the BBox it is necessary to load the glyph */ 80 | /* at a large ppem value (so that the hinting instructions can */ 81 | /* properly shift and scale the subglyphs), then extracting the BBox, */ 82 | /* which can be eventually converted back to font units. */ 83 | /* */ 84 | FT_EXPORT( FT_Error ) 85 | FT_Outline_Get_BBox( FT_Outline* outline, 86 | FT_BBox *abbox ); 87 | 88 | /* */ 89 | 90 | 91 | FT_END_HEADER 92 | 93 | #endif /* FTBBOX_H_ */ 94 | 95 | 96 | /* END */ 97 | 98 | 99 | /* Local Variables: */ 100 | /* coding: utf-8 */ 101 | /* End: */ 102 | -------------------------------------------------------------------------------- /common/include/freetype/ftbdf.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftbdf.h */ 4 | /* */ 5 | /* FreeType API for accessing BDF-specific strings (specification). */ 6 | /* */ 7 | /* Copyright 2002-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTBDF_H_ 20 | #define FTBDF_H_ 21 | 22 | #include 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /*
*/ 38 | /* bdf_fonts */ 39 | /* */ 40 | /* */ 41 | /* BDF and PCF Files */ 42 | /* */ 43 | /* <Abstract> */ 44 | /* BDF and PCF specific API. */ 45 | /* */ 46 | /* <Description> */ 47 | /* This section contains the declaration of functions specific to BDF */ 48 | /* and PCF fonts. */ 49 | /* */ 50 | /*************************************************************************/ 51 | 52 | 53 | /********************************************************************** 54 | * 55 | * @enum: 56 | * BDF_PropertyType 57 | * 58 | * @description: 59 | * A list of BDF property types. 60 | * 61 | * @values: 62 | * BDF_PROPERTY_TYPE_NONE :: 63 | * Value~0 is used to indicate a missing property. 64 | * 65 | * BDF_PROPERTY_TYPE_ATOM :: 66 | * Property is a string atom. 67 | * 68 | * BDF_PROPERTY_TYPE_INTEGER :: 69 | * Property is a 32-bit signed integer. 70 | * 71 | * BDF_PROPERTY_TYPE_CARDINAL :: 72 | * Property is a 32-bit unsigned integer. 73 | */ 74 | typedef enum BDF_PropertyType_ 75 | { 76 | BDF_PROPERTY_TYPE_NONE = 0, 77 | BDF_PROPERTY_TYPE_ATOM = 1, 78 | BDF_PROPERTY_TYPE_INTEGER = 2, 79 | BDF_PROPERTY_TYPE_CARDINAL = 3 80 | 81 | } BDF_PropertyType; 82 | 83 | 84 | /********************************************************************** 85 | * 86 | * @type: 87 | * BDF_Property 88 | * 89 | * @description: 90 | * A handle to a @BDF_PropertyRec structure to model a given 91 | * BDF/PCF property. 92 | */ 93 | typedef struct BDF_PropertyRec_* BDF_Property; 94 | 95 | 96 | /********************************************************************** 97 | * 98 | * @struct: 99 | * BDF_PropertyRec 100 | * 101 | * @description: 102 | * This structure models a given BDF/PCF property. 103 | * 104 | * @fields: 105 | * type :: 106 | * The property type. 107 | * 108 | * u.atom :: 109 | * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be 110 | * NULL, indicating an empty string. 111 | * 112 | * u.integer :: 113 | * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. 114 | * 115 | * u.cardinal :: 116 | * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. 117 | */ 118 | typedef struct BDF_PropertyRec_ 119 | { 120 | BDF_PropertyType type; 121 | union { 122 | const char* atom; 123 | FT_Int32 integer; 124 | FT_UInt32 cardinal; 125 | 126 | } u; 127 | 128 | } BDF_PropertyRec; 129 | 130 | 131 | /********************************************************************** 132 | * 133 | * @function: 134 | * FT_Get_BDF_Charset_ID 135 | * 136 | * @description: 137 | * Retrieve a BDF font character set identity, according to 138 | * the BDF specification. 139 | * 140 | * @input: 141 | * face :: 142 | * A handle to the input face. 143 | * 144 | * @output: 145 | * acharset_encoding :: 146 | * Charset encoding, as a C~string, owned by the face. 147 | * 148 | * acharset_registry :: 149 | * Charset registry, as a C~string, owned by the face. 150 | * 151 | * @return: 152 | * FreeType error code. 0~means success. 153 | * 154 | * @note: 155 | * This function only works with BDF faces, returning an error otherwise. 156 | */ 157 | FT_EXPORT( FT_Error ) 158 | FT_Get_BDF_Charset_ID( FT_Face face, 159 | const char* *acharset_encoding, 160 | const char* *acharset_registry ); 161 | 162 | 163 | /********************************************************************** 164 | * 165 | * @function: 166 | * FT_Get_BDF_Property 167 | * 168 | * @description: 169 | * Retrieve a BDF property from a BDF or PCF font file. 170 | * 171 | * @input: 172 | * face :: A handle to the input face. 173 | * 174 | * name :: The property name. 175 | * 176 | * @output: 177 | * aproperty :: The property. 178 | * 179 | * @return: 180 | * FreeType error code. 0~means success. 181 | * 182 | * @note: 183 | * This function works with BDF _and_ PCF fonts. It returns an error 184 | * otherwise. It also returns an error if the property is not in the 185 | * font. 186 | * 187 | * A `property' is a either key-value pair within the STARTPROPERTIES 188 | * ... ENDPROPERTIES block of a BDF font or a key-value pair from the 189 | * `info->props' array within a `FontRec' structure of a PCF font. 190 | * 191 | * Integer properties are always stored as `signed' within PCF fonts; 192 | * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value 193 | * for BDF fonts only. 194 | * 195 | * In case of error, `aproperty->type' is always set to 196 | * @BDF_PROPERTY_TYPE_NONE. 197 | */ 198 | FT_EXPORT( FT_Error ) 199 | FT_Get_BDF_Property( FT_Face face, 200 | const char* prop_name, 201 | BDF_PropertyRec *aproperty ); 202 | 203 | /* */ 204 | 205 | FT_END_HEADER 206 | 207 | #endif /* FTBDF_H_ */ 208 | 209 | 210 | /* END */ 211 | -------------------------------------------------------------------------------- /common/include/freetype/ftbzip2.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftbzip2.h */ 4 | /* */ 5 | /* Bzip2-compressed stream support. */ 6 | /* */ 7 | /* Copyright 2010-2017 by */ 8 | /* Joel Klinghed. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTBZIP2_H_ 20 | #define FTBZIP2_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | /*************************************************************************/ 35 | /* */ 36 | /* <Section> */ 37 | /* bzip2 */ 38 | /* */ 39 | /* <Title> */ 40 | /* BZIP2 Streams */ 41 | /* */ 42 | /* <Abstract> */ 43 | /* Using bzip2-compressed font files. */ 44 | /* */ 45 | /* <Description> */ 46 | /* This section contains the declaration of Bzip2-specific functions. */ 47 | /* */ 48 | /*************************************************************************/ 49 | 50 | 51 | /************************************************************************ 52 | * 53 | * @function: 54 | * FT_Stream_OpenBzip2 55 | * 56 | * @description: 57 | * Open a new stream to parse bzip2-compressed font files. This is 58 | * mainly used to support the compressed `*.pcf.bz2' fonts that come 59 | * with XFree86. 60 | * 61 | * @input: 62 | * stream :: 63 | * The target embedding stream. 64 | * 65 | * source :: 66 | * The source stream. 67 | * 68 | * @return: 69 | * FreeType error code. 0~means success. 70 | * 71 | * @note: 72 | * The source stream must be opened _before_ calling this function. 73 | * 74 | * Calling the internal function `FT_Stream_Close' on the new stream will 75 | * *not* call `FT_Stream_Close' on the source stream. None of the stream 76 | * objects will be released to the heap. 77 | * 78 | * The stream implementation is very basic and resets the decompression 79 | * process each time seeking backwards is needed within the stream. 80 | * 81 | * In certain builds of the library, bzip2 compression recognition is 82 | * automatically handled when calling @FT_New_Face or @FT_Open_Face. 83 | * This means that if no font driver is capable of handling the raw 84 | * compressed file, the library will try to open a bzip2 compressed stream 85 | * from it and re-open the face with it. 86 | * 87 | * This function may return `FT_Err_Unimplemented_Feature' if your build 88 | * of FreeType was not compiled with bzip2 support. 89 | */ 90 | FT_EXPORT( FT_Error ) 91 | FT_Stream_OpenBzip2( FT_Stream stream, 92 | FT_Stream source ); 93 | 94 | /* */ 95 | 96 | 97 | FT_END_HEADER 98 | 99 | #endif /* FTBZIP2_H_ */ 100 | 101 | 102 | /* END */ 103 | -------------------------------------------------------------------------------- /common/include/freetype/ftchapters.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* This file defines the structure of the FreeType reference. */ 4 | /* It is used by the python script that generates the HTML files. */ 5 | /* */ 6 | /***************************************************************************/ 7 | 8 | 9 | /***************************************************************************/ 10 | /* */ 11 | /* <Chapter> */ 12 | /* general_remarks */ 13 | /* */ 14 | /* <Title> */ 15 | /* General Remarks */ 16 | /* */ 17 | /* <Sections> */ 18 | /* header_inclusion */ 19 | /* user_allocation */ 20 | /* */ 21 | /***************************************************************************/ 22 | 23 | 24 | /***************************************************************************/ 25 | /* */ 26 | /* <Chapter> */ 27 | /* core_api */ 28 | /* */ 29 | /* <Title> */ 30 | /* Core API */ 31 | /* */ 32 | /* <Sections> */ 33 | /* version */ 34 | /* basic_types */ 35 | /* base_interface */ 36 | /* glyph_variants */ 37 | /* glyph_management */ 38 | /* mac_specific */ 39 | /* sizes_management */ 40 | /* header_file_macros */ 41 | /* */ 42 | /***************************************************************************/ 43 | 44 | 45 | /***************************************************************************/ 46 | /* */ 47 | /* <Chapter> */ 48 | /* format_specific */ 49 | /* */ 50 | /* <Title> */ 51 | /* Format-Specific API */ 52 | /* */ 53 | /* <Sections> */ 54 | /* multiple_masters */ 55 | /* truetype_tables */ 56 | /* type1_tables */ 57 | /* sfnt_names */ 58 | /* bdf_fonts */ 59 | /* cid_fonts */ 60 | /* pfr_fonts */ 61 | /* winfnt_fonts */ 62 | /* font_formats */ 63 | /* gasp_table */ 64 | /* */ 65 | /***************************************************************************/ 66 | 67 | 68 | /***************************************************************************/ 69 | /* */ 70 | /* <Chapter> */ 71 | /* module_specific */ 72 | /* */ 73 | /* <Title> */ 74 | /* Controlling FreeType Modules */ 75 | /* */ 76 | /* <Sections> */ 77 | /* auto_hinter */ 78 | /* cff_driver */ 79 | /* tt_driver */ 80 | /* pcf_driver */ 81 | /* */ 82 | /***************************************************************************/ 83 | 84 | 85 | /***************************************************************************/ 86 | /* */ 87 | /* <Chapter> */ 88 | /* cache_subsystem */ 89 | /* */ 90 | /* <Title> */ 91 | /* Cache Sub-System */ 92 | /* */ 93 | /* <Sections> */ 94 | /* cache_subsystem */ 95 | /* */ 96 | /***************************************************************************/ 97 | 98 | 99 | /***************************************************************************/ 100 | /* */ 101 | /* <Chapter> */ 102 | /* support_api */ 103 | /* */ 104 | /* <Title> */ 105 | /* Support API */ 106 | /* */ 107 | /* <Sections> */ 108 | /* computations */ 109 | /* list_processing */ 110 | /* outline_processing */ 111 | /* quick_advance */ 112 | /* bitmap_handling */ 113 | /* raster */ 114 | /* glyph_stroker */ 115 | /* system_interface */ 116 | /* module_management */ 117 | /* gzip */ 118 | /* lzw */ 119 | /* bzip2 */ 120 | /* lcd_filtering */ 121 | /* */ 122 | /***************************************************************************/ 123 | 124 | /***************************************************************************/ 125 | /* */ 126 | /* <Chapter> */ 127 | /* error_codes */ 128 | /* */ 129 | /* <Title> */ 130 | /* Error Codes */ 131 | /* */ 132 | /* <Sections> */ 133 | /* error_enumerations */ 134 | /* error_code_values */ 135 | /* */ 136 | /***************************************************************************/ 137 | -------------------------------------------------------------------------------- /common/include/freetype/ftcid.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftcid.h */ 4 | /* */ 5 | /* FreeType API for accessing CID font information (specification). */ 6 | /* */ 7 | /* Copyright 2007-2017 by */ 8 | /* Dereg Clegg and Michael Toftdal. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTCID_H_ 20 | #define FTCID_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /* <Section> */ 38 | /* cid_fonts */ 39 | /* */ 40 | /* <Title> */ 41 | /* CID Fonts */ 42 | /* */ 43 | /* <Abstract> */ 44 | /* CID-keyed font specific API. */ 45 | /* */ 46 | /* <Description> */ 47 | /* This section contains the declaration of CID-keyed font specific */ 48 | /* functions. */ 49 | /* */ 50 | /*************************************************************************/ 51 | 52 | 53 | /********************************************************************** 54 | * 55 | * @function: 56 | * FT_Get_CID_Registry_Ordering_Supplement 57 | * 58 | * @description: 59 | * Retrieve the Registry/Ordering/Supplement triple (also known as the 60 | * "R/O/S") from a CID-keyed font. 61 | * 62 | * @input: 63 | * face :: 64 | * A handle to the input face. 65 | * 66 | * @output: 67 | * registry :: 68 | * The registry, as a C~string, owned by the face. 69 | * 70 | * ordering :: 71 | * The ordering, as a C~string, owned by the face. 72 | * 73 | * supplement :: 74 | * The supplement. 75 | * 76 | * @return: 77 | * FreeType error code. 0~means success. 78 | * 79 | * @note: 80 | * This function only works with CID faces, returning an error 81 | * otherwise. 82 | * 83 | * @since: 84 | * 2.3.6 85 | */ 86 | FT_EXPORT( FT_Error ) 87 | FT_Get_CID_Registry_Ordering_Supplement( FT_Face face, 88 | const char* *registry, 89 | const char* *ordering, 90 | FT_Int *supplement); 91 | 92 | 93 | /********************************************************************** 94 | * 95 | * @function: 96 | * FT_Get_CID_Is_Internally_CID_Keyed 97 | * 98 | * @description: 99 | * Retrieve the type of the input face, CID keyed or not. In 100 | * contrast to the @FT_IS_CID_KEYED macro this function returns 101 | * successfully also for CID-keyed fonts in an SFNT wrapper. 102 | * 103 | * @input: 104 | * face :: 105 | * A handle to the input face. 106 | * 107 | * @output: 108 | * is_cid :: 109 | * The type of the face as an @FT_Bool. 110 | * 111 | * @return: 112 | * FreeType error code. 0~means success. 113 | * 114 | * @note: 115 | * This function only works with CID faces and OpenType fonts, 116 | * returning an error otherwise. 117 | * 118 | * @since: 119 | * 2.3.9 120 | */ 121 | FT_EXPORT( FT_Error ) 122 | FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, 123 | FT_Bool *is_cid ); 124 | 125 | 126 | /********************************************************************** 127 | * 128 | * @function: 129 | * FT_Get_CID_From_Glyph_Index 130 | * 131 | * @description: 132 | * Retrieve the CID of the input glyph index. 133 | * 134 | * @input: 135 | * face :: 136 | * A handle to the input face. 137 | * 138 | * glyph_index :: 139 | * The input glyph index. 140 | * 141 | * @output: 142 | * cid :: 143 | * The CID as an @FT_UInt. 144 | * 145 | * @return: 146 | * FreeType error code. 0~means success. 147 | * 148 | * @note: 149 | * This function only works with CID faces and OpenType fonts, 150 | * returning an error otherwise. 151 | * 152 | * @since: 153 | * 2.3.9 154 | */ 155 | FT_EXPORT( FT_Error ) 156 | FT_Get_CID_From_Glyph_Index( FT_Face face, 157 | FT_UInt glyph_index, 158 | FT_UInt *cid ); 159 | 160 | /* */ 161 | 162 | 163 | FT_END_HEADER 164 | 165 | #endif /* FTCID_H_ */ 166 | 167 | 168 | /* END */ 169 | -------------------------------------------------------------------------------- /common/include/freetype/ftfntfmt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftfntfmt.h */ 4 | /* */ 5 | /* Support functions for font formats. */ 6 | /* */ 7 | /* Copyright 2002-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTFNTFMT_H_ 20 | #define FTFNTFMT_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /* <Section> */ 38 | /* font_formats */ 39 | /* */ 40 | /* <Title> */ 41 | /* Font Formats */ 42 | /* */ 43 | /* <Abstract> */ 44 | /* Getting the font format. */ 45 | /* */ 46 | /* <Description> */ 47 | /* The single function in this section can be used to get the font */ 48 | /* format. Note that this information is not needed normally; */ 49 | /* however, there are special cases (like in PDF devices) where it is */ 50 | /* important to differentiate, in spite of FreeType's uniform API. */ 51 | /* */ 52 | /*************************************************************************/ 53 | 54 | 55 | /*************************************************************************/ 56 | /* */ 57 | /* <Function> */ 58 | /* FT_Get_Font_Format */ 59 | /* */ 60 | /* <Description> */ 61 | /* Return a string describing the format of a given face. Possible */ 62 | /* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */ 63 | /* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */ 64 | /* */ 65 | /* The return value is suitable to be used as an X11 FONT_PROPERTY. */ 66 | /* */ 67 | /* <Input> */ 68 | /* face :: */ 69 | /* Input face handle. */ 70 | /* */ 71 | /* <Return> */ 72 | /* Font format string. NULL in case of error. */ 73 | /* */ 74 | /* <Note> */ 75 | /* A deprecated name for the same function is */ 76 | /* `FT_Get_X11_Font_Format'. */ 77 | /* */ 78 | FT_EXPORT( const char* ) 79 | FT_Get_Font_Format( FT_Face face ); 80 | 81 | 82 | /* deprecated */ 83 | FT_EXPORT( const char* ) 84 | FT_Get_X11_Font_Format( FT_Face face ); 85 | 86 | 87 | /* */ 88 | 89 | 90 | FT_END_HEADER 91 | 92 | #endif /* FTFNTFMT_H_ */ 93 | 94 | 95 | /* END */ 96 | -------------------------------------------------------------------------------- /common/include/freetype/ftgasp.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftgasp.h */ 4 | /* */ 5 | /* Access of TrueType's `gasp' table (specification). */ 6 | /* */ 7 | /* Copyright 2007-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTGASP_H_ 20 | #define FTGASP_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | /*************************************************************************** 33 | * 34 | * @section: 35 | * gasp_table 36 | * 37 | * @title: 38 | * Gasp Table 39 | * 40 | * @abstract: 41 | * Retrieving TrueType `gasp' table entries. 42 | * 43 | * @description: 44 | * The function @FT_Get_Gasp can be used to query a TrueType or OpenType 45 | * font for specific entries in its `gasp' table, if any. This is 46 | * mainly useful when implementing native TrueType hinting with the 47 | * bytecode interpreter to duplicate the Windows text rendering results. 48 | */ 49 | 50 | /************************************************************************* 51 | * 52 | * @enum: 53 | * FT_GASP_XXX 54 | * 55 | * @description: 56 | * A list of values and/or bit-flags returned by the @FT_Get_Gasp 57 | * function. 58 | * 59 | * @values: 60 | * FT_GASP_NO_TABLE :: 61 | * This special value means that there is no GASP table in this face. 62 | * It is up to the client to decide what to do. 63 | * 64 | * FT_GASP_DO_GRIDFIT :: 65 | * Grid-fitting and hinting should be performed at the specified ppem. 66 | * This *really* means TrueType bytecode interpretation. If this bit 67 | * is not set, no hinting gets applied. 68 | * 69 | * FT_GASP_DO_GRAY :: 70 | * Anti-aliased rendering should be performed at the specified ppem. 71 | * If not set, do monochrome rendering. 72 | * 73 | * FT_GASP_SYMMETRIC_SMOOTHING :: 74 | * If set, smoothing along multiple axes must be used with ClearType. 75 | * 76 | * FT_GASP_SYMMETRIC_GRIDFIT :: 77 | * Grid-fitting must be used with ClearType's symmetric smoothing. 78 | * 79 | * @note: 80 | * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be 81 | * used for standard font rasterization only. Independently of that, 82 | * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to 83 | * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and 84 | * `FT_GASP_DO_GRAY' are consequently ignored). 85 | * 86 | * `ClearType' is Microsoft's implementation of LCD rendering, partly 87 | * protected by patents. 88 | * 89 | * @since: 90 | * 2.3.0 91 | */ 92 | #define FT_GASP_NO_TABLE -1 93 | #define FT_GASP_DO_GRIDFIT 0x01 94 | #define FT_GASP_DO_GRAY 0x02 95 | #define FT_GASP_SYMMETRIC_GRIDFIT 0x04 96 | #define FT_GASP_SYMMETRIC_SMOOTHING 0x08 97 | 98 | 99 | /************************************************************************* 100 | * 101 | * @func: 102 | * FT_Get_Gasp 103 | * 104 | * @description: 105 | * For a TrueType or OpenType font file, return the rasterizer behaviour 106 | * flags from the font's `gasp' table corresponding to a given 107 | * character pixel size. 108 | * 109 | * @input: 110 | * face :: The source face handle. 111 | * 112 | * ppem :: The vertical character pixel size. 113 | * 114 | * @return: 115 | * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no 116 | * `gasp' table in the face. 117 | * 118 | * @note: 119 | * If you want to use the MM functionality of OpenType variation fonts 120 | * (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this 121 | * function *after* setting an instance since the return values can 122 | * change. 123 | * 124 | * @since: 125 | * 2.3.0 126 | */ 127 | FT_EXPORT( FT_Int ) 128 | FT_Get_Gasp( FT_Face face, 129 | FT_UInt ppem ); 130 | 131 | /* */ 132 | 133 | 134 | #endif /* FTGASP_H_ */ 135 | 136 | 137 | /* END */ 138 | -------------------------------------------------------------------------------- /common/include/freetype/ftgzip.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftgzip.h */ 4 | /* */ 5 | /* Gzip-compressed stream support. */ 6 | /* */ 7 | /* Copyright 2002-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTGZIP_H_ 20 | #define FTGZIP_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | /*************************************************************************/ 35 | /* */ 36 | /* <Section> */ 37 | /* gzip */ 38 | /* */ 39 | /* <Title> */ 40 | /* GZIP Streams */ 41 | /* */ 42 | /* <Abstract> */ 43 | /* Using gzip-compressed font files. */ 44 | /* */ 45 | /* <Description> */ 46 | /* This section contains the declaration of Gzip-specific functions. */ 47 | /* */ 48 | /*************************************************************************/ 49 | 50 | 51 | /************************************************************************ 52 | * 53 | * @function: 54 | * FT_Stream_OpenGzip 55 | * 56 | * @description: 57 | * Open a new stream to parse gzip-compressed font files. This is 58 | * mainly used to support the compressed `*.pcf.gz' fonts that come 59 | * with XFree86. 60 | * 61 | * @input: 62 | * stream :: 63 | * The target embedding stream. 64 | * 65 | * source :: 66 | * The source stream. 67 | * 68 | * @return: 69 | * FreeType error code. 0~means success. 70 | * 71 | * @note: 72 | * The source stream must be opened _before_ calling this function. 73 | * 74 | * Calling the internal function `FT_Stream_Close' on the new stream will 75 | * *not* call `FT_Stream_Close' on the source stream. None of the stream 76 | * objects will be released to the heap. 77 | * 78 | * The stream implementation is very basic and resets the decompression 79 | * process each time seeking backwards is needed within the stream. 80 | * 81 | * In certain builds of the library, gzip compression recognition is 82 | * automatically handled when calling @FT_New_Face or @FT_Open_Face. 83 | * This means that if no font driver is capable of handling the raw 84 | * compressed file, the library will try to open a gzipped stream from 85 | * it and re-open the face with it. 86 | * 87 | * This function may return `FT_Err_Unimplemented_Feature' if your build 88 | * of FreeType was not compiled with zlib support. 89 | */ 90 | FT_EXPORT( FT_Error ) 91 | FT_Stream_OpenGzip( FT_Stream stream, 92 | FT_Stream source ); 93 | 94 | 95 | /************************************************************************ 96 | * 97 | * @function: 98 | * FT_Gzip_Uncompress 99 | * 100 | * @description: 101 | * Decompress a zipped input buffer into an output buffer. This function 102 | * is modeled after zlib's `uncompress' function. 103 | * 104 | * @input: 105 | * memory :: 106 | * A FreeType memory handle. 107 | * 108 | * input :: 109 | * The input buffer. 110 | * 111 | * input_len :: 112 | * The length of the input buffer. 113 | * 114 | * @output: 115 | * output:: 116 | * The output buffer. 117 | * 118 | * @inout: 119 | * output_len :: 120 | * Before calling the function, this is the total size of the output 121 | * buffer, which must be large enough to hold the entire uncompressed 122 | * data (so the size of the uncompressed data must be known in 123 | * advance). After calling the function, `output_len' is the size of 124 | * the used data in `output'. 125 | * 126 | * @return: 127 | * FreeType error code. 0~means success. 128 | * 129 | * @note: 130 | * This function may return `FT_Err_Unimplemented_Feature' if your build 131 | * of FreeType was not compiled with zlib support. 132 | */ 133 | FT_EXPORT( FT_Error ) 134 | FT_Gzip_Uncompress( FT_Memory memory, 135 | FT_Byte* output, 136 | FT_ULong* output_len, 137 | const FT_Byte* input, 138 | FT_ULong input_len ); 139 | 140 | /* */ 141 | 142 | 143 | FT_END_HEADER 144 | 145 | #endif /* FTGZIP_H_ */ 146 | 147 | 148 | /* END */ 149 | -------------------------------------------------------------------------------- /common/include/freetype/ftlzw.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftlzw.h */ 4 | /* */ 5 | /* LZW-compressed stream support. */ 6 | /* */ 7 | /* Copyright 2004-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTLZW_H_ 20 | #define FTLZW_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | /*************************************************************************/ 35 | /* */ 36 | /* <Section> */ 37 | /* lzw */ 38 | /* */ 39 | /* <Title> */ 40 | /* LZW Streams */ 41 | /* */ 42 | /* <Abstract> */ 43 | /* Using LZW-compressed font files. */ 44 | /* */ 45 | /* <Description> */ 46 | /* This section contains the declaration of LZW-specific functions. */ 47 | /* */ 48 | /*************************************************************************/ 49 | 50 | /************************************************************************ 51 | * 52 | * @function: 53 | * FT_Stream_OpenLZW 54 | * 55 | * @description: 56 | * Open a new stream to parse LZW-compressed font files. This is 57 | * mainly used to support the compressed `*.pcf.Z' fonts that come 58 | * with XFree86. 59 | * 60 | * @input: 61 | * stream :: The target embedding stream. 62 | * 63 | * source :: The source stream. 64 | * 65 | * @return: 66 | * FreeType error code. 0~means success. 67 | * 68 | * @note: 69 | * The source stream must be opened _before_ calling this function. 70 | * 71 | * Calling the internal function `FT_Stream_Close' on the new stream will 72 | * *not* call `FT_Stream_Close' on the source stream. None of the stream 73 | * objects will be released to the heap. 74 | * 75 | * The stream implementation is very basic and resets the decompression 76 | * process each time seeking backwards is needed within the stream 77 | * 78 | * In certain builds of the library, LZW compression recognition is 79 | * automatically handled when calling @FT_New_Face or @FT_Open_Face. 80 | * This means that if no font driver is capable of handling the raw 81 | * compressed file, the library will try to open a LZW stream from it 82 | * and re-open the face with it. 83 | * 84 | * This function may return `FT_Err_Unimplemented_Feature' if your build 85 | * of FreeType was not compiled with LZW support. 86 | */ 87 | FT_EXPORT( FT_Error ) 88 | FT_Stream_OpenLZW( FT_Stream stream, 89 | FT_Stream source ); 90 | 91 | /* */ 92 | 93 | 94 | FT_END_HEADER 95 | 96 | #endif /* FTLZW_H_ */ 97 | 98 | 99 | /* END */ 100 | -------------------------------------------------------------------------------- /common/include/freetype/ftotval.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftotval.h */ 4 | /* */ 5 | /* FreeType API for validating OpenType tables (specification). */ 6 | /* */ 7 | /* Copyright 2004-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /***************************************************************************/ 20 | /* */ 21 | /* */ 22 | /* Warning: This module might be moved to a different library in the */ 23 | /* future to avoid a tight dependency between FreeType and the */ 24 | /* OpenType specification. */ 25 | /* */ 26 | /* */ 27 | /***************************************************************************/ 28 | 29 | 30 | #ifndef FTOTVAL_H_ 31 | #define FTOTVAL_H_ 32 | 33 | #include <ft2build.h> 34 | #include FT_FREETYPE_H 35 | 36 | #ifdef FREETYPE_H 37 | #error "freetype.h of FreeType 1 has been loaded!" 38 | #error "Please fix the directory search order for header files" 39 | #error "so that freetype.h of FreeType 2 is found first." 40 | #endif 41 | 42 | 43 | FT_BEGIN_HEADER 44 | 45 | 46 | /*************************************************************************/ 47 | /* */ 48 | /* <Section> */ 49 | /* ot_validation */ 50 | /* */ 51 | /* <Title> */ 52 | /* OpenType Validation */ 53 | /* */ 54 | /* <Abstract> */ 55 | /* An API to validate OpenType tables. */ 56 | /* */ 57 | /* <Description> */ 58 | /* This section contains the declaration of functions to validate */ 59 | /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */ 60 | /* */ 61 | /* <Order> */ 62 | /* FT_OpenType_Validate */ 63 | /* FT_OpenType_Free */ 64 | /* */ 65 | /* FT_VALIDATE_OTXXX */ 66 | /* */ 67 | /*************************************************************************/ 68 | 69 | 70 | /********************************************************************** 71 | * 72 | * @enum: 73 | * FT_VALIDATE_OTXXX 74 | * 75 | * @description: 76 | * A list of bit-field constants used with @FT_OpenType_Validate to 77 | * indicate which OpenType tables should be validated. 78 | * 79 | * @values: 80 | * FT_VALIDATE_BASE :: 81 | * Validate BASE table. 82 | * 83 | * FT_VALIDATE_GDEF :: 84 | * Validate GDEF table. 85 | * 86 | * FT_VALIDATE_GPOS :: 87 | * Validate GPOS table. 88 | * 89 | * FT_VALIDATE_GSUB :: 90 | * Validate GSUB table. 91 | * 92 | * FT_VALIDATE_JSTF :: 93 | * Validate JSTF table. 94 | * 95 | * FT_VALIDATE_MATH :: 96 | * Validate MATH table. 97 | * 98 | * FT_VALIDATE_OT :: 99 | * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). 100 | * 101 | */ 102 | #define FT_VALIDATE_BASE 0x0100 103 | #define FT_VALIDATE_GDEF 0x0200 104 | #define FT_VALIDATE_GPOS 0x0400 105 | #define FT_VALIDATE_GSUB 0x0800 106 | #define FT_VALIDATE_JSTF 0x1000 107 | #define FT_VALIDATE_MATH 0x2000 108 | 109 | #define FT_VALIDATE_OT ( FT_VALIDATE_BASE | \ 110 | FT_VALIDATE_GDEF | \ 111 | FT_VALIDATE_GPOS | \ 112 | FT_VALIDATE_GSUB | \ 113 | FT_VALIDATE_JSTF | \ 114 | FT_VALIDATE_MATH ) 115 | 116 | /********************************************************************** 117 | * 118 | * @function: 119 | * FT_OpenType_Validate 120 | * 121 | * @description: 122 | * Validate various OpenType tables to assure that all offsets and 123 | * indices are valid. The idea is that a higher-level library that 124 | * actually does the text layout can access those tables without 125 | * error checking (which can be quite time consuming). 126 | * 127 | * @input: 128 | * face :: 129 | * A handle to the input face. 130 | * 131 | * validation_flags :: 132 | * A bit field that specifies the tables to be validated. See 133 | * @FT_VALIDATE_OTXXX for possible values. 134 | * 135 | * @output: 136 | * BASE_table :: 137 | * A pointer to the BASE table. 138 | * 139 | * GDEF_table :: 140 | * A pointer to the GDEF table. 141 | * 142 | * GPOS_table :: 143 | * A pointer to the GPOS table. 144 | * 145 | * GSUB_table :: 146 | * A pointer to the GSUB table. 147 | * 148 | * JSTF_table :: 149 | * A pointer to the JSTF table. 150 | * 151 | * @return: 152 | * FreeType error code. 0~means success. 153 | * 154 | * @note: 155 | * This function only works with OpenType fonts, returning an error 156 | * otherwise. 157 | * 158 | * After use, the application should deallocate the five tables with 159 | * @FT_OpenType_Free. A NULL value indicates that the table either 160 | * doesn't exist in the font, or the application hasn't asked for 161 | * validation. 162 | */ 163 | FT_EXPORT( FT_Error ) 164 | FT_OpenType_Validate( FT_Face face, 165 | FT_UInt validation_flags, 166 | FT_Bytes *BASE_table, 167 | FT_Bytes *GDEF_table, 168 | FT_Bytes *GPOS_table, 169 | FT_Bytes *GSUB_table, 170 | FT_Bytes *JSTF_table ); 171 | 172 | /********************************************************************** 173 | * 174 | * @function: 175 | * FT_OpenType_Free 176 | * 177 | * @description: 178 | * Free the buffer allocated by OpenType validator. 179 | * 180 | * @input: 181 | * face :: 182 | * A handle to the input face. 183 | * 184 | * table :: 185 | * The pointer to the buffer that is allocated by 186 | * @FT_OpenType_Validate. 187 | * 188 | * @note: 189 | * This function must be used to free the buffer allocated by 190 | * @FT_OpenType_Validate only. 191 | */ 192 | FT_EXPORT( void ) 193 | FT_OpenType_Free( FT_Face face, 194 | FT_Bytes table ); 195 | 196 | /* */ 197 | 198 | 199 | FT_END_HEADER 200 | 201 | #endif /* FTOTVAL_H_ */ 202 | 203 | 204 | /* END */ 205 | -------------------------------------------------------------------------------- /common/include/freetype/ftpcfdrv.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftpcfdrv.h */ 4 | /* */ 5 | /* FreeType API for controlling the PCF driver (specification only). */ 6 | /* */ 7 | /* Copyright 2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTPCFDRV_H_ 20 | #define FTPCFDRV_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /************************************************************************** 36 | * 37 | * @section: 38 | * pcf_driver 39 | * 40 | * @title: 41 | * The PCF driver 42 | * 43 | * @abstract: 44 | * Controlling the PCF driver module. 45 | * 46 | * @description: 47 | * While FreeType's PCF driver doesn't expose API functions by itself, 48 | * it is possible to control its behaviour with @FT_Property_Set and 49 | * @FT_Property_Get. Right now, there is a single property 50 | * `no-long-family-names' available if FreeType is compiled with 51 | * PCF_CONFIG_OPTION_LONG_FAMILY_NAMES. 52 | * 53 | * The PCF driver's module name is `pcf'. 54 | * 55 | */ 56 | 57 | 58 | /************************************************************************** 59 | * 60 | * @property: 61 | * no-long-family-names 62 | * 63 | * @description: 64 | * If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling 65 | * FreeType, the PCF driver constructs long family names. 66 | * 67 | * There are many PCF fonts just called `Fixed' which look completely 68 | * different, and which have nothing to do with each other. When 69 | * selecting `Fixed' in KDE or Gnome one gets results that appear rather 70 | * random, the style changes often if one changes the size and one 71 | * cannot select some fonts at all. The improve this situation, the PCF 72 | * module prepends the foundry name (plus a space) to the family name. 73 | * It also checks whether there are `wide' characters; all put together, 74 | * family names like `Sony Fixed' or `Misc Fixed Wide' are constructed. 75 | * 76 | * If `no-long-family-names' is set, this feature gets switched off. 77 | * 78 | * { 79 | * FT_Library library; 80 | * FT_Bool no_long_family_names = TRUE; 81 | * 82 | * 83 | * FT_Init_FreeType( &library ); 84 | * 85 | * FT_Property_Set( library, "pcf", 86 | * "no-long-family-names", 87 | * &no_long_family_names ); 88 | * } 89 | * 90 | * @note: 91 | * This property can be used with @FT_Property_Get also. 92 | * 93 | * This property can be set via the `FREETYPE_PROPERTIES' environment 94 | * variable (using values 1 and 0 for `on' and `off', respectively). 95 | * 96 | */ 97 | 98 | 99 | FT_END_HEADER 100 | 101 | 102 | #endif /* FTPCFDRV_H_ */ 103 | 104 | 105 | /* END */ 106 | -------------------------------------------------------------------------------- /common/include/freetype/ftpfr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftpfr.h */ 4 | /* */ 5 | /* FreeType API for accessing PFR-specific data (specification only). */ 6 | /* */ 7 | /* Copyright 2002-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTPFR_H_ 20 | #define FTPFR_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /* <Section> */ 38 | /* pfr_fonts */ 39 | /* */ 40 | /* <Title> */ 41 | /* PFR Fonts */ 42 | /* */ 43 | /* <Abstract> */ 44 | /* PFR/TrueDoc specific API. */ 45 | /* */ 46 | /* <Description> */ 47 | /* This section contains the declaration of PFR-specific functions. */ 48 | /* */ 49 | /*************************************************************************/ 50 | 51 | 52 | /********************************************************************** 53 | * 54 | * @function: 55 | * FT_Get_PFR_Metrics 56 | * 57 | * @description: 58 | * Return the outline and metrics resolutions of a given PFR face. 59 | * 60 | * @input: 61 | * face :: Handle to the input face. It can be a non-PFR face. 62 | * 63 | * @output: 64 | * aoutline_resolution :: 65 | * Outline resolution. This is equivalent to `face->units_per_EM' 66 | * for non-PFR fonts. Optional (parameter can be NULL). 67 | * 68 | * ametrics_resolution :: 69 | * Metrics resolution. This is equivalent to `outline_resolution' 70 | * for non-PFR fonts. Optional (parameter can be NULL). 71 | * 72 | * ametrics_x_scale :: 73 | * A 16.16 fixed-point number used to scale distance expressed 74 | * in metrics units to device sub-pixels. This is equivalent to 75 | * `face->size->x_scale', but for metrics only. Optional (parameter 76 | * can be NULL). 77 | * 78 | * ametrics_y_scale :: 79 | * Same as `ametrics_x_scale' but for the vertical direction. 80 | * optional (parameter can be NULL). 81 | * 82 | * @return: 83 | * FreeType error code. 0~means success. 84 | * 85 | * @note: 86 | * If the input face is not a PFR, this function will return an error. 87 | * However, in all cases, it will return valid values. 88 | */ 89 | FT_EXPORT( FT_Error ) 90 | FT_Get_PFR_Metrics( FT_Face face, 91 | FT_UInt *aoutline_resolution, 92 | FT_UInt *ametrics_resolution, 93 | FT_Fixed *ametrics_x_scale, 94 | FT_Fixed *ametrics_y_scale ); 95 | 96 | 97 | /********************************************************************** 98 | * 99 | * @function: 100 | * FT_Get_PFR_Kerning 101 | * 102 | * @description: 103 | * Return the kerning pair corresponding to two glyphs in a PFR face. 104 | * The distance is expressed in metrics units, unlike the result of 105 | * @FT_Get_Kerning. 106 | * 107 | * @input: 108 | * face :: A handle to the input face. 109 | * 110 | * left :: Index of the left glyph. 111 | * 112 | * right :: Index of the right glyph. 113 | * 114 | * @output: 115 | * avector :: A kerning vector. 116 | * 117 | * @return: 118 | * FreeType error code. 0~means success. 119 | * 120 | * @note: 121 | * This function always return distances in original PFR metrics 122 | * units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED 123 | * mode, which always returns distances converted to outline units. 124 | * 125 | * You can use the value of the `x_scale' and `y_scale' parameters 126 | * returned by @FT_Get_PFR_Metrics to scale these to device sub-pixels. 127 | */ 128 | FT_EXPORT( FT_Error ) 129 | FT_Get_PFR_Kerning( FT_Face face, 130 | FT_UInt left, 131 | FT_UInt right, 132 | FT_Vector *avector ); 133 | 134 | 135 | /********************************************************************** 136 | * 137 | * @function: 138 | * FT_Get_PFR_Advance 139 | * 140 | * @description: 141 | * Return a given glyph advance, expressed in original metrics units, 142 | * from a PFR font. 143 | * 144 | * @input: 145 | * face :: A handle to the input face. 146 | * 147 | * gindex :: The glyph index. 148 | * 149 | * @output: 150 | * aadvance :: The glyph advance in metrics units. 151 | * 152 | * @return: 153 | * FreeType error code. 0~means success. 154 | * 155 | * @note: 156 | * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics 157 | * to convert the advance to device sub-pixels (i.e., 1/64th of pixels). 158 | */ 159 | FT_EXPORT( FT_Error ) 160 | FT_Get_PFR_Advance( FT_Face face, 161 | FT_UInt gindex, 162 | FT_Pos *aadvance ); 163 | 164 | /* */ 165 | 166 | 167 | FT_END_HEADER 168 | 169 | #endif /* FTPFR_H_ */ 170 | 171 | 172 | /* END */ 173 | -------------------------------------------------------------------------------- /common/include/freetype/ftsizes.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftsizes.h */ 4 | /* */ 5 | /* FreeType size objects management (specification). */ 6 | /* */ 7 | /* Copyright 1996-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /*************************************************************************/ 20 | /* */ 21 | /* Typical application would normally not need to use these functions. */ 22 | /* However, they have been placed in a public API for the rare cases */ 23 | /* where they are needed. */ 24 | /* */ 25 | /*************************************************************************/ 26 | 27 | 28 | #ifndef FTSIZES_H_ 29 | #define FTSIZES_H_ 30 | 31 | 32 | #include <ft2build.h> 33 | #include FT_FREETYPE_H 34 | 35 | #ifdef FREETYPE_H 36 | #error "freetype.h of FreeType 1 has been loaded!" 37 | #error "Please fix the directory search order for header files" 38 | #error "so that freetype.h of FreeType 2 is found first." 39 | #endif 40 | 41 | 42 | FT_BEGIN_HEADER 43 | 44 | 45 | /*************************************************************************/ 46 | /* */ 47 | /* <Section> */ 48 | /* sizes_management */ 49 | /* */ 50 | /* <Title> */ 51 | /* Size Management */ 52 | /* */ 53 | /* <Abstract> */ 54 | /* Managing multiple sizes per face. */ 55 | /* */ 56 | /* <Description> */ 57 | /* When creating a new face object (e.g., with @FT_New_Face), an */ 58 | /* @FT_Size object is automatically created and used to store all */ 59 | /* pixel-size dependent information, available in the `face->size' */ 60 | /* field. */ 61 | /* */ 62 | /* It is however possible to create more sizes for a given face, */ 63 | /* mostly in order to manage several character pixel sizes of the */ 64 | /* same font family and style. See @FT_New_Size and @FT_Done_Size. */ 65 | /* */ 66 | /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */ 67 | /* modify the contents of the current `active' size; you thus need */ 68 | /* to use @FT_Activate_Size to change it. */ 69 | /* */ 70 | /* 99% of applications won't need the functions provided here, */ 71 | /* especially if they use the caching sub-system, so be cautious */ 72 | /* when using these. */ 73 | /* */ 74 | /*************************************************************************/ 75 | 76 | 77 | /*************************************************************************/ 78 | /* */ 79 | /* <Function> */ 80 | /* FT_New_Size */ 81 | /* */ 82 | /* <Description> */ 83 | /* Create a new size object from a given face object. */ 84 | /* */ 85 | /* <Input> */ 86 | /* face :: A handle to a parent face object. */ 87 | /* */ 88 | /* <Output> */ 89 | /* asize :: A handle to a new size object. */ 90 | /* */ 91 | /* <Return> */ 92 | /* FreeType error code. 0~means success. */ 93 | /* */ 94 | /* <Note> */ 95 | /* You need to call @FT_Activate_Size in order to select the new size */ 96 | /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */ 97 | /* @FT_Load_Glyph, @FT_Load_Char, etc. */ 98 | /* */ 99 | FT_EXPORT( FT_Error ) 100 | FT_New_Size( FT_Face face, 101 | FT_Size* size ); 102 | 103 | 104 | /*************************************************************************/ 105 | /* */ 106 | /* <Function> */ 107 | /* FT_Done_Size */ 108 | /* */ 109 | /* <Description> */ 110 | /* Discard a given size object. Note that @FT_Done_Face */ 111 | /* automatically discards all size objects allocated with */ 112 | /* @FT_New_Size. */ 113 | /* */ 114 | /* <Input> */ 115 | /* size :: A handle to a target size object. */ 116 | /* */ 117 | /* <Return> */ 118 | /* FreeType error code. 0~means success. */ 119 | /* */ 120 | FT_EXPORT( FT_Error ) 121 | FT_Done_Size( FT_Size size ); 122 | 123 | 124 | /*************************************************************************/ 125 | /* */ 126 | /* <Function> */ 127 | /* FT_Activate_Size */ 128 | /* */ 129 | /* <Description> */ 130 | /* Even though it is possible to create several size objects for a */ 131 | /* given face (see @FT_New_Size for details), functions like */ 132 | /* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */ 133 | /* activated last to determine the `current character pixel size'. */ 134 | /* */ 135 | /* This function can be used to `activate' a previously created size */ 136 | /* object. */ 137 | /* */ 138 | /* <Input> */ 139 | /* size :: A handle to a target size object. */ 140 | /* */ 141 | /* <Return> */ 142 | /* FreeType error code. 0~means success. */ 143 | /* */ 144 | /* <Note> */ 145 | /* If `face' is the size's parent face object, this function changes */ 146 | /* the value of `face->size' to the input size handle. */ 147 | /* */ 148 | FT_EXPORT( FT_Error ) 149 | FT_Activate_Size( FT_Size size ); 150 | 151 | /* */ 152 | 153 | 154 | FT_END_HEADER 155 | 156 | #endif /* FTSIZES_H_ */ 157 | 158 | 159 | /* END */ 160 | -------------------------------------------------------------------------------- /common/include/freetype/ftsynth.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftsynth.h */ 4 | /* */ 5 | /* FreeType synthesizing code for emboldening and slanting */ 6 | /* (specification). */ 7 | /* */ 8 | /* Copyright 2000-2017 by */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* This file is part of the FreeType project, and may only be used, */ 12 | /* modified, and distributed under the terms of the FreeType project */ 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 | /* this file you indicate that you have read the license and */ 15 | /* understand and accept it fully. */ 16 | /* */ 17 | /***************************************************************************/ 18 | 19 | 20 | /*************************************************************************/ 21 | /*************************************************************************/ 22 | /*************************************************************************/ 23 | /*************************************************************************/ 24 | /*************************************************************************/ 25 | /********* *********/ 26 | /********* WARNING, THIS IS ALPHA CODE! THIS API *********/ 27 | /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/ 28 | /********* FREETYPE DEVELOPMENT TEAM *********/ 29 | /********* *********/ 30 | /*************************************************************************/ 31 | /*************************************************************************/ 32 | /*************************************************************************/ 33 | /*************************************************************************/ 34 | /*************************************************************************/ 35 | 36 | 37 | /* Main reason for not lifting the functions in this module to a */ 38 | /* `standard' API is that the used parameters for emboldening and */ 39 | /* slanting are not configurable. Consider the functions as a */ 40 | /* code resource that should be copied into the application and */ 41 | /* adapted to the particular needs. */ 42 | 43 | 44 | #ifndef FTSYNTH_H_ 45 | #define FTSYNTH_H_ 46 | 47 | 48 | #include <ft2build.h> 49 | #include FT_FREETYPE_H 50 | 51 | #ifdef FREETYPE_H 52 | #error "freetype.h of FreeType 1 has been loaded!" 53 | #error "Please fix the directory search order for header files" 54 | #error "so that freetype.h of FreeType 2 is found first." 55 | #endif 56 | 57 | 58 | FT_BEGIN_HEADER 59 | 60 | /* Embolden a glyph by a `reasonable' value (which is highly a matter of */ 61 | /* taste). This function is actually a convenience function, providing */ 62 | /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ 63 | /* */ 64 | /* For emboldened outlines the height, width, and advance metrics are */ 65 | /* increased by the strength of the emboldening -- this even affects */ 66 | /* mono-width fonts! */ 67 | /* */ 68 | /* You can also call @FT_Outline_Get_CBox to get precise values. */ 69 | FT_EXPORT( void ) 70 | FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); 71 | 72 | /* Slant an outline glyph to the right by about 12 degrees. */ 73 | FT_EXPORT( void ) 74 | FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); 75 | 76 | /* */ 77 | 78 | 79 | FT_END_HEADER 80 | 81 | #endif /* FTSYNTH_H_ */ 82 | 83 | 84 | /* END */ 85 | -------------------------------------------------------------------------------- /common/include/freetype/fttrigon.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* fttrigon.h */ 4 | /* */ 5 | /* FreeType trigonometric functions (specification). */ 6 | /* */ 7 | /* Copyright 2001-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTTRIGON_H_ 20 | #define FTTRIGON_H_ 21 | 22 | #include FT_FREETYPE_H 23 | 24 | #ifdef FREETYPE_H 25 | #error "freetype.h of FreeType 1 has been loaded!" 26 | #error "Please fix the directory search order for header files" 27 | #error "so that freetype.h of FreeType 2 is found first." 28 | #endif 29 | 30 | 31 | FT_BEGIN_HEADER 32 | 33 | 34 | /*************************************************************************/ 35 | /* */ 36 | /* <Section> */ 37 | /* computations */ 38 | /* */ 39 | /*************************************************************************/ 40 | 41 | 42 | /************************************************************************* 43 | * 44 | * @type: 45 | * FT_Angle 46 | * 47 | * @description: 48 | * This type is used to model angle values in FreeType. Note that the 49 | * angle is a 16.16 fixed-point value expressed in degrees. 50 | * 51 | */ 52 | typedef FT_Fixed FT_Angle; 53 | 54 | 55 | /************************************************************************* 56 | * 57 | * @macro: 58 | * FT_ANGLE_PI 59 | * 60 | * @description: 61 | * The angle pi expressed in @FT_Angle units. 62 | * 63 | */ 64 | #define FT_ANGLE_PI ( 180L << 16 ) 65 | 66 | 67 | /************************************************************************* 68 | * 69 | * @macro: 70 | * FT_ANGLE_2PI 71 | * 72 | * @description: 73 | * The angle 2*pi expressed in @FT_Angle units. 74 | * 75 | */ 76 | #define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) 77 | 78 | 79 | /************************************************************************* 80 | * 81 | * @macro: 82 | * FT_ANGLE_PI2 83 | * 84 | * @description: 85 | * The angle pi/2 expressed in @FT_Angle units. 86 | * 87 | */ 88 | #define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) 89 | 90 | 91 | /************************************************************************* 92 | * 93 | * @macro: 94 | * FT_ANGLE_PI4 95 | * 96 | * @description: 97 | * The angle pi/4 expressed in @FT_Angle units. 98 | * 99 | */ 100 | #define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) 101 | 102 | 103 | /************************************************************************* 104 | * 105 | * @function: 106 | * FT_Sin 107 | * 108 | * @description: 109 | * Return the sinus of a given angle in fixed-point format. 110 | * 111 | * @input: 112 | * angle :: 113 | * The input angle. 114 | * 115 | * @return: 116 | * The sinus value. 117 | * 118 | * @note: 119 | * If you need both the sinus and cosinus for a given angle, use the 120 | * function @FT_Vector_Unit. 121 | * 122 | */ 123 | FT_EXPORT( FT_Fixed ) 124 | FT_Sin( FT_Angle angle ); 125 | 126 | 127 | /************************************************************************* 128 | * 129 | * @function: 130 | * FT_Cos 131 | * 132 | * @description: 133 | * Return the cosinus of a given angle in fixed-point format. 134 | * 135 | * @input: 136 | * angle :: 137 | * The input angle. 138 | * 139 | * @return: 140 | * The cosinus value. 141 | * 142 | * @note: 143 | * If you need both the sinus and cosinus for a given angle, use the 144 | * function @FT_Vector_Unit. 145 | * 146 | */ 147 | FT_EXPORT( FT_Fixed ) 148 | FT_Cos( FT_Angle angle ); 149 | 150 | 151 | /************************************************************************* 152 | * 153 | * @function: 154 | * FT_Tan 155 | * 156 | * @description: 157 | * Return the tangent of a given angle in fixed-point format. 158 | * 159 | * @input: 160 | * angle :: 161 | * The input angle. 162 | * 163 | * @return: 164 | * The tangent value. 165 | * 166 | */ 167 | FT_EXPORT( FT_Fixed ) 168 | FT_Tan( FT_Angle angle ); 169 | 170 | 171 | /************************************************************************* 172 | * 173 | * @function: 174 | * FT_Atan2 175 | * 176 | * @description: 177 | * Return the arc-tangent corresponding to a given vector (x,y) in 178 | * the 2d plane. 179 | * 180 | * @input: 181 | * x :: 182 | * The horizontal vector coordinate. 183 | * 184 | * y :: 185 | * The vertical vector coordinate. 186 | * 187 | * @return: 188 | * The arc-tangent value (i.e. angle). 189 | * 190 | */ 191 | FT_EXPORT( FT_Angle ) 192 | FT_Atan2( FT_Fixed x, 193 | FT_Fixed y ); 194 | 195 | 196 | /************************************************************************* 197 | * 198 | * @function: 199 | * FT_Angle_Diff 200 | * 201 | * @description: 202 | * Return the difference between two angles. The result is always 203 | * constrained to the ]-PI..PI] interval. 204 | * 205 | * @input: 206 | * angle1 :: 207 | * First angle. 208 | * 209 | * angle2 :: 210 | * Second angle. 211 | * 212 | * @return: 213 | * Constrained value of `value2-value1'. 214 | * 215 | */ 216 | FT_EXPORT( FT_Angle ) 217 | FT_Angle_Diff( FT_Angle angle1, 218 | FT_Angle angle2 ); 219 | 220 | 221 | /************************************************************************* 222 | * 223 | * @function: 224 | * FT_Vector_Unit 225 | * 226 | * @description: 227 | * Return the unit vector corresponding to a given angle. After the 228 | * call, the value of `vec.x' will be `cos(angle)', and the value of 229 | * `vec.y' will be `sin(angle)'. 230 | * 231 | * This function is useful to retrieve both the sinus and cosinus of a 232 | * given angle quickly. 233 | * 234 | * @output: 235 | * vec :: 236 | * The address of target vector. 237 | * 238 | * @input: 239 | * angle :: 240 | * The input angle. 241 | * 242 | */ 243 | FT_EXPORT( void ) 244 | FT_Vector_Unit( FT_Vector* vec, 245 | FT_Angle angle ); 246 | 247 | 248 | /************************************************************************* 249 | * 250 | * @function: 251 | * FT_Vector_Rotate 252 | * 253 | * @description: 254 | * Rotate a vector by a given angle. 255 | * 256 | * @inout: 257 | * vec :: 258 | * The address of target vector. 259 | * 260 | * @input: 261 | * angle :: 262 | * The input angle. 263 | * 264 | */ 265 | FT_EXPORT( void ) 266 | FT_Vector_Rotate( FT_Vector* vec, 267 | FT_Angle angle ); 268 | 269 | 270 | /************************************************************************* 271 | * 272 | * @function: 273 | * FT_Vector_Length 274 | * 275 | * @description: 276 | * Return the length of a given vector. 277 | * 278 | * @input: 279 | * vec :: 280 | * The address of target vector. 281 | * 282 | * @return: 283 | * The vector length, expressed in the same units that the original 284 | * vector coordinates. 285 | * 286 | */ 287 | FT_EXPORT( FT_Fixed ) 288 | FT_Vector_Length( FT_Vector* vec ); 289 | 290 | 291 | /************************************************************************* 292 | * 293 | * @function: 294 | * FT_Vector_Polarize 295 | * 296 | * @description: 297 | * Compute both the length and angle of a given vector. 298 | * 299 | * @input: 300 | * vec :: 301 | * The address of source vector. 302 | * 303 | * @output: 304 | * length :: 305 | * The vector length. 306 | * 307 | * angle :: 308 | * The vector angle. 309 | * 310 | */ 311 | FT_EXPORT( void ) 312 | FT_Vector_Polarize( FT_Vector* vec, 313 | FT_Fixed *length, 314 | FT_Angle *angle ); 315 | 316 | 317 | /************************************************************************* 318 | * 319 | * @function: 320 | * FT_Vector_From_Polar 321 | * 322 | * @description: 323 | * Compute vector coordinates from a length and angle. 324 | * 325 | * @output: 326 | * vec :: 327 | * The address of source vector. 328 | * 329 | * @input: 330 | * length :: 331 | * The vector length. 332 | * 333 | * angle :: 334 | * The vector angle. 335 | * 336 | */ 337 | FT_EXPORT( void ) 338 | FT_Vector_From_Polar( FT_Vector* vec, 339 | FT_Fixed length, 340 | FT_Angle angle ); 341 | 342 | /* */ 343 | 344 | 345 | FT_END_HEADER 346 | 347 | #endif /* FTTRIGON_H_ */ 348 | 349 | 350 | /* END */ 351 | -------------------------------------------------------------------------------- /common/include/freetype/tttags.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* tttags.h */ 4 | /* */ 5 | /* Tags for TrueType and OpenType tables (specification only). */ 6 | /* */ 7 | /* Copyright 1996-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef TTAGS_H_ 20 | #define TTAGS_H_ 21 | 22 | 23 | #include <ft2build.h> 24 | #include FT_FREETYPE_H 25 | 26 | #ifdef FREETYPE_H 27 | #error "freetype.h of FreeType 1 has been loaded!" 28 | #error "Please fix the directory search order for header files" 29 | #error "so that freetype.h of FreeType 2 is found first." 30 | #endif 31 | 32 | 33 | FT_BEGIN_HEADER 34 | 35 | 36 | #define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) 37 | #define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) 38 | #define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) 39 | #define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) 40 | #define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) 41 | #define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) 42 | #define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) 43 | #define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) 44 | #define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) 45 | #define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) 46 | #define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' ) 47 | #define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) 48 | #define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) 49 | #define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) 50 | #define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) 51 | #define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) 52 | #define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) 53 | #define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) 54 | #define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) 55 | #define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) 56 | #define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) 57 | #define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) 58 | #define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) 59 | #define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) 60 | #define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) 61 | #define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) 62 | #define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) 63 | #define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) 64 | #define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) 65 | #define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' ) 66 | #define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) 67 | #define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) 68 | #define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) 69 | #define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) 70 | #define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) 71 | #define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) 72 | #define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) 73 | #define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) 74 | #define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) 75 | #define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) 76 | #define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) 77 | #define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) 78 | #define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) 79 | #define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) 80 | #define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) 81 | #define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) 82 | #define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) 83 | #define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) 84 | #define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' ) 85 | #define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) 86 | #define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) 87 | #define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) 88 | #define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) 89 | #define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) 90 | #define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' ) 91 | #define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) 92 | #define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) 93 | #define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) 94 | #define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' ) 95 | #define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' ) 96 | #define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) 97 | #define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) 98 | #define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) 99 | #define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) 100 | #define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) 101 | #define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) 102 | #define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' ) 103 | #define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) 104 | #define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) 105 | #define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) 106 | #define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' ) 107 | #define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) 108 | 109 | /* used by "Keyboard.dfont" on legacy Mac OS X */ 110 | #define TTAG_0xA5kbd FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' ) 111 | 112 | /* used by "LastResort.dfont" on legacy Mac OS X */ 113 | #define TTAG_0xA5lst FT_MAKE_TAG( 0xA5, 'l', 's', 't' ) 114 | 115 | 116 | FT_END_HEADER 117 | 118 | #endif /* TTAGS_H_ */ 119 | 120 | 121 | /* END */ 122 | -------------------------------------------------------------------------------- /common/include/freetype/ttunpat.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ttunpat.h */ 4 | /* */ 5 | /* Definitions for the unpatented TrueType hinting system. */ 6 | /* Obsolete, retained for backward compatibility. */ 7 | /* */ 8 | /* Copyright 2003-2017 by */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* Written by Graham Asher <graham.asher@btinternet.com> */ 12 | /* */ 13 | /* This file is part of the FreeType project, and may only be used, */ 14 | /* modified, and distributed under the terms of the FreeType project */ 15 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 16 | /* this file you indicate that you have read the license and */ 17 | /* understand and accept it fully. */ 18 | /* */ 19 | /***************************************************************************/ 20 | 21 | 22 | #ifndef TTUNPAT_H_ 23 | #define TTUNPAT_H_ 24 | 25 | 26 | #include <ft2build.h> 27 | #include FT_FREETYPE_H 28 | 29 | #ifdef FREETYPE_H 30 | #error "freetype.h of FreeType 1 has been loaded!" 31 | #error "Please fix the directory search order for header files" 32 | #error "so that freetype.h of FreeType 2 is found first." 33 | #endif 34 | 35 | 36 | FT_BEGIN_HEADER 37 | 38 | 39 | /*************************************************************************** 40 | * 41 | * @constant: 42 | * FT_PARAM_TAG_UNPATENTED_HINTING 43 | * 44 | * @description: 45 | * Deprecated. 46 | * 47 | * Previously: A constant used as the tag of an @FT_Parameter structure to 48 | * indicate that unpatented methods only should be used by the TrueType 49 | * bytecode interpreter for a typeface opened by @FT_Open_Face. 50 | * 51 | */ 52 | #define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) 53 | 54 | /* */ 55 | 56 | 57 | FT_END_HEADER 58 | 59 | 60 | #endif /* TTUNPAT_H_ */ 61 | 62 | 63 | /* END */ 64 | -------------------------------------------------------------------------------- /common/include/ft2build.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ft2build.h */ 4 | /* */ 5 | /* FreeType 2 build and setup macros. */ 6 | /* */ 7 | /* Copyright 1996-2017 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /*************************************************************************/ 20 | /* */ 21 | /* This is the `entry point' for FreeType header file inclusions. It is */ 22 | /* the only header file which should be included directly; all other */ 23 | /* FreeType header files should be accessed with macro names (after */ 24 | /* including `ft2build.h'). */ 25 | /* */ 26 | /* A typical example is */ 27 | /* */ 28 | /* #include <ft2build.h> */ 29 | /* #include FT_FREETYPE_H */ 30 | /* */ 31 | /*************************************************************************/ 32 | 33 | 34 | #ifndef FT2BUILD_H_ 35 | #define FT2BUILD_H_ 36 | 37 | #include <freetype/config/ftheader.h> 38 | 39 | #endif /* FT2BUILD_H_ */ 40 | 41 | 42 | /* END */ 43 | -------------------------------------------------------------------------------- /common/include/iconv.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1999-2003, 2005-2006, 2008-2011 Free Software Foundation, Inc. 2 | This file is part of the GNU LIBICONV Library. 3 | 4 | The GNU LIBICONV Library is free software; you can redistribute it 5 | and/or modify it under the terms of the GNU Library General Public 6 | License as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | The GNU LIBICONV Library is distributed in the hope that it will be 10 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with the GNU LIBICONV Library; see the file COPYING.LIB. 16 | If not, see <http://www.gnu.org/licenses/>. */ 17 | 18 | /* When installed, this file is called "iconv.h". */ 19 | 20 | #ifndef _LIBICONV_H 21 | #define _LIBICONV_H 22 | 23 | #define _LIBICONV_VERSION 0x010F /* version number: (major<<8) + minor */ 24 | extern int _libiconv_version; /* Likewise */ 25 | 26 | /* We would like to #include any system header file which could define 27 | iconv_t, 1. in order to eliminate the risk that the user gets compilation 28 | errors because some other system header file includes /usr/include/iconv.h 29 | which defines iconv_t or declares iconv after this file, 2. when compiling 30 | for LIBICONV_PLUG, we need the proper iconv_t type in order to produce 31 | binary compatible code. 32 | But gcc's #include_next is not portable. Thus, once libiconv's iconv.h 33 | has been installed in /usr/local/include, there is no way any more to 34 | include the original /usr/include/iconv.h. We simply have to get away 35 | without it. 36 | Ad 1. The risk that a system header file does 37 | #include "iconv.h" or #include_next "iconv.h" 38 | is small. They all do #include <iconv.h>. 39 | Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It 40 | has to be a scalar type because (iconv_t)(-1) is a possible return value 41 | from iconv_open().) */ 42 | 43 | /* Define iconv_t ourselves. */ 44 | #undef iconv_t 45 | #define iconv_t libiconv_t 46 | typedef void* iconv_t; 47 | 48 | /* Get size_t declaration. 49 | Get wchar_t declaration if it exists. */ 50 | #include <stddef.h> 51 | 52 | /* Get errno declaration and values. */ 53 | #include <errno.h> 54 | /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, 55 | have EILSEQ in a different header. On these systems, define EILSEQ 56 | ourselves. */ 57 | #ifndef EILSEQ 58 | #define EILSEQ 59 | #endif 60 | 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | 67 | /* Allocates descriptor for code conversion from encoding ‘fromcode’ to 68 | encoding ‘tocode’. */ 69 | #ifndef LIBICONV_PLUG 70 | #define iconv_open libiconv_open 71 | #endif 72 | extern iconv_t iconv_open (const char* tocode, const char* fromcode); 73 | 74 | /* Converts, using conversion descriptor ‘cd’, at most ‘*inbytesleft’ bytes 75 | starting at ‘*inbuf’, writing at most ‘*outbytesleft’ bytes starting at 76 | ‘*outbuf’. 77 | Decrements ‘*inbytesleft’ and increments ‘*inbuf’ by the same amount. 78 | Decrements ‘*outbytesleft’ and increments ‘*outbuf’ by the same amount. */ 79 | #ifndef LIBICONV_PLUG 80 | #define iconv libiconv 81 | #endif 82 | extern size_t iconv (iconv_t cd, char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); 83 | 84 | /* Frees resources allocated for conversion descriptor ‘cd’. */ 85 | #ifndef LIBICONV_PLUG 86 | #define iconv_close libiconv_close 87 | #endif 88 | extern int iconv_close (iconv_t cd); 89 | 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | 96 | #ifndef LIBICONV_PLUG 97 | 98 | /* Nonstandard extensions. */ 99 | 100 | #if 1 101 | #if 0 102 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 103 | <wchar.h>. 104 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 105 | included before <wchar.h>. */ 106 | #include <stddef.h> 107 | #include <stdio.h> 108 | #include <time.h> 109 | #endif 110 | #include <wchar.h> 111 | #endif 112 | 113 | #ifdef __cplusplus 114 | extern "C" { 115 | #endif 116 | 117 | /* A type that holds all memory needed by a conversion descriptor. 118 | A pointer to such an object can be used as an iconv_t. */ 119 | typedef struct { 120 | void* dummy1[28]; 121 | #if 1 122 | mbstate_t dummy2; 123 | #endif 124 | } iconv_allocation_t; 125 | 126 | /* Allocates descriptor for code conversion from encoding ‘fromcode’ to 127 | encoding ‘tocode’ into preallocated memory. Returns an error indicator 128 | (0 or -1 with errno set). */ 129 | #define iconv_open_into libiconv_open_into 130 | extern int iconv_open_into (const char* tocode, const char* fromcode, 131 | iconv_allocation_t* resultp); 132 | 133 | /* Control of attributes. */ 134 | #define iconvctl libiconvctl 135 | extern int iconvctl (iconv_t cd, int request, void* argument); 136 | 137 | /* Hook performed after every successful conversion of a Unicode character. */ 138 | typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data); 139 | /* Hook performed after every successful conversion of a wide character. */ 140 | typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data); 141 | /* Set of hooks. */ 142 | struct iconv_hooks { 143 | iconv_unicode_char_hook uc_hook; 144 | iconv_wide_char_hook wc_hook; 145 | void* data; 146 | }; 147 | 148 | /* Fallback function. Invoked when a small number of bytes could not be 149 | converted to a Unicode character. This function should process all 150 | bytes from inbuf and may produce replacement Unicode characters by calling 151 | the write_replacement callback repeatedly. */ 152 | typedef void (*iconv_unicode_mb_to_uc_fallback) 153 | (const char* inbuf, size_t inbufsize, 154 | void (*write_replacement) (const unsigned int *buf, size_t buflen, 155 | void* callback_arg), 156 | void* callback_arg, 157 | void* data); 158 | /* Fallback function. Invoked when a Unicode character could not be converted 159 | to the target encoding. This function should process the character and 160 | may produce replacement bytes (in the target encoding) by calling the 161 | write_replacement callback repeatedly. */ 162 | typedef void (*iconv_unicode_uc_to_mb_fallback) 163 | (unsigned int code, 164 | void (*write_replacement) (const char *buf, size_t buflen, 165 | void* callback_arg), 166 | void* callback_arg, 167 | void* data); 168 | #if 1 169 | /* Fallback function. Invoked when a number of bytes could not be converted to 170 | a wide character. This function should process all bytes from inbuf and may 171 | produce replacement wide characters by calling the write_replacement 172 | callback repeatedly. */ 173 | typedef void (*iconv_wchar_mb_to_wc_fallback) 174 | (const char* inbuf, size_t inbufsize, 175 | void (*write_replacement) (const wchar_t *buf, size_t buflen, 176 | void* callback_arg), 177 | void* callback_arg, 178 | void* data); 179 | /* Fallback function. Invoked when a wide character could not be converted to 180 | the target encoding. This function should process the character and may 181 | produce replacement bytes (in the target encoding) by calling the 182 | write_replacement callback repeatedly. */ 183 | typedef void (*iconv_wchar_wc_to_mb_fallback) 184 | (wchar_t code, 185 | void (*write_replacement) (const char *buf, size_t buflen, 186 | void* callback_arg), 187 | void* callback_arg, 188 | void* data); 189 | #else 190 | /* If the wchar_t type does not exist, these two fallback functions are never 191 | invoked. Their argument list therefore does not matter. */ 192 | typedef void (*iconv_wchar_mb_to_wc_fallback) (); 193 | typedef void (*iconv_wchar_wc_to_mb_fallback) (); 194 | #endif 195 | /* Set of fallbacks. */ 196 | struct iconv_fallbacks { 197 | iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; 198 | iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; 199 | iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback; 200 | iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback; 201 | void* data; 202 | }; 203 | 204 | /* Requests for iconvctl. */ 205 | #define ICONV_TRIVIALP 0 /* int *argument */ 206 | #define ICONV_GET_TRANSLITERATE 1 /* int *argument */ 207 | #define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ 208 | #define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ 209 | #define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ 210 | #define ICONV_SET_HOOKS 5 /* const struct iconv_hooks *argument */ 211 | #define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument */ 212 | 213 | /* Listing of locale independent encodings. */ 214 | #define iconvlist libiconvlist 215 | extern void iconvlist (int (*do_one) (unsigned int namescount, 216 | const char * const * names, 217 | void* data), 218 | void* data); 219 | 220 | /* Canonicalize an encoding name. 221 | The result is either a canonical encoding name, or name itself. */ 222 | extern const char * iconv_canonicalize (const char * name); 223 | 224 | /* Support for relocatable packages. */ 225 | 226 | /* Sets the original and the current installation prefix of the package. 227 | Relocation simply replaces a pathname starting with the original prefix 228 | by the corresponding pathname with the current prefix instead. Both 229 | prefixes should be directory names without trailing slash (i.e. use "" 230 | instead of "/"). */ 231 | extern void libiconv_set_relocation_prefix (const char *orig_prefix, 232 | const char *curr_prefix); 233 | 234 | #ifdef __cplusplus 235 | } 236 | #endif 237 | 238 | #endif 239 | 240 | 241 | #endif /* _LIBICONV_H */ 242 | -------------------------------------------------------------------------------- /common/include/kvec.h: -------------------------------------------------------------------------------- 1 | /* The MIT License 2 | 3 | Copyright (c) 2008, by Attractive Chaos <attractor@live.co.uk> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | */ 25 | 26 | /* 27 | An example: 28 | 29 | #include "kvec.h" 30 | int main() { 31 | kvec_t(int) array; 32 | kv_init(array); 33 | kv_push(int, array, 10); // append 34 | kv_a(int, array, 20) = 5; // dynamic 35 | kv_A(array, 20) = 4; // static 36 | kv_destroy(array); 37 | return 0; 38 | } 39 | */ 40 | 41 | /* 42 | 2008-09-22 (0.1.0): 43 | 44 | * The initial version. 45 | 46 | */ 47 | 48 | #ifndef AC_KVEC_H 49 | #define AC_KVEC_H 50 | 51 | #include <stdlib.h> 52 | 53 | #define kv_roundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) 54 | 55 | #define kvec_t(type) struct { size_t n, m; type *a; } 56 | #define kv_init(v) ((v).n = (v).m = 0, (v).a = 0) 57 | #define kv_destroy(v) free((v).a) 58 | #define kv_A(v, i) ((v).a[(i)]) 59 | #define kv_pop(v) ((v).a[--(v).n]) 60 | #define kv_size(v) ((v).n) 61 | #define kv_max(v) ((v).m) 62 | 63 | #define kv_resize(type, v, s) ((v).m = (s), (v).a = (type*)realloc((v).a, sizeof(type) * (v).m)) 64 | 65 | #define kv_copy(type, v1, v0) do { \ 66 | if ((v1).m < (v0).n) kv_resize(type, v1, (v0).n); \ 67 | (v1).n = (v0).n; \ 68 | memcpy((v1).a, (v0).a, sizeof(type) * (v0).n); \ 69 | } while (0) \ 70 | 71 | #define kv_push(type, v, x) do { \ 72 | if ((v).n == (v).m) { \ 73 | (v).m = (v).m? (v).m<<1 : 2; \ 74 | (v).a = (type*)realloc((v).a, sizeof(type) * (v).m); \ 75 | } \ 76 | (v).a[(v).n++] = (x); \ 77 | } while (0) 78 | 79 | #define kv_pushp(type, v) (((v).n == (v).m)? \ 80 | ((v).m = ((v).m? (v).m<<1 : 2), \ 81 | (v).a = (type*)realloc((v).a, sizeof(type) * (v).m), 0) \ 82 | : 0), ((v).a + ((v).n++)) 83 | 84 | #define kv_a(type, v, i) (((v).m <= (size_t)(i)? \ 85 | ((v).m = (v).n = (i) + 1, kv_roundup32((v).m), \ 86 | (v).a = (type*)realloc((v).a, sizeof(type) * (v).m), 0) \ 87 | : (v).n <= (size_t)(i)? (v).n = (i) + 1 \ 88 | : 0), (v).a[(i)]) 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /common/include/pnglibconf.h: -------------------------------------------------------------------------------- 1 | /* libpng 1.6.32 STANDARD API DEFINITION */ 2 | 3 | /* pnglibconf.h - library build configuration */ 4 | 5 | /* Libpng version 1.6.32 - August 24, 2017 */ 6 | 7 | /* Copyright (c) 1998-2017 Glenn Randers-Pehrson */ 8 | 9 | /* This code is released under the libpng license. */ 10 | /* For conditions of distribution and use, see the disclaimer */ 11 | /* and license in png.h */ 12 | 13 | /* pnglibconf.h */ 14 | /* Machine generated file: DO NOT EDIT */ 15 | /* Derived from: scripts/pnglibconf.dfa */ 16 | #ifndef PNGLCONF_H 17 | #define PNGLCONF_H 18 | /* options */ 19 | #define PNG_16BIT_SUPPORTED 20 | #define PNG_ALIGNED_MEMORY_SUPPORTED 21 | /*#undef PNG_ARM_NEON_API_SUPPORTED*/ 22 | /*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ 23 | /*#undef PNG_POWERPC_VSX_API_SUPPORTED*/ 24 | /*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/ 25 | #define PNG_BENIGN_ERRORS_SUPPORTED 26 | #define PNG_BENIGN_READ_ERRORS_SUPPORTED 27 | /*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ 28 | #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED 29 | #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED 30 | #define PNG_COLORSPACE_SUPPORTED 31 | #define PNG_CONSOLE_IO_SUPPORTED 32 | #define PNG_CONVERT_tIME_SUPPORTED 33 | #define PNG_EASY_ACCESS_SUPPORTED 34 | /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ 35 | #define PNG_ERROR_TEXT_SUPPORTED 36 | #define PNG_FIXED_POINT_SUPPORTED 37 | #define PNG_FLOATING_ARITHMETIC_SUPPORTED 38 | #define PNG_FLOATING_POINT_SUPPORTED 39 | #define PNG_FORMAT_AFIRST_SUPPORTED 40 | #define PNG_FORMAT_BGR_SUPPORTED 41 | #define PNG_GAMMA_SUPPORTED 42 | #define PNG_GET_PALETTE_MAX_SUPPORTED 43 | #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED 44 | #define PNG_INCH_CONVERSIONS_SUPPORTED 45 | #define PNG_INFO_IMAGE_SUPPORTED 46 | #define PNG_IO_STATE_SUPPORTED 47 | #define PNG_MNG_FEATURES_SUPPORTED 48 | #define PNG_POINTER_INDEXING_SUPPORTED 49 | #define PNG_PROGRESSIVE_READ_SUPPORTED 50 | #define PNG_READ_16BIT_SUPPORTED 51 | #define PNG_READ_ALPHA_MODE_SUPPORTED 52 | #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED 53 | #define PNG_READ_BACKGROUND_SUPPORTED 54 | #define PNG_READ_BGR_SUPPORTED 55 | #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED 56 | #define PNG_READ_COMPOSITE_NODIV_SUPPORTED 57 | #define PNG_READ_COMPRESSED_TEXT_SUPPORTED 58 | #define PNG_READ_EXPAND_16_SUPPORTED 59 | #define PNG_READ_EXPAND_SUPPORTED 60 | #define PNG_READ_FILLER_SUPPORTED 61 | #define PNG_READ_GAMMA_SUPPORTED 62 | #define PNG_READ_GET_PALETTE_MAX_SUPPORTED 63 | #define PNG_READ_GRAY_TO_RGB_SUPPORTED 64 | #define PNG_READ_INTERLACING_SUPPORTED 65 | #define PNG_READ_INT_FUNCTIONS_SUPPORTED 66 | #define PNG_READ_INVERT_ALPHA_SUPPORTED 67 | #define PNG_READ_INVERT_SUPPORTED 68 | #define PNG_READ_OPT_PLTE_SUPPORTED 69 | #define PNG_READ_PACKSWAP_SUPPORTED 70 | #define PNG_READ_PACK_SUPPORTED 71 | #define PNG_READ_QUANTIZE_SUPPORTED 72 | #define PNG_READ_RGB_TO_GRAY_SUPPORTED 73 | #define PNG_READ_SCALE_16_TO_8_SUPPORTED 74 | #define PNG_READ_SHIFT_SUPPORTED 75 | #define PNG_READ_STRIP_16_TO_8_SUPPORTED 76 | #define PNG_READ_STRIP_ALPHA_SUPPORTED 77 | #define PNG_READ_SUPPORTED 78 | #define PNG_READ_SWAP_ALPHA_SUPPORTED 79 | #define PNG_READ_SWAP_SUPPORTED 80 | #define PNG_READ_TEXT_SUPPORTED 81 | #define PNG_READ_TRANSFORMS_SUPPORTED 82 | #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 83 | #define PNG_READ_USER_CHUNKS_SUPPORTED 84 | #define PNG_READ_USER_TRANSFORM_SUPPORTED 85 | #define PNG_READ_bKGD_SUPPORTED 86 | #define PNG_READ_cHRM_SUPPORTED 87 | #define PNG_READ_eXIf_SUPPORTED 88 | #define PNG_READ_gAMA_SUPPORTED 89 | #define PNG_READ_hIST_SUPPORTED 90 | #define PNG_READ_iCCP_SUPPORTED 91 | #define PNG_READ_iTXt_SUPPORTED 92 | #define PNG_READ_oFFs_SUPPORTED 93 | #define PNG_READ_pCAL_SUPPORTED 94 | #define PNG_READ_pHYs_SUPPORTED 95 | #define PNG_READ_sBIT_SUPPORTED 96 | #define PNG_READ_sCAL_SUPPORTED 97 | #define PNG_READ_sPLT_SUPPORTED 98 | #define PNG_READ_sRGB_SUPPORTED 99 | #define PNG_READ_tEXt_SUPPORTED 100 | #define PNG_READ_tIME_SUPPORTED 101 | #define PNG_READ_tRNS_SUPPORTED 102 | #define PNG_READ_zTXt_SUPPORTED 103 | #define PNG_SAVE_INT_32_SUPPORTED 104 | #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED 105 | #define PNG_SEQUENTIAL_READ_SUPPORTED 106 | #define PNG_SETJMP_SUPPORTED 107 | #define PNG_SET_OPTION_SUPPORTED 108 | #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED 109 | #define PNG_SET_USER_LIMITS_SUPPORTED 110 | #define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED 111 | #define PNG_SIMPLIFIED_READ_BGR_SUPPORTED 112 | #define PNG_SIMPLIFIED_READ_SUPPORTED 113 | #define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED 114 | #define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED 115 | #define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED 116 | #define PNG_SIMPLIFIED_WRITE_SUPPORTED 117 | #define PNG_STDIO_SUPPORTED 118 | #define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED 119 | #define PNG_TEXT_SUPPORTED 120 | #define PNG_TIME_RFC1123_SUPPORTED 121 | #define PNG_UNKNOWN_CHUNKS_SUPPORTED 122 | #define PNG_USER_CHUNKS_SUPPORTED 123 | #define PNG_USER_LIMITS_SUPPORTED 124 | #define PNG_USER_MEM_SUPPORTED 125 | #define PNG_USER_TRANSFORM_INFO_SUPPORTED 126 | #define PNG_USER_TRANSFORM_PTR_SUPPORTED 127 | #define PNG_WARNINGS_SUPPORTED 128 | #define PNG_WRITE_16BIT_SUPPORTED 129 | #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED 130 | #define PNG_WRITE_BGR_SUPPORTED 131 | #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED 132 | #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED 133 | #define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED 134 | #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED 135 | #define PNG_WRITE_FILLER_SUPPORTED 136 | #define PNG_WRITE_FILTER_SUPPORTED 137 | #define PNG_WRITE_FLUSH_SUPPORTED 138 | #define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED 139 | #define PNG_WRITE_INTERLACING_SUPPORTED 140 | #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED 141 | #define PNG_WRITE_INVERT_ALPHA_SUPPORTED 142 | #define PNG_WRITE_INVERT_SUPPORTED 143 | #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED 144 | #define PNG_WRITE_PACKSWAP_SUPPORTED 145 | #define PNG_WRITE_PACK_SUPPORTED 146 | #define PNG_WRITE_SHIFT_SUPPORTED 147 | #define PNG_WRITE_SUPPORTED 148 | #define PNG_WRITE_SWAP_ALPHA_SUPPORTED 149 | #define PNG_WRITE_SWAP_SUPPORTED 150 | #define PNG_WRITE_TEXT_SUPPORTED 151 | #define PNG_WRITE_TRANSFORMS_SUPPORTED 152 | #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 153 | #define PNG_WRITE_USER_TRANSFORM_SUPPORTED 154 | #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 155 | #define PNG_WRITE_bKGD_SUPPORTED 156 | #define PNG_WRITE_cHRM_SUPPORTED 157 | #define PNG_WRITE_eXIf_SUPPORTED 158 | #define PNG_WRITE_gAMA_SUPPORTED 159 | #define PNG_WRITE_hIST_SUPPORTED 160 | #define PNG_WRITE_iCCP_SUPPORTED 161 | #define PNG_WRITE_iTXt_SUPPORTED 162 | #define PNG_WRITE_oFFs_SUPPORTED 163 | #define PNG_WRITE_pCAL_SUPPORTED 164 | #define PNG_WRITE_pHYs_SUPPORTED 165 | #define PNG_WRITE_sBIT_SUPPORTED 166 | #define PNG_WRITE_sCAL_SUPPORTED 167 | #define PNG_WRITE_sPLT_SUPPORTED 168 | #define PNG_WRITE_sRGB_SUPPORTED 169 | #define PNG_WRITE_tEXt_SUPPORTED 170 | #define PNG_WRITE_tIME_SUPPORTED 171 | #define PNG_WRITE_tRNS_SUPPORTED 172 | #define PNG_WRITE_zTXt_SUPPORTED 173 | #define PNG_bKGD_SUPPORTED 174 | #define PNG_cHRM_SUPPORTED 175 | #define PNG_eXIf_SUPPORTED 176 | #define PNG_gAMA_SUPPORTED 177 | #define PNG_hIST_SUPPORTED 178 | #define PNG_iCCP_SUPPORTED 179 | #define PNG_iTXt_SUPPORTED 180 | #define PNG_oFFs_SUPPORTED 181 | #define PNG_pCAL_SUPPORTED 182 | #define PNG_pHYs_SUPPORTED 183 | #define PNG_sBIT_SUPPORTED 184 | #define PNG_sCAL_SUPPORTED 185 | #define PNG_sPLT_SUPPORTED 186 | #define PNG_sRGB_SUPPORTED 187 | #define PNG_tEXt_SUPPORTED 188 | #define PNG_tIME_SUPPORTED 189 | #define PNG_tRNS_SUPPORTED 190 | #define PNG_zTXt_SUPPORTED 191 | /* end of options */ 192 | /* settings */ 193 | #define PNG_API_RULE 0 194 | #define PNG_DEFAULT_READ_MACROS 1 195 | #define PNG_GAMMA_THRESHOLD_FIXED 5000 196 | #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE 197 | #define PNG_INFLATE_BUF_SIZE 1024 198 | #define PNG_LINKAGE_API extern 199 | #define PNG_LINKAGE_CALLBACK extern 200 | #define PNG_LINKAGE_DATA extern 201 | #define PNG_LINKAGE_FUNCTION extern 202 | #define PNG_MAX_GAMMA_8 11 203 | #define PNG_QUANTIZE_BLUE_BITS 5 204 | #define PNG_QUANTIZE_GREEN_BITS 5 205 | #define PNG_QUANTIZE_RED_BITS 5 206 | #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) 207 | #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 208 | #define PNG_USER_CHUNK_CACHE_MAX 1000 209 | #define PNG_USER_CHUNK_MALLOC_MAX 8000000 210 | #define PNG_USER_HEIGHT_MAX 1000000 211 | #define PNG_USER_WIDTH_MAX 1000000 212 | #define PNG_ZBUF_SIZE 8192 213 | #define PNG_ZLIB_VERNUM 0 /* unknown */ 214 | #define PNG_Z_DEFAULT_COMPRESSION (-1) 215 | #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 216 | #define PNG_Z_DEFAULT_STRATEGY 1 217 | #define PNG_sCAL_PRECISION 5 218 | #define PNG_sRGB_PROFILE_CHECKS 2 219 | /* end of settings */ 220 | #endif /* PNGLCONF_H */ 221 | -------------------------------------------------------------------------------- /common/lib/libfreetype.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Inori/Falcom/77ac477e5f2ec5dd66943eb0ab4a7cc5e1b48799/common/lib/libfreetype.a -------------------------------------------------------------------------------- /common/lib/libiconv.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Inori/Falcom/77ac477e5f2ec5dd66943eb0ab4a7cc5e1b48799/common/lib/libiconv.a -------------------------------------------------------------------------------- /common/lib/libpng.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Inori/Falcom/77ac477e5f2ec5dd66943eb0ab4a7cc5e1b48799/common/lib/libpng.a -------------------------------------------------------------------------------- /common/lib/libz.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Inori/Falcom/77ac477e5f2ec5dd66943eb0ab4a7cc5e1b48799/common/lib/libz.a -------------------------------------------------------------------------------- /edao-patch/PCSG00246.txt: -------------------------------------------------------------------------------- 1 | app0:sce_module/asuka_patch.suprx 1 -------------------------------------------------------------------------------- /edao-patch/src/.clang_complete: -------------------------------------------------------------------------------- 1 | -I/home/asuka/local/vita/vitasdk/arm-vita-eabi/include 2 | -I/home/asuka/local/vita/vitasdk/lib/gcc/arm-vita-eabi/7.2.0/include -------------------------------------------------------------------------------- /edao-patch/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = asuka_patch 2 | TITLE_ID = PCSG00246 3 | PSVITAIP = 192.168.31.183 4 | 5 | OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) $(patsubst %.S, %.o, $(wildcard *.S)) 6 | HEADERS = $(wildcard *.h) 7 | 8 | LIBS = -lSceIofilemgr_stub -lSceThreadmgrForDriver_stub -lSceAppMgr_stub 9 | 10 | PREFIX = arm-vita-eabi 11 | CC = $(PREFIX)-gcc 12 | CFLAGS = -Wl,-q -Wall -O3 -nostartfiles 13 | ASFLAGS = $(CFLAGS) 14 | 15 | all: $(TARGET).suprx 16 | 17 | %.suprx: %.velf 18 | vita-make-fself $< $@ 19 | 20 | %.velf: %.elf 21 | vita-elf-create $< $@ 22 | 23 | $(TARGET).elf: $(OBJS) 24 | $(CC) $(CFLAGS) $^ $(LIBS) -o $@ 25 | 26 | clean: 27 | @rm -rf $(TARGET).suprx $(TARGET).velf $(TARGET).elf $(OBJS) 28 | 29 | send: $(TARGET).suprx 30 | curl -T $(TARGET).suprx ftp://$(PSVITAIP):1337/ux0:/app/$(TITLE_ID)/sce_module/ 31 | @echo "Sent." 32 | -------------------------------------------------------------------------------- /edao-patch/src/hook.h: -------------------------------------------------------------------------------- 1 | #ifndef EDAO_HOOK_H 2 | #define EDAO_HOOK_H 3 | 4 | #include <stdint.h> 5 | 6 | 7 | #include "log.h" 8 | #include "tools.h" 9 | #include "translator.h" 10 | 11 | //#define EDAO_HOOK_DEBUG 12 | 13 | extern TL_CONTEXT g_tl_context; 14 | 15 | int init_hooks(); 16 | 17 | 18 | #endif //EDAO_HOOK_H -------------------------------------------------------------------------------- /edao-patch/src/hook_stub.s: -------------------------------------------------------------------------------- 1 | # EDAO-Patch 2 | # Copyright (C) 2017, Asuka(Inori) 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. 16 | 17 | 18 | # Compile: 19 | # arm-vita-eabi-gcc -c hook_stub.s -o hook_stub.o 20 | # 21 | # View assembly: 22 | # arm-vita-eabi-objdump -d hook_stub.o 23 | # 24 | # Convert to binary: 25 | # arm-vita-eabi-objcopy -S -O binary hook_stub.o hook_stub.bin 26 | # 27 | 28 | .syntax unified 29 | .section .text 30 | .thumb 31 | 32 | .global hook_stub 33 | 34 | #hook_stub is a template, copy this function, 35 | #modify 'original instructions' part 36 | #nop to align 37 | hook_stub: 38 | # No operation to support the ldr relativity 39 | nop 40 | 41 | #pushad 42 | stmfd sp!, {r0-r12} 43 | #pushfd 44 | mrs r7, cpsr 45 | str r7, [sp, #-4]! 46 | 47 | #load hook function address 48 | ldr.w r7, [pc, #0x1c] 49 | ldr.w r7, [r7, #0] 50 | #call hook function 51 | blx r7 52 | #popfd 53 | ldr r7, [sp], #4 54 | msr cpsr, r7 55 | #popad 56 | ldmfd sp!, {r0-r12} 57 | 58 | #original instructions 59 | 60 | 61 | #jmp to original function 62 | ldr.w pc, [pc, #0] 63 | 64 | .word 0x11111111 65 | .word 0x22222222 66 | 67 | 68 | jmp_stub: 69 | push {r6-r8, lr} 70 | 71 | # get function table address 72 | adr r6, FUNC_TABLE 73 | ldr r6, [r6] 74 | 75 | # get new function pointer 76 | ldr r7, [r6] 77 | 78 | # get old function pointer 79 | adr r8, OLD_FUNC 80 | 81 | # save old func pointer 82 | str r8, [r6, #4] 83 | 84 | # call our new function 85 | blx r7 86 | pop {r6-r8, pc} 87 | 88 | FUNC_TABLE: 89 | .word 0x11111111 90 | 91 | OLD_FUNC: 92 | 93 | #original instructions 94 | 95 | ldr.w pc, [pc, #0] 96 | .word 0x22222222 97 | 98 | 99 | 100 | test_func: 101 | b test_label 102 | nop 103 | sub sp, sp, #0xBC 104 | movw r2, #0x44F0 105 | movt.w r2, #0x811F 106 | nop 107 | ldr.w pc, [pc, #0] 108 | .word 0x33333333 109 | test_label: 110 | ldr.w pc, [pc, #0] 111 | .word 0x44444444 112 | 113 | 114 | 115 | 116 | jmp_stub_stack_arg: 117 | push {r6-r8, lr} 118 | sub sp, sp, #0x18 119 | 120 | # save 5th arg 121 | ldr r6, [sp, #0x28] 122 | str r6, [sp] 123 | # save 6th arg 124 | ldr r6, [sp, #0x2c] 125 | str r6, [sp, #4] 126 | # save 7th arg 127 | ldr r6, [sp, #0x30] 128 | str r6, [sp, #8] 129 | # save 8th arg 130 | ldr r6, [sp, #0x34] 131 | str r6, [sp, #0xc] 132 | # save 9th arg 133 | ldr r6, [sp, #0x38] 134 | str r6, [sp, #0x10] 135 | # save 10th arg 136 | ldr r6, [sp, #0x3c] 137 | str r6, [sp, #0x14] 138 | 139 | # get function table address 140 | adr r6, FUNC_TABLE_2 141 | ldr r6, [r6] 142 | 143 | # get new function pointer 144 | ldr r7, [r6] 145 | 146 | # get old function pointer 147 | adr r8, OLD_FUNC_2 148 | 149 | # save old func pointer 150 | str r8, [r6, #4] 151 | 152 | # call our new function 153 | blx r7 154 | add sp, sp, #0x18 155 | pop {r6-r8, pc} 156 | 157 | FUNC_TABLE_2: 158 | .word 0x11111111 159 | 160 | OLD_FUNC_2: 161 | 162 | #original instructions 163 | 164 | ldr.w pc, [pc, #0] 165 | .word 0x22222222 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /edao-patch/src/log.c: -------------------------------------------------------------------------------- 1 | #include "log.h" 2 | 3 | 4 | #include <stdarg.h> 5 | #include <stdio.h> 6 | #include <string.h> 7 | 8 | #include <psp2/io/fcntl.h> 9 | #include <psp2/io/stat.h> 10 | 11 | //Note: 12 | //It seems that the game folder will be mount to app0 on start, 13 | //and can't write anything in it. 14 | //So we have to find a place where we have write permission. 15 | #define LOG_FILENAME "ux0:plugins/asuka_log.txt" 16 | #define LOG_BUFFER_LEN 4096 17 | void debug_print(const char* format, ...) 18 | { 19 | va_list list; 20 | char string[LOG_BUFFER_LEN] = {0}; 21 | 22 | va_start(list, format); 23 | vsprintf(string, format, list); 24 | va_end(list); 25 | 26 | SceUID fd = sceIoOpen(LOG_FILENAME, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_APPEND, 0777); 27 | if (fd < 0) 28 | { 29 | return; 30 | } 31 | 32 | sceIoWrite(fd, string, strlen(string)); 33 | sceIoClose(fd); 34 | } 35 | -------------------------------------------------------------------------------- /edao-patch/src/log.h: -------------------------------------------------------------------------------- 1 | #ifndef VITA_LOG_H 2 | #define VITA_LOG_H 3 | 4 | 5 | #define DEBUG 6 | 7 | 8 | 9 | void debug_print(const char* format, ...); 10 | 11 | 12 | 13 | #ifdef DEBUG 14 | #define DEBUG_PRINT(...) debug_print(__VA_ARGS__) 15 | #else 16 | #define DEBUG_PRINT(...) 17 | #endif 18 | 19 | 20 | #endif //VITA_LOG_H -------------------------------------------------------------------------------- /edao-patch/src/main.c: -------------------------------------------------------------------------------- 1 | #include <string.h> 2 | #include <psp2/types.h> 3 | #include <psp2/kernel/modulemgr.h> 4 | 5 | #include "log.h" 6 | #include "tools.h" 7 | #include "hook.h" 8 | 9 | #define TL_MAP_FILENAME "app0:string_map.acr" 10 | 11 | int _start(SceSize args, void *argp) 12 | { 13 | int ret = -1; 14 | char title_id[VITA_TITLE_ID_LEN] = {0}; 15 | 16 | get_title_id(title_id); 17 | 18 | DEBUG_PRINT("module start - TITLE ID: %s\n", title_id); 19 | 20 | ret = tl_init(&g_tl_context, TL_MAP_FILENAME); 21 | 22 | ret = init_hooks(); 23 | 24 | return ret; 25 | } 26 | -------------------------------------------------------------------------------- /edao-patch/src/memcpy_asm.S: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Asuka Langley on 2018/8/21. 3 | // 4 | .syntax unified 5 | .section .text 6 | //.arm 7 | .thumb 8 | .thumb_func 9 | .global memcpy_asm 10 | .type memcpy_asm, %function 11 | 12 | 13 | 14 | memcpy_asm: 15 | /* Assumes that n >= 0, and dst, src are valid pointers. 16 | If there is at least 8 bytes to copy, use LDRD/STRD. 17 | If src and dst are misaligned with different offsets, 18 | first copy byte by byte until dst is aligned, 19 | and then copy using LDRD/STRD and shift if needed. 20 | When less than 8 left, copy a word and then byte by byte. */ 21 | 22 | /* Save registers (r0 holds the return value): 23 | optimized push {r0, r4, r5, lr}. 24 | To try and improve performance, stack layout changed, 25 | i.e., not keeping the stack looking like users expect 26 | (highest numbered register at highest address). */ 27 | 28 | push {r0, lr} 29 | strd r4, r5, [sp, #-8]! 30 | 31 | /* TODO: Add debug frame directives. 32 | We don't need exception unwind directives, because the code below 33 | does not throw any exceptions and does not call any other functions. 34 | Generally, newlib functions like this lack debug information for 35 | assembler source. */ 36 | 37 | /* Get copying of tiny blocks out of the way first. */ 38 | 39 | /* Is there at least 4 bytes to copy? */ 40 | subs r2, r2, #4 41 | blt copy_less_than_4 /* If n < 4. */ 42 | /* Check word alignment. */ 43 | ands ip, r0, #3 /* ip = last 2 bits of dst. */ 44 | bne dst_not_word_aligned /* If dst is not word-aligned. */ 45 | /* Get here if dst is word-aligned. */ 46 | ands ip, r1, #3 /* ip = last 2 bits of src. */ 47 | bne src_not_word_aligned /* If src is not word-aligned. */ 48 | 49 | word_aligned: 50 | /* Get here if source and dst both are word-aligned. 51 | The number of bytes remaining to copy is r2+4. */ 52 | /* Is there is at least 64 bytes to copy? */ 53 | subs r2, r2, #60 54 | blt copy_less_than_64 /* If r2 + 4 < 64. */ 55 | 56 | /* First, align the destination buffer to 8-bytes, 57 | to make sure double loads and stores don't cross cache line boundary, 58 | as they are then more expensive even if the data is in the cache 59 | (require two load/store issue cycles instead of one). 60 | If only one of the buffers is not 8-bytes aligned, 61 | then it's more important to align dst than src, 62 | because there is more penalty for stores 63 | than loads that cross cacheline boundary. 64 | This check and realignment are only worth doing 65 | if there is a lot to copy. */ 66 | 67 | /* Get here if dst is word aligned, 68 | i.e., the 2 least significant bits are 0. 69 | If dst is not 2w aligned (i.e., the 3rd bit is not set in dst), 70 | then copy 1 word (4 bytes). */ 71 | ands r3, r0, #4 72 | beq 11f /* If dst already two-word aligned. */ 73 | ldr r3, [r1], #4 74 | str r3, [r0], #4 75 | subs r2, r2, #4 76 | blt copy_less_than_64 77 | 11: 78 | /* TODO: Align to cacheline (useful for PLD optimization). */ 79 | /* Every loop iteration copies 64 bytes. */ 80 | 1: 81 | .irp offset, #0, #8, #16, #24, #32, #40, #48, #56 82 | ldrd r4, r5, [r1, \offset] 83 | strd r4, r5, [r0, \offset] 84 | .endr 85 | add r0, r0, #64 86 | add r1, r1, #64 87 | subs r2, r2, #64 88 | bge 1b /* If there is more to copy. */ 89 | copy_less_than_64: 90 | /* Get here if less than 64 bytes to copy, -64 <= r2 < 0. 91 | Restore the count if there is more than 7 bytes to copy. */ 92 | adds r2, r2, #56 93 | blt copy_less_than_8 94 | /* Copy 8 bytes at a time. */ 95 | 2: 96 | ldrd r4, r5, [r1], #8 97 | strd r4, r5, [r0], #8 98 | subs r2, r2, #8 99 | bge 2b /* If there is more to copy. */ 100 | copy_less_than_8: 101 | /* Get here if less than 8 bytes to copy, -8 <= r2 < 0. 102 | Check if there is more to copy. */ 103 | cmn r2, #8 104 | beq return /* If r2 + 8 == 0. */ 105 | /* Restore the count if there is more than 3 bytes to copy. */ 106 | adds r2, r2, #4 107 | blt copy_less_than_4 108 | /* Copy 4 bytes. */ 109 | ldr r3, [r1], #4 110 | str r3, [r0], #4 111 | copy_less_than_4: 112 | /* Get here if less than 4 bytes to copy, -4 <= r2 < 0. */ 113 | /* Restore the count, check if there is more to copy. */ 114 | adds r2, r2, #4 115 | beq return /* If r2 == 0. */ 116 | /* Get here with r2 is in {1,2,3}={01,10,11}. */ 117 | /* Logical shift left r2, insert 0s, update flags. */ 118 | lsls r2, r2, #31 119 | /* Copy byte by byte. 120 | Condition ne means the last bit of r2 is 0. 121 | Condition cs means the second to last bit of r2 is set, 122 | i.e., r2 is 1 or 3. */ 123 | itt ne 124 | ldrbne r3, [r1], #1 125 | strbne r3, [r0], #1 126 | itttt cs 127 | ldrbcs r4, [r1], #1 128 | ldrbcs r5, [r1] 129 | strbcs r4, [r0], #1 130 | strbcs r5, [r0] 131 | return: 132 | /* Restore registers: optimized pop {r0, r4, r5, pc} */ 133 | ldrd r4, r5, [sp], #8 134 | 135 | pop {r0, pc} /* This is the only return point of memcpy. */ 136 | 137 | 138 | dst_not_word_aligned: 139 | /* Get here when dst is not aligned and ip has the last 2 bits of dst, 140 | i.e., ip is the offset of dst from word. 141 | The number of bytes that remains to copy is r2 + 4, 142 | i.e., there are at least 4 bytes to copy. 143 | Write a partial word (0 to 3 bytes), such that dst becomes 144 | word-aligned. */ 145 | 146 | /* If dst is at ip bytes offset from a word (with 0 < ip < 4), 147 | then there are (4 - ip) bytes to fill up to align dst to the next 148 | word. */ 149 | rsb ip, ip, #4 /* ip = #4 - ip. */ 150 | cmp ip, #2 151 | 152 | /* Copy byte by byte with conditionals. */ 153 | itt gt 154 | ldrbgt r3, [r1], #1 155 | strbgt r3, [r0], #1 156 | itt ge 157 | ldrbge r4, [r1], #1 158 | strbge r4, [r0], #1 159 | ldrb lr, [r1], #1 160 | strb lr, [r0], #1 161 | 162 | /* Update the count. 163 | ip holds the number of bytes we have just copied. */ 164 | subs r2, r2, ip /* r2 = r2 - ip. */ 165 | blt copy_less_than_4 /* If r2 < ip. */ 166 | 167 | /* Get here if there are more than 4 bytes to copy. 168 | Check if src is aligned. If beforehand src and dst were not word 169 | aligned but congruent (same offset), then now they are both 170 | word-aligned, and we can copy the rest efficiently (without 171 | shifting). */ 172 | ands ip, r1, #3 /* ip = last 2 bits of src. */ 173 | beq word_aligned /* If r1 is word-aligned. */ 174 | src_not_word_aligned: 175 | /* Get here when src is not word-aligned, but dst is word-aligned. 176 | The number of bytes that remains to copy is r2+4. */ 177 | 178 | /* Copy word by word using LDR when alignment can be done in hardware, 179 | i.e., SCTLR.A is set, supporting unaligned access in LDR and STR. */ 180 | subs r2, r2, #60 181 | blt 8f 182 | 7: 183 | /* Copy 64 bytes in every loop iteration. */ 184 | .irp offset, #0, #4, #8, #12, #16, #20, #24, #28, #32, #36, #40, #44, #48, #52, #56, #60 185 | ldr r3, [r1, \offset] 186 | str r3, [r0, \offset] 187 | .endr 188 | add r0, r0, #64 189 | add r1, r1, #64 190 | subs r2, r2, #64 191 | bge 7b 192 | 8: 193 | /* Get here if less than 64 bytes to copy, -64 <= r2 < 0. 194 | Check if there is more than 3 bytes to copy. */ 195 | adds r2, r2, #60 196 | blt copy_less_than_4 197 | 9: 198 | /* Get here if there is less than 64 but at least 4 bytes to copy, 199 | where the number of bytes to copy is r2+4. */ 200 | ldr r3, [r1], #4 201 | str r3, [r0], #4 202 | subs r2, r2, #4 203 | bge 9b 204 | b copy_less_than_4 205 | 206 | 207 | -------------------------------------------------------------------------------- /edao-patch/src/tools.c: -------------------------------------------------------------------------------- 1 | #include <stdio.h> 2 | #include <string.h> 3 | #include <psp2/kernel/processmgr.h> 4 | #include <psp2/appmgr.h> 5 | #include <psp2/kernel/sysmem.h> 6 | 7 | #include "tools.h" 8 | #include "log.h" 9 | 10 | #define SCE_APPMGR_APP_PARAM_TITLE_ID 12 11 | 12 | int get_title_id(char title_id[VITA_TITLE_ID_LEN]) 13 | { 14 | if (!title_id) 15 | { 16 | return -1; 17 | } 18 | 19 | SceUID pid = sceKernelGetProcessId(); 20 | if (pid < 0) 21 | { 22 | return -1; 23 | } 24 | 25 | int ret = sceAppMgrAppParamGetString(pid, SCE_APPMGR_APP_PARAM_TITLE_ID, title_id, VITA_TITLE_ID_LEN); 26 | if (ret < 0) 27 | { 28 | return -1; 29 | } 30 | 31 | 32 | 33 | return 0; 34 | } 35 | 36 | void hex_to_string(unsigned char* data, int data_len, char* string, int str_len) 37 | { 38 | if (!data || !string || !data_len || !str_len) 39 | { 40 | return; 41 | } 42 | 43 | if (data_len * 3 > str_len - 1) 44 | { 45 | return; 46 | } 47 | 48 | int i = 0; 49 | for (; i != data_len; ++i) 50 | { 51 | snprintf(&string[i * 3], str_len - i * 3, "%02X ", data[i]); 52 | } 53 | string[(i + 1)* 3] = 0; 54 | } 55 | 56 | 57 | #define DUMP_LINE_BUFF_SIZE (16 * 3 + 1) 58 | void dump_mem(char* tag, unsigned char* data, int len) 59 | { 60 | if (!data || !len) 61 | { 62 | return; 63 | } 64 | 65 | if (tag) 66 | { 67 | DEBUG_PRINT("%s\n", tag); 68 | } 69 | 70 | char buffer[DUMP_LINE_BUFF_SIZE] = {0}; 71 | int i = 0; 72 | for (; i < len / 16; ++i) 73 | { 74 | hex_to_string(data + i * 16, 16, buffer, DUMP_LINE_BUFF_SIZE); 75 | DEBUG_PRINT("%s\n", buffer); 76 | } 77 | 78 | int pad = len % 16; 79 | if (pad) 80 | { 81 | hex_to_string(data + i * 16, pad, buffer, DUMP_LINE_BUFF_SIZE); 82 | DEBUG_PRINT("%s\n", buffer); 83 | } 84 | } 85 | 86 | 87 | void* vita_malloc(unsigned int size) 88 | { 89 | if (!size) 90 | { 91 | return NULL; 92 | } 93 | 94 | unsigned int inner_size = size + sizeof(SceUID) + sizeof(unsigned int); 95 | SceUID block = sceKernelAllocMemBlock("asuka", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW, ALIGN(inner_size, PAGE_SIZE), NULL); 96 | if (block <= 0) 97 | { 98 | return NULL; 99 | } 100 | 101 | void* base = NULL; 102 | sceKernelGetMemBlockBase(block, &base); 103 | if (!base) 104 | { 105 | sceKernelFreeMemBlock(block); 106 | return NULL; 107 | } 108 | 109 | *(unsigned int*)base = block; 110 | *(unsigned int*)((unsigned char*)base + sizeof(SceUID)) = size; 111 | 112 | void* user_base = (void*)((unsigned char*)base + sizeof(SceUID) + sizeof(unsigned int)); 113 | 114 | return user_base; 115 | } 116 | 117 | void* vita_calloc(unsigned int num, unsigned int size) 118 | { 119 | uint32_t buffer_size = num * size; 120 | if (!buffer_size) 121 | { 122 | return NULL; 123 | } 124 | 125 | void* buffer = vita_malloc(buffer_size); 126 | if (!buffer) 127 | { 128 | return NULL; 129 | } 130 | 131 | memset(buffer, 0, buffer_size); 132 | return buffer; 133 | } 134 | 135 | void* vita_realloc(void* ptr, unsigned int size) 136 | { 137 | if (!ptr) 138 | { 139 | return vita_malloc(size); 140 | } 141 | 142 | if (!size) 143 | { 144 | vita_free(ptr); 145 | return NULL; 146 | } 147 | 148 | unsigned int old_size = *(unsigned int*)((unsigned char*)ptr - sizeof(unsigned int)); 149 | if (old_size == size) 150 | { 151 | return ptr; 152 | } 153 | 154 | unsigned int copy_size = old_size < size ? old_size : size; 155 | void* buffer = vita_malloc(size); 156 | if (!buffer) 157 | { 158 | return NULL; 159 | } 160 | 161 | memcpy(buffer, ptr, copy_size); 162 | vita_free(ptr); 163 | return buffer; 164 | } 165 | 166 | void vita_free(void* mem) 167 | { 168 | if (!mem) 169 | { 170 | return; 171 | } 172 | 173 | unsigned char* inner_mem = (unsigned char*)mem - sizeof(SceUID) - sizeof(unsigned int); 174 | SceUID block = 0; 175 | block = *(unsigned int*)inner_mem; 176 | if (block <= 0) 177 | { 178 | return; 179 | } 180 | sceKernelFreeMemBlock(block); 181 | } 182 | 183 | 184 | //string tools 185 | 186 | 187 | 188 | int is_acsii_char(unsigned char c) 189 | { 190 | if (c >= 0x20 && c <= 0x7E) 191 | { 192 | return 1; 193 | } 194 | if (c == '\t' || c == '\n' || c == '\r') 195 | { 196 | return 1; 197 | } 198 | return 0; 199 | } 200 | 201 | int is_sjis_char(unsigned char c) 202 | { 203 | //half-width sjis char 204 | if (c >= 0xA1 && c <= 0xDF) 205 | { 206 | return 1; 207 | } 208 | 209 | //sjis first char 210 | if ((c >= 0x81 && c <= 0x9F) || 211 | (c >= 0xE0 && c <= 0xEF)) 212 | { 213 | return 1; 214 | } 215 | 216 | //sjis second char 217 | if ((c >= 0x40 && c <= 0x7E) || 218 | (c >= 0x80 && c <= 0xFC)) 219 | { 220 | return 1; 221 | } 222 | return 0; 223 | } 224 | 225 | int is_opcode(unsigned char c) 226 | { 227 | return (!is_acsii_char(c) && !is_sjis_char(c)); 228 | } 229 | 230 | 231 | #define EDAO_STR_BUFF_LEN 1024 232 | 233 | char* rip_string(char* old_str) 234 | { 235 | static char string_buff[EDAO_STR_BUFF_LEN] = {0}; 236 | 237 | if (!old_str) 238 | { 239 | return NULL; 240 | } 241 | 242 | int len = strlen(old_str); 243 | int j = 0; 244 | for(int i = 0; i != len; ++i) 245 | { 246 | if (!is_opcode(old_str[i])) 247 | { 248 | string_buff[j++] = old_str[i]; 249 | } 250 | } 251 | string_buff[j] = 0; 252 | return string_buff; 253 | } 254 | 255 | 256 | 257 | 258 | -------------------------------------------------------------------------------- /edao-patch/src/tools.h: -------------------------------------------------------------------------------- 1 | #ifndef VITA_TOOLS_H 2 | #define VITA_TOOLS_H 3 | 4 | #include <stdint.h> 5 | 6 | #define VITA_TITLE_ID_LEN 12 7 | 8 | #ifndef PAGE_SIZE 9 | #define PAGE_SIZE 0x1000 10 | #endif 11 | 12 | #define ALIGN(x, align) (((x) + ((align) - 1)) & ~((align) - 1)) 13 | 14 | #define ADDR_THUMB(addr) ((unsigned int)(addr) | 1) 15 | #define ADDR_ARM(addr) ((unsigned int)(addr) & ~1) 16 | 17 | #define DECL_INLINE_ASM_ARM __attribute__((naked, target("arm"))) 18 | #define DECL_INLINE_ASM_THUMB __attribute__((naked, target("thumb"))) 19 | 20 | #define DECL_FUNCTION_ARM __attribute__((target("arm"))) 21 | #define DECL_FUNCTION_THUMB __attribute__((target("thumb"))) 22 | #define DECL_FUNCTION_NOINLINE __attribute__ ((noinline)) 23 | 24 | 25 | int get_title_id(char title_id[VITA_TITLE_ID_LEN]); 26 | 27 | void hex_to_string(unsigned char* data, int data_len, char* string, int str_len); 28 | 29 | void dump_mem(char* tag, unsigned char* data, int len); 30 | 31 | void* vita_malloc(unsigned int size); 32 | 33 | void* vita_calloc(unsigned int num, unsigned int size); 34 | 35 | void* vita_realloc(void* ptr, unsigned int size); 36 | 37 | void vita_free(void* mem); 38 | 39 | //Do not use default memcpy, use this version instead. 40 | //seems memcpy will use NEON register without protect 41 | //cause some float values in game corrupt 42 | void *memcpy_asm(void* dst, void* src, uint32_t size); 43 | #ifdef memcpy 44 | #undef memcpy 45 | #endif 46 | #define memcpy memcpy_asm 47 | 48 | //string tools 49 | 50 | int is_acsii_char(unsigned char c); 51 | 52 | int is_sjis_char(unsigned char c); 53 | 54 | char* rip_string(char* old_str); 55 | 56 | 57 | #endif -------------------------------------------------------------------------------- /edao-patch/src/translator.c: -------------------------------------------------------------------------------- 1 | #include "translator.h" 2 | #include "log.h" 3 | #include "tools.h" 4 | #include <psp2/io/fcntl.h> 5 | #include <psp2/io/stat.h> 6 | 7 | 8 | 9 | int tl_init(TL_CONTEXT* ctx, const char* fn_map) 10 | { 11 | int ret = -1; 12 | SceUID file_id = 0; 13 | acr_header header = {0}; 14 | do 15 | { 16 | if (!ctx || !fn_map) 17 | { 18 | break; 19 | } 20 | 21 | file_id = sceIoOpen(fn_map, SCE_O_RDONLY, 0777); 22 | if (file_id < 0) 23 | { 24 | break; 25 | } 26 | 27 | int read = sceIoRead(file_id, &header, sizeof(header)); 28 | if (read != sizeof(header)) 29 | { 30 | break; 31 | } 32 | 33 | if (header.compress_flag) 34 | { 35 | break; 36 | } 37 | 38 | ctx->str_count = header.index_count; 39 | 40 | uint32_t buffer_size = header.orgsize; 41 | uint8_t* map_buffer = vita_malloc(buffer_size); 42 | if (!map_buffer) 43 | { 44 | break; 45 | } 46 | 47 | ctx->map_buffer = map_buffer; 48 | 49 | read = sceIoRead(file_id, map_buffer, buffer_size); 50 | if (read != buffer_size) 51 | { 52 | break; 53 | } 54 | 55 | ret = tl_init_hash_map(ctx, map_buffer, buffer_size); 56 | if (ret < 0) 57 | { 58 | break; 59 | } 60 | 61 | ret = 0; 62 | } while(0); 63 | 64 | if (file_id > 0) 65 | { 66 | sceIoClose(file_id); 67 | } 68 | return ret; 69 | } 70 | 71 | void tl_unit(TL_CONTEXT* ctx) 72 | { 73 | if (!ctx) 74 | { 75 | return; 76 | } 77 | if (ctx->map_buffer) 78 | { 79 | vita_free(ctx->map_buffer); 80 | } 81 | if (ctx->map) 82 | { 83 | kh_destroy(INT_ACR_NAME, ctx->map); 84 | } 85 | memset(ctx, 0, sizeof(TL_CONTEXT)); 86 | } 87 | 88 | /* 89 | def BKDRHash(bytes): 90 | hash = 0 91 | seed = 131 92 | for c in bytes: 93 | if c != 0: 94 | hash = hash * seed + c 95 | return (hash & 0x7FFFFFFF) 96 | */ 97 | 98 | inline uint32_t bkdr_hash(const uint8_t* string, uint32_t len) 99 | { 100 | const uint32_t seed = 131; 101 | register uint32_t hash = 0; 102 | 103 | for (uint32_t i = 0; i != len; ++i) 104 | { 105 | if (string[i] != 0) 106 | { 107 | hash = hash * seed + string[i]; 108 | } 109 | } 110 | return (hash & 0x7FFFFFFF); 111 | } 112 | 113 | int tl_init_hash_map(TL_CONTEXT* ctx, uint8_t* map_buffer, uint32_t map_size) 114 | { 115 | int ret = -1; 116 | do 117 | { 118 | if (!ctx || !map_buffer || !map_size) 119 | { 120 | break; 121 | } 122 | 123 | INT_ACR_MAP* map = kh_init(INT_ACR_NAME); 124 | if (!map) 125 | { 126 | break; 127 | } 128 | 129 | uint32_t str_count = ctx->str_count; 130 | acr_index* str_index = (acr_index*)map_buffer; 131 | khiter_t iter = 0; 132 | khint_t kret = -1; 133 | 134 | for (uint32_t i = 0; i != str_count; ++i) 135 | { 136 | iter = kh_put(INT_ACR_NAME, map, str_index[i].hash, &kret); 137 | if (kret == -1) 138 | { 139 | continue; 140 | } 141 | kh_val(map, iter) = &str_index[i]; 142 | } 143 | 144 | ctx->map = map; 145 | 146 | ret = 0; 147 | } while (0); 148 | 149 | return ret; 150 | } 151 | 152 | 153 | int tl_translate(TL_CONTEXT* ctx, const char* jp_str, uint32_t jp_len, 154 | char* cn_str, uint32_t* cn_len) 155 | { 156 | int translated = 0; 157 | 158 | do 159 | { 160 | if (!ctx) 161 | { 162 | break; 163 | } 164 | 165 | INT_ACR_MAP* map = ctx->map; 166 | 167 | uint32_t hash = bkdr_hash((uint8_t*)jp_str, jp_len); 168 | 169 | //dump_mem("jpstr", jp_str, jp_len); 170 | //DEBUG_PRINT("jp hash: 0x%08X\n", hash); 171 | 172 | khiter_t iter = kh_get(INT_ACR_NAME, map, hash); 173 | if (iter == kh_end(map)) 174 | { 175 | break; 176 | } 177 | 178 | //DEBUG_PRINT("find key sucess\n"); 179 | 180 | acr_index* index = kh_val(map, iter); 181 | if (!index) 182 | { 183 | break; 184 | } 185 | 186 | char* new_str = (char*)(ctx->map_buffer - sizeof(acr_header) + index->new_str_off); 187 | uint32_t new_len = index->new_str_len; 188 | if (!new_str || !new_len) 189 | { 190 | break; 191 | } 192 | 193 | 194 | uint32_t copy_len = new_len < *cn_len ? new_len : *cn_len; 195 | *cn_len = copy_len; 196 | 197 | //seems memcpy will use NEON register without protect 198 | //cause some float values in game corrupt 199 | //memcpy(cn_str, new_str, copy_len); 200 | 201 | memcpy_asm(cn_str, new_str, copy_len); 202 | 203 | // for (int i = 0; i != copy_len; ++i) 204 | // { 205 | // cn_str[i] = new_str[i]; 206 | // } 207 | 208 | 209 | translated = 1; 210 | } while (0); 211 | return translated; 212 | } -------------------------------------------------------------------------------- /edao-patch/src/translator.h: -------------------------------------------------------------------------------- 1 | #ifndef VITA_TRANSLATOR_H 2 | #define VITA_TRANSLATOR_H 3 | 4 | #include <psp2/types.h> 5 | #include <stdint.h> 6 | #include "khash.h" 7 | 8 | // 9 | 10 | #pragma pack (1) 11 | 12 | typedef struct _acr_header 13 | { 14 | uint32_t index_count; //包含索引数,即字符串数 15 | uint32_t compress_flag; //是否压缩。 0没有压缩 16 | uint32_t compsize; //如果有压缩,为压缩后大小,否则等于orgsize 17 | uint32_t orgsize; //如果有压缩,为压缩前【压缩部分】大小,否则为实际大小 18 | } acr_header; 19 | 20 | typedef struct _acr_index 21 | { 22 | uint32_t hash; //oldstr的hash值,用于map查找 23 | uint32_t new_str_off; //newstr 地址 24 | uint32_t new_str_len; //newstr 长度 25 | } acr_index; 26 | 27 | #pragma pack () 28 | 29 | 30 | // 31 | 32 | KHASH_MAP_INIT_INT(INT_ACR_NAME, acr_index*) 33 | #define INT_ACR_MAP khash_t(INT_ACR_NAME) 34 | 35 | typedef struct TL_CONTEXT_S 36 | { 37 | INT_ACR_MAP* map; 38 | uint8_t* map_buffer; 39 | uint32_t str_count; 40 | } TL_CONTEXT; 41 | 42 | 43 | // 44 | 45 | int tl_init(TL_CONTEXT* ctx, const char* fn_map); 46 | 47 | void tl_unit(TL_CONTEXT* ctx); 48 | 49 | int tl_translate(TL_CONTEXT* ctx, const char* jp_str, uint32_t jp_len, 50 | char* cn_str, uint32_t* cn_len); 51 | 52 | // 53 | int tl_init_hash_map(TL_CONTEXT* ctx, uint8_t* map_buffer, uint32_t map_size); 54 | 55 | 56 | uint32_t bkdr_hash(const uint8_t* string, uint32_t len); 57 | 58 | #endif //VITA_TRANSLATOR_H -------------------------------------------------------------------------------- /font2png/src/Makefile: -------------------------------------------------------------------------------- 1 | SRCDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) 2 | TARGET = $(SRCDIR)font2png 3 | 4 | OBJS = $(patsubst %.c, %.o, $(wildcard $(SRCDIR)*.c)) 5 | HEADERS = $(wildcard *.h) 6 | 7 | CINCLUDES = -I$(SRCDIR)../../common/include 8 | LIBS = -L$(SRCDIR)../../common/lib -lpng -lz -lm 9 | 10 | CC = gcc 11 | CFLAGS = -Wl,-q -Wall -g $(CINCLUDES)#-O3 12 | ASFLAGS = $(CFLAGS) 13 | 14 | all: $(TARGET) 15 | 16 | $(TARGET): $(OBJS) 17 | $(CC) $(CFLAGS) $^ $(LIBS) -o $@ 18 | 19 | clean: 20 | @rm -rf $(TARGET) $(OBJS) -------------------------------------------------------------------------------- /font2png/src/font2png.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This program extract font glyph data in vitafont2bit.fnt file 3 | * into a png file. 4 | * 5 | * Support: 6 | * Eiyuu Densetsu: Ao no Kiseki - Evolution 7 | * Eiyuu Densetsu: Zero no Kiseki - Evolution (change the "#if 0" and do some modification, I'm lazy:) ) 8 | * 9 | * Author: Asuka(Inori) 10 | * Date: 2017/10/22 11 | */ 12 | 13 | 14 | 15 | #include <asuka.h> 16 | #include "pnglibconf.h" 17 | #include "png.h" 18 | 19 | #if 0 20 | 21 | //For vitafont.dat in ED ZERO 22 | #define OFF_NUMBER 0x00C0 23 | #define GET_VALUE(PTR, OFF, VAR) (*((decltype(VAR)*)(((unsigned char*)PTR) + OFF))); 24 | #define SIZE_ONE_CHA 0x20 25 | #define NUM_ONE_ROW 32 26 | #define BITS_ONE_BYTE 8 27 | 28 | bool font2png(const std::string& fontFileName, const std::string& pngName) 29 | { 30 | std::string font_name = "C:\\Users\\Asuka\\Desktop\\FalcomToolchain\\font\\vitafont.dat"; 31 | 32 | FILE* fpFont = fopen(font_name.c_str(), "rb"); 33 | if (fpFont == NULL) 34 | return false; 35 | 36 | fseek(fpFont, 0, SEEK_END); 37 | u32 fontFileLength = ftell(fpFont); 38 | fseek(fpFont, 0, SEEK_SET); 39 | 40 | u8* buffFont = new u8[fontFileLength]; 41 | fread(buffFont, sizeof(*buffFont), fontFileLength, fpFont); 42 | fclose(fpFont); 43 | 44 | u32 index = OFF_NUMBER; 45 | u32 num = GET_VALUE(buffFont, index, num); index += sizeof(num); 46 | 47 | u32 width = SIZE_ONE_CHA * NUM_ONE_ROW; 48 | u32 numOfRows = (num + NUM_ONE_ROW - 1) / NUM_ONE_ROW; 49 | u32 height = SIZE_ONE_CHA * numOfRows; 50 | 51 | u8* buffData = new u8[width * height]; 52 | memset(buffData, 0, width * height); 53 | 54 | for (u32 i = 0; i < numOfRows; ++i) 55 | { 56 | unsigned y0 = i * SIZE_ONE_CHA; 57 | for (u32 j = 0; j < NUM_ONE_ROW; ++j) 58 | { 59 | if (index > OFF_NUMBER + num * 4) 60 | break; 61 | 62 | u32 tmp = GET_VALUE(buffFont, index, tmp); index += sizeof(tmp); 63 | u32 off = (tmp & 0x00FFFFFF) * 4 + 64 | OFF_NUMBER + 4 + 65 | num * 4 + 4; 66 | 67 | u32 size = tmp >> 24; 68 | 69 | u32 x0 = j * SIZE_ONE_CHA; 70 | 71 | for (u32 x = x0; x < x0 + size; x += 1) 72 | { 73 | for (u32 y = y0; y < y0 + SIZE_ONE_CHA; y += BITS_ONE_BYTE) 74 | { 75 | buffData[(y)* width + x] = (buffFont[off]) & 0x01; 76 | buffData[(y + 1) * width + x] = (buffFont[off] >> 1) & 0x01; 77 | buffData[(y + 2) * width + x] = (buffFont[off] >> 2) & 0x01; 78 | buffData[(y + 3) * width + x] = (buffFont[off] >> 3) & 0x01; 79 | buffData[(y + 4) * width + x] = (buffFont[off] >> 4) & 0x01; 80 | buffData[(y + 5) * width + x] = (buffFont[off] >> 5) & 0x01; 81 | buffData[(y + 6) * width + x] = (buffFont[off] >> 6) & 0x01; 82 | buffData[(y + 7) * width + x] = (buffFont[off] >> 7) & 0x01; 83 | 84 | ++off; 85 | } 86 | } 87 | 88 | size = off; 89 | 90 | } 91 | } 92 | delete[] buffFont; 93 | 94 | bool rst = WritePNG(pngName.c_str(), width, height, buffData); 95 | 96 | delete[] buffData; 97 | 98 | return rst; 99 | } 100 | 101 | #endif 102 | 103 | #define INDEX_OFFSET 0x0100 104 | #define FONT_SIZE 0x20 //font png_width = font png_height = font size 105 | #define FONT_HALF_SIZE (FONT_SIZE/2) 106 | #define NUM_ONE_ROW 32 107 | #define COLORS_IN_PALETTE 256 108 | 109 | int write_png_file( const char* png_name, uint32_t png_width, uint32_t png_height, const uint8_t* buffer) 110 | { 111 | FILE *fp; 112 | png_structp png_ptr; 113 | png_infop info_ptr; 114 | png_colorp palette; 115 | png_bytep trns_alpha; 116 | uint32_t i; 117 | 118 | 119 | fp = fopen(png_name, "wb"); 120 | if (fp == NULL) 121 | return -1; 122 | 123 | 124 | png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 125 | NULL, NULL, NULL); 126 | if (png_ptr == NULL) 127 | { 128 | fclose(fp); 129 | return -1; 130 | } 131 | 132 | info_ptr = png_create_info_struct(png_ptr); 133 | if (info_ptr == NULL) 134 | { 135 | fclose(fp); 136 | png_destroy_write_struct(&png_ptr, NULL); 137 | return -1; 138 | } 139 | 140 | if (setjmp(png_jmpbuf(png_ptr))) 141 | { 142 | fclose(fp); 143 | png_destroy_write_struct(&png_ptr, &info_ptr); 144 | return -1; 145 | } 146 | 147 | png_init_io(png_ptr, fp); 148 | png_set_IHDR(png_ptr, info_ptr, png_width, png_height, 8, PNG_COLOR_TYPE_PALETTE, 149 | PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); 150 | 151 | palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH 152 | * sizeof(png_color)); 153 | trns_alpha = (png_bytep)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH 154 | * sizeof(png_byte)); 155 | for(i = 0; i < COLORS_IN_PALETTE; ++i) 156 | { 157 | palette[i].red = 0xFF; 158 | palette[i].green = 0; 159 | palette[i].blue = 0; 160 | trns_alpha[i] = (png_byte)(i * 0x55); 161 | } 162 | 163 | png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); 164 | png_set_tRNS(png_ptr, info_ptr, trns_alpha, PNG_MAX_PALETTE_LENGTH, NULL); 165 | 166 | png_write_info(png_ptr, info_ptr); 167 | 168 | const uint8_t* ptrRow = buffer; 169 | for(png_uint_32 y = 0;y < png_height; ++y) 170 | { 171 | png_write_row(png_ptr, ptrRow); 172 | ptrRow += png_width; 173 | } 174 | 175 | 176 | png_free(png_ptr, trns_alpha); 177 | png_free(png_ptr, palette); 178 | 179 | png_destroy_write_struct(&png_ptr, &info_ptr); 180 | fclose(fp); 181 | 182 | return 0; 183 | } 184 | 185 | 186 | int font2png(const char* font_filename, const char* png_filename) 187 | { 188 | if (!font_filename || !png_filename) 189 | { 190 | return -1; 191 | } 192 | 193 | uint32_t font_filesize = 0; 194 | uint8_t* font_buff = load_file(font_filename, &font_filesize); 195 | if (!font_buff) 196 | { 197 | return -1; 198 | } 199 | 200 | // 201 | 202 | uint32_t index = INDEX_OFFSET; 203 | uint32_t char_num = GET_VALUE(font_buff, index, uint32_t); 204 | index += sizeof(char_num); 205 | 206 | uint32_t png_width = FONT_SIZE * NUM_ONE_ROW; 207 | uint32_t png_height = FONT_SIZE * (ALIGN(char_num, NUM_ONE_ROW) / NUM_ONE_ROW); 208 | 209 | uint8_t* png_buff = (uint8_t*)malloc(png_width * png_height); 210 | memset(png_buff, 0, png_width * png_height); 211 | 212 | for (uint32_t i = 0; i != char_num; ++i) 213 | { 214 | uint32_t x0 = (i % NUM_ONE_ROW) * FONT_SIZE; 215 | uint32_t y0 = (i / NUM_ONE_ROW) * FONT_SIZE; 216 | 217 | uint32_t val = GET_VALUE(font_buff, index, uint32_t); 218 | index += sizeof(val); 219 | 220 | //font graph data start 221 | uint32_t font_start = INDEX_OFFSET + sizeof(uint32_t) + 222 | char_num * sizeof(uint32_t) + 223 | 4; 224 | uint32_t offset = font_start + (val & 0x00FFFFFF); 225 | uint32_t char_width = val >> 24; 226 | 227 | for (uint32_t x = x0; x < x0 + char_width; x += 1) 228 | { 229 | for (uint32_t y = y0; y < y0 + FONT_SIZE; y += FONT_HALF_SIZE) 230 | { 231 | uint32_t reverse_y = y + FONT_HALF_SIZE; 232 | for (uint32_t k = 0; k != FONT_HALF_SIZE; ++k) 233 | { 234 | if (k == FONT_HALF_SIZE / 2) 235 | { 236 | offset += 2; 237 | } 238 | uint16_t cur_short = *(uint16_t*)&font_buff[offset]; 239 | uint32_t shift = 2 * (k % (FONT_HALF_SIZE / 2)); 240 | png_buff[(reverse_y - k - 1) * png_width + x] = (cur_short >> shift) & 0x03; 241 | } 242 | offset += 2; 243 | } 244 | } 245 | } 246 | 247 | free_file(font_buff); 248 | 249 | int ret = write_png_file(png_filename, png_width, png_height, png_buff); 250 | 251 | free(png_buff); 252 | 253 | return ret; 254 | } 255 | 256 | int main(int argc, char** argv) 257 | { 258 | if (argc != 2) 259 | { 260 | printf("usage: %s <vitafont2bit.fnt>\n", argv[0]); 261 | return -1; 262 | } 263 | 264 | char* font_filename = argv[1]; 265 | char png_filename[256] = {0}; 266 | strcpy(png_filename, font_filename); 267 | strcat(png_filename, ".png"); 268 | 269 | int ret = font2png(font_filename, png_filename); 270 | 271 | return ret; 272 | } -------------------------------------------------------------------------------- /makefont/src/Makefile: -------------------------------------------------------------------------------- 1 | SRCDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) 2 | TARGET = $(SRCDIR)makefont 3 | 4 | OBJS = $(patsubst %.c, %.o, $(wildcard $(SRCDIR)*.c)) 5 | HEADERS = $(wildcard *.h) 6 | 7 | #LIBS = -L$(SRCDIR)../../common/lib -lfreetype -lpng -lz -lm 8 | LIBS = -L/opt/local/lib -lfreetype -lpng -lz -liconv 9 | 10 | CC = gcc 11 | #CFLAGS = -Wl,-q -Wall -std=gnu11 -g -I$(SRCDIR)../../common/include #-O3 12 | CFLAGS = -Wl, -Wall -std=gnu11 -g -I$(SRCDIR)../../common/include -I/opt/local/include #-O3 13 | ASFLAGS = $(CFLAGS) 14 | 15 | all: $(TARGET) 16 | 17 | $(TARGET): $(OBJS) 18 | $(CC) $(CFLAGS) $^ $(LIBS) -o $@ 19 | 20 | clean: 21 | @rm -rf $(TARGET) $(OBJS) -------------------------------------------------------------------------------- /makefont/src/codeconvert.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by asuka on 10/29/17. 3 | // 4 | #include "codeconvert.h" 5 | #include <iconv.h> 6 | 7 | 8 | static iconv_t g_u16_to_u8_ic = (iconv_t)(-1); 9 | static iconv_t g_u8_to_u16_ic = (iconv_t)(-1); 10 | 11 | 12 | 13 | int cc_init() 14 | { 15 | g_u16_to_u8_ic = iconv_open("UTF-8", "UTF-16LE"); 16 | if (g_u16_to_u8_ic == (iconv_t)-1) 17 | { 18 | return -1; 19 | } 20 | 21 | g_u8_to_u16_ic = iconv_open("UTF-16", "UTF-8"); 22 | if (g_u8_to_u16_ic == (iconv_t)-1) 23 | { 24 | return -1; 25 | } 26 | return 0; 27 | } 28 | 29 | 30 | int cc_utf16_to_utf8(uint16_t* u16_buff, uint32_t u16_size, 31 | uint8_t* u8_buff, uint32_t u8_size) 32 | { 33 | uint8_t * in_buff = u16_buff; 34 | size_t in_size = u16_size; 35 | uint8_t * out_buff = u8_buff; 36 | size_t out_size = u8_size; 37 | 38 | size_t ret = iconv(g_u16_to_u8_ic, &in_buff, &in_size, &out_buff, &out_size); 39 | if (ret == -1) 40 | { 41 | return 0; 42 | } 43 | return (u8_size - out_size); 44 | } 45 | 46 | 47 | int cc_utf8_to_utf16(uint8_t* u8_buff, uint32_t u8_size, 48 | uint16_t* u16_buff, uint32_t u16_size) 49 | { 50 | uint8_t * in_buff = u8_buff; 51 | size_t in_size = u8_size; 52 | uint8_t * out_buff = u16_buff; 53 | size_t out_size = u16_size; 54 | 55 | size_t ret = iconv(g_u8_to_u16_ic, &in_buff, &in_size, &out_buff, &out_size); 56 | if (ret == -1) 57 | { 58 | return 0; 59 | } 60 | return (u16_size - out_size); 61 | } 62 | 63 | 64 | void cc_unit() 65 | { 66 | if (g_u16_to_u8_ic != (iconv_t)-1) 67 | { 68 | iconv_close(g_u16_to_u8_ic); 69 | } 70 | 71 | if (g_u8_to_u16_ic != (iconv_t)-1) 72 | { 73 | iconv_close(g_u8_to_u16_ic); 74 | } 75 | } -------------------------------------------------------------------------------- /makefont/src/codeconvert.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by asuka on 10/29/17. 3 | // 4 | 5 | #ifndef CODECONVERT_H 6 | #define CODECONVERT_H 7 | 8 | #include <stdint.h> 9 | 10 | int cc_init(); 11 | 12 | 13 | int cc_utf16_to_utf8(uint16_t* u16_buff, uint32_t u16_size, 14 | uint8_t* u8_buff, uint32_t u8_size); 15 | 16 | 17 | int cc_utf8_to_utf16(uint8_t* u8_buff, uint32_t u8_size, 18 | uint16_t* u16_buff, uint32_t u16_size); 19 | 20 | 21 | void cc_unit(); 22 | 23 | 24 | #endif //CODECONVERT_H 25 | -------------------------------------------------------------------------------- /makefont/src/easyfont.c: -------------------------------------------------------------------------------- 1 | #include "easyfont.h" 2 | #include FT_OUTLINE_H 3 | 4 | 5 | 6 | 7 | int ef_init(EF_CONTEXT *ef_ctx, const char* fontname, uint32_t size) 8 | { 9 | FT_Error error = -1; 10 | 11 | if (!ef_ctx || !fontname) 12 | { 13 | return error; 14 | } 15 | 16 | memset(ef_ctx, 0, sizeof(EF_CONTEXT)); 17 | 18 | error = FT_Init_FreeType(&ef_ctx->library); 19 | if (error) 20 | { 21 | goto FAILED; 22 | } 23 | 24 | error = FT_New_Face(ef_ctx->library, fontname, 0, &ef_ctx->face); 25 | if (error) 26 | { 27 | goto FAILED; 28 | } 29 | 30 | error = FT_Set_Pixel_Sizes(ef_ctx->face, 0, size); 31 | if (error) 32 | { 33 | goto FAILED; 34 | } 35 | 36 | return error; 37 | FAILED: 38 | if (ef_ctx->library) 39 | { 40 | FT_Done_FreeType(ef_ctx->library); 41 | } 42 | if (ef_ctx->face) 43 | { 44 | FT_Done_Face(ef_ctx->face); 45 | } 46 | 47 | return error; 48 | } 49 | 50 | void ef_unit(EF_CONTEXT *ef_ctx) 51 | { 52 | if (!ef_ctx) 53 | { 54 | return; 55 | } 56 | 57 | if (ef_ctx->face) 58 | { 59 | FT_Done_Face(ef_ctx->face); 60 | } 61 | 62 | if (ef_ctx->library) 63 | { 64 | FT_Done_FreeType(ef_ctx->library); 65 | } 66 | 67 | memset(ef_ctx, 0, sizeof(EF_CONTEXT)); 68 | } 69 | 70 | void blt_bitmap(FT_Bitmap* bitmap, uint8_t* dst_buff, 71 | FT_Int x, FT_Int y, FT_Int w, FT_Int h) 72 | { 73 | 74 | if (!bitmap || !dst_buff) 75 | { 76 | return; 77 | } 78 | 79 | memset(dst_buff, 0, w * h); 80 | 81 | uint8_t* src_buff = bitmap->buffer; 82 | uint32_t k = 0; 83 | for (FT_Int i = 0; i < bitmap->rows; ++i) 84 | { 85 | for (FT_Int j = 0; j < bitmap->width; ++j) 86 | { 87 | FT_Int cur_x = x + j; 88 | FT_Int cur_y = y + i; 89 | if (cur_x < 0 || cur_y < 0 || cur_x >= w || cur_y >= h) 90 | { 91 | continue; 92 | } 93 | dst_buff[cur_y * w + cur_x] |= src_buff[k++]; 94 | } 95 | } 96 | 97 | } 98 | 99 | int ef_get_font_glyph(EF_CONTEXT *ef_ctx, IN OUT EF_FONT_INFO *info) 100 | { 101 | FT_Error error = -1; 102 | 103 | if (!ef_ctx || !info) 104 | { 105 | return error; 106 | } 107 | 108 | FT_UInt glyph_index = FT_Get_Char_Index(ef_ctx->face, info->wc); 109 | error = FT_Load_Glyph(ef_ctx->face, glyph_index, 0); 110 | if (error) 111 | { 112 | goto FAILED; 113 | } 114 | 115 | if(info->bold) 116 | { 117 | error = FT_Outline_Embolden(&ef_ctx->face->glyph->outline, (FT_Pos)(info->bold)); 118 | if (error) 119 | { 120 | goto FAILED; 121 | } 122 | } 123 | 124 | if(info->italic) 125 | { 126 | double lean = 1.0f * info->italic / 100; 127 | FT_Matrix matrix; 128 | matrix.xx = (FT_Fixed)(1 * 0x10000L); 129 | matrix.xy = (FT_Fixed)(lean * 0x10000L); 130 | matrix.yx = (FT_Fixed)(0 * 0x10000L); 131 | matrix.yy = (FT_Fixed)(1 * 0x10000L); 132 | FT_Set_Transform(ef_ctx->face, &matrix, 0 ); 133 | } 134 | 135 | if(ef_ctx->face->glyph->format != FT_GLYPH_FORMAT_BITMAP) 136 | { 137 | error = FT_Render_Glyph(ef_ctx->face->glyph, FT_RENDER_MODE_NORMAL); 138 | if (error) 139 | { 140 | goto FAILED; 141 | } 142 | } 143 | 144 | FT_GlyphSlot slot = ef_ctx->face->glyph; 145 | FT_Bitmap* bitmap = &slot->bitmap; 146 | 147 | FT_Int x = info->x + slot->bitmap_left; 148 | FT_Int y = info->y + info->h - slot->bitmap_top; 149 | 150 | blt_bitmap(bitmap, info->buffer, x, y, info->w, info->h); 151 | 152 | info->real_width = x + bitmap->width; 153 | info->real_height = y + bitmap->rows; 154 | FAILED: 155 | return error; 156 | } 157 | -------------------------------------------------------------------------------- /makefont/src/easyfont.h: -------------------------------------------------------------------------------- 1 | #ifndef EASY_FONT_H 2 | #define EASY_FONT_H 3 | 4 | #include <asuka.h> 5 | #include <ft2build.h> 6 | #include FT_FREETYPE_H 7 | 8 | // 9 | struct EF_CONTEXT_S 10 | { 11 | FT_Library library; 12 | FT_Face face; 13 | }; 14 | typedef struct EF_CONTEXT_S EF_CONTEXT; 15 | 16 | struct EF_FONT_INFO_S 17 | { 18 | wchar_t wc; 19 | int x; //start x 20 | int y; //start y 21 | int w; //buffer width 22 | int h; //buffer height 23 | uint8_t* buffer; 24 | int bold; 25 | int italic; 26 | int real_width; //real glyph width; return 27 | int real_height; //real glyph height; return 28 | }; 29 | typedef struct EF_FONT_INFO_S EF_FONT_INFO; 30 | 31 | // 32 | int ef_init(EF_CONTEXT *ef_ctx, const char* fontname, uint32_t size); 33 | 34 | void ef_unit(EF_CONTEXT *ef_ctx); 35 | 36 | int ef_get_font_glyph(EF_CONTEXT *ef_ctx, IN OUT EF_FONT_INFO *info); 37 | 38 | #endif //EASY_FONT_H -------------------------------------------------------------------------------- /makefont/src/makefont.h: -------------------------------------------------------------------------------- 1 | #ifndef MAKE_FONT_H 2 | #define MAKE_FONT_H 3 | 4 | #define FONT_SIZE 0x20 5 | #define FONT_HALF_SIZE (FONT_SIZE/2) 6 | #define RANGE_NUM 4 7 | #define RANGE_BLOCK_SIZE 0x40 8 | 9 | #define BITS_EACH_PIXEL 2 //vitafont2bi.fnt use 2 bits to represent 1 pixel 10 | //which means 4 gray levels per pixle 11 | //compared to 256 gray levels of FreeType font 12 | 13 | #define FONT_SIZE_FATOR (FONT_SIZE * BITS_EACH_PIXEL / 8) 14 | 15 | #define INVILID_CHAR_INDEX 0xFFFFFFFF 16 | 17 | 18 | #pragma pack(1) 19 | 20 | 21 | typedef struct FONT_HEADER_S 22 | { 23 | uint8_t magic[4]; //VFNT 24 | uint32_t version; // not sure 25 | uint32_t bit_width; 26 | uint32_t glyph_data_size; //header + range * 3 + index + glyph_data_size = filesize 27 | uint32_t shift_data_size; // shift_data_size = glyph_data_size >> 3 28 | uint32_t unknown; 29 | uint32_t pad[10]; 30 | } FONT_HEADER; 31 | 32 | typedef struct FONT_RANGE_S 33 | { 34 | uint32_t begin; 35 | uint32_t end; 36 | uint32_t plus; 37 | } FONT_RANGE; 38 | 39 | typedef struct FONT_INDEX_S 40 | { 41 | uint32_t count; 42 | uint32_t val[1]; 43 | } FONT_INDEX; 44 | 45 | 46 | #pragma pack() 47 | 48 | typedef struct CHAR_INFO_S 49 | { 50 | uint32_t offset; 51 | uint32_t width; 52 | uint8_t buffer[FONT_SIZE * FONT_SIZE / 4]; 53 | } CHAR_INFO; 54 | 55 | typedef struct CODE_PAIR_S 56 | { 57 | uint16_t code; 58 | wchar_t wch; 59 | } CODE_PAIR; 60 | 61 | #endif //MAKE_FONT_H -------------------------------------------------------------------------------- /scripts/CheckCNJPMatch.py: -------------------------------------------------------------------------------- 1 | import Common 2 | 3 | 4 | def CheckOnePair(fn_jp, fn_cn, report): 5 | jp = open(fn_jp, 'r', encoding='utf16') 6 | cn = open(fn_cn, 'r', encoding='utf16') 7 | 8 | lines = jp.readlines() 9 | jp_lines = [line for line in lines if line != '' and line != '\n'] 10 | lines = cn.readlines() 11 | cn_lines = [line for line in lines if line != '' and line != '\n'] 12 | 13 | if len(cn_lines) != len(jp_lines): 14 | log = 'Line num not match:{}\n'.format(Common.BaseName(fn_jp)) 15 | report.write(log) 16 | return 17 | 18 | for jp_line, cn_line in zip(jp_lines, cn_lines): 19 | offset, size, jp_text = Common.ParseWQSGLine(jp_line.rstrip('\n')) 20 | offset, size, cn_text = Common.ParseWQSGLine(cn_line.rstrip('\n')) 21 | 22 | jp_group_count = len(Common.SplitString(jp_text)) 23 | cn_group_count = len(Common.SplitString(cn_text)) 24 | 25 | if jp_group_count != cn_group_count: 26 | log = 'Group num not match: {}:{}\t{}:{}\n'.format(fn_jp, jp_text, fn_cn, cn_text) 27 | report.write(log) 28 | 29 | 30 | jp.close() 31 | cn.close() 32 | 33 | 34 | 35 | def main(): 36 | cn_files = Common.Walk('PC_CN_TXT') 37 | jp_files = Common.Walk('PSP_JP_TXT') 38 | 39 | if len(cn_files) != len(jp_files): 40 | print('File num not match') 41 | return 42 | 43 | report = open('CNJPGroupNotMatch.txt', 'w', encoding='utf16') 44 | for fn_jp, fn_cn in zip(jp_files, cn_files): 45 | print('Compare {} - {}\n', fn_jp, fn_cn) 46 | CheckOnePair(fn_jp, fn_cn, report) 47 | 48 | report.close() 49 | 50 | print('Process done.') 51 | 52 | 53 | 54 | if __name__ == '__main__': 55 | main() -------------------------------------------------------------------------------- /scripts/Common.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | import os 4 | import re 5 | 6 | #遍历文件夹,返回文件列表 7 | def Walk(adr): 8 | mylist=[] 9 | for root,dirs,files in os.walk(adr): 10 | for name in files: 11 | adrlist=os.path.join(root, name) 12 | mylist.append(adrlist) 13 | return mylist 14 | 15 | 16 | def BaseName(fullname): 17 | return os.path.basename(fullname) 18 | 19 | 20 | def IsAlNum(string): 21 | for ch in string: 22 | if ord(ch) >= 0x20 and ord(ch) <= 0x7F: 23 | continue 24 | else: 25 | return False 26 | return True 27 | 28 | 29 | 30 | def SplitString(string): 31 | 32 | if '\\n' in string: 33 | string = string.replace('\\n', '{0A}') 34 | 35 | #以 {01} {0B} 等这种字节转义作为分隔符,将字符串分组 36 | pattern = re.compile('\{[0-9A-Fa-f]{2}\}') 37 | 38 | str_list = [] 39 | remain = string 40 | mc = pattern.search(remain) 41 | while mc: 42 | s = mc.start(0) 43 | e = mc.end(0) 44 | 45 | if s != 0: 46 | cur_item = remain[:s] 47 | str_list.append(cur_item) 48 | 49 | remain = remain[e:] 50 | mc = pattern.search(remain) 51 | 52 | if remain: 53 | str_list.append(remain) 54 | 55 | # 去掉带有#号的opcode 56 | for idx, cur_string in enumerate(str_list): 57 | if not '#' in cur_string: 58 | continue 59 | 60 | rip_string = '' 61 | for ch in string: 62 | if ord(ch) >= 0x20 and ord(ch) <= 0x7F: 63 | continue 64 | rip_string += ch 65 | str_list[idx] = rip_string 66 | 67 | return str_list 68 | 69 | 70 | def ParseWQSGLine(line): 71 | group = line.split(',', 2) 72 | return (group[0], group[1], group[2]) 73 | 74 | def FormatWQSGLine(offset, len, text): 75 | return '{0:},{1:},{2:}'.format(offset, len, text) -------------------------------------------------------------------------------- /scripts/CompareLength.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | import Common 4 | 5 | def CompareLength(psp_jp_files, pc_cn_files, report): 6 | 7 | if len(psp_jp_files) != len(pc_cn_files): 8 | print('File num not match') 9 | input() 10 | return 11 | 12 | for fn_jp, fn_cn in zip(psp_jp_files, pc_cn_files): 13 | 14 | if Common.BaseName(fn_jp) != Common.BaseName(fn_cn): 15 | print('Filename not match: {} {}'.format(fn_jp, fn_cn)) 16 | input() 17 | exit(1) 18 | 19 | fname = Common.BaseName(fn_cn) 20 | print('process jp cn: {}'.format(fname)) 21 | 22 | jp = open(fn_jp, 'r', encoding='utf16') 23 | cn = open(fn_cn, 'r', encoding='utf16') 24 | 25 | lines = jp.readlines() 26 | jp_lines = [line.rstrip('\n') for line in lines if line != '' and line != '\n'] 27 | lines = cn.readlines() 28 | cn_lines = [line.rstrip('\n') for line in lines if line != '' and line != '\n'] 29 | 30 | if len(jp_lines) != len(cn_lines): 31 | input('Line num not match: {}'.format(Common.BaseName(fn_jp))) 32 | exit(1) 33 | 34 | for jp_line, cn_line in zip(jp_lines, cn_lines): 35 | offset, size, jp_text = Common.ParseWQSGLine(jp_line) 36 | offset, size, cn_text = Common.ParseWQSGLine(cn_line) 37 | 38 | if (not jp_text) and (not cn_text): 39 | continue 40 | 41 | if len(jp_text) < len(cn_text): 42 | report.write('{} > {} -- {}\n'.format(fname, jp_text, cn_text)) 43 | 44 | # jp_group = Common.SplitString(jp_text) 45 | # cn_group = Common.SplitString(cn_text) 46 | 47 | 48 | jp.close() 49 | cn.close() 50 | 51 | 52 | 53 | def main(): 54 | jp_flist = Common.Walk('psp_jp_dt') 55 | cn_flist = Common.Walk('pc_cn_dt') 56 | report = open('ReportLargeLength.txt', 'w', encoding='utf16') 57 | CompareLength(jp_flist, cn_flist, report) 58 | 59 | 60 | 61 | if __name__ == '__main__': 62 | main() -------------------------------------------------------------------------------- /scripts/ExtractNotTranslate.py: -------------------------------------------------------------------------------- 1 | import Common 2 | 3 | 4 | def MakeJpCnDict(jp_lines, cn_lines): 5 | 6 | jp_lines = [line.rstrip('\n') for line in jp_lines if line != '' and line != '\n'] 7 | cn_lines = [line.rstrip('\n') for line in cn_lines if line != '' and line != '\n'] 8 | 9 | if len(jp_lines) != len(cn_lines): 10 | print('line num not match') 11 | exit(1) 12 | 13 | jp_cn_dic = {} 14 | for jp_line, cn_line in zip(jp_lines, cn_lines): 15 | 16 | o, l, jp_text = Common.ParseWQSGLine(jp_line) 17 | o, l, cn_text = Common.ParseWQSGLine(cn_line) 18 | 19 | jp_text = jp_text.rstrip('\n') 20 | cn_text = cn_text.rstrip('\n') 21 | 22 | if len(cn_text) > len(jp_text): 23 | print('OverLength: {}--{}'.format(jp_text, cn_text)) 24 | continue 25 | 26 | jp_cn_dic[jp_text] = cn_text 27 | 28 | return jp_cn_dic 29 | 30 | 31 | def main(): 32 | 33 | jp_fname = 'psp_EBOOT_jp.BIN.txt' 34 | cn_fname = 'psp_EBOOT_cn.BIN.txt' 35 | src_fname = 'eboot.beauty.txt' 36 | dst_fname = 'vita_eboot_cn.txt' 37 | report_fname = 'ReportNotTranslate.txt' 38 | 39 | with open(jp_fname, 'r', encoding='utf16') as jp_file, open(cn_fname, 'r', encoding='utf16') as cn_file: 40 | jp_cn_dic = MakeJpCnDict(jp_file.readlines(), cn_file.readlines()) 41 | 42 | with open(src_fname, 'r', encoding='utf16') as src, open(dst_fname, 'w', encoding='utf16') as dst, open(report_fname, 'w', encoding='utf16') as report: 43 | 44 | for line in src.readlines(): 45 | if line == '' or line == '\n': 46 | continue 47 | 48 | if '全属性' in line: 49 | print(line) 50 | 51 | o, l, text = Common.ParseWQSGLine(line) 52 | text = text.rstrip('\n') 53 | 54 | 55 | 56 | if text in jp_cn_dic: 57 | cn_text = jp_cn_dic[text] 58 | dst.write(Common.FormatWQSGLine(o, l, cn_text) + '\n\n') 59 | else: 60 | dst.write(Common.FormatWQSGLine(o, l, text) + '\n\n') 61 | report.write(Common.FormatWQSGLine(o, l, text) + '\n\n') 62 | 63 | 64 | if __name__ == '__main__': 65 | main() -------------------------------------------------------------------------------- /scripts/GenSJISCodeTable.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def GetSJISChar(code): 4 | if code <= 0x7F: 5 | char = chr(code) 6 | else: 7 | if code >= 0xA1 and code <= 0xDF: 8 | bs = bytes([code&0xFF]) 9 | else: 10 | bs = bytes([(code >> 8)&0xFF, code&0xFF]) 11 | 12 | try: 13 | char = bs.decode('shift_jis_2004') 14 | except: 15 | print(bs) 16 | char = '?' 17 | 18 | if len(char) != 1: 19 | return '' 20 | return char 21 | 22 | def FormatLine(code, char): 23 | line = "{0:X}={1:}\n".format(code, char) 24 | return line 25 | 26 | def WriteLine(dst, code): 27 | char = GetSJISChar(code) 28 | if not char: 29 | return 30 | line = FormatLine(code, char) 31 | dst.write(line) 32 | 33 | 34 | def main(): 35 | 36 | dst = open('SJISTable.txt', 'w', encoding='utf16', newline='\r\n') 37 | for code in range(0x20, 0x7F): 38 | WriteLine(dst, code) 39 | 40 | for code in range(0xA1, 0xDF+1): 41 | WriteLine(dst, code) 42 | 43 | for first_byte in range(0x81, 0x9F+1): 44 | for second_byte in range(0x40, 0x7E+1): 45 | code = first_byte << 8 | second_byte 46 | WriteLine(dst, code) 47 | for second_byte in range(0x80, 0xFC+1): 48 | code = first_byte << 8 | second_byte 49 | WriteLine(dst, code) 50 | 51 | for first_byte in range(0xE0, 0xEF+1): 52 | for second_byte in range(0x40, 0x7E+1): 53 | code = first_byte << 8 | second_byte 54 | WriteLine(dst, code) 55 | 56 | for second_byte in range(0x80, 0xFC+1): 57 | code = first_byte << 8 | second_byte 58 | WriteLine(dst, code) 59 | 60 | dst.close() 61 | 62 | 63 | if __name__ == '__main__': 64 | main() -------------------------------------------------------------------------------- /scripts/GenUTF8CodeTable.py: -------------------------------------------------------------------------------- 1 | import struct 2 | 3 | def GetSJISChar(code): 4 | if code <= 0x7F: 5 | char = chr(code) 6 | else: 7 | if code >= 0xA1 and code <= 0xDF: 8 | bs = bytes([code&0xFF]) 9 | else: 10 | bs = bytes([(code >> 8)&0xFF, code&0xFF]) 11 | 12 | try: 13 | char = bs.decode('shift_jis_2004') 14 | except: 15 | print(bs) 16 | char = '?' 17 | 18 | if len(char) != 1: 19 | return '' 20 | return char 21 | 22 | def FormatLine(code, char): 23 | 24 | code_str = '' 25 | for c in code: 26 | code_str += '{:2X}'.format(c) 27 | 28 | line = "{0:}={1:}\n".format(code_str, char) 29 | return line 30 | 31 | def WriteLine(dst, code): 32 | char = GetSJISChar(code) 33 | if not char: 34 | return 35 | 36 | if code <= 0xFF: 37 | bin_code = struct.pack('B', code) 38 | else: 39 | bin_code = struct.pack('>H', code) 40 | 41 | try: 42 | utf8_code = bin_code.decode('shift_jis_2004').encode('utf8') 43 | except: 44 | print(bin_code) 45 | return 46 | 47 | line = FormatLine(utf8_code, char) 48 | dst.write(line) 49 | 50 | 51 | def main(): 52 | 53 | dst = open('UTF8Table.txt', 'w', encoding='utf16', newline='\r\n') 54 | for code in range(0x20, 0x7F): 55 | WriteLine(dst, code) 56 | 57 | for code in range(0xA1, 0xDF+1): 58 | WriteLine(dst, code) 59 | 60 | for first_byte in range(0x81, 0x9F+1): 61 | for second_byte in range(0x40, 0x7E+1): 62 | code = first_byte << 8 | second_byte 63 | WriteLine(dst, code) 64 | for second_byte in range(0x80, 0xFC+1): 65 | code = first_byte << 8 | second_byte 66 | WriteLine(dst, code) 67 | 68 | for first_byte in range(0xE0, 0xEF+1): 69 | for second_byte in range(0x40, 0x7E+1): 70 | code = first_byte << 8 | second_byte 71 | WriteLine(dst, code) 72 | 73 | for second_byte in range(0x80, 0xFC+1): 74 | code = first_byte << 8 | second_byte 75 | WriteLine(dst, code) 76 | 77 | dst.close() 78 | 79 | 80 | if __name__ == '__main__': 81 | main() -------------------------------------------------------------------------------- /scripts/ImportCodeTable.TBL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Inori/Falcom/77ac477e5f2ec5dd66943eb0ab4a7cc5e1b48799/scripts/ImportCodeTable.TBL -------------------------------------------------------------------------------- /scripts/MakeCodeTable.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | dst = open('test.txt', mode='w', encoding='utf16') 4 | dst.write('fuck you\n') 5 | dst.close() -------------------------------------------------------------------------------- /scripts/MakeJPCNMap.py: -------------------------------------------------------------------------------- 1 | # -*-coding:utf-8-*- 2 | import Common 3 | from fuzzywuzzy import fuzz 4 | 5 | # t_ittxt._dt和t_ittxt2._dt里 6 | # 有类似 7 | # 【HP5%回復 「戦闘不能」解除】{09}{09}{09}{09}\n 早くて安くて美味い。最も親しまれている東方料理。--【HP回复5% 「战斗不能」解除】\n 简单便宜又美味,是最为普及的东方料理。 8 | # 这样的文本,要特殊处理一下 9 | def ProcessITTXTCNText(jp_text, cn_text): 10 | new_cn_text = cn_text 11 | if (('【' in jp_text and '】' in jp_text) or ('「' in jp_text and '」' in jp_text)) \ 12 | and '{09}' in jp_text \ 13 | and '\\n' in jp_text: 14 | pos = cn_text.find('\\n') 15 | new_cn_text = cn_text[:pos] + '{09}' + cn_text[pos:] 16 | return new_cn_text 17 | 18 | 19 | def MakeStrDic(psp_jp_files, pc_cn_files, report): 20 | 21 | if len(psp_jp_files) != len(pc_cn_files): 22 | print('File num not match') 23 | input() 24 | return 25 | 26 | dst_dic = dict() 27 | match_dic = dict() 28 | 29 | for fn_jp, fn_cn in zip(psp_jp_files, pc_cn_files): 30 | 31 | if Common.BaseName(fn_jp) != Common.BaseName(fn_cn): 32 | print('Filename not match: {} {}'.format(fn_jp, fn_cn)) 33 | input() 34 | exit(1) 35 | 36 | jp_group_list = [] 37 | fname = Common.BaseName(fn_cn) 38 | print('process jp cn: {}'.format(fname)) 39 | 40 | jp = open(fn_jp, 'r', encoding='utf16') 41 | cn = open(fn_cn, 'r', encoding='utf16') 42 | 43 | lines = jp.readlines() 44 | jp_lines = [line.rstrip('\n') for line in lines if line != '' and line != '\n'] 45 | lines = cn.readlines() 46 | cn_lines = [line.rstrip('\n') for line in lines if line != '' and line != '\n'] 47 | 48 | if len(jp_lines) != len(cn_lines): 49 | input('Line num not match: {}'.format(Common.BaseName(fn_jp))) 50 | exit(1) 51 | 52 | for jp_line, cn_line in zip(jp_lines, cn_lines): 53 | offset, size, jp_text = Common.ParseWQSGLine(jp_line) 54 | offset, size, cn_text = Common.ParseWQSGLine(cn_line) 55 | 56 | if (not jp_text) and (not cn_text): 57 | continue 58 | 59 | # if 't_ittxt' in fname: 60 | # cn_text = ProcessITTXTCNText(jp_text, cn_text) 61 | 62 | jp_group = Common.SplitString(jp_text) 63 | cn_group = Common.SplitString(cn_text) 64 | 65 | if len(jp_group) != len(cn_group): 66 | log = 'Group not match {}:{}--{}'.format(fname, jp_text, cn_text) 67 | print(log) 68 | report.write(log + '\n') 69 | continue 70 | 71 | jp_group_list += jp_group 72 | 73 | for key, value in zip(jp_group, cn_group): 74 | dst_dic[key] = value 75 | 76 | match_dic[fname] = jp_group_list 77 | jp.close() 78 | cn.close() 79 | 80 | return dst_dic, match_dic 81 | 82 | 83 | def IsAlNum(string): 84 | for ch in string: 85 | if ord(ch) >= 0x20 and ord(ch) <= 0x7F: 86 | continue 87 | else: 88 | return False 89 | return True 90 | 91 | 92 | def ReadVitaGroups(vita_fn_list): 93 | 94 | dst_list = [] 95 | for fn in vita_fn_list: 96 | fname = Common.BaseName(fn) 97 | print('process vita txt: {}'.format(fname)) 98 | src = open(fn, 'r', encoding='utf16') 99 | 100 | _lines = src.readlines() 101 | lines = [line.rstrip('\n') for line in _lines if line != '' and line != '\n'] 102 | 103 | for line in lines: 104 | offset, size, text = Common.ParseWQSGLine(line) 105 | 106 | if not text: 107 | continue 108 | 109 | group = Common.SplitString(text) 110 | for string in group: 111 | 112 | if IsAlNum(string): 113 | continue 114 | 115 | if len(string) >= 2 and \ 116 | ((IsAlNum(string[0]) and (not IsAlNum(string[1]))) or 117 | ((not IsAlNum(string[0])) and IsAlNum(string[1]))) and \ 118 | (string[0] != ' ' and string[1] != ' '): 119 | # this was originally prevent junk chars to be added 120 | # since now the vita text is pretty better with almost no junk chars 121 | # I just log it out and comment this line 122 | # continue 123 | print('alpha string:{}'.format(string)) 124 | dst_list.append((fname, string)) 125 | 126 | src.close() 127 | return dst_list 128 | 129 | 130 | def FormatString(index, jp_line, cn_line): 131 | res = "○%08d○%s\n●%08d●%s\n\n"%(index, jp_line, index, cn_line) 132 | return res 133 | 134 | 135 | def FuzzyMatch(src_line, fname, match_dic, report): 136 | 137 | lines = match_dic[fname] 138 | matched_line = '' 139 | for line in lines: 140 | score = fuzz.ratio(src_line, line) 141 | if score < 90: 142 | continue 143 | matched_line = line 144 | log = 'fuzzy match: {} > {} -- {}'.format(fname, src_line, matched_line) 145 | print(log) 146 | report.write(log + '\n') 147 | break 148 | return matched_line 149 | 150 | # 有一些特殊的映射,编程处理不是很方便,直接手动放到 special_map.txt 文件里 151 | def ParseSpecialMap(): 152 | src = open('special_map.txt', 'r', encoding='utf16') 153 | _lines = src.readlines() 154 | src.close() 155 | lines = [line.rstrip('\n') for line in _lines if line] 156 | map_list = [] 157 | for line in lines: 158 | pair = line.split('/=') 159 | key_str = pair[0] 160 | value_str = pair[1] 161 | map_list.append((key_str, value_str)) 162 | return map_list 163 | 164 | # 这里做一些修正 165 | def FixKeyString(key_str): 166 | key_str = key_str.replace('――', '──') 167 | return key_str 168 | 169 | 170 | def OutputMapFile(text_list, jpcn_dic, match_dic, dst_file, report_not_match, report_fuzzy_match): 171 | 172 | idx = 0 173 | for fname, key_str in text_list: 174 | if key_str not in jpcn_dic: 175 | matched_line = FuzzyMatch(key_str, fname, match_dic, report_fuzzy_match) 176 | if not matched_line: 177 | report_not_match.write('{}:{}\n'.format(fname, key_str)) 178 | continue 179 | value_str = jpcn_dic[matched_line] 180 | else: 181 | value_str = jpcn_dic[key_str] 182 | 183 | key_str = FixKeyString(key_str) 184 | dst_file.write(FormatString(idx, key_str, value_str)) 185 | idx += 1 186 | 187 | special_list = ParseSpecialMap() 188 | for key_str, value_str in special_list: 189 | dst_file.write(FormatString(idx, key_str, value_str)) 190 | idx += 1 191 | 192 | def main(): 193 | 194 | report_not_match = open('ReportNotMatch.txt', 'w', encoding='utf16') 195 | report_group_error = open('ReportGroupError.txt', 'w', encoding='utf16') 196 | report_fuzzy_match = open('ReportFuzzyMatch.txt', 'w', encoding='utf16') 197 | 198 | vita_flist = Common.Walk('vita_jp_txt') 199 | jp_flist = Common.Walk('psp_jp_txt') 200 | cn_flist = Common.Walk('pc_cn_txt') 201 | 202 | # vita_flist = Common.Walk('vita_jp_dt') 203 | # jp_flist = Common.Walk('psp_jp_dt') 204 | # cn_flist = Common.Walk('pc_cn_dt') 205 | 206 | text_list = ReadVitaGroups(vita_flist) 207 | jpcn_dic, match_dic = MakeStrDic(jp_flist, cn_flist, report_group_error) 208 | 209 | dst = open('string_map.txt', 'w', encoding='utf16') 210 | # dst = open('sys_map.txt', 'w', encoding='utf16') 211 | 212 | OutputMapFile(text_list, jpcn_dic, match_dic, dst, report_not_match, report_fuzzy_match) 213 | 214 | dst.close() 215 | report_not_match.close() 216 | 217 | print('Process done.') 218 | 219 | 220 | if __name__ == '__main__': 221 | main() -------------------------------------------------------------------------------- /scripts/MoveExtra.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | import os 4 | import shutil 5 | import Common 6 | 7 | 8 | 9 | 10 | #这里把不需要导出文本的二进制文件移动到PSP_EXTRA_BIN 11 | def main(): 12 | pc_bin_list = Common.Walk('PC_CN_BIN') 13 | 14 | psp_bin_list = Common.Walk('PSP_JP_BIN') 15 | 16 | vita_bin_list = Common.Walk('VITA_JP_BIN') 17 | 18 | 19 | for file in psp_bin_list: 20 | found = False 21 | for fn in pc_bin_list: 22 | if os.path.basename(file) in fn: 23 | found = True 24 | 25 | if not found: 26 | print ('PspExtra: ' + file) 27 | shutil.move(file, 'PSP_EXTRA_BIN') 28 | found = False 29 | 30 | for file in vita_bin_list: 31 | found = False 32 | for fn in pc_bin_list: 33 | if os.path.basename(file) in fn: 34 | found = True 35 | 36 | if not found: 37 | print('VitaExtra: ' + file) 38 | shutil.move(file, 'VITA_EXTRA_BIN') 39 | found = False 40 | 41 | 42 | if __name__ == '__main__': 43 | main() 44 | -------------------------------------------------------------------------------- /scripts/MoveOutput.bat: -------------------------------------------------------------------------------- 1 | mkdir CN_OUTPUT 2 | mkdir JP_OUTPUT 3 | mkdir VITA_JP_OUTPUT 4 | 5 | move PC_CN_BIN\*.txt CN_OUTPUT 6 | move PSP_JP_BIN\*.txt JP_OUTPUT 7 | 8 | pause -------------------------------------------------------------------------------- /scripts/PackJPCNMap.py: -------------------------------------------------------------------------------- 1 | import struct, os, sys, re 2 | 3 | ''' 4 | //脚本封包文件头 5 | #pragma pack (1) 6 | 7 | typedef struct _acr_header 8 | { 9 | uint32_t index_count; //包含索引数,即字符串数 10 | uint32_t compress_flag; //是否压缩。 0没有压缩 11 | uint32_t compsize; //如果有压缩,为压缩后大小,否则等于orgsize 12 | uint32_t orgsize; //如果有压缩,为压缩前【压缩部分】大小,否则为实际大小 13 | }acr_header; 14 | 15 | typedef struct _acr_index 16 | { 17 | uint32_t hash; //oldstr的hash值,用于map查找 18 | uint32_t new_str_off; //newstr 地址 19 | uint32_t new_str_len; //newstr 长度 20 | }acr_index; 21 | 22 | #pragma pack () 23 | ''' 24 | 25 | COMPRESS = 0 26 | HEADERLEN = 0x10 27 | INDEXLEN = 0xC 28 | 29 | CODE_TABLE_FILE = 'ImportCodeTable.TBL' 30 | 31 | 32 | 33 | # 将4字节byte转换成整数 34 | def byte2int(byte): 35 | long_tuple = struct.unpack('=I', byte) 36 | long = long_tuple[0] 37 | return long 38 | 39 | 40 | # 将整数转换为4字节二进制byte 41 | def int2byte(num): 42 | return struct.pack('=I', num) 43 | 44 | 45 | 46 | # 将txt转换成文本列表,重写此函数可以适应于不同格式的文本 47 | def makestr(lines): 48 | oldstr_list = [] 49 | newstr_list = [] 50 | old_pat = re.compile('○[0-9A-Fa-f]+○') 51 | new_pat = re.compile('●[0-9A-Fa-f]+●') 52 | for index, line in enumerate(lines): 53 | if old_pat.match(line): 54 | oldstr_list.append(line[10:-1]) 55 | 56 | if new_pat.match(line): 57 | newstr_list.append(line[10:-1]) 58 | 59 | return oldstr_list, newstr_list 60 | 61 | 62 | def ParseCodeTable(fname): 63 | ct_dic = {} 64 | ct = open(fname, 'r', encoding='utf16') 65 | 66 | lines = ct.readlines() 67 | for line in lines: 68 | if line == '' or line == '\n': 69 | continue 70 | 71 | line = line.rstrip('\n') 72 | code, char = line.split('=', 1) 73 | ct_dic[char] = bytearray.fromhex(code) 74 | 75 | ct.close() 76 | return ct_dic 77 | 78 | 79 | def EncodeString(ct, string): 80 | bstring = b'' 81 | for ch in string: 82 | if ch in ct: 83 | bstring += ct[ch] 84 | else: 85 | print('Encode error: {}'.format(ch)) 86 | bstring += ct['?'] 87 | 88 | return bstring 89 | 90 | 91 | def BKDRHash(bytes): 92 | hash = 0 93 | seed = 131 94 | for c in bytes: 95 | if c != 0: 96 | hash = hash * seed + c 97 | return (hash & 0x7FFFFFFF) 98 | 99 | 100 | def WriteString(src, oldstr_list, newstr_list, ct, report): 101 | index = [] 102 | for oldstr, newstr in zip(oldstr_list, newstr_list): 103 | 104 | # bstring = oldstr.encode('sjis', errors='ignore') 105 | try: 106 | bstring = oldstr.encode('cp932') 107 | except Exception as e: 108 | bstring = oldstr.encode('cp932', errors='ignore') 109 | sjis_string = bstring.decode('cp932') 110 | log = '{} -- {}'.format(oldstr, sjis_string) 111 | report.write(log + '\n') 112 | print(e) 113 | print(log) 114 | 115 | hash = BKDRHash(bstring) 116 | 117 | newoff = src.tell() 118 | bstring = EncodeString(ct, newstr) 119 | newlen = len(bstring) 120 | src.write(bstring) 121 | 122 | index.append((hash, newoff, newlen)) 123 | 124 | filesize = src.tell() 125 | return index, filesize 126 | 127 | 128 | def WriteIndex(dst, index): 129 | dst.seek(HEADERLEN) 130 | for [hash, newoff, newlen] in index: 131 | dst.write(int2byte(hash)) 132 | dst.write(int2byte(newoff)) 133 | dst.write(int2byte(newlen)) 134 | 135 | 136 | def Main(): 137 | text_filename = sys.argv[1] 138 | pac_filename = text_filename[:-4] + '.acr' 139 | 140 | txt = open(text_filename, 'r', encoding='utf16') 141 | dst = open(pac_filename, 'wb') 142 | report = open('ReportEncodeError.txt', 'w', encoding='utf16') 143 | 144 | lines = txt.readlines() 145 | 146 | oldstr_list, newstr_list = makestr(lines) 147 | 148 | if len(oldstr_list) != len(newstr_list): 149 | print('number not match') 150 | exit(1) 151 | 152 | 153 | ct = ParseCodeTable(CODE_TABLE_FILE) 154 | 155 | index_count = len(newstr_list) 156 | dst.seek(HEADERLEN + index_count * INDEXLEN) 157 | index_list, filesize = WriteString(dst, oldstr_list, newstr_list, ct, report) 158 | 159 | dst.seek(HEADERLEN) 160 | WriteIndex(dst, index_list) 161 | 162 | dst.seek(0) 163 | dst.write(int2byte(index_count)) 164 | dst.write(int2byte(COMPRESS)) 165 | dst.write(int2byte(filesize - HEADERLEN)) 166 | dst.write(int2byte(filesize - HEADERLEN)) 167 | 168 | txt.close() 169 | dst.close() 170 | 171 | print('pack map file done.') 172 | 173 | 174 | Main() -------------------------------------------------------------------------------- /scripts/ProcessEbootText.py: -------------------------------------------------------------------------------- 1 | import Common 2 | 3 | 4 | def main(): 5 | src = open('eboot.bin.org.TXT', 'r', encoding='utf16') 6 | dst = open('eboot.beauty.txt', 'w', encoding='utf16') 7 | 8 | lines = src.readlines() 9 | 10 | for line in lines: 11 | if not line or line == '\n': 12 | continue 13 | 14 | offset, len, text = Common.ParseWQSGLine(line) 15 | 16 | text = text.rstrip('\n') 17 | if not text: 18 | continue 19 | 20 | if Common.IsAlNum(text): 21 | continue 22 | 23 | dst.write(Common.FormatWQSGLine(offset, len, text) + '\n') 24 | 25 | 26 | src.close() 27 | dst.close() 28 | 29 | 30 | if __name__ == '__main__': 31 | main() -------------------------------------------------------------------------------- /scripts/ReportDiff.py: -------------------------------------------------------------------------------- 1 | import Common 2 | import os 3 | 4 | #比较一下TextOutPut_CnJpn.exe输出的文本(CN_OUTPUT)和最终导入文本(PC_CN_TXT 即完美文本)有哪些不同 5 | def CompareOneFile(fn_out, fn_perfect, dst): 6 | with open(fn_out, encoding='utf16') as out, open(fn_perfect, encoding='utf16') as per: 7 | ln_out = 0 8 | for line in out.readlines(): 9 | if line != '' and line != '\n': 10 | ln_out += 1 11 | 12 | ln_per = 0 13 | for line in per.readlines(): 14 | if line != '' and line != '\n': 15 | ln_per += 1 16 | 17 | if ln_out != ln_per: 18 | print(fn_out) 19 | dst.write('{} -> OUT : {} lines -- PER : {} lines\n'.format(os.path.basename(fn_out), 20 | ln_out, ln_per)) 21 | 22 | 23 | 24 | def main(): 25 | report = open('ReportDiff.txt', 'w') 26 | fl_out = Common.Walk('CN_OUTPUT') 27 | fl_per = Common.Walk('PC_CN_TXT') 28 | 29 | if len(fl_out) != len(fl_per): 30 | print('Error') 31 | input() 32 | 33 | for fn_out, fn_per in zip(fl_out, fl_per): 34 | CompareOneFile(fn_out, fn_per, report) 35 | 36 | report.close() 37 | 38 | 39 | 40 | 41 | if __name__ == '__main__': 42 | main() -------------------------------------------------------------------------------- /scripts/ReportNotMatch.py: -------------------------------------------------------------------------------- 1 | import Common 2 | import os 3 | 4 | 5 | 6 | def MakeStrDic(psp_files): 7 | dst_dic = dict() 8 | for fn in psp_files: 9 | src = open(fn, 'r', encoding='utf16') 10 | 11 | for line in src.readlines(): 12 | if line == '' or line == '\n': 13 | continue 14 | 15 | line = line.rstrip('\n') 16 | offset, size, text = Common.ParseWQSGLine(line) 17 | 18 | if not text: 19 | continue 20 | 21 | str_list = Common.SplitString(text) 22 | for s in str_list: 23 | dst_dic[s] = os.path.basename(fn) 24 | 25 | src.close() 26 | return dst_dic 27 | 28 | 29 | def IsAlNum(string): 30 | for ch in string: 31 | if ord(ch) >= 0x20 and ord(ch) <= 0x7F: 32 | continue 33 | else: 34 | return False 35 | return True 36 | 37 | def main(): 38 | 39 | report = open('NotMatch.txt', 'w', encoding='utf16') 40 | 41 | vita_files = Common.Walk('VITA_JP_OUTPUT') 42 | psp_files = Common.Walk('PSP_JP_TXT') 43 | 44 | psp_txt_dic = MakeStrDic(psp_files) 45 | vita_txt_dic = MakeStrDic(vita_files) 46 | 47 | pre_list = [] 48 | for string in vita_txt_dic.keys(): 49 | if not string in psp_txt_dic: 50 | pre_list.append((vita_txt_dic[string], string)) 51 | 52 | for fname, string in pre_list: 53 | if len(string) == 1: 54 | continue 55 | 56 | if IsAlNum(string): 57 | continue 58 | 59 | if (IsAlNum(string[0]) and (not IsAlNum(string[1]))) or ((not IsAlNum(string[0])) and IsAlNum(string[1])): 60 | continue 61 | 62 | if fname[1] == '_': 63 | continue 64 | 65 | log = '{}:{}\n'.format(fname, string) 66 | print(log) 67 | report.write(log) 68 | 69 | 70 | 71 | report.close() 72 | print('Parse finish.') 73 | 74 | 75 | if __name__ == '__main__': 76 | main() -------------------------------------------------------------------------------- /scripts/ShiftJisCodeTable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Inori/Falcom/77ac477e5f2ec5dd66943eb0ab4a7cc5e1b48799/scripts/ShiftJisCodeTable.png -------------------------------------------------------------------------------- /scripts/nidformat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import yaml 4 | import subprocess 5 | import string 6 | 7 | from glob import glob 8 | from sys import argv 9 | 10 | hardcoded_nids = [ 11 | ("0x79F8E492", "module_stop"), 12 | ("0x913482A9", "module_exit"), 13 | ("0x935CD196", "module_start"), 14 | ] 15 | 16 | fnids = open(argv[1]) 17 | fout = open(argv[2], "w") 18 | 19 | for entry in hardcoded_nids: 20 | fout.write("{} {}\n".format(entry[0], entry[1])) 21 | 22 | nids = yaml.safe_load(fnids) 23 | fnids.close() 24 | 25 | modules = nids["modules"] 26 | for module in modules: 27 | libraries = modules[module]["libraries"] 28 | for library in libraries: 29 | try: 30 | functis = libraries[library]["functions"] 31 | except: 32 | continue 33 | for functi in functis: 34 | nid = hex(functis[functi]) 35 | fout.write("{} {}\n".format(nid, functi)) 36 | 37 | fout.close() 38 | 39 | --------------------------------------------------------------------------------