vttcompilepy 0.0.1.6__zip → 0.0.1.8__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vttcompilepy might be problematic. Click here for more details.
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/PKG-INFO +2 -1
- vttcompilepy-0.0.1.8/setup.py +92 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/TTAssembler.cpp +128 -34
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/TextBuffer.cpp +15 -4
- vttcompilepy-0.0.1.8/src/application.h +47 -0
- vttcompilepy-0.0.1.8/src/pch.h +68 -0
- vttcompilepy-0.0.1.8/tests/test_vttcompile.py +163 -0
- vttcompilepy-0.0.1.8/vttcompilepy/quit_to_glyphs.py +115 -0
- vttcompilepy-0.0.1.8/vttcompilepy/vttcompilepy.cpp +14392 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy.egg-info/PKG-INFO +2 -1
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy.egg-info/SOURCES.txt +4 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy.egg-info/entry_points.txt +1 -0
- vttcompilepy-0.0.1.6/setup.py +0 -69
- vttcompilepy-0.0.1.6/vttcompilepy/vttcompilepy.cpp +0 -8474
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/README.md +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/pyproject.toml +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/setup.cfg +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/CvtManager.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/File.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/List.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/MathUtils.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/Memory.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/Platform.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/TMTParser.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/TTEngine.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/TTFont.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/TTGenerator.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/Variation.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/VariationInstance.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/VariationModels.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/application.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/src/ttiua.cpp +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy/__init__.py +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy/__main__.py +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy/_version.py +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy.egg-info/dependency_links.txt +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy.egg-info/not-zip-safe +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy.egg-info/requires.txt +0 -0
- {vttcompilepy-0.0.1.6 → vttcompilepy-0.0.1.8}/vttcompilepy.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vttcompilepy
|
|
3
|
-
Version: 0.0.1.
|
|
3
|
+
Version: 0.0.1.8
|
|
4
4
|
Summary: Python extension for Visual TrueType font compile.
|
|
5
5
|
Home-page: https://github.com/microsoft/VisualTrueType
|
|
6
6
|
Author: Paul Linnerud
|
|
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Requires-Python: >=3.7
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: fonttools>=4.33.0
|
|
13
14
|
|
|
14
15
|
# Project
|
|
15
16
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from io import open
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import platform
|
|
6
|
+
from setuptools import Extension, setup
|
|
7
|
+
from Cython.Build import cythonize
|
|
8
|
+
|
|
9
|
+
# from _version import __version__ as vttpy_version
|
|
10
|
+
|
|
11
|
+
here = os.path.abspath(os.path.dirname(__file__))
|
|
12
|
+
|
|
13
|
+
# Get the long description from the pypi.md file
|
|
14
|
+
with open(os.path.join(here, "pypi.md"), encoding="utf-8") as f:
|
|
15
|
+
long_description = f.read()
|
|
16
|
+
|
|
17
|
+
define_macros = [("UNICODE", 1), ("_UNICODE", 1)]
|
|
18
|
+
linetrace = False
|
|
19
|
+
if int(os.environ.get("CYTHON_LINETRACE", "0")):
|
|
20
|
+
linetrace = True
|
|
21
|
+
define_macros.append(("CYTHON_TRACE_NOGIL", "1"))
|
|
22
|
+
|
|
23
|
+
extra_compile_args = []
|
|
24
|
+
|
|
25
|
+
if platform.system() != "Windows":
|
|
26
|
+
extra_compile_args.append("-std=c++14")
|
|
27
|
+
|
|
28
|
+
if platform.system() == "Windows":
|
|
29
|
+
extra_compile_args.append("-sdl")
|
|
30
|
+
|
|
31
|
+
extension = Extension(
|
|
32
|
+
"vttcompilepy.vttcompilepy",
|
|
33
|
+
define_macros=define_macros,
|
|
34
|
+
include_dirs=[".", "src"],
|
|
35
|
+
sources=[
|
|
36
|
+
"vttcompilepy/vttcompilepy.pyx",
|
|
37
|
+
"src/application.cpp",
|
|
38
|
+
"src/CvtManager.cpp",
|
|
39
|
+
"src/File.cpp",
|
|
40
|
+
"src/List.cpp",
|
|
41
|
+
"src/MathUtils.cpp",
|
|
42
|
+
"src/Memory.cpp",
|
|
43
|
+
"src/Platform.cpp",
|
|
44
|
+
"src/TextBuffer.cpp",
|
|
45
|
+
"src/TMTParser.cpp",
|
|
46
|
+
"src/TTAssembler.cpp",
|
|
47
|
+
"src/TTEngine.cpp",
|
|
48
|
+
"src/TTFont.cpp",
|
|
49
|
+
"src/TTGenerator.cpp",
|
|
50
|
+
"src/Variation.cpp",
|
|
51
|
+
"src/VariationInstance.cpp",
|
|
52
|
+
"src/VariationModels.cpp",
|
|
53
|
+
"src/ttiua.cpp",
|
|
54
|
+
],
|
|
55
|
+
language="c++",
|
|
56
|
+
extra_compile_args=extra_compile_args,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
setup(
|
|
60
|
+
name="vttcompilepy",
|
|
61
|
+
# version= vttpy_version,
|
|
62
|
+
version="0.0.1.8",
|
|
63
|
+
description="Python extension for Visual TrueType font compile. ",
|
|
64
|
+
long_description=long_description,
|
|
65
|
+
long_description_content_type="text/markdown",
|
|
66
|
+
author="Paul Linnerud",
|
|
67
|
+
author_email="paulli@microsoft.com",
|
|
68
|
+
url="https://github.com/microsoft/VisualTrueType",
|
|
69
|
+
license="MIT",
|
|
70
|
+
classifiers=[
|
|
71
|
+
"Programming Language :: Python :: 3",
|
|
72
|
+
"License :: OSI Approved :: MIT License",
|
|
73
|
+
],
|
|
74
|
+
package_dir={"": "."},
|
|
75
|
+
packages=["vttcompilepy"],
|
|
76
|
+
zip_safe=False,
|
|
77
|
+
install_requires=[
|
|
78
|
+
"fonttools>=4.33.0",
|
|
79
|
+
],
|
|
80
|
+
python_requires=">=3.7",
|
|
81
|
+
ext_modules=cythonize(
|
|
82
|
+
extension,
|
|
83
|
+
annotate=bool(int(os.environ.get("CYTHON_ANNOTATE", "0"))),
|
|
84
|
+
compiler_directives={"linetrace": linetrace},
|
|
85
|
+
),
|
|
86
|
+
entry_points={
|
|
87
|
+
"console_scripts": [
|
|
88
|
+
"vttcompilepy = vttcompilepy.__main__:main",
|
|
89
|
+
"quit_to_glyphs = vttcompilepy.quit_to_glyphs:main",
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
)
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
#define SHORTMIN -32768
|
|
28
28
|
#define USHORTMAX 65535
|
|
29
29
|
|
|
30
|
-
#define MAXINSTRUCTIONCOUNT
|
|
30
|
+
#define MAXINSTRUCTIONCOUNT 0x1000000
|
|
31
31
|
#define MAXARGUMENTS (0x8000L - 4L) // don't push the limit
|
|
32
32
|
#define ARGTYPEBUFFER_SIZE 300
|
|
33
33
|
|
|
@@ -47,8 +47,6 @@
|
|
|
47
47
|
/* for the DovMan partial compilation feature that flash points referenced by the current command */
|
|
48
48
|
#define tt_MAXFLASHINGPOINTS 4
|
|
49
49
|
|
|
50
|
-
#define tt_MAXINSTRUCTIONS 8000 /* size needed for the chicago Japanese fonts */
|
|
51
|
-
|
|
52
50
|
typedef struct {
|
|
53
51
|
unsigned short flashingPoints[tt_MAXFLASHINGPOINTS];
|
|
54
52
|
short NumberOfFlashingPoint;
|
|
@@ -151,7 +149,8 @@ typedef struct {
|
|
|
151
149
|
#define tt_End_Switch 5
|
|
152
150
|
#define tt_GHTBlockBegin_Switch 6
|
|
153
151
|
#define tt_GHTBlockEnd_Switch 7
|
|
154
|
-
#define tt_MaxStack_Switch
|
|
152
|
+
#define tt_MaxStack_Switch 8
|
|
153
|
+
#define tt_DB_Switch 9
|
|
155
154
|
|
|
156
155
|
#define co_NoError 0
|
|
157
156
|
|
|
@@ -266,7 +265,8 @@ tt_CompilerSwitchType tt_CompilerSwitch[] = {
|
|
|
266
265
|
{ L"GHTBLOCK", L"Beginning of a new Sampo block", tt_GHTBlockBegin_Switch },
|
|
267
266
|
{ L"GHTB", L"Beginning of a new Sampo block", tt_GHTBlockBegin_Switch },
|
|
268
267
|
{ L"GHTE", L"End of a new Sampo block", tt_GHTBlockEnd_Switch },
|
|
269
|
-
{L"MAXSTACK",
|
|
268
|
+
{ L"MAXSTACK", L"Max Stack", tt_MaxStack_Switch },
|
|
269
|
+
{ L"DB", L"Embed Binary", tt_DB_Switch},
|
|
270
270
|
};
|
|
271
271
|
|
|
272
272
|
#define asm_SLOOP 0x17
|
|
@@ -521,14 +521,14 @@ const asm_BooleanTranslationType asm_booleanTranslation1[] = {
|
|
|
521
521
|
/**** label related code *****/
|
|
522
522
|
/**** moved and adapted from label.c */
|
|
523
523
|
|
|
524
|
-
#define
|
|
524
|
+
#define MAXJRPAIR 0x4000 /* max. number of labels "#L100" or JR[]
|
|
525
525
|
* lines in one block (#BEGIN-#END
|
|
526
526
|
*/
|
|
527
527
|
#define MAXLABELLENGTH 22
|
|
528
528
|
|
|
529
529
|
typedef struct {
|
|
530
530
|
wchar_t label[MAXLABELLENGTH]; /* label ["#L100"] */
|
|
531
|
-
|
|
531
|
+
long iPos; /* instruction position from #BEGIN */
|
|
532
532
|
short *aPtr; /* start ptr of argument storage */
|
|
533
533
|
|
|
534
534
|
short cArg;
|
|
@@ -587,7 +587,7 @@ typedef struct {
|
|
|
587
587
|
typedef struct {
|
|
588
588
|
wchar_t label[MAXLABELLENGTH]; /* Label ["#L100"] */
|
|
589
589
|
wchar_t BWLabel[MAXLABELLENGTH]; /* BW word ["B1"} */
|
|
590
|
-
|
|
590
|
+
long iPos; /* instruction position from #BEGIN */
|
|
591
591
|
wchar_t *linePtr; /* pointer in the source to be able to display the location of an error */
|
|
592
592
|
}tt_JrBWwordType;
|
|
593
593
|
|
|
@@ -827,13 +827,66 @@ wchar_t *TT_ParsePUSHandSave(tt_PStype *ps,wchar_t *CurrentPtr,wchar_t * EOLPtr,
|
|
|
827
827
|
}
|
|
828
828
|
|
|
829
829
|
|
|
830
|
+
wchar_t* TT_ParseHexSequence(wchar_t* p, wchar_t* endP, unsigned char** iPtr, unsigned char* iPtrMax, int32_t* SelectionLength, short* error);
|
|
831
|
+
wchar_t* TT_ParseHexSequence(wchar_t* p, wchar_t* endP, unsigned char** iPtr, unsigned char* iPtrMax, int32_t* SelectionLength, short* error)
|
|
832
|
+
{
|
|
833
|
+
bool parity = true;
|
|
834
|
+
uint8_t tempByte = 0x00;
|
|
835
|
+
short i = 1;
|
|
836
|
+
|
|
837
|
+
while (p < endP)
|
|
838
|
+
{
|
|
839
|
+
/* skip white space */
|
|
840
|
+
while (*p == L' ' && p < endP)
|
|
841
|
+
p++;
|
|
842
|
+
|
|
843
|
+
while (((*p >= L'0' && *p <= L'9') || (*p >= L'A' && *p <= L'F') || (*p >= L'a' && *p <= L'f')) && p < endP)
|
|
844
|
+
{
|
|
845
|
+
|
|
846
|
+
if (*p >= L'0' && *p <= L'9')
|
|
847
|
+
{
|
|
848
|
+
tempByte = (tempByte << 4) | static_cast<uint8_t>((int32_t)*p - (int32_t)L'0');
|
|
849
|
+
}
|
|
850
|
+
else if (*p >= L'A' && *p <= L'F')
|
|
851
|
+
{
|
|
852
|
+
tempByte = (tempByte << 4) | static_cast<uint8_t>((int32_t)*p - (int32_t)L'A' + 10);
|
|
853
|
+
}
|
|
854
|
+
else if (*p >= L'a' && *p <= L'f')
|
|
855
|
+
{
|
|
856
|
+
tempByte = (tempByte << 4) | static_cast<uint8_t>((int32_t)*p - (int32_t)L'a' + 10);
|
|
857
|
+
}
|
|
858
|
+
parity = !parity;
|
|
859
|
+
if (parity)
|
|
860
|
+
{
|
|
861
|
+
if (*iPtr + 1 > iPtrMax)
|
|
862
|
+
{
|
|
863
|
+
*error = tt_ProgramTooBig;
|
|
864
|
+
return p;
|
|
865
|
+
}
|
|
866
|
+
else {
|
|
867
|
+
**iPtr = tempByte;
|
|
868
|
+
*iPtr += 1;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
p++;
|
|
872
|
+
i++;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
if (i == 0 || !parity)
|
|
876
|
+
*error = tt_UnableToParseArgument;
|
|
877
|
+
|
|
878
|
+
return p;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
830
883
|
/*
|
|
831
884
|
* given label = "#L100"
|
|
832
885
|
* return the index in the Label->lab[index]
|
|
833
886
|
* return -1 on error
|
|
834
887
|
*/
|
|
835
|
-
static
|
|
836
|
-
static
|
|
888
|
+
static long TT_findLabelPos(tt_LabelType *Label,wchar_t *label, short * tt_error );
|
|
889
|
+
static long TT_findLabelPos(tt_LabelType *Label,wchar_t *label, short * tt_error )
|
|
837
890
|
{
|
|
838
891
|
short i;
|
|
839
892
|
|
|
@@ -854,13 +907,14 @@ static short TT_findLabelPos(tt_LabelType *Label,wchar_t *label, short * tt_erro
|
|
|
854
907
|
void TT_JRpushON_ReplaceLabel(tt_JRtype *JR,tt_LabelType *Label,short *argStore, short * tt_error);
|
|
855
908
|
void TT_JRpushON_ReplaceLabel(tt_JRtype *JR,tt_LabelType *Label,short *argStore, short * tt_error)
|
|
856
909
|
{
|
|
857
|
-
short i,
|
|
910
|
+
short i, index, delta;
|
|
911
|
+
long labeliPos, JRiPos;
|
|
858
912
|
|
|
859
913
|
for ( i = 0; i < JR->num; i++) {
|
|
860
914
|
labeliPos = TT_findLabelPos( Label, JR->jr[i]->label, tt_error );
|
|
861
915
|
JRiPos = JR->jr[i]->iPos;
|
|
862
916
|
|
|
863
|
-
delta = labeliPos - JRiPos;
|
|
917
|
+
delta = static_cast<short>(labeliPos - JRiPos);
|
|
864
918
|
/* if ( delta < 0 ) delta --; */
|
|
865
919
|
|
|
866
920
|
index = JR->jr[i]->cArg;
|
|
@@ -881,7 +935,8 @@ void TT_JRpushON_ReplaceLabel(tt_JRtype *JR,tt_LabelType *Label,short *argStore
|
|
|
881
935
|
void TT_JRpushOFF_ReplaceLabel(tt_JrBWtype *JrBW,tt_PStype *PS,tt_LabelType *Label, short * tt_error);
|
|
882
936
|
void TT_JRpushOFF_ReplaceLabel(tt_JrBWtype *JrBW,tt_PStype *PS,tt_LabelType *Label, short * tt_error)
|
|
883
937
|
{
|
|
884
|
-
short i,
|
|
938
|
+
short i, delta, index;
|
|
939
|
+
long labeliPos;
|
|
885
940
|
|
|
886
941
|
for ( i = 0; i < PS->num; i++) {
|
|
887
942
|
/* for each #PUSH Bn or Wn, look fot the corresponding JR */
|
|
@@ -890,7 +945,7 @@ void TT_JRpushOFF_ReplaceLabel(tt_JrBWtype *JrBW,tt_PStype *PS,tt_LabelType
|
|
|
890
945
|
}
|
|
891
946
|
|
|
892
947
|
labeliPos = TT_findLabelPos( Label, JrBW->bw[index]->label, tt_error );
|
|
893
|
-
delta = labeliPos - JrBW->bw[i]->iPos;
|
|
948
|
+
delta = static_cast<short>(labeliPos - JrBW->bw[i]->iPos);
|
|
894
949
|
|
|
895
950
|
if ( (*PS->ps[i]).IsAByte && (delta > 255 ))
|
|
896
951
|
{
|
|
@@ -987,8 +1042,8 @@ wchar_t * TT_FindLabelError(tt_PStype *PS, tt_JrBWtype *JrBW, tt_JRtype *JR
|
|
|
987
1042
|
*/
|
|
988
1043
|
|
|
989
1044
|
|
|
990
|
-
void TT_SaveLabel(short numberofArgs,
|
|
991
|
-
void TT_SaveLabel(short numberofArgs,
|
|
1045
|
+
void TT_SaveLabel(short numberofArgs, long numberofInstructions,int32_t stringLenth,wchar_t *p,tt_LabelType *Label, short * tt_error);
|
|
1046
|
+
void TT_SaveLabel(short numberofArgs, long numberofInstructions,int32_t stringLenth,wchar_t *p,tt_LabelType *Label, short * tt_error)
|
|
992
1047
|
{
|
|
993
1048
|
short i, k;
|
|
994
1049
|
|
|
@@ -1026,9 +1081,9 @@ void TT_SaveLabel(short numberofArgs,short numberofInstructions,int32_t stringLe
|
|
|
1026
1081
|
|
|
1027
1082
|
//void TT_SavePSLabel(short numberofArgs,short numberofInstructions,short stringLenth,char *p,tt_LabelType *Label, short * tt_error);
|
|
1028
1083
|
|
|
1029
|
-
wchar_t * TT_SaveJR(short numberofArgs,
|
|
1084
|
+
wchar_t * TT_SaveJR(short numberofArgs,long numberofInstructions,wchar_t * CurrentPtr, wchar_t *LabelPtr,int32_t stringLenth,
|
|
1030
1085
|
wchar_t *BWLabelPtr,short BWstringLenth,tt_JRtype *JRList,tt_JrBWtype *JrBW, short *aPtr,int32_t * SelectionLength, short * tt_error);
|
|
1031
|
-
wchar_t * TT_SaveJR(short numberofArgs,
|
|
1086
|
+
wchar_t * TT_SaveJR(short numberofArgs,long numberofInstructions,wchar_t * CurrentPtr, wchar_t *LabelPtr,int32_t stringLenth,
|
|
1032
1087
|
wchar_t *BWLabelPtr,short BWstringLenth,tt_JRtype *JRList,tt_JrBWtype *JrBW, short *aPtr,int32_t * SelectionLength, short * tt_error)
|
|
1033
1088
|
{
|
|
1034
1089
|
short i, k;
|
|
@@ -1642,7 +1697,7 @@ wchar_t * TT_ReadInstructionParameters (wchar_t * CurrentPtr, wchar_t * EOLPtr,
|
|
|
1642
1697
|
asm_PushAndPopDescriptionType asm_ppDescription[], short pushOn, wchar_t * ArgTypeBuffer, short *argc,short *args,short *argc2,wchar_t *args2,
|
|
1643
1698
|
wchar_t ** LabelHandle, short * LabelLength, wchar_t ** BWLabelHandle, short * BWLabelLength, int32_t * SelectionLength, short * MaxFunctionDefs,
|
|
1644
1699
|
/* offset in the instruction stream to the instruction corresponding to the cursor position, used for trace mode */
|
|
1645
|
-
|
|
1700
|
+
long * BinaryOffset,
|
|
1646
1701
|
/* for the DovMan partial compilation feature that flash points referenced by the current command */
|
|
1647
1702
|
tt_flashingPoints * flashingPoints,
|
|
1648
1703
|
short * tt_error);
|
|
@@ -1650,7 +1705,7 @@ wchar_t * TT_ReadInstructionParameters (wchar_t * CurrentPtr, wchar_t * EOLPtr,
|
|
|
1650
1705
|
asm_PushAndPopDescriptionType asm_ppDescription[], short pushOn, wchar_t * ArgTypeBuffer, short *argc,short *args,short *argc2,wchar_t *args2,
|
|
1651
1706
|
wchar_t ** LabelHandle, short * LabelLength, wchar_t ** BWLabelHandle, short * BWLabelLength, int32_t * SelectionLength, short * MaxFunctionDefs,
|
|
1652
1707
|
/* offset in the instruction stream to the instruction corresponding to the cursor position, used for trace mode */
|
|
1653
|
-
|
|
1708
|
+
long * BinaryOffset,
|
|
1654
1709
|
/* for the DovMan partial compilation feature that flash points referenced by the current command */
|
|
1655
1710
|
tt_flashingPoints * flashingPoints,
|
|
1656
1711
|
short * tt_error)
|
|
@@ -2221,18 +2276,18 @@ short TT_OptimizingPushArguments( unsigned char * BinaryOut,unsigned char * Bina
|
|
|
2221
2276
|
}
|
|
2222
2277
|
|
|
2223
2278
|
|
|
2224
|
-
|
|
2225
|
-
unsigned char insStore[], short numberofArgs,
|
|
2226
|
-
|
|
2227
|
-
unsigned char insStore[], short numberofArgs,
|
|
2279
|
+
long TT_WriteOutBlock(unsigned char* BinaryOut, unsigned char* BinaryOutEndPtr, long* BinaryOffset, short AddOffset, short argStore[],
|
|
2280
|
+
unsigned char insStore[], short numberofArgs, long numberofInstructions, short* tt_error);
|
|
2281
|
+
long TT_WriteOutBlock(unsigned char* BinaryOut, unsigned char* BinaryOutEndPtr, long* BinaryOffset, short AddOffset, short argStore[],
|
|
2282
|
+
unsigned char insStore[], short numberofArgs, long numberofInstructions, short* tt_error)
|
|
2228
2283
|
{
|
|
2229
|
-
|
|
2230
|
-
|
|
2284
|
+
long i, k;
|
|
2285
|
+
long count;
|
|
2231
2286
|
|
|
2232
2287
|
/* Reverse arguments since we are pushing them */
|
|
2233
2288
|
k = numberofArgs >> 1;
|
|
2234
2289
|
for ( i = 0; i < k; i++ ) {
|
|
2235
|
-
j = argStore[i];
|
|
2290
|
+
short j = argStore[i];
|
|
2236
2291
|
argStore[i] = argStore[numberofArgs-1-i];
|
|
2237
2292
|
argStore[numberofArgs-1-i] = j;
|
|
2238
2293
|
}
|
|
@@ -2441,7 +2496,7 @@ wchar_t *TT_InnerCompile(
|
|
|
2441
2496
|
/* pointer to the output buffer, it's maximal length and return the Binary length */
|
|
2442
2497
|
unsigned char * BinaryOut, char * BinaryOutEndPtr, int32_t * BinaryLength,
|
|
2443
2498
|
/* offset in the instruction stream to the instruction corresponding to the cursor position, used for trace mode */
|
|
2444
|
-
|
|
2499
|
+
long * BinaryOffset,
|
|
2445
2500
|
/* length of the text to be selected in case of error */
|
|
2446
2501
|
int32_t * SelectionLength,
|
|
2447
2502
|
/* line number where the first error occur */
|
|
@@ -2463,7 +2518,7 @@ wchar_t *TT_InnerCompile(
|
|
|
2463
2518
|
/* pointer to the output buffer, it's maximal length and return the Binary length */
|
|
2464
2519
|
unsigned char * BinaryOut, char * BinaryOutEndPtr, int32_t * BinaryLength,
|
|
2465
2520
|
/* offset in the instruction stream to the instruction corresponding to the cursor position, used for trace mode */
|
|
2466
|
-
|
|
2521
|
+
long * BinaryOffset,
|
|
2467
2522
|
/* length of the text to be selected in case of error */
|
|
2468
2523
|
int32_t * SelectionLength,
|
|
2469
2524
|
/* line number where the first error occur */
|
|
@@ -2482,7 +2537,8 @@ wchar_t *TT_InnerCompile(
|
|
|
2482
2537
|
short LineNb, LastLineCompiled;
|
|
2483
2538
|
int32_t LineLength, SLoopLineLength;
|
|
2484
2539
|
wchar_t *CurrentPtr, *SLoopPtr;
|
|
2485
|
-
short numberofArgs
|
|
2540
|
+
short numberofArgs;
|
|
2541
|
+
long numberofInstructions;
|
|
2486
2542
|
short *argStore, *aPtr;
|
|
2487
2543
|
unsigned char *insStore, *iPtr;
|
|
2488
2544
|
short NeedTwoPass = false; /* used to be MyCode */
|
|
@@ -2891,6 +2947,43 @@ wchar_t *TT_InnerCompile(
|
|
|
2891
2947
|
CompilationStatus->ExplicitMaxStack = maxStack;
|
|
2892
2948
|
}
|
|
2893
2949
|
break;
|
|
2950
|
+
case tt_DB_Switch:
|
|
2951
|
+
if (CompilationStatus->WeAreInsideGHBlock)
|
|
2952
|
+
{
|
|
2953
|
+
CurrentPtr = CurrentPtr + LineLength;
|
|
2954
|
+
}
|
|
2955
|
+
else
|
|
2956
|
+
{
|
|
2957
|
+
wchar_t* EOLPtr;
|
|
2958
|
+
EOLPtr = CurrentPtr + LineLength;
|
|
2959
|
+
short maxStack = 0;
|
|
2960
|
+
|
|
2961
|
+
CurrentPtr = CurrentPtr + StringLength + 1;
|
|
2962
|
+
|
|
2963
|
+
/* skip spaces */
|
|
2964
|
+
while (*CurrentPtr == L' ' && CurrentPtr <= EOLPtr)
|
|
2965
|
+
CurrentPtr++;
|
|
2966
|
+
|
|
2967
|
+
if (CurrentPtr >= EOLPtr)
|
|
2968
|
+
*tt_error = tt_ExpectingAValue;
|
|
2969
|
+
|
|
2970
|
+
/* look for the comma */
|
|
2971
|
+
if (*CurrentPtr != L',')
|
|
2972
|
+
{
|
|
2973
|
+
break; /* it could be a comment */
|
|
2974
|
+
}
|
|
2975
|
+
CurrentPtr = CurrentPtr + 1;
|
|
2976
|
+
|
|
2977
|
+
/* skip extra spaces */
|
|
2978
|
+
while (*CurrentPtr == L' ' && CurrentPtr <= EOLPtr)
|
|
2979
|
+
CurrentPtr++;
|
|
2980
|
+
|
|
2981
|
+
if (CurrentPtr >= EOLPtr)
|
|
2982
|
+
*tt_error = tt_ExpectingAValue;
|
|
2983
|
+
|
|
2984
|
+
CurrentPtr = TT_ParseHexSequence(CurrentPtr, EOLPtr, &iPtr, InnerBinaryOutMaxPtr, SelectionLength, tt_error);
|
|
2985
|
+
}
|
|
2986
|
+
break;
|
|
2894
2987
|
}
|
|
2895
2988
|
}
|
|
2896
2989
|
}
|
|
@@ -3125,7 +3218,7 @@ wchar_t *TT_InnerCompile(
|
|
|
3125
3218
|
} else {
|
|
3126
3219
|
/* write the new code */
|
|
3127
3220
|
numberofArgs = (short)(ptrdiff_t)(aPtr - argStore); /* number of arguments */
|
|
3128
|
-
numberofInstructions = (
|
|
3221
|
+
numberofInstructions = (long)(ptrdiff_t)(iPtr - insStore); /* number of instructions */
|
|
3129
3222
|
|
|
3130
3223
|
if (NeedTwoPass)
|
|
3131
3224
|
{
|
|
@@ -3160,7 +3253,7 @@ wchar_t *TT_Compile(
|
|
|
3160
3253
|
/* pointer to the output buffer, it's maximal length and return the length of the resulting binary */
|
|
3161
3254
|
unsigned char * BinaryOut, short MaxBinaryLength, int32_t * BinaryLength,
|
|
3162
3255
|
/* offset in the instruction stream to the instruction corresponding to the cursor position, used for trace mode */
|
|
3163
|
-
|
|
3256
|
+
long * BinaryOffset,
|
|
3164
3257
|
/* length of the text to be selected in case of error */
|
|
3165
3258
|
int32_t * SelectionLength,
|
|
3166
3259
|
/* line number where the first error occur */
|
|
@@ -3176,7 +3269,7 @@ wchar_t *TT_Compile(
|
|
|
3176
3269
|
short * tt_error);
|
|
3177
3270
|
|
|
3178
3271
|
wchar_t *TT_Compile(wchar_t *StartPtr, wchar_t * EndPtr, wchar_t * SelStartPtr, unsigned char * BinaryOut, int32_t MaxBinaryLength,
|
|
3179
|
-
int32_t * BinaryLength,
|
|
3272
|
+
int32_t * BinaryLength, long * BinaryOffset, int32_t * SelectionLength, short * ErrorLineNb,
|
|
3180
3273
|
short* StackNeed, short* MaxFunctionDefs, short* ExplicitStackNeed,
|
|
3181
3274
|
/* for the DovMan partial compilation feature that flash points referenced by the current command */
|
|
3182
3275
|
tt_flashingPoints * flashingPoints,
|
|
@@ -4078,7 +4171,8 @@ bool TTAssemble(ASMType asmType, TextBuffer* src, TrueTypeFont* font, TrueTypeGl
|
|
|
4078
4171
|
int32_t maxBinLen, unsigned char* bin, int32_t* actBinLen, bool variationCompositeGuard, int32_t* errPos, int32_t* errLen, wchar_t errMsg[], size_t errMsgLen) {
|
|
4079
4172
|
|
|
4080
4173
|
wchar_t* startPtr, * endPtr, * SelStartPtr, * tempPtr;
|
|
4081
|
-
|
|
4174
|
+
long BinaryOffset;
|
|
4175
|
+
short CompileError = co_NoError, StackNeed, MaxFunctionDefs, ExplicitStackNeed, ErrorLineNb, componentSize, numCompositeContours, numCompositePoints, maxContourNumber, maxPointNumber;
|
|
4082
4176
|
int32_t srcLen, highestCvtNum;
|
|
4083
4177
|
sfnt_maxProfileTable profile;
|
|
4084
4178
|
short componentData[MAXCOMPONENTSIZE];
|
|
@@ -122,9 +122,20 @@ void TextBuffer::SetText(int32_t textLen, const char text[])
|
|
|
122
122
|
}
|
|
123
123
|
else
|
|
124
124
|
{
|
|
125
|
-
std::
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
std::wstring wstr;
|
|
126
|
+
std::string str(reinterpret_cast<const char*>(text), textLen);
|
|
127
|
+
try
|
|
128
|
+
{
|
|
129
|
+
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
|
130
|
+
wstr = converter.from_bytes(str);
|
|
131
|
+
}
|
|
132
|
+
catch (const std::range_error)
|
|
133
|
+
{
|
|
134
|
+
// Some really old VTT source data has sequences that fail above conversion so we do a naive conversion as backup.
|
|
135
|
+
// Note that VTT desktop version of this code uses Windows MultiByteToWideChar() which seems more error resilient.
|
|
136
|
+
wstr.resize(str.length(), L' ');
|
|
137
|
+
std::copy(str.begin(), str.end(), wstr.begin());
|
|
138
|
+
}
|
|
128
139
|
|
|
129
140
|
this->SetText(wstr.length(), wstr.c_str());
|
|
130
141
|
}
|
|
@@ -354,4 +365,4 @@ bool TextBuffer::AssertTextSize(size_t deltaSize) {
|
|
|
354
365
|
this->text = tmpText;
|
|
355
366
|
}
|
|
356
367
|
return tmpText != NULL;
|
|
357
|
-
} // TextBuffer::AssertTextSize
|
|
368
|
+
} // TextBuffer::AssertTextSize
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
class Application
|
|
6
|
+
{
|
|
7
|
+
public:
|
|
8
|
+
Application(void);
|
|
9
|
+
bool Create();
|
|
10
|
+
virtual ~Application(void);
|
|
11
|
+
|
|
12
|
+
bool OpenFont(std::string fileName, wchar_t errMsg[], size_t errMsgLen);
|
|
13
|
+
bool OpenMemFont(void* font, uint32_t fontLen, wchar_t errMsg[], size_t errMsgLen);
|
|
14
|
+
|
|
15
|
+
bool SaveFont(std::string fileName, StripCommand strip, wchar_t errMsg[], size_t errMsgLen);
|
|
16
|
+
bool SaveMemFont(void* font, uint32_t fontLen, StripCommand strip, wchar_t errMsg[], size_t errMsgLen);
|
|
17
|
+
bool GetMemFont(void* font, uint32_t fontLen, wchar_t errMsg[], size_t errMsgLen);
|
|
18
|
+
uint32_t GetFontSize();
|
|
19
|
+
|
|
20
|
+
bool ImportSourceFromBinary(wchar_t errMsg[], size_t errMsgLen);
|
|
21
|
+
|
|
22
|
+
bool GotoFont(wchar_t errMsg[], size_t errMsgLen);
|
|
23
|
+
bool GotoGlyph(int32_t code, bool isGlyphIndex);
|
|
24
|
+
|
|
25
|
+
bool CompileTalk(int32_t* errPos, int32_t* errLen, wchar_t errMsg[], size_t errMsgLen);
|
|
26
|
+
bool CompileCommon(bool legacy, bool variationCompositeGuard, int32_t* errPos, int32_t* errLen, wchar_t errMsg[], size_t errMsgLen);
|
|
27
|
+
|
|
28
|
+
bool CompileGlyphRange(unsigned short g1, unsigned short g2, bool quiet, bool legacy, bool variationCompositeGuard, wchar_t errMsg[], size_t errMsgLen);
|
|
29
|
+
bool CompileAll(bool quiet, bool legacy, bool variationCompositeGuard, wchar_t errMsg[], size_t errMsgLen);
|
|
30
|
+
|
|
31
|
+
bool BuildFont(StripCommand strip, wchar_t errMsg[], size_t errMsgLen);
|
|
32
|
+
|
|
33
|
+
char* wCharToChar(char out[], const wchar_t in[]);
|
|
34
|
+
|
|
35
|
+
private:
|
|
36
|
+
|
|
37
|
+
std::unique_ptr<TextBuffer> glyf = nullptr, prep = nullptr, talk = nullptr, fpgm = nullptr, cpgm = nullptr;
|
|
38
|
+
short platformID = 3, encodingID = 1;
|
|
39
|
+
|
|
40
|
+
wchar_t mainFont[maxLineSize], textFont[maxLineSize];
|
|
41
|
+
|
|
42
|
+
std::unique_ptr<TrueTypeFont> font = nullptr;
|
|
43
|
+
std::unique_ptr<TrueTypeGlyph> glyph = nullptr;
|
|
44
|
+
std::string fileName;
|
|
45
|
+
int32_t charCode = 0, glyphIndex = 0;
|
|
46
|
+
};
|
|
47
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#define maxLineSize 0x100
|
|
7
|
+
|
|
8
|
+
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
|
|
9
|
+
|
|
10
|
+
#include <assert.h>
|
|
11
|
+
#include <stdint.h>
|
|
12
|
+
#include <string.h>
|
|
13
|
+
#include <stdio.h>
|
|
14
|
+
|
|
15
|
+
#include <string>
|
|
16
|
+
#include <map>
|
|
17
|
+
#include <algorithm>
|
|
18
|
+
#include <limits>
|
|
19
|
+
#include <list>
|
|
20
|
+
#include <vector>
|
|
21
|
+
#include <deque>
|
|
22
|
+
#include <climits>
|
|
23
|
+
#include <codecvt>
|
|
24
|
+
#include <locale>
|
|
25
|
+
#include <cmath>
|
|
26
|
+
|
|
27
|
+
#include "opentypedefs.h"
|
|
28
|
+
#include "Platform.h"
|
|
29
|
+
#include "FixedMath.h"
|
|
30
|
+
#include "MathUtils.h"
|
|
31
|
+
#include "List.h"
|
|
32
|
+
#include "Memory.h"
|
|
33
|
+
#include "File.h"
|
|
34
|
+
#include "TextBuffer.h"
|
|
35
|
+
#include "Variation.h"
|
|
36
|
+
#include "VariationModels.h"
|
|
37
|
+
#include "VariationInstance.h"
|
|
38
|
+
#include "TTFont.h"
|
|
39
|
+
#include "GUIDecorations.h"
|
|
40
|
+
#include "TTAssembler.h"
|
|
41
|
+
#include "TTEngine.h"
|
|
42
|
+
#include "TTGenerator.h"
|
|
43
|
+
#include "CvtManager.h"
|
|
44
|
+
#include "TMTParser.h"
|
|
45
|
+
#include "ttiua.h"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
#define STRCPYW wcscpy
|
|
49
|
+
#define STRCATW wcscat
|
|
50
|
+
#define STRLENW wcslen
|
|
51
|
+
#define STRNCPYW wcsncpy
|
|
52
|
+
#define STRSTRW wcsstr
|
|
53
|
+
#define STRCHARW wcschr
|
|
54
|
+
#define STRCMPW wcscmp
|
|
55
|
+
|
|
56
|
+
#ifndef _WIN32
|
|
57
|
+
#define wprintf_s wprintf
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
#ifndef _MSC_VER
|
|
61
|
+
/* ISO C Standard for *w*printf() */
|
|
62
|
+
#define WIDE_STR_FORMAT L"%S"
|
|
63
|
+
#define NARROW_STR_FORMAT L"%s"
|
|
64
|
+
#else
|
|
65
|
+
/* Microsoft compiler's w*printf() behavior */
|
|
66
|
+
#define WIDE_STR_FORMAT L"%s"
|
|
67
|
+
#define NARROW_STR_FORMAT L"%S"
|
|
68
|
+
#endif
|