forked from takkaO/OpenFontRender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModifyLibs.ps1
99 lines (85 loc) · 5.74 KB
/
ModifyLibs.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -------------------------------------------------------
# ModifyLibs.ps1
#
# Copyright (c) 2021 takkaO
#
# If you use, modify, or redistribute this file independently
# of the original repository, this program is licensed under
# the MIT License.
#
# If you use, modify or redistribute this file as part of
# the original repository, please follow the repository's license.
#
# -------------------------------------------------------
Write-Host "** Start modify FreeType libraries **"
Write-Host "Processing remove some codes and files"
foreach ($f in Get-ChildItem "./src/*/" -Include *.c -Recurse) {
@(Get-Content $f) -replace "^(#include.*\.c)", "//`$1" | Set-Content $f
}
Remove-Item "./src/freetype/ftmac.h" -Force -ErrorAction Ignore
Remove-Item "./src/base/ftmac.c" -Force -ErrorAction Ignore
Remove-Item "./src/truetype/ttgxvar.h" -Force -ErrorAction Ignore
Remove-Item "./src/truetype/ttgxvar.c" -Force -ErrorAction Ignore
Rename-Item "./src/base/ftsystem.c" -NewName "ftsystem.cpp" -Force -ErrorAction Ignore
$target = "./src/freetype/config/ftoption.h"
Write-Host ("Processing " + $target)
# Disable some options
$(Get-Content $target) -replace "^(#define FT_CONFIG_OPTION_USE_LZW)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define FT_CONFIG_OPTION_USE_ZLIB)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define FT_CONFIG_OPTION_MAC_FONTS)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define FT_CONFIG_OPTION_INCREMENTAL)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_OPTION_COLOR_LAYERS)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_OPTION_SFNT_NAMES)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_CMAP_FORMAT_0)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_CMAP_FORMAT_2)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_CMAP_FORMAT_6)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_CMAP_FORMAT_8)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_CMAP_FORMAT_10)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_CMAP_FORMAT_12)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_CMAP_FORMAT_13)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_CMAP_FORMAT_14)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_OPTION_SUBPIXEL_HINTING)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_OPTION_GX_VAR_SUPPORT)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define TT_CONFIG_OPTION_BDF)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define AF_CONFIG_OPTION_CJK)", "//`$1" | Set-Content $target
# Enable some options
$(Get-Content $target) -replace "^.*(#define FT_DEBUG_LEVEL_ERROR).*", "`$1" | Set-Content $target
$target = "./src/freetype/config/ftmodule.h"
Write-Host ("Processing " + $target)
# Disable all modules
$(Get-Content $target) -replace "^(FT_USE_MODULE.*)", "//`$1" | Set-Content $target
# Enable some modules
$(Get-Content $target) -replace "^.*(FT_USE_MODULE.*tt_driver_class.*)", "`$1" | Set-Content $target
$(Get-Content $target) -replace "^.*(FT_USE_MODULE.*sfnt_module_class.*)", "`$1" | Set-Content $target
$(Get-Content $target) -replace "^.*(FT_USE_MODULE.*ft_smooth_renderer_class.*)", "`$1" | Set-Content $target
$target = "./src/freetype/config/ftstdlib.h"
Write-Host ("Processing " + $target)
# Disable some options
$(Get-Content $target) -replace "^(#define FT_FILE.*)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define ft_fclose.*)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define ft_fopen.*)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define ft_fread.*)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define ft_fseek.*)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define ft_ftell.*)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define ft_scalloc.*)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define ft_smalloc.*)", "//`$1" | Set-Content $target
$(Get-Content $target) -replace "^(#define ft_srealloc.*)", "//`$1" | Set-Content $target
$target = "./src/ft2build.h"
if ( !($(Get-Content $target) -match "#define FT2_BUILD_LIBRARY") ) {
# If the required definition does not exist
Write-Host ("Processing " + $target)
$(Get-Content -Raw $target) -replace "(?smi)^(#define \w*)([\r\n]+)", "`$1`$2#define FT2_BUILD_LIBRARY`$2" | Set-Content $target
#$(Get-Content $target) | Set-Content $target
}
$target = "./src/base/ftsystem.cpp"
if ( !($(Get-Content $target) -match "#include `"../FileSupport.h`"") ) {
# If the required definition does not exist
Write-Host ("Processing " + $target)
$(Get-Content -Raw $target) -replace "(?smi)^(#include .*)([\r\n]+)", "#include `"../FileSupport.h`"`$2`$1`$2" | Set-Content $target
#$(Get-Content $target) | Set-Content $target
}
Write-Host "** Finish modify FreeType libraries **"