mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
common script
This commit is contained in:
123
Common/js/make.py
Normal file
123
Common/js/make.py
Normal file
@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
sys.path.append("./../../../build_tools/scripts")
|
||||
import base
|
||||
import os
|
||||
import json
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
# fetch emsdk
|
||||
command_prefix = "" if ("windows" == base.host_platform()) else "./"
|
||||
core_path = "./../../"
|
||||
if not base.is_dir("emsdk"):
|
||||
base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"])
|
||||
os.chdir("emsdk")
|
||||
base.cmd(command_prefix + "emsdk", ["install", "latest"])
|
||||
base.cmd(command_prefix + "emsdk", ["activate", "latest"])
|
||||
os.chdir("../")
|
||||
|
||||
|
||||
def exec_wasm(data, compiler_flags, wasm):
|
||||
for include in data.include_path:
|
||||
compiler_flags.append("-I" + include)
|
||||
for define in data.define:
|
||||
compiler_flags.append("-D" + define)
|
||||
|
||||
# arguments
|
||||
arguments = ""
|
||||
for item in compiler_flags:
|
||||
arguments += (item + " ")
|
||||
|
||||
# command
|
||||
external_file = []
|
||||
prefix_call = ""
|
||||
if base.host_platform() == "windows":
|
||||
prefix_call = "call "
|
||||
external_file.append("call emsdk/emsdk_env.bat")
|
||||
else:
|
||||
external_file.append("#!/bin/bash")
|
||||
external_file.append("source ./emsdk/emsdk_env.sh")
|
||||
|
||||
libs = ""
|
||||
for compile_files in data.compile_files_array:
|
||||
base.create_dir("./o/" + compile_files.name)
|
||||
for item in compile_files.files:
|
||||
file_name = os.path.splitext(os.path.basename(item))[0]
|
||||
if not base.is_file("./o/" + compile_files.name + "/" + file_name + ".o"):
|
||||
external_file.append(prefix_call + "emcc -o o/" + compile_files.name + "/" + file_name + ".o -c " + arguments + compile_files.folder + item)
|
||||
libs += ("o/" + compile_files.name + "/" + file_name + ".o ")
|
||||
|
||||
arguments += "-s EXPORTED_FUNCTIONS=\"["
|
||||
for item in data.exported_functions:
|
||||
arguments += ("'" + item + "',")
|
||||
arguments = arguments[:-1]
|
||||
arguments += "]\" "
|
||||
|
||||
for item in data.sources:
|
||||
arguments += (item + " ")
|
||||
|
||||
external_file.append(prefix_call + "emcc -o " + data.name + ".js " + arguments + libs)
|
||||
print("run " + data.name)
|
||||
cur_dir = os.getcwd()
|
||||
os.chdir(data.work_folder)
|
||||
base.run_as_bat(external_file)
|
||||
os.chdir(cur_dir)
|
||||
|
||||
# finalize
|
||||
print("finalize " + data.name)
|
||||
module_js_content = base.readFile(command_prefix + data.name + ".js")
|
||||
engine_base_js_content = base.readFile("data.base_js_content")
|
||||
string_utf8_content = base.readFile("./string_utf8.js")
|
||||
polyfill_js_content = base.readFile("./../3dParty/hunspell/wasm/js/polyfill.js")
|
||||
engine_js_content = engine_base_js_content.replace("//module", module_js_content)
|
||||
engine_js_content = engine_js_content.replace("//string_utf8", string_utf8_content)
|
||||
engine_js_content = engine_js_content.replace("//polyfill", polyfill_js_content)
|
||||
|
||||
# write new version
|
||||
base.writeFile(core_path + data.res_folder + "/" + data.name + ("" if wasm else "_ie") + ".js", engine_js_content)
|
||||
base.copy_file("./" + data.name + (".wasm" if wasm else ".js.mem"), core_path + data.res_folder + "/" + data.name + (".wasm" if wasm else ".js.mem"))
|
||||
|
||||
# clear
|
||||
base.delete_file("./" + data.name + ".js")
|
||||
base.delete_file("./" + data.name + ".wasm")
|
||||
base.delete_file("./" + data.name + ".js.mem")
|
||||
|
||||
|
||||
argv = sys.argv
|
||||
argv.pop(0)
|
||||
for param in argv:
|
||||
print(param)
|
||||
with open(param, "r") as json_file:
|
||||
json_data = json.load(json_file)
|
||||
json_file.close()
|
||||
|
||||
print("before " + json_data.run_before)
|
||||
base.cmd_in_dir(core_path + json_data.work_folder, "python", [json_data.run_before])
|
||||
|
||||
print(json_data.name)
|
||||
# remove previous version
|
||||
if base.is_dir("./deploy"):
|
||||
base.delete_dir("./deploy")
|
||||
base.create_dir("./deploy")
|
||||
if base.is_dir("./o"):
|
||||
base.delete_dir("./o")
|
||||
base.create_dir("./o")
|
||||
if base.is_dir(core_path + json_data.res_folder):
|
||||
base.delete_dir(core_path + json_data.res_folder)
|
||||
base.create_dir(core_path + json_data.res_folder)
|
||||
|
||||
# wasm or asm
|
||||
if json_data.wasm:
|
||||
flags = json_data.compiler_flags
|
||||
flags.append("-s WASM=1")
|
||||
exec_wasm(json_data, flags, True)
|
||||
if json_data.asm:
|
||||
flags = json_data.compiler_flags
|
||||
flags.append("-s WASM=0")
|
||||
exec_wasm(json_data, flags, False)
|
||||
|
||||
print("after " + json_data.run_after)
|
||||
base.cmd_in_dir(core_path + json_data.work_folder, "python", [json_data.run_after])
|
||||
18
DesktopEditor/graphics/pro/js/after.py
Normal file
18
DesktopEditor/graphics/pro/js/after.py
Normal file
@ -0,0 +1,18 @@
|
||||
import sys
|
||||
sys.path.append("../../../../../build_tools/scripts")
|
||||
import base
|
||||
import os
|
||||
import json
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;", "\n{\n UDataMemory tData;")
|
||||
|
||||
# finalize
|
||||
base.replaceInFile("./drawingfile.js", "function getBinaryPromise()", "function getBinaryPromise2()")
|
||||
base.replaceInFile("./drawingfile.js", "__ATPOSTRUN__=[];", "__ATPOSTRUN__=[function(){window[\"AscViewer\"] && window[\"AscViewer\"][\"onLoadModule\"] && window[\"AscViewer\"][\"onLoadModule\"]();}];")
|
||||
base.replaceInFile("./drawingfile.js", "__ATPOSTRUN__ = [];", "__ATPOSTRUN__=[function(){window[\"AscViewer\"] && window[\"AscViewer\"][\"onLoadModule\"] && window[\"AscViewer\"][\"onLoadModule\"]();}];")
|
||||
base.replaceInFile("./drawingfile.js", "\"drawingfile.js.mem\"", "getMemoryPathIE(\"drawingfile.js.mem\")")
|
||||
|
||||
base.delete_dir("./xml")
|
||||
base.delete_dir("./freetype-2.10.4")
|
||||
45
DesktopEditor/graphics/pro/js/before.py
Normal file
45
DesktopEditor/graphics/pro/js/before.py
Normal file
@ -0,0 +1,45 @@
|
||||
import sys
|
||||
sys.path.append("../../../../../build_tools/scripts")
|
||||
import base
|
||||
import os
|
||||
import json
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
def apply_patch(file, patch):
|
||||
file_content = base.readFile(file)
|
||||
patch_content = base.readFile(patch)
|
||||
index1 = patch_content.find("<<<<<<<")
|
||||
index2 = patch_content.find("=======")
|
||||
index3 = patch_content.find(">>>>>>>")
|
||||
file_content_old = patch_content[index1 + 7:index2]
|
||||
file_content_new = "\n#if 0" + file_content_old + "#else" + patch_content[index2 + 7:index3] + "#endif\n"
|
||||
base.replaceInFile(file, file_content_old, file_content_new)
|
||||
return
|
||||
|
||||
if not base.is_dir("xml"):
|
||||
base.copy_dir("../../../xml", "./xml")
|
||||
base.replaceInFile("./xml/libxml2/libxml.h", "xmlNop(void)", "xmlNop(void* context, char* buffer, int len)")
|
||||
base.replaceInFile("./xml/libxml2/xmlIO.c", "xmlNop(void)", "xmlNop(void* context, char* buffer, int len)")
|
||||
base.replaceInFile("./xml/src/xmllight_private.h", "#include \"../../common/", "#include \"../../../../../common/")
|
||||
base.replaceInFile("./xml/include/xmlutils.h", "#include \"../../common/", "#include \"../../../../../common/")
|
||||
|
||||
if not base.is_dir("freetype-2.10.4"):
|
||||
base.copy_dir("../../../freetype-2.10.4", "./freetype-2.10.4")
|
||||
# smooth
|
||||
base.copy_file("./freetype-2.10.4/src/smooth/ftgrays.c", "./freetype-2.10.4/src/smooth/ftgrays.cpp");
|
||||
apply_patch("./freetype-2.10.4/src/smooth/ftgrays.cpp", "./wasm/patches/ftgrays1.patch")
|
||||
apply_patch("./freetype-2.10.4/src/smooth/ftgrays.cpp", "./wasm/patches/ftgrays2.patch")
|
||||
apply_patch("./freetype-2.10.4/src/smooth/ftgrays.cpp", "./wasm/patches/ftgrays3.patch")
|
||||
base.copy_file("./freetype-2.10.4/src/smooth/smooth.c", "./freetype-2.10.4/src/smooth/smooth.cpp");
|
||||
apply_patch("./freetype-2.10.4/src/smooth/smooth.cpp", "./wasm/patches/smooth.patch")
|
||||
# ftobjs
|
||||
apply_patch("./freetype-2.10.4/src/base/ftobjs.c", "./wasm/patches/ftobjs1.patch")
|
||||
apply_patch("./freetype-2.10.4/src/base/ftobjs.c", "./wasm/patches/ftobjs2.patch")
|
||||
# ttcmap
|
||||
base.copy_file("./freetype-2.10.4/src/sfnt/ttcmap.c", "./freetype-2.10.4/src/sfnt/ttcmap.cpp");
|
||||
apply_patch("./freetype-2.10.4/src/sfnt/ttcmap.cpp", "./wasm/patches/ttcmap.patch")
|
||||
base.copy_file("./freetype-2.10.4/src/sfnt/sfnt.c", "./freetype-2.10.4/src/sfnt/sfnt.cpp");
|
||||
apply_patch("./freetype-2.10.4/src/sfnt/sfnt.cpp", "./wasm/patches/sfnt.patch")
|
||||
|
||||
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n UDataMemory tData;", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;")
|
||||
182
DesktopEditor/graphics/pro/js/drawingfile.json
Normal file
182
DesktopEditor/graphics/pro/js/drawingfile.json
Normal file
@ -0,0 +1,182 @@
|
||||
{
|
||||
"name": "drawingfile",
|
||||
"work_folder": "./DesktopEditor/graphics/pro/js",
|
||||
"res_folder": "./DesktopEditor/graphics/pro/js/deploy",
|
||||
"wasm": true,
|
||||
"asm": true,
|
||||
"run_before": "before.py",
|
||||
"run_after": "after.py",
|
||||
"base_js_content": "./wasm/js/drawingfile_base.js",
|
||||
|
||||
"compiler_flags": [
|
||||
"-O3",
|
||||
"-fexceptions",
|
||||
"-Wno-unused-command-line-argument",
|
||||
"-s WASM=1",
|
||||
"-s ALLOW_MEMORY_GROWTH=1",
|
||||
"-s FILESYSTEM=0",
|
||||
"-s ENVIRONMENT='web'",
|
||||
"-s LLD_REPORT_UNDEFINED"
|
||||
],
|
||||
"exported_functions": [
|
||||
"_malloc",
|
||||
"_free",
|
||||
"_GetType",
|
||||
"_Open",
|
||||
"_Close",
|
||||
"_GetErrorCode",
|
||||
"_GetInfo",
|
||||
"_GetPixmap",
|
||||
"_GetGlyphs",
|
||||
"_GetLinks",
|
||||
"_GetStructure",
|
||||
"_InitializeFontsBin",
|
||||
"_InitializeFontsBase64",
|
||||
"_SetFontBinary",
|
||||
"_IsFontBinaryExist"
|
||||
],
|
||||
"include_path": [
|
||||
"wasm/src/lib", "../../../agg-2.4/include", "../../../cximage/jasper/include", "../../../cximage/jpeg", "../../../cximage/png", "freetype-2.10.4/include", "freetype-2.10.4/include/freetype", "../../../../OfficeUtils/src/zlib-1.2.11", "../../../../Common/3dParty/icu/icu/source/common", "../../../xml/libxml2/include", "../../../xml/build/qt", "../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip", "../../../../PdfReader/lib/goo", "../../../../PdfReader/lib/fofi", "../../../../PdfReader/lib/splash", "../../../../PdfReader/lib"
|
||||
],
|
||||
"define": [
|
||||
"__linux__", "_LINUX", "UNIX", "FT2_BUILD_LIBRARY", "HAVE_FCNTL_H", "FT_CONFIG_OPTION_SYSTEM_ZLIB", "BUILDING_WASM_MODULE", "U_COMMON_IMPLEMENTATION", "errno=0", "THREADMODEL=0", "DEBUGLVL=0", "HAVE_MBSTATE_T", "HAVE_STDINCLUDES", "HAS_WCHAR", "HAVE_VA_COPY", "LIBXML_READER_ENABLED", "LIBXML_PUSH_ENABLED", "LIBXML_HTML_ENABLED", "LIBXML_XPATH_ENABLED", "LIBXML_OUTPUT_ENABLED", "LIBXML_C14N_ENABLED", "LIBXML_SAX1_ENABLED", "LIBXML_TREE_ENABLED", "LIBXML_XPTR_ENABLED", "IN_LIBXML", "LIBXML_STATIC", "BUILD_ZLIB_AS_SOURCES", "DISABLE_PDF_CONVERTATION", "_ARM_ALIGN_", "_tcsnicmp=strncmp", "_lseek=lseek", "_getcwd=getcwd", "NO_CONSOLE_IO"
|
||||
],
|
||||
"compile_files_array": [
|
||||
{
|
||||
"name": "r"
|
||||
"folder": "../../../raster/",
|
||||
"files": ["BgraFrame.cpp", "ImageFileFormatChecker.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "ci"
|
||||
"folder": "../../../cximage/CxImage/",
|
||||
"files": ["ximaenc.cpp", "ximaexif.cpp", "ximage.cpp", "ximainfo.cpp", "ximajpg.cpp", "ximalpha.cpp", "ximapal.cpp", "ximasel.cpp", "xmemfile.cpp", "ximapng.cpp", "ximabmp.cpp", "ximatran.cpp", "ximatif.cpp", "tif_xfile.cpp", "ximajas.cpp", "ximagif.cpp", "ximaico.cpp", "ximatga.cpp", "ximapcx.cpp", "ximawbmp.cpp", "ximamng.cpp", "ximapsd.cpp", "ximaska.cpp", "ximaraw.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "j"
|
||||
"folder": "../../../cximage/jpeg/",
|
||||
"files": ["jerror.c", "jdmarker.c", "jdapimin.c", "jdmaster.c", "jdapistd.c", "jcomapi.c", "jutils.c", "jdinput.c", "jdmainct.c", "jmemmgr.c", "jquant1.c", "jquant2.c", "jdmerge.c", "jdcolor.c", "jdsample.c", "jdpostct.c", "jddctmgr.c", "jdarith.c", "jdhuff.c", "jdcoefct.c", "jmemnobs.c", "jidctint.c", "jidctfst.c", "jidctflt.c", "jaricom.c", "jcapimin.c", "jcparam.c", "jcapistd.c", "jcinit.c", "jcmaster.c", "jccolor.c", "jcmarker.c", "jcsample.c", "jcprepct.c", "jcdctmgr.c", "jcarith.c", "jchuff.c", "jccoefct.c", "jcmainct.c", "jfdctint.c", "jfdctfst.c", "jfdctflt.c"]
|
||||
},
|
||||
{
|
||||
"name": "p"
|
||||
"folder": "../../../cximage/png/",
|
||||
"files": ["pngread.c", "pngmem.c", "pngerror.c", "png.c", "pngrio.c", "pngtrans.c", "pngget.c", "pngrutil.c", "pngrtran.c", "pngset.c", "pngwrite.c", "pngwio.c", "pngwutil.c", "pngwtran.c"]
|
||||
},
|
||||
{
|
||||
"name": "t"
|
||||
"folder": "../../../cximage/tiff/",
|
||||
"files": ["tif_close.c", "tif_dir.c", "tif_aux.c", "tif_getimage.c", "tif_strip.c", "tif_open.c", "tif_tile.c", "tif_error.c", "tif_read.c", "tif_flush.c", "tif_dirinfo.c", "tif_compress.c", "tif_warning.c", "tif_swab.c", "tif_color.c", "tif_dirread.c", "tif_write.c", "tif_codec.c", "tif_luv.c", "tif_dirwrite.c", "tif_dumpmode.c", "tif_fax3.c", "tif_ojpeg.c", "tif_jpeg.c", "tif_next.c", "tif_thunder.c", "tif_packbits.c", "tif_lzw.c", "tif_zip.c", "tif_fax3sm.c", "tif_predict.c"]
|
||||
},
|
||||
{
|
||||
"name": "ja"
|
||||
"folder": "../../../cximage/jasper/",
|
||||
"files": ["base/jas_init.c", "base/jas_stream.c", "base/jas_malloc.c", "base/jas_image.c", "base/jas_cm.c", "base/jas_seq.c", "base/jas_string.c", "base/jas_icc.c", "base/jas_debug.c", "base/jas_iccdata.c", "base/jas_tvp.c", "base/jas_version.c", "mif/mif_cod.c", "pnm/pnm_dec.c", "pnm/pnm_enc.c", "pnm/pnm_cod.c", "bmp/bmp_dec.c", "bmp/bmp_enc.c", "bmp/bmp_cod.c", "ras/ras_dec.c", "ras/ras_enc.c", "jp2/jp2_dec.c", "jp2/jp2_enc.c", "jp2/jp2_cod.c", "jpc/jpc_cs.c", "jpc/jpc_enc.c", "jpc/jpc_dec.c", "jpc/jpc_t1cod.c", "jpc/jpc_math.c", "jpc/jpc_util.c", "jpc/jpc_tsfb.c", "jpc/jpc_mct.c", "jpc/jpc_t1enc.c", "jpc/jpc_t1dec.c", "jpc/jpc_bs.c", "jpc/jpc_t2cod.c", "jpc/jpc_t2enc.c", "jpc/jpc_t2dec.c", "jpc/jpc_tagtree.c", "jpc/jpc_mqenc.c", "jpc/jpc_mqdec.c", "jpc/jpc_mqcod.c", "jpc/jpc_qmfb.c", "jpg/jpg_val.c", "jpg/jpg_dummy.c", "pgx/pgx_dec.c", "pgx/pgx_enc.c"]
|
||||
},
|
||||
{
|
||||
"name": "jp"
|
||||
"folder": "../../../raster/Jp2/",
|
||||
"files": ["J2kFile.cpp", "Reader.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "m"
|
||||
"folder": "../../../cximage/mng/",
|
||||
"files": ["libmng_hlapi.c", "libmng_callback_xs.c", "libmng_prop_xs.c", "libmng_object_prc.c", "libmng_zlib.c", "libmng_jpeg.c", "libmng_pixels.c", "libmng_read.c", "libmng_error.c", "libmng_display.c", "libmng_write.c", "libmng_chunk_io.c", "libmng_cms.c", "libmng_filter.c", "libmng_chunk_prc.c", "libmng_chunk_xs.c"]
|
||||
},
|
||||
{
|
||||
"name": "lp"
|
||||
"folder": "../../../cximage/libpsd/",
|
||||
"files": ["psd.c", "file_header.c", "color_mode.c", "image_resource.c", "blend.c", "layer_mask.c", "image_data.c", "stream.c", "psd_system.c", "color.c", "pattern_fill.c", "color_balance.c", "channel_image.c", "gradient_fill.c", "invert.c", "posterize.c", "brightness_contrast.c", "solid_color.c", "threshold.c", "effects.c", "selective_color.c", "channel_mixer.c", "photo_filter.c", "type_tool.c", "gradient_map.c", "hue_saturation.c", "levels.c", "curves.c", "pattern.c", "psd_zip.c", "descriptor.c", "drop_shadow.c", "inner_shadow.c", "color_overlay.c", "outer_glow.c", "inner_glow.c", "bevel_emboss.c", "satin.c", "gradient_overlay.c", "stroke.c", "pattern_overlay.c"]
|
||||
},
|
||||
{
|
||||
"name": "ra"
|
||||
"folder": "../../../cximage/raw/",
|
||||
"files": ["libdcr.c"]
|
||||
},
|
||||
{
|
||||
"name": "jb"
|
||||
"folder": "../../../raster/JBig2/source/",
|
||||
"files": ["JBig2File.cpp", "Encoder/jbig2enc.cpp", "Encoder/jbig2arith.cpp", "Encoder/jbig2sym.cpp", "LeptonLib/pixconv.cpp", "LeptonLib/writefile.cpp", "LeptonLib/scale.cpp", "LeptonLib/pix1.cpp", "LeptonLib/pix2.cpp", "LeptonLib/pix3.cpp", "LeptonLib/pix4.cpp", "LeptonLib/pix5.cpp", "LeptonLib/grayquant.cpp", "LeptonLib/grayquantlow.cpp", "LeptonLib/seedfill.cpp", "LeptonLib/jbclass.cpp", "LeptonLib/pixabasic.cpp", "LeptonLib/numabasic.cpp", "LeptonLib/morphseq.cpp", "LeptonLib/binexpandlow.cpp", "LeptonLib/ptabasic.cpp", "LeptonLib/rop.cpp", "LeptonLib/colormap.cpp", "LeptonLib/pngiostub.cpp", "LeptonLib/lepton_utils.cpp", "LeptonLib/scalelow.cpp", "LeptonLib/enhance.cpp", "LeptonLib/jpegio.cpp", "LeptonLib/jpegiostub.cpp", "LeptonLib/spixio.cpp", "LeptonLib/webpio.cpp", "LeptonLib/webpiostub.cpp", "LeptonLib/psio2.cpp", "LeptonLib/gifio.cpp", "LeptonLib/gifiostub.cpp", "LeptonLib/pnmio.cpp", "LeptonLib/tiffio.cpp", "LeptonLib/tiffiostub.cpp", "LeptonLib/bmpio.cpp", "LeptonLib/binexpand.cpp", "LeptonLib/compare.cpp", "LeptonLib/boxbasic.cpp", "LeptonLib/conncomp.cpp", "LeptonLib/pixafunc1.cpp", "LeptonLib/boxfunc1.cpp", "LeptonLib/ptafunc1.cpp", "LeptonLib/binreduce.cpp", "LeptonLib/seedfilllow.cpp", "LeptonLib/sel1.cpp", "LeptonLib/morphapp.cpp", "LeptonLib/correlscore.cpp", "LeptonLib/sarray.cpp", "LeptonLib/morph.cpp", "LeptonLib/roplow.cpp", "LeptonLib/fpix1.cpp", "LeptonLib/stack.cpp", "LeptonLib/pixacc.cpp", "LeptonLib/pixarith.cpp", "LeptonLib/convolve.cpp", "LeptonLib/binreducelow.cpp", "LeptonLib/convolvelow.cpp", "LeptonLib/arithlow.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "lib"
|
||||
"folder": "./",
|
||||
"files": ["wasm/src/lib/wasm_jmp.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "f"
|
||||
"folder": "freetype-2.10.4/src/",
|
||||
"files": ["base/ftdebug.c","autofit/autofit.c","bdf/bdf.c","cff/cff.c","base/ftbase.c","base/ftbitmap.c","base/ftfstype.c","base/ftgasp.c","cache/ftcache.c","base/ftglyph.c","gzip/ftgzip.c","base/ftinit.c","lzw/ftlzw.c","base/ftstroke.c","base/ftsystem.c","smooth/smooth.cpp","base/ftbbox.c","base/ftbdf.c","base/ftcid.c","base/ftmm.c","base/ftpfr.c","base/ftsynth.c","base/fttype1.c","base/ftwinfnt.c","base/ftgxval.c","base/ftotval.c","base/ftpatent.c","pcf/pcf.c","pfr/pfr.c","psaux/psaux.c","pshinter/pshinter.c","psnames/psmodule.c","raster/raster.c","sfnt/sfnt.cpp","truetype/truetype.c","type1/type1.c","cid/type1cid.c","type42/type42.c","winfonts/winfnt.c"]
|
||||
},
|
||||
{
|
||||
"name": "g"
|
||||
"folder": "../../",
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "fe"
|
||||
"folder": "../../../fontengine/",
|
||||
"files": ["GlyphString.cpp", "FontManager.cpp", "FontFile.cpp", "FontPath.cpp", "ApplicationFonts.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "a"
|
||||
"folder": "../../../agg-2.4/src/",
|
||||
"files": ["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "c"
|
||||
"folder": "../../../common/",
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "i"
|
||||
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
|
||||
"files": ["ucnv.c", "ustr_wcs.cpp", "ucnv_err.c", "ucnv_bld.cpp", "ustrtrns.cpp", "ucnv_cb.c", "udata.cpp", "ucnv_io.cpp", "uhash.c", "udatamem.c", "cmemory.c", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucnvlat1.c", "ucnv_u16.c", "ucnv_u8.c", "ucnv_u32.c", "ucnv_u7.c", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnv_lmb.c", "ucnvhz.c", "ucnvscsu.c", "ucnvisci.c", "ucnvbocu.cpp", "ucnv_ct.c", "ucnv_cnv.c", "stringpiece.cpp", "charstr.cpp", "umapfile.c", "ucmndata.c", "ucnv_ext.cpp", "uobject.cpp", "umath.c", "ubidi_props.c", "uchar.c", "uinvchar.c", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "utf_impl.c", "ustrcase.cpp", "cstring.c", "bytestrie.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "o"
|
||||
"folder": "../../../../OfficeUtils/src/",
|
||||
"files": ["OfficeUtils.cpp", "ZipBuffer.cpp", "ZipUtilsCP.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "m"
|
||||
"folder": "../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip/",
|
||||
"files": ["ioapi.c", "miniunz.c", "minizip.c", "mztools.c", "unzip.c", "zip.c", "ioapibuf.c"]
|
||||
},
|
||||
{
|
||||
"name": "z"
|
||||
"folder": "../../../../OfficeUtils/src/zlib-1.2.11/",
|
||||
"files": ["adler32.c", "crc32.c", "deflate.c", "infback.c", "inffast.c", "inflate.c", "inftrees.c", "trees.c", "zutil.c", "compress.c"]
|
||||
},
|
||||
{
|
||||
"name": "x"
|
||||
"folder": "./",
|
||||
"files": ["xml/src/xmllight.cpp", "xml/src/xmldom.cpp", "xml/build/qt/libxml2_all.c", "xml/build/qt/libxml2_all2.c"]
|
||||
},
|
||||
{
|
||||
"name": "p"
|
||||
"folder": "../../../../PdfReader/",
|
||||
"files": ["PdfReader.cpp", "Src/Adaptors.cpp", "Src/GfxClip.cpp", "Src/RendererOutputDev.cpp", "lib/fofi/FofiBase.cc", "lib/fofi/FofiEncodings.cc", "lib/fofi/FofiIdentifier.cc", "lib/fofi/FofiTrueType.cc", "lib/fofi/FofiType1.cc", "lib/fofi/FofiType1C.cc", "lib/goo/FixedPoint.cc", "lib/goo/gfile.cc", "lib/goo/GHash.cc", "lib/goo/GList.cc", "lib/goo/gmem.cc", "lib/goo/gmempp.cc", "lib/goo/GString.cc", "lib/goo/parseargs.c", "lib/goo/Trace.cc", "lib/splash/Splash.cc", "lib/splash/SplashBitmap.cc", "lib/splash/SplashClip.cc", "lib/splash/SplashFont.cc", "lib/splash/SplashFontEngine.cc", "lib/splash/SplashFontFile.cc", "lib/splash/SplashFontFileID.cc", "lib/splash/SplashFTFont.cc", "lib/splash/SplashFTFontEngine.cc", "lib/splash/SplashFTFontFile.cc", "lib/splash/SplashPath.cc", "lib/splash/SplashPattern.cc", "lib/splash/SplashScreen.cc", "lib/splash/SplashState.cc", "lib/splash/SplashXPath.cc", "lib/splash/SplashXPathScanner.cc", "lib/xpdf/AcroForm.cc", "lib/xpdf/Annot.cc", "lib/xpdf/Array.cc", "lib/xpdf/BuiltinFont.cc", "lib/xpdf/BuiltinFontTables.cc", "lib/xpdf/Catalog.cc", "lib/xpdf/CharCodeToUnicode.cc", "lib/xpdf/CMap.cc", "lib/xpdf/Decrypt.cc", "lib/xpdf/Dict.cc", "lib/xpdf/DisplayState.cc", "lib/xpdf/Error.cc", "lib/xpdf/FontEncodingTables.cc", "lib/xpdf/Function.cc", "lib/xpdf/Gfx.cc", "lib/xpdf/GfxFont.cc", "lib/xpdf/GfxState.cc", "lib/xpdf/GlobalParams.cc", "lib/xpdf/ImageOutputDev.cc", "lib/xpdf/JArithmeticDecoder.cc", "lib/xpdf/JBIG2Stream.cc", "lib/xpdf/JPXStream.cc", "lib/xpdf/Lexer.cc", "lib/xpdf/Link.cc", "lib/xpdf/NameToCharCode.cc", "lib/xpdf/Object.cc", "lib/xpdf/OptionalContent.cc", "lib/xpdf/Outline.cc", "lib/xpdf/OutputDev.cc", "lib/xpdf/Page.cc", "lib/xpdf/Parser.cc", "lib/xpdf/PDF417Barcode.cc", "lib/xpdf/PDFCore.cc", "lib/xpdf/PDFDoc.cc", "lib/xpdf/PDFDocEncoding.cc", "lib/xpdf/PreScanOutputDev.cc", "lib/xpdf/PSOutputDev.cc", "lib/xpdf/PSTokenizer.cc", "lib/xpdf/SecurityHandler.cc", "lib/xpdf/ShadingImage.cc", "lib/xpdf/SplashOutputDev.cc", "lib/xpdf/Stream.cc", "lib/xpdf/TextOutputDev.cc", "lib/xpdf/TextString.cc", "lib/xpdf/TileCache.cc", "lib/xpdf/TileCompositor.cc", "lib/xpdf/TileMap.cc", "lib/xpdf/UnicodeMap.cc", "lib/xpdf/UnicodeRemapping.cc", "lib/xpdf/UnicodeTypeTable.cc", "lib/xpdf/UTF8.cc", "lib/xpdf/WebFont.cc", "lib/xpdf/XFAScanner.cc", "lib/xpdf/XRef.cc", "lib/xpdf/Zoox.cc"]
|
||||
},
|
||||
{
|
||||
"name": "x"
|
||||
"folder": "../../../../XpsFile/",
|
||||
"files": ["XpsFile.cpp", "XpsLib/Document.cpp", "XpsLib/XpsPage.cpp", "XpsLib/StaticResources.cpp", "XpsLib/Utils.cpp", "XpsLib/WString.cpp", "XpsLib/ContextState.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "d"
|
||||
"folder": "../../../../DjVuFile/libdjvu/",
|
||||
"files": ["../DjVu.cpp", "../DjVuFileImplementation.cpp", "Arrays.cpp", "BSByteStream.cpp", "BSEncodeByteStream.cpp", "ByteStream.cpp", "DataPool.cpp", "debug.cpp", "DjVmDir.cpp", "DjVmDir0.cpp", "DjVmDoc.cpp", "DjVmNav.cpp", "DjVuAnno.cpp", "DjVuDocEditor.cpp", "DjVuDocument.cpp", "DjVuDumpHelper.cpp", "DjVuErrorList.cpp", "DjVuFile.cpp", "DjVuFileCache.cpp", "DjVuGlobal.cpp", "DjVuGlobalMemory.cpp", "DjVuImage.cpp", "DjVuInfo.cpp", "DjVuMessageLite.cpp", "DjVuNavDir.cpp", "DjVuPalette.cpp", "DjVuPort.cpp", "DjVuText.cpp", "DjVuToPS.cpp", "GBitmap.cpp", "GContainer.cpp", "GException.cpp", "GIFFManager.cpp", "GMapAreas.cpp", "GPixmap.cpp", "GRect.cpp", "GScaler.cpp", "GSmartPointer.cpp", "DjVuGString.cpp", "GThreads.cpp", "GUnicode.cpp", "IFFByteStream.cpp", "IW44EncodeCodec.cpp", "IW44Image.cpp", "JB2EncodeCodec.cpp", "JB2Image.cpp", "JPEGDecoder.cpp", "MMRDecoder.cpp", "MMX.cpp", "UnicodeByteStream.cpp", "XMLParser.cpp", "XMLTags.cpp", "ZPCodec.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "d"
|
||||
"folder": "../../../../DjVuFile/wasm/libdjvu/",
|
||||
"files": ["atomic.cpp", "DjVuMessage.cpp", "GOS.cpp", "GURL.cpp"]
|
||||
},
|
||||
{
|
||||
"name": "u"
|
||||
"folder": "../../../../UnicodeConverter/",
|
||||
"files": ["UnicodeConverter.cpp"]
|
||||
}
|
||||
],
|
||||
"sources": ["raster.o", "wasm/src/drawingfile.cpp", "wasm/src/metafile.cpp"]
|
||||
}
|
||||
@ -508,11 +508,13 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
|
||||
// m_pInternal->m_oWriter.WriteText(pTempUnicodes, (const int*)pGids, nTempUnicodesLen, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
bool bIsDumpFont = false;
|
||||
double dFontSize;
|
||||
std::wstring sCurrentFontName; double dFontSize;
|
||||
m_pRenderer->get_FontName(&sCurrentFontName);
|
||||
m_pRenderer->get_FontSize(&dFontSize);
|
||||
if (m_lCurrentFont || (dFontSize != m_dCurrentFontSize))
|
||||
int nCurrentFont = 0;
|
||||
if ((nCurrentFont != m_lCurrentFont) || (dFontSize != m_dCurrentFontSize))
|
||||
{
|
||||
m_lCurrentFont = 0;
|
||||
m_lCurrentFont = nCurrentFont;
|
||||
m_dCurrentFontSize = dFontSize;
|
||||
bIsDumpFont = true;
|
||||
}
|
||||
@ -523,11 +525,44 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
double _y1 = y;
|
||||
double _x2 = x + 1;
|
||||
double _y2 = y;
|
||||
double sx, shy, shx, sy, tx, ty, tmp;
|
||||
m_pRenderer->GetTransform(&sx, ­, &shx, &sy, &tx, &ty);
|
||||
// m_pTransform->TransformPoint(_x1, _y1);
|
||||
tmp = _x1;
|
||||
_x1 = tmp * sx + _y1 * shx + tx;
|
||||
_y1 = tmp * shy + _y1 * sy + ty;
|
||||
// m_pTransform->TransformPoint(_x2, _y2);
|
||||
tmp = _x2;
|
||||
_x2 = tmp * sx + _y2 * shx + tx;
|
||||
_y2 = tmp * shy + _y2 * sy + ty;
|
||||
|
||||
double _k = 0;
|
||||
double _b = 0;
|
||||
bool _isConstX = false;
|
||||
if (fabs(_x1 - _x2) < 0.001)
|
||||
{
|
||||
_isConstX = true;
|
||||
_b = _x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_k = (_y1 - _y2) / (_x1 - _x2);
|
||||
_b = _y1 - _k * _x1;
|
||||
}
|
||||
|
||||
double dAbsVec = sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
|
||||
if (dAbsVec == 0)
|
||||
dAbsVec = 1;
|
||||
|
||||
LONG nCountChars = m_oLine.GetCountChars();
|
||||
bool bIsNewLine = 0 == nCountChars;
|
||||
bool bIsNewLine = true;
|
||||
if (0 != nCountChars)
|
||||
{
|
||||
if (_isConstX && m_oLine.m_bIsConstX && fabs(_b - m_oLine.m_dB) < 0.001)
|
||||
bIsNewLine = false;
|
||||
else if (!_isConstX && !m_oLine.m_bIsConstX && fabs(_k - m_oLine.m_dK) < 0.001 && fabs(_b - m_oLine.m_dB) < 0.001)
|
||||
bIsNewLine = false;
|
||||
}
|
||||
if (bIsNewLine && (nCountChars != 0))
|
||||
{
|
||||
// не совпала baseline. поэтому просто скидываем линию в поток
|
||||
@ -539,13 +574,15 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
double dOffsetX = 0;
|
||||
if (nCountChars == 0)
|
||||
{
|
||||
m_oLine.m_bIsConstX = false;
|
||||
m_oLine.m_bIsConstX = _isConstX;
|
||||
m_oLine.m_dK = _k;
|
||||
m_oLine.m_dB = _b;
|
||||
|
||||
m_oLine.m_dX = _x1;
|
||||
m_oLine.m_dY = _y1;
|
||||
|
||||
m_oLine.m_ex = _x2 - _x1;
|
||||
m_oLine.m_ey = _y2 - _y1;
|
||||
m_oLine.m_ex = (_x2 - _x1) / dAbsVec;
|
||||
m_oLine.m_ey = (_y2 - _y1) / dAbsVec;
|
||||
|
||||
m_oLine.m_dEndX = _x1;
|
||||
m_oLine.m_dEndY = _y1;
|
||||
@ -583,13 +620,16 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
// предварительно сбросив старую
|
||||
DumpLine();
|
||||
|
||||
m_oLine.m_bIsConstX = false;
|
||||
m_oLine.m_bIsConstX = _isConstX;
|
||||
|
||||
m_oLine.m_dX = _x1;
|
||||
m_oLine.m_dY = _y1;
|
||||
|
||||
m_oLine.m_ex = _x2 - _x1;
|
||||
m_oLine.m_ey = _y2 - _y1;
|
||||
m_oLine.m_dK = _k;
|
||||
m_oLine.m_dB = _b;
|
||||
|
||||
m_oLine.m_ex = (_x2 - _x1) / dAbsVec;
|
||||
m_oLine.m_ey = (_y2 - _y1) / dAbsVec;
|
||||
}
|
||||
|
||||
m_oLine.m_dEndX = _x1;
|
||||
@ -597,14 +637,16 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
}
|
||||
|
||||
// смотрим, совпадает ли главная часть матрицы.
|
||||
bool bIsTransform = !(fabs(m_pLastTransform.sx() - 1.0) < 0.001 &&
|
||||
fabs(m_pLastTransform.sy() - 1.0) < 0.001 &&
|
||||
fabs(m_pLastTransform.shx()) < 0.001 &&
|
||||
fabs(m_pLastTransform.shy()) < 0.001);
|
||||
bool bIsTransform = !(fabs(m_pLastTransform.sx() - sx) < 0.001 &&
|
||||
fabs(m_pLastTransform.sy() - sy) < 0.001 &&
|
||||
fabs(m_pLastTransform.shx() - shx) < 0.001 &&
|
||||
fabs(m_pLastTransform.shy() - shy) < 0.001);
|
||||
if (bIsTransform)
|
||||
bIsDumpFont = true;
|
||||
|
||||
LONG nColor1 = 0, nAlpha1 = 255;
|
||||
LONG nColor1, nAlpha1;
|
||||
m_pRenderer->get_BrushColor1(&nColor1);
|
||||
m_pRenderer->get_BrushAlpha1(&nAlpha1);
|
||||
bool bIsColor = ((nColor1 != m_nLastBrushColor1) || (nAlpha1 != m_nLastBrushAlpha1));
|
||||
|
||||
BYTE nLenMetaCommands = 0;
|
||||
@ -619,10 +661,10 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
|
||||
double _dumpSize = dFontSize;
|
||||
double _dumpMtx[4];
|
||||
_dumpMtx[0] = 1.0;
|
||||
_dumpMtx[1] = 0.0;
|
||||
_dumpMtx[2] = 0.0;
|
||||
_dumpMtx[3] = 1.0;
|
||||
_dumpMtx[0] = sx;
|
||||
_dumpMtx[1] = shy;
|
||||
_dumpMtx[2] = shx;
|
||||
_dumpMtx[3] = sy;
|
||||
|
||||
double dTextScale = std::min(sqrt(_dumpMtx[2] * _dumpMtx[2] + _dumpMtx[3] * _dumpMtx[3]),
|
||||
sqrt(_dumpMtx[0] * _dumpMtx[0] + _dumpMtx[1] * _dumpMtx[1]));
|
||||
@ -639,20 +681,23 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
|
||||
if (bIsDumpFont)
|
||||
{
|
||||
LONG nFontStyle;
|
||||
m_pRenderer->get_FontStyle(&nFontStyle);
|
||||
|
||||
m_oMeta.WriteBYTE(41); // CMetafile::ctFontName
|
||||
m_oMeta.AddInt(0); // nCurrentFont
|
||||
m_oMeta.AddInt(0); // get_FontStyle
|
||||
m_oMeta.AddInt(nCurrentFont);
|
||||
m_oMeta.AddInt(nFontStyle);
|
||||
m_oMeta.WriteDouble(_dumpSize);
|
||||
}
|
||||
if (bIsTransform)
|
||||
{
|
||||
m_pLastTransform.SetElements(1.0, 0.0, 0.0, 1.0);
|
||||
m_pLastTransform.SetElements(sx, shy, shx, sy);
|
||||
|
||||
m_oLine.m_bIsSetUpTransform = true;
|
||||
m_oLine.m_sx = 1.0;
|
||||
m_oLine.m_shx = 0.0;
|
||||
m_oLine.m_shy = 0.0;
|
||||
m_oLine.m_sy = 1.0;
|
||||
m_oLine.m_sx = sx;
|
||||
m_oLine.m_shx = shx;
|
||||
m_oLine.m_shy = shy;
|
||||
m_oLine.m_sy = sy;
|
||||
|
||||
m_oMeta.WriteBYTE(161); // CMetafile::ctCommandTextTransform
|
||||
m_oMeta.WriteDouble(_dumpMtx[0]);
|
||||
@ -678,13 +723,13 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
// все, baseline установлен. теперь просто продолжаем линию
|
||||
if (bIsDumpFont)
|
||||
{
|
||||
m_pFontManager->LoadFontFromFile(L"DjvuEmptyFont", 0, dFontSize, 72.0, 72.0);
|
||||
m_pFontManager->LoadFontFromFile(sCurrentFontName, 0, dFontSize, 72.0, 72.0);
|
||||
m_pFontManager->AfterLoad();
|
||||
}
|
||||
|
||||
double dKoef = dFontSize * 25.4 / (72 * abs(m_pFontManager->GetUnitsPerEm()));
|
||||
double dAscender = abs(m_pFontManager->GetAscender()) * dKoef;
|
||||
double dDescender = abs(m_pFontManager->GetDescender()) * dKoef;
|
||||
double dAscender = abs(m_pFontManager->GetAscender()) * dKoef * dAbsVec;
|
||||
double dDescender = abs(m_pFontManager->GetDescender()) * dKoef * dAbsVec;
|
||||
|
||||
if (m_oLine.m_dAscent < dAscender)
|
||||
m_oLine.m_dAscent = dAscender;
|
||||
@ -720,7 +765,7 @@ void CDjVuFileImplementation::GetGlyphs(IRenderer* m_pRenderer, co
|
||||
dPlusOffset += dOffsetX;
|
||||
dOffsetX = dBoxW;
|
||||
|
||||
pChar->width = dBoxW;
|
||||
pChar->width = dBoxW * dAbsVec;
|
||||
|
||||
if (i != 0)
|
||||
m_oMeta.WriteBYTE(0);
|
||||
|
||||
Reference in New Issue
Block a user