├── .appveyor.yml ├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ └── c-cpp.yml ├── .gitignore ├── .hgignore ├── .hgtags ├── AUTHORS ├── COPYING ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── README.md ├── configure.ac ├── doc ├── Makefile.am ├── conf-dblatex-man.xsl ├── conf-dblatex-pdf.xsl ├── dvisvgm.1 ├── dvisvgm.txt.in ├── generate-dvisvgm-sty.xsl ├── tweak-db-article.xsl ├── tweak-db-refentry.xsl ├── tweak-dblatex-pdf.xsl └── tweak-dblatex-tex.py ├── libs ├── Makefile.am ├── boost │ ├── LICENSE.txt │ ├── Makefile.am │ ├── boost-vectorstream.hpp │ └── vectorstream.hpp ├── brotli │ ├── LICENSE │ ├── Makefile.am │ ├── common │ │ ├── constants.c │ │ ├── constants.h │ │ ├── context.c │ │ ├── context.h │ │ ├── dictionary.c │ │ ├── dictionary.h │ │ ├── platform.c │ │ ├── platform.h │ │ ├── shared_dictionary_internal.h │ │ ├── transform.c │ │ ├── transform.h │ │ └── version.h │ ├── enc │ │ ├── backward_references.c │ │ ├── backward_references.h │ │ ├── backward_references_hq.c │ │ ├── backward_references_hq.h │ │ ├── backward_references_inc.h │ │ ├── bit_cost.c │ │ ├── bit_cost.h │ │ ├── bit_cost_inc.h │ │ ├── block_encoder_inc.h │ │ ├── block_splitter.c │ │ ├── block_splitter.h │ │ ├── block_splitter_inc.h │ │ ├── brotli_bit_stream.c │ │ ├── brotli_bit_stream.h │ │ ├── cluster.c │ │ ├── cluster.h │ │ ├── cluster_inc.h │ │ ├── command.c │ │ ├── command.h │ │ ├── compound_dictionary.c │ │ ├── compound_dictionary.h │ │ ├── compress_fragment.c │ │ ├── compress_fragment.h │ │ ├── compress_fragment_two_pass.c │ │ ├── compress_fragment_two_pass.h │ │ ├── dictionary_hash.c │ │ ├── dictionary_hash.h │ │ ├── encode.c │ │ ├── encoder_dict.c │ │ ├── encoder_dict.h │ │ ├── entropy_encode.c │ │ ├── entropy_encode.h │ │ ├── entropy_encode_static.h │ │ ├── fast_log.c │ │ ├── fast_log.h │ │ ├── find_match_length.h │ │ ├── hash.h │ │ ├── hash_composite_inc.h │ │ ├── hash_forgetful_chain_inc.h │ │ ├── hash_longest_match64_inc.h │ │ ├── hash_longest_match_inc.h │ │ ├── hash_longest_match_quickly_inc.h │ │ ├── hash_rolling_inc.h │ │ ├── hash_to_binary_tree_inc.h │ │ ├── histogram.c │ │ ├── histogram.h │ │ ├── histogram_inc.h │ │ ├── literal_cost.c │ │ ├── literal_cost.h │ │ ├── memory.c │ │ ├── memory.h │ │ ├── metablock.c │ │ ├── metablock.h │ │ ├── metablock_inc.h │ │ ├── params.h │ │ ├── prefix.h │ │ ├── quality.h │ │ ├── ringbuffer.h │ │ ├── state.h │ │ ├── static_dict.c │ │ ├── static_dict.h │ │ ├── static_dict_lut.h │ │ ├── utf8_util.c │ │ ├── utf8_util.h │ │ └── write_bits.h │ └── include │ │ └── brotli │ │ ├── decode.h │ │ ├── encode.h │ │ ├── port.h │ │ ├── shared_dictionary.h │ │ └── types.h ├── clipper │ ├── License.txt │ ├── Makefile.am │ ├── clipper.cpp │ └── clipper.hpp ├── defs.am ├── md5 │ ├── Makefile.am │ ├── md5.c │ └── md5.h ├── potrace │ ├── Makefile.am │ ├── auxiliary.h │ ├── bitmap.h │ ├── config.h │ ├── curve.c │ ├── curve.h │ ├── decompose.c │ ├── decompose.h │ ├── lists.h │ ├── potracelib.c │ ├── potracelib.h │ ├── progress.h │ ├── trace.c │ └── trace.h ├── variant │ ├── LICENSE.md │ ├── Makefile.am │ └── include │ │ └── mpark │ │ └── variant.hpp ├── woff2 │ ├── LICENSE │ ├── Makefile.am │ ├── include │ │ └── woff2 │ │ │ ├── decode.h │ │ │ ├── encode.h │ │ │ ├── output.h │ │ │ └── version.h │ └── src │ │ ├── buffer.h │ │ ├── font.cc │ │ ├── font.h │ │ ├── glyph.cc │ │ ├── glyph.h │ │ ├── normalize.cc │ │ ├── normalize.h │ │ ├── port.h │ │ ├── round.h │ │ ├── store_bytes.h │ │ ├── table_tags.cc │ │ ├── table_tags.h │ │ ├── transform.cc │ │ ├── transform.h │ │ ├── variable_length.cc │ │ ├── variable_length.h │ │ ├── woff2_common.cc │ │ ├── woff2_common.h │ │ ├── woff2_enc.cc │ │ └── woff2_out.cc └── xxHash │ ├── LICENSE │ ├── Makefile.am │ ├── xxh3.h │ ├── xxhash.c │ └── xxhash.h ├── m4 ├── ax_ac_append_to_file.m4 ├── ax_ac_print_to_file.m4 ├── ax_add_am_macro_static.m4 ├── ax_am_macros_static.m4 ├── ax_check_compile_flag.m4 ├── ax_code_coverage.m4 ├── ax_cxx_compile_stdcxx.m4 ├── ax_file_escapes.m4 └── ax_gcc_builtin.m4 ├── src ├── AGLTable.hpp ├── BasicDVIReader.cpp ├── BasicDVIReader.hpp ├── Bezier.cpp ├── Bezier.hpp ├── BgColorSpecialHandler.cpp ├── BgColorSpecialHandler.hpp ├── Bitmap.cpp ├── Bitmap.hpp ├── BoundingBox.cpp ├── BoundingBox.hpp ├── CLCommandLine.cpp ├── CLCommandLine.hpp ├── CLOption.hpp ├── CMap.cpp ├── CMap.hpp ├── CMapManager.cpp ├── CMapManager.hpp ├── CMapReader.cpp ├── CMapReader.hpp ├── Calculator.cpp ├── Calculator.hpp ├── CharMapID.cpp ├── CharMapID.hpp ├── Character.hpp ├── Color.cpp ├── Color.hpp ├── ColorSpecialHandler.cpp ├── ColorSpecialHandler.hpp ├── CommandLine.hpp ├── DLLoader.cpp ├── DLLoader.hpp ├── DVIActions.hpp ├── DVIReader.cpp ├── DVIReader.hpp ├── DVIToSVG.cpp ├── DVIToSVG.hpp ├── DVIToSVGActions.cpp ├── DVIToSVGActions.hpp ├── Directory.cpp ├── Directory.hpp ├── Doxyfile ├── DvisvgmSpecialHandler.cpp ├── DvisvgmSpecialHandler.hpp ├── EPSFile.cpp ├── EPSFile.hpp ├── EPSToSVG.hpp ├── EllipticalArc.cpp ├── EllipticalArc.hpp ├── EmSpecialHandler.cpp ├── EmSpecialHandler.hpp ├── EncFile.cpp ├── EncFile.hpp ├── FileFinder.cpp ├── FileFinder.hpp ├── FilePath.cpp ├── FilePath.hpp ├── FileSystem.cpp ├── FileSystem.hpp ├── FixWord.hpp ├── Font.cpp ├── Font.hpp ├── FontCache.cpp ├── FontCache.hpp ├── FontEncoding.cpp ├── FontEncoding.hpp ├── FontEngine.cpp ├── FontEngine.hpp ├── FontManager.cpp ├── FontManager.hpp ├── FontMap.cpp ├── FontMap.hpp ├── FontMetrics.cpp ├── FontMetrics.hpp ├── FontStyle.hpp ├── FontWriter.cpp ├── FontWriter.hpp ├── GFGlyphTracer.cpp ├── GFGlyphTracer.hpp ├── GFReader.cpp ├── GFReader.hpp ├── GFTracer.cpp ├── GFTracer.hpp ├── Ghostscript.cpp ├── Ghostscript.hpp ├── Glyph.hpp ├── GlyphTracerMessages.hpp ├── GraphicsPath.hpp ├── GraphicsPathParser.hpp ├── HashFunction.cpp ├── HashFunction.hpp ├── HtmlSpecialHandler.cpp ├── HtmlSpecialHandler.hpp ├── HyperlinkManager.cpp ├── HyperlinkManager.hpp ├── ImageToSVG.cpp ├── ImageToSVG.hpp ├── InputBuffer.cpp ├── InputBuffer.hpp ├── InputReader.cpp ├── InputReader.hpp ├── JFM.cpp ├── JFM.hpp ├── Length.cpp ├── Length.hpp ├── MD5HashFunction.hpp ├── Makefile.am ├── MapLine.cpp ├── MapLine.hpp ├── Matrix.cpp ├── Matrix.hpp ├── Message.cpp ├── Message.hpp ├── MessageException.hpp ├── MetafontWrapper.cpp ├── MetafontWrapper.hpp ├── MiKTeXCom.cpp ├── MiKTeXCom.hpp ├── NoPsSpecialHandler.cpp ├── NoPsSpecialHandler.hpp ├── NumericRanges.hpp ├── OFM.cpp ├── OFM.hpp ├── Opacity.cpp ├── Opacity.hpp ├── PDFHandler.cpp ├── PDFHandler.hpp ├── PDFParser.cpp ├── PDFParser.hpp ├── PDFToSVG.cpp ├── PDFToSVG.hpp ├── PSInterpreter.cpp ├── PSInterpreter.hpp ├── PSPattern.cpp ├── PSPattern.hpp ├── PSPreviewHandler.cpp ├── PSPreviewHandler.hpp ├── PageRanges.cpp ├── PageRanges.hpp ├── PageSize.cpp ├── PageSize.hpp ├── Pair.hpp ├── PapersizeSpecialHandler.cpp ├── PapersizeSpecialHandler.hpp ├── PathClipper.cpp ├── PathClipper.hpp ├── PdfSpecialHandler.cpp ├── PdfSpecialHandler.hpp ├── PreScanDVIReader.cpp ├── PreScanDVIReader.hpp ├── Process.cpp ├── Process.hpp ├── PsSpecialHandler.cpp ├── PsSpecialHandler.hpp ├── PsSpecialHandlerProxy.cpp ├── PsSpecialHandlerProxy.hpp ├── RangeMap.cpp ├── RangeMap.hpp ├── SVGCharHandler.cpp ├── SVGCharHandler.hpp ├── SVGCharHandlerFactory.cpp ├── SVGCharHandlerFactory.hpp ├── SVGCharPathHandler.cpp ├── SVGCharPathHandler.hpp ├── SVGCharTspanTextHandler.cpp ├── SVGCharTspanTextHandler.hpp ├── SVGElement.cpp ├── SVGElement.hpp ├── SVGOutput.cpp ├── SVGOutput.hpp ├── SVGSingleCharTextHandler.cpp ├── SVGSingleCharTextHandler.hpp ├── SVGTree.cpp ├── SVGTree.hpp ├── ShadingPatch.cpp ├── ShadingPatch.hpp ├── SignalHandler.cpp ├── SignalHandler.hpp ├── SourceInput.cpp ├── SourceInput.hpp ├── SpecialActions.cpp ├── SpecialActions.hpp ├── SpecialHandler.hpp ├── SpecialManager.cpp ├── SpecialManager.hpp ├── StreamReader.cpp ├── StreamReader.hpp ├── StreamWriter.cpp ├── StreamWriter.hpp ├── Subfont.cpp ├── Subfont.hpp ├── System.cpp ├── System.hpp ├── TFM.cpp ├── TFM.hpp ├── TensorProductPatch.cpp ├── TensorProductPatch.hpp ├── Terminal.cpp ├── Terminal.hpp ├── ToUnicodeMap.cpp ├── ToUnicodeMap.hpp ├── TpicSpecialHandler.cpp ├── TpicSpecialHandler.hpp ├── TriangularPatch.cpp ├── TriangularPatch.hpp ├── Unicode.cpp ├── Unicode.hpp ├── VFActions.hpp ├── VFReader.cpp ├── VFReader.hpp ├── VectorIterator.hpp ├── XMLDocument.cpp ├── XMLDocument.hpp ├── XMLNode.cpp ├── XMLNode.hpp ├── XMLParser.cpp ├── XMLParser.hpp ├── XMLString.cpp ├── XMLString.hpp ├── XXHashFunction.hpp ├── ZLibOutputStream.hpp ├── algorithm.hpp ├── dvisvgm.cpp ├── fonts │ ├── Base14Fonts.cpp │ ├── Base14Fonts.hpp │ ├── Dingbats.cff.cpp │ ├── Makefile.am │ ├── NimbusMonoPS-Bold.cff.cpp │ ├── NimbusMonoPS-BoldItalic.cff.cpp │ ├── NimbusMonoPS-Italic.cff.cpp │ ├── NimbusMonoPS-Regular.cff.cpp │ ├── NimbusRoman-Bold.cff.cpp │ ├── NimbusRoman-BoldItalic.cff.cpp │ ├── NimbusRoman-Italic.cff.cpp │ ├── NimbusRoman-Regular.cff.cpp │ ├── NimbusSans-Bold.cff.cpp │ ├── NimbusSans-BoldItalic.cff.cpp │ ├── NimbusSans-Italic.cff.cpp │ ├── NimbusSans-Regular.cff.cpp │ └── StandardSymbolsPS.cff.cpp ├── iapi.h ├── ierrors.h ├── macros.hpp ├── opt2cpp.py ├── optimizer │ ├── AttributeExtractor.cpp │ ├── AttributeExtractor.hpp │ ├── ClipPathReassigner.cpp │ ├── ClipPathReassigner.hpp │ ├── DependencyGraph.hpp │ ├── GroupCollapser.cpp │ ├── GroupCollapser.hpp │ ├── Makefile.am │ ├── OptimizerModule.hpp │ ├── RedundantElementRemover.cpp │ ├── RedundantElementRemover.hpp │ ├── SVGOptimizer.cpp │ ├── SVGOptimizer.hpp │ ├── TextSimplifier.cpp │ ├── TextSimplifier.hpp │ ├── TransformSimplifier.cpp │ ├── TransformSimplifier.hpp │ ├── WSNodeRemover.cpp │ └── WSNodeRemover.hpp ├── options.dtd ├── options.xml ├── psdefs.cpp ├── ttf │ ├── CmapTable.cpp │ ├── CmapTable.hpp │ ├── GlyfTable.cpp │ ├── GlyfTable.hpp │ ├── HeadTable.cpp │ ├── HeadTable.hpp │ ├── HheaTable.cpp │ ├── HheaTable.hpp │ ├── HmtxTable.cpp │ ├── HmtxTable.hpp │ ├── LocaTable.hpp │ ├── Makefile.am │ ├── MaxpTable.cpp │ ├── MaxpTable.hpp │ ├── NameTable.cpp │ ├── NameTable.hpp │ ├── OS2Table.cpp │ ├── OS2Table.hpp │ ├── PostTable.cpp │ ├── PostTable.hpp │ ├── TTFAutohint.cpp │ ├── TTFAutohint.hpp │ ├── TTFTable.cpp │ ├── TTFTable.hpp │ ├── TTFWriter.cpp │ ├── TTFWriter.hpp │ ├── VheaTable.cpp │ ├── VheaTable.hpp │ ├── VmtxTable.cpp │ └── VmtxTable.hpp ├── utility.cpp ├── utility.hpp ├── version.hpp ├── version.hpp.in └── windows.hpp ├── tests ├── BezierTest.cpp ├── BitmapTest.cpp ├── BoundingBoxTest.cpp ├── CMapManagerTest.cpp ├── CMapReaderTest.cpp ├── CMapTest.cpp ├── CalculatorTest.cpp ├── ColorSpecialTest.cpp ├── ColorTest.cpp ├── CommandLineTest.cpp ├── DVIReaderTest.cpp ├── DependencyGraphTest.cpp ├── DirectoryTest.cpp ├── DvisvgmSpecialTest.cpp ├── EllipticalArcTest.cpp ├── EmSpecialTest.cpp ├── FileFinderTest.cpp ├── FilePathTest.cpp ├── FileSystemTest.cpp ├── FontCacheTest.cpp ├── FontManagerTest.cpp ├── FontMapTest.cpp ├── GFGlyphTracerTest.cpp ├── GFReaderTest.cpp ├── GhostscriptTest.cpp ├── GraphicsPathParserTest.cpp ├── GraphicsPathTest.cpp ├── HashFunctionTest.cpp ├── JFMReaderTest.cpp ├── LengthTest.cpp ├── Makefile.am ├── MapLineTest.cpp ├── MatrixTest.cpp ├── MessageExceptionTest.cpp ├── NumericRangesTest.cpp ├── OFMReaderTest.cpp ├── PDFParserTest.cpp ├── PSInterpreterTest.cpp ├── PageRagesTest.cpp ├── PageSizeTest.cpp ├── PairTest.cpp ├── PapersizeSpecialTest.cpp ├── RangeMapTest.cpp ├── SVGOutputTest.cpp ├── ShadingPatchTest.cpp ├── SpecialManagerTest.cpp ├── SplittedCharInputBufferTest.cpp ├── StreamInputBufferTest.cpp ├── StreamReaderTest.cpp ├── StreamWriterTest.cpp ├── StringMatcherTest.cpp ├── SubfontTest.cpp ├── TFMReaderTest.cpp ├── TensorProductPatchTest.cpp ├── ToUnicodeMapTest.cpp ├── TpicSpecialTest.cpp ├── TriangularPatchTest.cpp ├── UnicodeTest.cpp ├── UtilityTest.cpp ├── VectorIteratorTest.cpp ├── XMLNodeTest.cpp ├── XMLStringTest.cpp ├── check-conv ├── create-makefile ├── data │ ├── Makefile.am │ ├── cidjmgr0-h.tfm │ ├── cmr10.600gf │ ├── cmr10.pfb │ ├── cmr10.tfm │ ├── dvipdfm_test.map │ ├── dvips_test.map │ ├── frktest-nf-cmp.svg │ ├── frktest-wf-cmp.svg │ ├── frktest.dvi │ ├── lmmono12-regular.otf │ ├── omarab.ofm │ ├── ot1.cmap │ ├── sample-nf-cmp.svg │ ├── sample-wf-cmp.svg │ ├── sample.dvi │ ├── sample.sfd │ ├── sample_v2.dvi │ ├── sample_v3.dvi │ └── upjf-g.ofm ├── genhashcheck.py ├── gtest │ ├── LICENSE │ ├── include │ │ └── gtest │ │ │ ├── gtest-assertion-result.h │ │ │ ├── gtest-death-test.h │ │ │ ├── gtest-matchers.h │ │ │ ├── gtest-message.h │ │ │ ├── gtest-param-test.h │ │ │ ├── gtest-printers.h │ │ │ ├── gtest-spi.h │ │ │ ├── gtest-test-part.h │ │ │ ├── gtest-typed-test.h │ │ │ ├── gtest.h │ │ │ ├── gtest_pred_impl.h │ │ │ ├── gtest_prod.h │ │ │ └── internal │ │ │ ├── custom │ │ │ ├── gtest-port.h │ │ │ ├── gtest-printers.h │ │ │ └── gtest.h │ │ │ ├── gtest-death-test-internal.h │ │ │ ├── gtest-filepath.h │ │ │ ├── gtest-internal.h │ │ │ ├── gtest-linked_ptr.h │ │ │ ├── gtest-param-util-generated.h │ │ │ ├── gtest-param-util.h │ │ │ ├── gtest-port-arch.h │ │ │ ├── gtest-port.h │ │ │ ├── gtest-string.h │ │ │ ├── gtest-tuple.h │ │ │ └── gtest-type-util.h │ └── src │ │ ├── gtest-all.cc │ │ ├── gtest-assertion-result.cc │ │ ├── gtest-death-test.cc │ │ ├── gtest-filepath.cc │ │ ├── gtest-internal-inl.h │ │ ├── gtest-matchers.cc │ │ ├── gtest-port.cc │ │ ├── gtest-printers.cc │ │ ├── gtest-test-part.cc │ │ ├── gtest-typed-test.cc │ │ ├── gtest.cc │ │ └── gtest_main.cc ├── normalize.xsl ├── testmain.cpp └── testutil.hpp └── vc ├── README ├── brotli ├── brotli.vcxproj └── brotli.vcxproj.filters ├── clipper ├── clipper.vcxproj └── clipper.vcxproj.filters ├── config.h ├── dvisvgm.rc ├── dvisvgm.sln ├── dvisvgm.vcxproj ├── dvisvgm.vcxproj.filters ├── freetype ├── freetype.vcxproj └── freetype.vcxproj.filters ├── md5 ├── md5.vcxproj └── md5.vcxproj.filters ├── miktex-com ├── miktex-com.vcxproj ├── miktex-com.vcxproj.filters ├── miktex-session.idl └── miktexidl.idl ├── potrace ├── libpotrace.vcxproj └── libpotrace.vcxproj.filters ├── woff2 ├── woff2.vcxproj └── woff2.vcxproj.filters ├── xxHash ├── xxhash.vcxproj └── xxhash.vcxproj.filters └── zlib ├── zlib.vcxproj └── zlib.vcxproj.filters /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 3.5-{build} 2 | configuration: Release 3 | 4 | image: Visual Studio 2022 5 | 6 | platform: 7 | - x64 8 | - Win32 9 | 10 | branches: 11 | except: 12 | - tmp 13 | 14 | install: 15 | - set FREETYPE_VER=2.13.2 16 | - set ZLIB_VER=1.3.1 17 | - set TTFA_VER=1.8.4 18 | - set TTFA_REV=1 19 | - cd vc 20 | - cd freetype 21 | - appveyor DownloadFile http://download.savannah.gnu.org/releases/freetype/freetype-%FREETYPE_VER%.tar.gz 22 | - tar xzf freetype-%FREETYPE_VER%.tar.gz --strip-components=1 23 | - del freetype-%FREETYPE_VER%.tar.gz 24 | - cd ..\zlib 25 | - appveyor DownloadFile http://zlib.net/zlib-%ZLIB_VER%.tar.gz 26 | - tar xzf zlib-%ZLIB_VER%.tar.gz --strip-components=1 27 | - del zlib-%ZLIB_VER%.tar.gz 28 | - cd .. 29 | - appveyor DownloadFile https://github.com/mgieseki/ttfautohint-dll/releases/download/r%TTFA_VER%-%TTFA_REV%/ttfautohint-%TTFA_VER%-dll64.zip 30 | - unzip -o -d ttfautohint ttfautohint-%TTFA_VER%-dll64.zip 31 | - del ttfautohint-%TTFA_VER%-dll64.zip 32 | 33 | build: 34 | project: vc\dvisvgm.sln 35 | verbosity: minimal 36 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | doc/dvisvgm.* linguist-documentation 2 | libs/** linguist-vendored 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: mgieseking 10 | issuehunt: mgieseki 11 | otechie: # Replace with a single Otechie username 12 | custom: https://www.paypal.me/mgieseking 13 | -------------------------------------------------------------------------------- /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: update packages 17 | run: sudo apt-get update 18 | - name: install dependencies 19 | run: > 20 | sudo apt-get install -qq autotools-dev autoconf-archive pkg-config 21 | libkpathsea-dev libfreetype6-dev libgs-dev libz-dev texlive-base 22 | python-is-python3 python3-lxml asciidoc xmlto xsltproc 23 | - name: autogen 24 | run: autoreconf -fi 25 | - name: configure 26 | run: ./configure --enable-bundled-libs 27 | - name: make clean 28 | run: make clean 29 | - name: make 30 | run: make -j 31 | - name: update timestamps 32 | run: make -C src -t 33 | - name: make check 34 | run: make -j check 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | *.a 3 | *.la 4 | *.o 5 | *.lo 6 | *.Po 7 | *.pyc 8 | *.obj 9 | *.dvi 10 | *.gch 11 | *.gcda 12 | *.gcno 13 | *.lib 14 | *.log 15 | *.lpro 16 | *.ncb 17 | *.tex 18 | *.svg 19 | *.svgz 20 | *.aux 21 | *.orig 22 | *.toc 23 | *.tar.* 24 | *.tgz 25 | *.trs 26 | *.zip 27 | *.swp 28 | *.exe 29 | *.tlog 30 | *.pdb 31 | *.png 32 | *.pdf 33 | *.tmp 34 | *.lastbuildstate 35 | *.opensdf 36 | *.vcxproj.user 37 | *.patch 38 | build 39 | callgrind.* 40 | cmdline.* 41 | Makefile 42 | Makefile.in 43 | autom4te.* 44 | dvisvgm 45 | aclocal.* 46 | aminclude_static.am 47 | ar-lib 48 | compile 49 | libtool 50 | ltmain.sh 51 | missing 52 | cov-int 53 | lcov 54 | /config.* 55 | doc/buildman 56 | doc/dvisvgm.txt 57 | doc/dvisvgm*.xml 58 | doc/dvisvgm.html 59 | doc/dvisvgm.sty 60 | doc/update-revdate 61 | doc/dvisvgm.1 62 | m4/libtool.m4 63 | m4/lt*.m4 64 | doxy 65 | backup/* 66 | Win32 67 | x64 68 | Debug 69 | Release 70 | vc/miktex-com/dlldata.c 71 | vc/*.s* 72 | vc/_* 73 | vc/Upgrade* 74 | configure 75 | configure~ 76 | depcomp 77 | install-sh 78 | src/samples 79 | src/psdefs.psc 80 | src/CommandLine.* 81 | test-driver 82 | tests/hashcheck* 83 | tests/*Test 84 | svg2vml 85 | nbproject 86 | stamp-h1 87 | a.out 88 | test*.* 89 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | *.a 3 | *.la 4 | *.o 5 | *.lo 6 | *.Po 7 | *.pyc 8 | *.obj 9 | *.dvi 10 | *.gch 11 | *.gcda 12 | *.gcno 13 | *.lib 14 | *.log 15 | *.lpro 16 | *.ncb 17 | *.tex 18 | *.svg 19 | *.svgz 20 | *.aux 21 | *.orig 22 | *.toc 23 | *.tar.* 24 | *.zip 25 | *.swp 26 | *.exe 27 | *.vcxproj.user 28 | .deps 29 | .dirstamp 30 | callgrind.* 31 | cmdline.* 32 | Makefile 33 | Makefile.in 34 | autom4te.* 35 | dvisvgm 36 | aclocal.* 37 | missing 38 | ./config.* 39 | doc/buildman 40 | doc/dvisvgm.txt 41 | doc/dvisvgm*.xml 42 | doc/dvisvgm.html 43 | doc/dvisvgm.1 44 | doc/*.pdf 45 | m4/libtool.m4 46 | m4/lt*.m4 47 | doxy 48 | Debug 49 | Release 50 | Win32 51 | x64 52 | vc/freetype 53 | vc/miktex-2.9.4106-sdk 54 | vc/zlib* 55 | vc/*.s* 56 | vc/_* 57 | vc/Upgrade* 58 | ar-lib 59 | compile 60 | configure 61 | depcomp 62 | install-sh 63 | libtool 64 | ltmain.sh 65 | src/CommandLine.* 66 | test-driver 67 | tests/hashcheck* 68 | tests/*Test 69 | nbproject 70 | stamp-h1 71 | a.out 72 | test*.* 73 | lcov 74 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Martin Gieseking 2 | author of dvisvgm 3 | 4 | Yann Collet 5 | libs/xxHash/xxhash.* 6 | https://github.com/Cyan4973/xxHash 7 | 8 | Google Inc. 9 | libs/brotli/* 10 | libs/woff2/* 11 | https://github.com/google/brotli 12 | https://github.com/google/woff2 13 | 14 | Angus Johnson 15 | libs/clipper/clipper.* 16 | https://sourceforge.net/projects/polyclipping/ 17 | 18 | Michael Park 19 | libs/variant/include/mpark/* 20 | https://github.com/mpark/variant 21 | 22 | Alexander Peslyak 23 | libs/md5/* 24 | 25 | Peter Selinger 26 | libs/potrace/* 27 | https://potrace.sourceforge.net 28 | 29 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## This file is part of dvisvgm 2 | ## Copyright (C) 2005-2025 Martin Gieseking 3 | ## 4 | ## Process this file with automake. 5 | 6 | include $(top_srcdir)/aminclude_static.am 7 | 8 | AUTOMAKE_OPTIONS = foreign 9 | EXTRA_DIST = COPYING 10 | SUBDIRS = libs src 11 | if !TEXLIVE_BUILD 12 | SUBDIRS += tests doc 13 | endif 14 | ACLOCAL_AMFLAGS = -I m4 15 | 16 | if USE_BUNDLED_LIBS 17 | AM_DISTCHECK_CONFIGURE_FLAGS = --enable-bundled-libs 18 | endif 19 | 20 | if CODE_COVERAGE_ENABLED 21 | lcov_dir=$(top_builddir)/lcov 22 | lcov_file=$(lcov_dir)/lcov.info 23 | 24 | lcov-report: 25 | @mkdir -p $(lcov_dir) 26 | lcov --capture --directory . --no-external -o $(lcov_file) 27 | genhtml --title "dvisvgm" --num-spaces 2 --legend -o $(lcov_dir) $(lcov_file) 28 | 29 | lcov-clean: 30 | @rm -rf $(lcov_dir) 31 | @find . -name "*.gcda" -exec rm {} \; 32 | lcov --zerocounters --directory . 33 | 34 | coverage: lcov-clean check lcov-report 35 | endif 36 | -------------------------------------------------------------------------------- /doc/conf-dblatex-man.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | \fB 8 | 9 | \fR 10 | 11 | 12 | 13 | 14 | 15 | (\m[blue] 16 | 17 | \m[]) 18 | 19 | 20 | 21 | 22 | 23 | 24 | x 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /doc/generate-dvisvgm-sty.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | % This is a generated file -- don't modify it manually. 6 | \NeedsTeXFormat{LaTeX2e} 7 | \ProvidesPackage{dvisvgm}[2015/02/04 dvisvgm DocBook style] 8 | \RequirePackageWithOptions{docbook} 9 | \RequirePackage[english]{babel} 10 | \RequirePackage[shortcuts]{extdash} 11 | \RequirePackage{underscore} 12 | \renewcommand*{\arraystretch}{-0.4} 13 | \AtBeginDocument{% 14 | \thispagestyle{empty} 15 | \lhead[]{\refmiscinfomanual} 16 | \rhead[]{\thepage} 17 | \lfoot[]{\refmiscinfosource{} \refmiscinfoversion} 18 | \rfoot[]{} % revision date given in dvisvgm.txt.in 19 | \def\tableofcontents{\stdtoc} % keep TOC on current page 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/tweak-db-article.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | dvisvgm {VERSION} Manual 16 | A fast DVI to SVG converter 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /doc/tweak-db-refentry.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 | -------------------------------------------------------------------------------- /doc/tweak-dblatex-pdf.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Synopsis 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/tweak-dblatex-tex.py: -------------------------------------------------------------------------------- 1 | import re 2 | import os 3 | 4 | def main (latex_file, stdout): 5 | latex_file_old = latex_file+"-old" 6 | os.rename(latex_file, latex_file_old) 7 | os.remove(os.path.splitext(latex_file)[0]+".pdf") 8 | with open(latex_file, "w") as outfile: 9 | with open(latex_file_old) as infile: 10 | lines = infile.readlines() 11 | for line in lines: 12 | if re.match(r'(.*\\def)|(.*\\href)', line) == None: 13 | line = re.sub(r'([a-zA-Z0-9]+)/', r'\1\\slash{}', line) 14 | line = re.sub(r'-{}-{}', r'\=/\=/', line) 15 | line = re.sub(r'([^a-zA-Z0-9])-{}', r'\1\=/', line) 16 | print(line.rstrip(), file=outfile) 17 | os.remove(latex_file_old) 18 | return 0 19 | -------------------------------------------------------------------------------- /libs/Makefile.am: -------------------------------------------------------------------------------- 1 | ## This file is part of dvisvgm 2 | ## Copyright (C) 2005-2025 Martin Gieseking 3 | ## 4 | ## Process this file with automake. 5 | 6 | SUBDIRS = boost clipper md5 variant xxHash 7 | 8 | if !TEXLIVE_BUILD 9 | SUBDIRS += potrace 10 | endif 11 | 12 | if ENABLE_WOFF 13 | SUBDIRS += brotli woff2 14 | endif 15 | -------------------------------------------------------------------------------- /libs/boost/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /libs/boost/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_HEADERS = \ 2 | boost-vectorstream.hpp \ 3 | vectorstream.hpp 4 | 5 | EXTRA_DIST = LICENSE.txt 6 | -------------------------------------------------------------------------------- /libs/boost/vectorstream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef BOOST_OVERRIDE 4 | #define BOOST_OVERRIDE override 5 | #endif 6 | 7 | #ifndef BOOST_ASSERT 8 | #define BOOST_ASSERT(expr) 9 | #endif 10 | 11 | #include "boost-vectorstream.hpp" 12 | 13 | template 14 | using ovectorstream = boost::interprocess::basic_ovectorstream>; 15 | 16 | template 17 | using ivectorstream = boost::interprocess::basic_ivectorstream>; 18 | -------------------------------------------------------------------------------- /libs/brotli/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /libs/brotli/common/constants.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | #include "constants.h" 8 | 9 | const BrotliPrefixCodeRange 10 | _kBrotliPrefixCodeRanges[BROTLI_NUM_BLOCK_LEN_SYMBOLS] = { 11 | {1, 2}, {5, 2}, {9, 2}, {13, 2}, {17, 3}, {25, 3}, 12 | {33, 3}, {41, 3}, {49, 4}, {65, 4}, {81, 4}, {97, 4}, 13 | {113, 5}, {145, 5}, {177, 5}, {209, 5}, {241, 6}, {305, 6}, 14 | {369, 7}, {497, 8}, {753, 9}, {1265, 10}, {2289, 11}, {4337, 12}, 15 | {8433, 13}, {16625, 24}}; 16 | -------------------------------------------------------------------------------- /libs/brotli/common/dictionary.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Collection of static dictionary words. */ 8 | 9 | #ifndef BROTLI_COMMON_DICTIONARY_H_ 10 | #define BROTLI_COMMON_DICTIONARY_H_ 11 | 12 | #include 13 | #include 14 | 15 | #if defined(__cplusplus) || defined(c_plusplus) 16 | extern "C" { 17 | #endif 18 | 19 | typedef struct BrotliDictionary { 20 | /** 21 | * Number of bits to encode index of dictionary word in a bucket. 22 | * 23 | * Specification: Appendix A. Static Dictionary Data 24 | * 25 | * Words in a dictionary are bucketed by length. 26 | * @c 0 means that there are no words of a given length. 27 | * Dictionary consists of words with length of [4..24] bytes. 28 | * Values at [0..3] and [25..31] indices should not be addressed. 29 | */ 30 | uint8_t size_bits_by_length[32]; 31 | 32 | /* assert(offset[i + 1] == offset[i] + (bits[i] ? (i << bits[i]) : 0)) */ 33 | uint32_t offsets_by_length[32]; 34 | 35 | /* assert(data_size == offsets_by_length[31]) */ 36 | size_t data_size; 37 | 38 | /* Data array is not bound, and should obey to size_bits_by_length values. 39 | Specified size matches default (RFC 7932) dictionary. Its size is 40 | defined by data_size */ 41 | const uint8_t* data; 42 | } BrotliDictionary; 43 | 44 | BROTLI_COMMON_API const BrotliDictionary* BrotliGetDictionary(void); 45 | 46 | /** 47 | * Sets dictionary data. 48 | * 49 | * When dictionary data is already set / present, this method is no-op. 50 | * 51 | * Dictionary data MUST be provided before BrotliGetDictionary is invoked. 52 | * This method is used ONLY in multi-client environment (e.g. C + Java), 53 | * to reduce storage by sharing single dictionary between implementations. 54 | */ 55 | BROTLI_COMMON_API void BrotliSetDictionaryData(const uint8_t* data); 56 | 57 | #define BROTLI_MIN_DICTIONARY_WORD_LENGTH 4 58 | #define BROTLI_MAX_DICTIONARY_WORD_LENGTH 24 59 | 60 | #if defined(__cplusplus) || defined(c_plusplus) 61 | } /* extern "C" */ 62 | #endif 63 | 64 | #endif /* BROTLI_COMMON_DICTIONARY_H_ */ 65 | -------------------------------------------------------------------------------- /libs/brotli/common/platform.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include "platform.h" 12 | 13 | /* Default brotli_alloc_func */ 14 | void* BrotliDefaultAllocFunc(void* opaque, size_t size) { 15 | BROTLI_UNUSED(opaque); 16 | return malloc(size); 17 | } 18 | 19 | /* Default brotli_free_func */ 20 | void BrotliDefaultFreeFunc(void* opaque, void* address) { 21 | BROTLI_UNUSED(opaque); 22 | free(address); 23 | } 24 | -------------------------------------------------------------------------------- /libs/brotli/common/version.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Version definition. */ 8 | 9 | #ifndef BROTLI_COMMON_VERSION_H_ 10 | #define BROTLI_COMMON_VERSION_H_ 11 | 12 | /* Compose 3 components into a single number. In a hexadecimal representation 13 | B and C components occupy exactly 3 digits. */ 14 | #define BROTLI_MAKE_HEX_VERSION(A, B, C) ((A << 24) | (B << 12) | C) 15 | 16 | /* Those macros should only be used when library is compiled together with 17 | the client. If library is dynamically linked, use BrotliDecoderVersion and 18 | BrotliEncoderVersion methods. */ 19 | 20 | #define BROTLI_VERSION_MAJOR 1 21 | #define BROTLI_VERSION_MINOR 1 22 | #define BROTLI_VERSION_PATCH 0 23 | 24 | #define BROTLI_VERSION BROTLI_MAKE_HEX_VERSION( \ 25 | BROTLI_VERSION_MAJOR, BROTLI_VERSION_MINOR, BROTLI_VERSION_PATCH) 26 | 27 | /* This macro is used by build system to produce Libtool-friendly soname. See 28 | https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html 29 | Version evolution rules: 30 | - interfaces added (or change is compatible) -> current+1:0:age+1 31 | - interfaces removed (or changed is incompatible) -> current+1:0:0 32 | - interfaces not changed -> current:revision+1:age 33 | */ 34 | 35 | #define BROTLI_ABI_CURRENT 2 36 | #define BROTLI_ABI_REVISION 0 37 | #define BROTLI_ABI_AGE 1 38 | 39 | #if BROTLI_VERSION_MAJOR != (BROTLI_ABI_CURRENT - BROTLI_ABI_AGE) 40 | #error ABI/API version inconsistency 41 | #endif 42 | 43 | #if BROTLI_VERSION_MINOR != BROTLI_ABI_AGE 44 | #error ABI/API version inconsistency 45 | #endif 46 | 47 | #if BROTLI_VERSION_PATCH != BROTLI_ABI_REVISION 48 | #error ABI/API version inconsistency 49 | #endif 50 | 51 | #endif /* BROTLI_COMMON_VERSION_H_ */ 52 | -------------------------------------------------------------------------------- /libs/brotli/enc/backward_references.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Function to find backward reference copies. */ 8 | 9 | #ifndef BROTLI_ENC_BACKWARD_REFERENCES_H_ 10 | #define BROTLI_ENC_BACKWARD_REFERENCES_H_ 11 | 12 | #include 13 | 14 | #include "../common/constants.h" 15 | #include "../common/context.h" 16 | #include "../common/dictionary.h" 17 | #include "../common/platform.h" 18 | #include "command.h" 19 | #include "hash.h" 20 | #include "quality.h" 21 | 22 | #if defined(__cplusplus) || defined(c_plusplus) 23 | extern "C" { 24 | #endif 25 | 26 | /* "commands" points to the next output command to write to, "*num_commands" is 27 | initially the total amount of commands output by previous 28 | CreateBackwardReferences calls, and must be incremented by the amount written 29 | by this call. */ 30 | BROTLI_INTERNAL void BrotliCreateBackwardReferences(size_t num_bytes, 31 | size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask, 32 | ContextLut literal_context_lut, const BrotliEncoderParams* params, 33 | Hasher* hasher, int* dist_cache, size_t* last_insert_len, 34 | Command* commands, size_t* num_commands, size_t* num_literals); 35 | 36 | #if defined(__cplusplus) || defined(c_plusplus) 37 | } /* extern "C" */ 38 | #endif 39 | 40 | #endif /* BROTLI_ENC_BACKWARD_REFERENCES_H_ */ 41 | -------------------------------------------------------------------------------- /libs/brotli/enc/bit_cost.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Functions to estimate the bit cost of Huffman trees. */ 8 | 9 | #include "bit_cost.h" 10 | 11 | #include 12 | 13 | #include "../common/constants.h" 14 | #include "../common/platform.h" 15 | #include "fast_log.h" 16 | #include "histogram.h" 17 | 18 | #if defined(__cplusplus) || defined(c_plusplus) 19 | extern "C" { 20 | #endif 21 | 22 | #define FN(X) X ## Literal 23 | #include "bit_cost_inc.h" /* NOLINT(build/include) */ 24 | #undef FN 25 | 26 | #define FN(X) X ## Command 27 | #include "bit_cost_inc.h" /* NOLINT(build/include) */ 28 | #undef FN 29 | 30 | #define FN(X) X ## Distance 31 | #include "bit_cost_inc.h" /* NOLINT(build/include) */ 32 | #undef FN 33 | 34 | #if defined(__cplusplus) || defined(c_plusplus) 35 | } /* extern "C" */ 36 | #endif 37 | -------------------------------------------------------------------------------- /libs/brotli/enc/bit_cost.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Functions to estimate the bit cost of Huffman trees. */ 8 | 9 | #ifndef BROTLI_ENC_BIT_COST_H_ 10 | #define BROTLI_ENC_BIT_COST_H_ 11 | 12 | #include 13 | 14 | #include "../common/platform.h" 15 | #include "fast_log.h" 16 | #include "histogram.h" 17 | 18 | #if defined(__cplusplus) || defined(c_plusplus) 19 | extern "C" { 20 | #endif 21 | 22 | static BROTLI_INLINE double ShannonEntropy( 23 | const uint32_t* population, size_t size, size_t* total) { 24 | size_t sum = 0; 25 | double retval = 0; 26 | const uint32_t* population_end = population + size; 27 | size_t p; 28 | if (size & 1) { 29 | goto odd_number_of_elements_left; 30 | } 31 | while (population < population_end) { 32 | p = *population++; 33 | sum += p; 34 | retval -= (double)p * FastLog2(p); 35 | odd_number_of_elements_left: 36 | p = *population++; 37 | sum += p; 38 | retval -= (double)p * FastLog2(p); 39 | } 40 | if (sum) retval += (double)sum * FastLog2(sum); 41 | *total = sum; 42 | return retval; 43 | } 44 | 45 | static BROTLI_INLINE double BitsEntropy( 46 | const uint32_t* population, size_t size) { 47 | size_t sum; 48 | double retval = ShannonEntropy(population, size, &sum); 49 | if (retval < (double)sum) { 50 | /* At least one bit per literal is needed. */ 51 | retval = (double)sum; 52 | } 53 | return retval; 54 | } 55 | 56 | BROTLI_INTERNAL double BrotliPopulationCostLiteral(const HistogramLiteral*); 57 | BROTLI_INTERNAL double BrotliPopulationCostCommand(const HistogramCommand*); 58 | BROTLI_INTERNAL double BrotliPopulationCostDistance(const HistogramDistance*); 59 | 60 | #if defined(__cplusplus) || defined(c_plusplus) 61 | } /* extern "C" */ 62 | #endif 63 | 64 | #endif /* BROTLI_ENC_BIT_COST_H_ */ 65 | -------------------------------------------------------------------------------- /libs/brotli/enc/block_encoder_inc.h: -------------------------------------------------------------------------------- 1 | /* NOLINT(build/header_guard) */ 2 | /* Copyright 2014 Google Inc. All Rights Reserved. 3 | 4 | Distributed under MIT license. 5 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 6 | */ 7 | 8 | /* template parameters: FN */ 9 | 10 | #define HistogramType FN(Histogram) 11 | 12 | /* Creates entropy codes for all block types and stores them to the bit 13 | stream. */ 14 | static void FN(BuildAndStoreEntropyCodes)(MemoryManager* m, BlockEncoder* self, 15 | const HistogramType* histograms, const size_t histograms_size, 16 | const size_t alphabet_size, HuffmanTree* tree, 17 | size_t* storage_ix, uint8_t* storage) { 18 | const size_t table_size = histograms_size * self->histogram_length_; 19 | self->depths_ = BROTLI_ALLOC(m, uint8_t, table_size); 20 | self->bits_ = BROTLI_ALLOC(m, uint16_t, table_size); 21 | if (BROTLI_IS_OOM(m)) return; 22 | 23 | { 24 | size_t i; 25 | for (i = 0; i < histograms_size; ++i) { 26 | size_t ix = i * self->histogram_length_; 27 | BuildAndStoreHuffmanTree(&histograms[i].data_[0], self->histogram_length_, 28 | alphabet_size, tree, &self->depths_[ix], &self->bits_[ix], 29 | storage_ix, storage); 30 | } 31 | } 32 | } 33 | 34 | #undef HistogramType 35 | -------------------------------------------------------------------------------- /libs/brotli/enc/block_splitter.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Block split point selection utilities. */ 8 | 9 | #ifndef BROTLI_ENC_BLOCK_SPLITTER_H_ 10 | #define BROTLI_ENC_BLOCK_SPLITTER_H_ 11 | 12 | #include 13 | 14 | #include "../common/platform.h" 15 | #include "command.h" 16 | #include "memory.h" 17 | #include "quality.h" 18 | 19 | #if defined(__cplusplus) || defined(c_plusplus) 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct BlockSplit { 24 | size_t num_types; /* Amount of distinct types */ 25 | size_t num_blocks; /* Amount of values in types and length */ 26 | uint8_t* types; 27 | uint32_t* lengths; 28 | 29 | size_t types_alloc_size; 30 | size_t lengths_alloc_size; 31 | } BlockSplit; 32 | 33 | BROTLI_INTERNAL void BrotliInitBlockSplit(BlockSplit* self); 34 | BROTLI_INTERNAL void BrotliDestroyBlockSplit(MemoryManager* m, 35 | BlockSplit* self); 36 | 37 | BROTLI_INTERNAL void BrotliSplitBlock(MemoryManager* m, 38 | const Command* cmds, 39 | const size_t num_commands, 40 | const uint8_t* data, 41 | const size_t offset, 42 | const size_t mask, 43 | const BrotliEncoderParams* params, 44 | BlockSplit* literal_split, 45 | BlockSplit* insert_and_copy_split, 46 | BlockSplit* dist_split); 47 | 48 | #if defined(__cplusplus) || defined(c_plusplus) 49 | } /* extern "C" */ 50 | #endif 51 | 52 | #endif /* BROTLI_ENC_BLOCK_SPLITTER_H_ */ 53 | -------------------------------------------------------------------------------- /libs/brotli/enc/cluster.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Functions for clustering similar histograms together. */ 8 | 9 | #include "cluster.h" 10 | 11 | #include 12 | 13 | #include "../common/platform.h" 14 | #include "bit_cost.h" /* BrotliPopulationCost */ 15 | #include "fast_log.h" 16 | #include "histogram.h" 17 | #include "memory.h" 18 | 19 | #if defined(__cplusplus) || defined(c_plusplus) 20 | extern "C" { 21 | #endif 22 | 23 | static BROTLI_INLINE BROTLI_BOOL HistogramPairIsLess( 24 | const HistogramPair* p1, const HistogramPair* p2) { 25 | if (p1->cost_diff != p2->cost_diff) { 26 | return TO_BROTLI_BOOL(p1->cost_diff > p2->cost_diff); 27 | } 28 | return TO_BROTLI_BOOL((p1->idx2 - p1->idx1) > (p2->idx2 - p2->idx1)); 29 | } 30 | 31 | /* Returns entropy reduction of the context map when we combine two clusters. */ 32 | static BROTLI_INLINE double ClusterCostDiff(size_t size_a, size_t size_b) { 33 | size_t size_c = size_a + size_b; 34 | return (double)size_a * FastLog2(size_a) + 35 | (double)size_b * FastLog2(size_b) - 36 | (double)size_c * FastLog2(size_c); 37 | } 38 | 39 | #define CODE(X) X 40 | 41 | #define FN(X) X ## Literal 42 | #include "cluster_inc.h" /* NOLINT(build/include) */ 43 | #undef FN 44 | 45 | #define FN(X) X ## Command 46 | #include "cluster_inc.h" /* NOLINT(build/include) */ 47 | #undef FN 48 | 49 | #define FN(X) X ## Distance 50 | #include "cluster_inc.h" /* NOLINT(build/include) */ 51 | #undef FN 52 | 53 | #undef CODE 54 | 55 | #if defined(__cplusplus) || defined(c_plusplus) 56 | } /* extern "C" */ 57 | #endif 58 | -------------------------------------------------------------------------------- /libs/brotli/enc/cluster.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Functions for clustering similar histograms together. */ 8 | 9 | #ifndef BROTLI_ENC_CLUSTER_H_ 10 | #define BROTLI_ENC_CLUSTER_H_ 11 | 12 | #include 13 | 14 | #include "../common/platform.h" 15 | #include "histogram.h" 16 | #include "memory.h" 17 | 18 | #if defined(__cplusplus) || defined(c_plusplus) 19 | extern "C" { 20 | #endif 21 | 22 | typedef struct HistogramPair { 23 | uint32_t idx1; 24 | uint32_t idx2; 25 | double cost_combo; 26 | double cost_diff; 27 | } HistogramPair; 28 | 29 | #define CODE(X) /* Declaration */; 30 | 31 | #define FN(X) X ## Literal 32 | #include "cluster_inc.h" /* NOLINT(build/include) */ 33 | #undef FN 34 | 35 | #define FN(X) X ## Command 36 | #include "cluster_inc.h" /* NOLINT(build/include) */ 37 | #undef FN 38 | 39 | #define FN(X) X ## Distance 40 | #include "cluster_inc.h" /* NOLINT(build/include) */ 41 | #undef FN 42 | 43 | #undef CODE 44 | 45 | #if defined(__cplusplus) || defined(c_plusplus) 46 | } /* extern "C" */ 47 | #endif 48 | 49 | #endif /* BROTLI_ENC_CLUSTER_H_ */ 50 | -------------------------------------------------------------------------------- /libs/brotli/enc/command.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | #include "command.h" 8 | 9 | #include 10 | 11 | #if defined(__cplusplus) || defined(c_plusplus) 12 | extern "C" { 13 | #endif 14 | 15 | const uint32_t kBrotliInsBase[BROTLI_NUM_INS_COPY_CODES] = { 16 | 0, 1, 2, 3, 4, 5, 6, 8, 10, 14, 18, 26, 17 | 34, 50, 66, 98, 130, 194, 322, 578, 1090, 2114, 6210, 22594}; 18 | const uint32_t kBrotliInsExtra[BROTLI_NUM_INS_COPY_CODES] = { 19 | 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 12, 14, 24}; 20 | const uint32_t kBrotliCopyBase[BROTLI_NUM_INS_COPY_CODES] = { 21 | 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 18, 22 | 22, 30, 38, 54, 70, 102, 134, 198, 326, 582, 1094, 2118}; 23 | const uint32_t kBrotliCopyExtra[BROTLI_NUM_INS_COPY_CODES] = { 24 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 24}; 25 | 26 | #if defined(__cplusplus) || defined(c_plusplus) 27 | } /* extern "C" */ 28 | #endif 29 | -------------------------------------------------------------------------------- /libs/brotli/enc/dictionary_hash.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Hash table on the 4-byte prefixes of static dictionary words. */ 8 | 9 | #ifndef BROTLI_ENC_DICTIONARY_HASH_H_ 10 | #define BROTLI_ENC_DICTIONARY_HASH_H_ 11 | 12 | #include 13 | 14 | #if defined(__cplusplus) || defined(c_plusplus) 15 | extern "C" { 16 | #endif 17 | 18 | extern const uint16_t kStaticDictionaryHashWords[32768]; 19 | extern const uint8_t kStaticDictionaryHashLengths[32768]; 20 | 21 | #if defined(__cplusplus) || defined(c_plusplus) 22 | } /* extern "C" */ 23 | #endif 24 | 25 | #endif /* BROTLI_ENC_DICTIONARY_HASH_H_ */ 26 | -------------------------------------------------------------------------------- /libs/brotli/enc/fast_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Utilities for fast computation of logarithms. */ 8 | 9 | #ifndef BROTLI_ENC_FAST_LOG_H_ 10 | #define BROTLI_ENC_FAST_LOG_H_ 11 | 12 | #include 13 | 14 | #include 15 | 16 | #include "../common/platform.h" 17 | 18 | #if defined(__cplusplus) || defined(c_plusplus) 19 | extern "C" { 20 | #endif 21 | 22 | static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) { 23 | #if defined(BROTLI_BSR32) 24 | return BROTLI_BSR32((uint32_t)n); 25 | #else 26 | uint32_t result = 0; 27 | while (n >>= 1) result++; 28 | return result; 29 | #endif 30 | } 31 | 32 | #define BROTLI_LOG2_TABLE_SIZE 256 33 | 34 | /* A lookup table for small values of log2(int) to be used in entropy 35 | computation. */ 36 | BROTLI_INTERNAL extern const double kBrotliLog2Table[BROTLI_LOG2_TABLE_SIZE]; 37 | 38 | /* Visual Studio 2012 and Android API levels < 18 do not have the log2() 39 | * function defined, so we use log() and a multiplication instead. */ 40 | #if !defined(BROTLI_HAVE_LOG2) 41 | #if ((defined(_MSC_VER) && _MSC_VER <= 1700) || \ 42 | (defined(__ANDROID_API__) && __ANDROID_API__ < 18)) 43 | #define BROTLI_HAVE_LOG2 0 44 | #else 45 | #define BROTLI_HAVE_LOG2 1 46 | #endif 47 | #endif 48 | 49 | #define LOG_2_INV 1.4426950408889634 50 | 51 | /* Faster logarithm for small integers, with the property of log2(0) == 0. */ 52 | static BROTLI_INLINE double FastLog2(size_t v) { 53 | if (v < BROTLI_LOG2_TABLE_SIZE) { 54 | return kBrotliLog2Table[v]; 55 | } 56 | #if !(BROTLI_HAVE_LOG2) 57 | return log((double)v) * LOG_2_INV; 58 | #else 59 | return log2((double)v); 60 | #endif 61 | } 62 | 63 | #if defined(__cplusplus) || defined(c_plusplus) 64 | } /* extern "C" */ 65 | #endif 66 | 67 | #endif /* BROTLI_ENC_FAST_LOG_H_ */ 68 | -------------------------------------------------------------------------------- /libs/brotli/enc/histogram.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Models the histograms of literals, commands and distance codes. */ 8 | 9 | #ifndef BROTLI_ENC_HISTOGRAM_H_ 10 | #define BROTLI_ENC_HISTOGRAM_H_ 11 | 12 | #include /* memset */ 13 | 14 | #include 15 | 16 | #include "../common/constants.h" 17 | #include "../common/context.h" 18 | #include "../common/platform.h" 19 | #include "block_splitter.h" 20 | #include "command.h" 21 | 22 | #if defined(__cplusplus) || defined(c_plusplus) 23 | extern "C" { 24 | #endif 25 | 26 | /* The distance symbols effectively used by "Large Window Brotli" (32-bit). */ 27 | #define BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS 544 28 | 29 | #define FN(X) X ## Literal 30 | #define DATA_SIZE BROTLI_NUM_LITERAL_SYMBOLS 31 | #define DataType uint8_t 32 | #include "histogram_inc.h" /* NOLINT(build/include) */ 33 | #undef DataType 34 | #undef DATA_SIZE 35 | #undef FN 36 | 37 | #define FN(X) X ## Command 38 | #define DataType uint16_t 39 | #define DATA_SIZE BROTLI_NUM_COMMAND_SYMBOLS 40 | #include "histogram_inc.h" /* NOLINT(build/include) */ 41 | #undef DATA_SIZE 42 | #undef FN 43 | 44 | #define FN(X) X ## Distance 45 | #define DATA_SIZE BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS 46 | #include "histogram_inc.h" /* NOLINT(build/include) */ 47 | #undef DataType 48 | #undef DATA_SIZE 49 | #undef FN 50 | 51 | BROTLI_INTERNAL void BrotliBuildHistogramsWithContext( 52 | const Command* cmds, const size_t num_commands, 53 | const BlockSplit* literal_split, const BlockSplit* insert_and_copy_split, 54 | const BlockSplit* dist_split, const uint8_t* ringbuffer, size_t pos, 55 | size_t mask, uint8_t prev_byte, uint8_t prev_byte2, 56 | const ContextType* context_modes, HistogramLiteral* literal_histograms, 57 | HistogramCommand* insert_and_copy_histograms, 58 | HistogramDistance* copy_dist_histograms); 59 | 60 | #if defined(__cplusplus) || defined(c_plusplus) 61 | } /* extern "C" */ 62 | #endif 63 | 64 | #endif /* BROTLI_ENC_HISTOGRAM_H_ */ 65 | -------------------------------------------------------------------------------- /libs/brotli/enc/histogram_inc.h: -------------------------------------------------------------------------------- 1 | /* NOLINT(build/header_guard) */ 2 | /* Copyright 2013 Google Inc. All Rights Reserved. 3 | 4 | Distributed under MIT license. 5 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 6 | */ 7 | 8 | /* template parameters: Histogram, DATA_SIZE, DataType */ 9 | 10 | /* A simple container for histograms of data in blocks. */ 11 | 12 | typedef struct FN(Histogram) { 13 | uint32_t data_[DATA_SIZE]; 14 | size_t total_count_; 15 | double bit_cost_; 16 | } FN(Histogram); 17 | 18 | static BROTLI_INLINE void FN(HistogramClear)(FN(Histogram)* self) { 19 | memset(self->data_, 0, sizeof(self->data_)); 20 | self->total_count_ = 0; 21 | self->bit_cost_ = HUGE_VAL; 22 | } 23 | 24 | static BROTLI_INLINE void FN(ClearHistograms)( 25 | FN(Histogram)* array, size_t length) { 26 | size_t i; 27 | for (i = 0; i < length; ++i) FN(HistogramClear)(array + i); 28 | } 29 | 30 | static BROTLI_INLINE void FN(HistogramAdd)(FN(Histogram)* self, size_t val) { 31 | ++self->data_[val]; 32 | ++self->total_count_; 33 | } 34 | 35 | static BROTLI_INLINE void FN(HistogramAddVector)(FN(Histogram)* self, 36 | const DataType* p, size_t n) { 37 | self->total_count_ += n; 38 | n += 1; 39 | while (--n) ++self->data_[*p++]; 40 | } 41 | 42 | static BROTLI_INLINE void FN(HistogramAddHistogram)(FN(Histogram)* self, 43 | const FN(Histogram)* v) { 44 | size_t i; 45 | self->total_count_ += v->total_count_; 46 | for (i = 0; i < DATA_SIZE; ++i) { 47 | self->data_[i] += v->data_[i]; 48 | } 49 | } 50 | 51 | static BROTLI_INLINE size_t FN(HistogramDataSize)(void) { return DATA_SIZE; } 52 | -------------------------------------------------------------------------------- /libs/brotli/enc/literal_cost.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Literal cost model to allow backward reference replacement to be efficient. 8 | */ 9 | 10 | #ifndef BROTLI_ENC_LITERAL_COST_H_ 11 | #define BROTLI_ENC_LITERAL_COST_H_ 12 | 13 | #include 14 | 15 | #include "../common/platform.h" 16 | 17 | #if defined(__cplusplus) || defined(c_plusplus) 18 | extern "C" { 19 | #endif 20 | 21 | /* Estimates how many bits the literals in the interval [pos, pos + len) in the 22 | ring-buffer (data, mask) will take entropy coded and writes these estimates 23 | to the cost[0..len) array. */ 24 | BROTLI_INTERNAL void BrotliEstimateBitCostsForLiterals( 25 | size_t pos, size_t len, size_t mask, const uint8_t* data, size_t* histogram, 26 | float* cost); 27 | 28 | #if defined(__cplusplus) || defined(c_plusplus) 29 | } /* extern "C" */ 30 | #endif 31 | 32 | #endif /* BROTLI_ENC_LITERAL_COST_H_ */ 33 | -------------------------------------------------------------------------------- /libs/brotli/enc/params.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Parameters for the Brotli encoder with chosen quality levels. */ 8 | 9 | #ifndef BROTLI_ENC_PARAMS_H_ 10 | #define BROTLI_ENC_PARAMS_H_ 11 | 12 | #include 13 | 14 | #include "encoder_dict.h" 15 | 16 | typedef struct BrotliHasherParams { 17 | int type; 18 | int bucket_bits; 19 | int block_bits; 20 | int num_last_distances_to_check; 21 | } BrotliHasherParams; 22 | 23 | typedef struct BrotliDistanceParams { 24 | uint32_t distance_postfix_bits; 25 | uint32_t num_direct_distance_codes; 26 | uint32_t alphabet_size_max; 27 | uint32_t alphabet_size_limit; 28 | size_t max_distance; 29 | } BrotliDistanceParams; 30 | 31 | /* Encoding parameters */ 32 | typedef struct BrotliEncoderParams { 33 | BrotliEncoderMode mode; 34 | int quality; 35 | int lgwin; 36 | int lgblock; 37 | size_t stream_offset; 38 | size_t size_hint; 39 | BROTLI_BOOL disable_literal_context_modeling; 40 | BROTLI_BOOL large_window; 41 | BrotliHasherParams hasher; 42 | BrotliDistanceParams dist; 43 | /* TODO(eustas): rename to BrotliShared... */ 44 | SharedEncoderDictionary dictionary; 45 | } BrotliEncoderParams; 46 | 47 | #endif /* BROTLI_ENC_PARAMS_H_ */ 48 | -------------------------------------------------------------------------------- /libs/brotli/enc/prefix.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Functions for encoding of integers into prefix codes the amount of extra 8 | bits, and the actual values of the extra bits. */ 9 | 10 | #ifndef BROTLI_ENC_PREFIX_H_ 11 | #define BROTLI_ENC_PREFIX_H_ 12 | 13 | #include 14 | 15 | #include "../common/constants.h" 16 | #include "../common/platform.h" 17 | #include "fast_log.h" 18 | 19 | #if defined(__cplusplus) || defined(c_plusplus) 20 | extern "C" { 21 | #endif 22 | 23 | /* Here distance_code is an intermediate code, i.e. one of the special codes or 24 | the actual distance increased by BROTLI_NUM_DISTANCE_SHORT_CODES - 1. */ 25 | static BROTLI_INLINE void PrefixEncodeCopyDistance(size_t distance_code, 26 | size_t num_direct_codes, 27 | size_t postfix_bits, 28 | uint16_t* code, 29 | uint32_t* extra_bits) { 30 | if (distance_code < BROTLI_NUM_DISTANCE_SHORT_CODES + num_direct_codes) { 31 | *code = (uint16_t)distance_code; 32 | *extra_bits = 0; 33 | return; 34 | } else { 35 | size_t dist = ((size_t)1 << (postfix_bits + 2u)) + 36 | (distance_code - BROTLI_NUM_DISTANCE_SHORT_CODES - num_direct_codes); 37 | size_t bucket = Log2FloorNonZero(dist) - 1; 38 | size_t postfix_mask = (1u << postfix_bits) - 1; 39 | size_t postfix = dist & postfix_mask; 40 | size_t prefix = (dist >> bucket) & 1; 41 | size_t offset = (2 + prefix) << bucket; 42 | size_t nbits = bucket - postfix_bits; 43 | *code = (uint16_t)((nbits << 10) | 44 | (BROTLI_NUM_DISTANCE_SHORT_CODES + num_direct_codes + 45 | ((2 * (nbits - 1) + prefix) << postfix_bits) + postfix)); 46 | *extra_bits = (uint32_t)((dist - offset) >> postfix_bits); 47 | } 48 | } 49 | 50 | #if defined(__cplusplus) || defined(c_plusplus) 51 | } /* extern "C" */ 52 | #endif 53 | 54 | #endif /* BROTLI_ENC_PREFIX_H_ */ 55 | -------------------------------------------------------------------------------- /libs/brotli/enc/static_dict.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Class to model the static dictionary. */ 8 | 9 | #ifndef BROTLI_ENC_STATIC_DICT_H_ 10 | #define BROTLI_ENC_STATIC_DICT_H_ 11 | 12 | #include 13 | 14 | #include "../common/dictionary.h" 15 | #include "../common/platform.h" 16 | #include "encoder_dict.h" 17 | 18 | #if defined(__cplusplus) || defined(c_plusplus) 19 | extern "C" { 20 | #endif 21 | 22 | #define BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN 37 23 | static const uint32_t kInvalidMatch = 0xFFFFFFF; 24 | 25 | /* Matches data against static dictionary words, and for each length l, 26 | for which a match is found, updates matches[l] to be the minimum possible 27 | (distance << 5) + len_code. 28 | Returns 1 if matches have been found, otherwise 0. 29 | Prerequisites: 30 | matches array is at least BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN + 1 long 31 | all elements are initialized to kInvalidMatch */ 32 | BROTLI_INTERNAL BROTLI_BOOL BrotliFindAllStaticDictionaryMatches( 33 | const BrotliEncoderDictionary* dictionary, 34 | const uint8_t* data, size_t min_length, size_t max_length, 35 | uint32_t* matches); 36 | 37 | #if defined(__cplusplus) || defined(c_plusplus) 38 | } /* extern "C" */ 39 | #endif 40 | 41 | #endif /* BROTLI_ENC_STATIC_DICT_H_ */ 42 | -------------------------------------------------------------------------------- /libs/brotli/enc/utf8_util.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Heuristics for deciding about the UTF8-ness of strings. */ 8 | 9 | #ifndef BROTLI_ENC_UTF8_UTIL_H_ 10 | #define BROTLI_ENC_UTF8_UTIL_H_ 11 | 12 | #include 13 | 14 | #include "../common/platform.h" 15 | 16 | #if defined(__cplusplus) || defined(c_plusplus) 17 | extern "C" { 18 | #endif 19 | 20 | static const double kMinUTF8Ratio = 0.75; 21 | 22 | /* Returns 1 if at least min_fraction of the bytes between pos and 23 | pos + length in the (data, mask) ring-buffer is UTF8-encoded, otherwise 24 | returns 0. */ 25 | BROTLI_INTERNAL BROTLI_BOOL BrotliIsMostlyUTF8( 26 | const uint8_t* data, const size_t pos, const size_t mask, 27 | const size_t length, const double min_fraction); 28 | 29 | #if defined(__cplusplus) || defined(c_plusplus) 30 | } /* extern "C" */ 31 | #endif 32 | 33 | #endif /* BROTLI_ENC_UTF8_UTIL_H_ */ 34 | -------------------------------------------------------------------------------- /libs/clipper/License.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | http://www.boost.org/LICENSE_1_0.txt 3 | 4 | Permission is hereby granted, free of charge, to any person or organization 5 | obtaining a copy of the software and accompanying documentation covered by 6 | this license (the "Software") to use, reproduce, display, distribute, 7 | execute, and transmit the Software, and to prepare derivative works of the 8 | Software, and to permit third-parties to whom the Software is furnished to 9 | do so, all subject to the following: 10 | 11 | The copyright notices in the Software and this entire statement, including 12 | the above license grant, this restriction and the following disclaimer, 13 | must be included in all copies of the Software, in whole or in part, and 14 | all derivative works of the Software, unless such copies or derivative 15 | works are solely in the form of machine-executable object code generated by 16 | a source language processor. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 21 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 22 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /libs/clipper/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES = libclipper.a 2 | libclipper_a_SOURCES = clipper.cpp clipper.hpp 3 | EXTRA_DIST = License.txt 4 | 5 | AM_CXXFLAGS = -Wall 6 | 7 | clipper.cpp: clipper.hpp 8 | 9 | CLEANFILES = *.gcda *.gcno 10 | -------------------------------------------------------------------------------- /libs/clipper/clipper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/libs/clipper/clipper.cpp -------------------------------------------------------------------------------- /libs/defs.am: -------------------------------------------------------------------------------- 1 | ## This file is part of dvisvgm 2 | ## Copyright (C) 2005-2025 Martin Gieseking 3 | 4 | if !HAVE_BROTLI 5 | BROTLI_CFLAGS += -I$(dvisvgm_srcdir)/libs/brotli/include 6 | BROTLI_LIBS += ../libs/brotli/libbrotli.a 7 | endif 8 | 9 | if TEXLIVE_BUILD 10 | POTRACE_CFLAGS = $(POTRACE_INCLUDES) 11 | else 12 | if !HAVE_POTRACE 13 | POTRACE_CFLAGS = -I$(dvisvgm_srcdir)/libs/potrace 14 | POTRACE_LIBS = ../libs/potrace/libpotrace.a 15 | endif !HAVE_POTRACE 16 | endif !TEXLIVE_BUILD 17 | 18 | if !HAVE_WOFF2 19 | WOFF2_CFLAGS += -I$(dvisvgm_srcdir)/libs/woff2/include 20 | WOFF2_LIBS += ../libs/woff2/libwoff2.a 21 | endif 22 | 23 | if !HAVE_XXHASH 24 | XXHASH_CFLAGS = -I$(dvisvgm_srcdir)/libs/xxHash 25 | XXHASH_LIBS = ../libs/xxHash/libxxhash.a 26 | endif 27 | -------------------------------------------------------------------------------- /libs/md5/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES = libmd5.a 2 | 3 | libmd5_a_SOURCES = md5.c md5.h 4 | AM_CXXFLAGS = -Wall 5 | 6 | md5.c: md5.h 7 | 8 | CLEANFILES = *.gcda *.gcno 9 | 10 | -------------------------------------------------------------------------------- /libs/md5/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. 3 | * MD5 Message-Digest Algorithm (RFC 1321). 4 | * 5 | * Homepage: 6 | * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 7 | * 8 | * Author: 9 | * Alexander Peslyak, better known as Solar Designer 10 | * 11 | * This software was written by Alexander Peslyak in 2001. No copyright is 12 | * claimed, and the software is hereby placed in the public domain. 13 | * In case this attempt to disclaim copyright and place the software in the 14 | * public domain is deemed null and void, then the software is 15 | * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the 16 | * general public under the following terms: 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted. 20 | * 21 | * There's ABSOLUTELY NO WARRANTY, express or implied. 22 | * 23 | * See md5.c for more information. 24 | */ 25 | 26 | #ifndef _MD5_H 27 | #define _MD5_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* Any 32-bit or wider unsigned integer data type will do */ 34 | typedef unsigned int MD5_u32plus; 35 | 36 | typedef struct { 37 | MD5_u32plus lo, hi; 38 | MD5_u32plus a, b, c, d; 39 | unsigned char buffer[64]; 40 | MD5_u32plus block[16]; 41 | } MD5_CTX; 42 | 43 | extern void MD5_Init(MD5_CTX *ctx); 44 | extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); 45 | extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /libs/potrace/Makefile.am: -------------------------------------------------------------------------------- 1 | if !HAVE_POTRACE 2 | noinst_LIBRARIES = libpotrace.a 3 | libpotrace_a_SOURCES = \ 4 | auxiliary.h \ 5 | bitmap.h \ 6 | config.h \ 7 | curve.c \ 8 | curve.h \ 9 | decompose.c \ 10 | decompose.h \ 11 | lists.h \ 12 | potracelib.c \ 13 | potracelib.h \ 14 | progress.h \ 15 | trace.c \ 16 | trace.h 17 | 18 | AM_CFLAGS = -Wall -I$(srcdir) 19 | 20 | endif 21 | 22 | CLEANFILES = *.gcda *.gcno 23 | -------------------------------------------------------------------------------- /libs/potrace/config.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | #define VERSION "1.16" 4 | #define HAVE_INTTYPES_H 1 5 | #endif 6 | -------------------------------------------------------------------------------- /libs/potrace/decompose.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2001-2019 Peter Selinger. 2 | This file is part of Potrace. It is free software and it is covered 3 | by the GNU General Public License. See the file COPYING for details. */ 4 | 5 | 6 | #ifndef DECOMPOSE_H 7 | #define DECOMPOSE_H 8 | 9 | #include "potracelib.h" 10 | #include "progress.h" 11 | #include "curve.h" 12 | 13 | int bm_to_pathlist(const potrace_bitmap_t *bm, path_t **plistp, const potrace_param_t *param, progress_t *progress); 14 | 15 | #endif /* DECOMPOSE_H */ 16 | 17 | -------------------------------------------------------------------------------- /libs/potrace/trace.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2001-2019 Peter Selinger. 2 | This file is part of Potrace. It is free software and it is covered 3 | by the GNU General Public License. See the file COPYING for details. */ 4 | 5 | 6 | #ifndef TRACE_H 7 | #define TRACE_H 8 | 9 | #include "potracelib.h" 10 | #include "progress.h" 11 | #include "curve.h" 12 | 13 | int process_path(path_t *plist, const potrace_param_t *param, progress_t *progress); 14 | 15 | #endif /* TRACE_H */ 16 | -------------------------------------------------------------------------------- /libs/variant/LICENSE.md: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /libs/variant/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_HEADERS = \ 2 | include/mpark/variant.hpp 3 | 4 | EXTRA_DIST = LICENSE.md 5 | -------------------------------------------------------------------------------- /libs/woff2/Makefile.am: -------------------------------------------------------------------------------- 1 | if !HAVE_WOFF2 2 | noinst_LIBRARIES = libwoff2.a 3 | libwoff2_a_SOURCES = \ 4 | include/woff2/decode.h \ 5 | include/woff2/encode.h \ 6 | include/woff2/output.h \ 7 | include/woff2/version.h \ 8 | src/buffer.h \ 9 | src/font.cc \ 10 | src/font.h \ 11 | src/glyph.cc \ 12 | src/glyph.h \ 13 | src/normalize.cc \ 14 | src/normalize.h \ 15 | src/port.h \ 16 | src/round.h \ 17 | src/store_bytes.h \ 18 | src/table_tags.cc \ 19 | src/table_tags.h \ 20 | src/transform.cc \ 21 | src/transform.h \ 22 | src/variable_length.cc \ 23 | src/variable_length.h \ 24 | src/woff2_common.cc \ 25 | src/woff2_common.h \ 26 | src/woff2_enc.cc \ 27 | src/woff2_out.cc 28 | 29 | AM_CXXFLAGS = -Wall -I$(srcdir)/include -I$(srcdir)/../brotli/include 30 | 31 | endif 32 | 33 | EXTRA_DIST = LICENSE 34 | CLEANFILES = *.gcda *.gcno 35 | -------------------------------------------------------------------------------- /libs/woff2/include/woff2/decode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2014 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Library for converting WOFF2 format font files to their TTF versions. */ 8 | 9 | #ifndef WOFF2_WOFF2_DEC_H_ 10 | #define WOFF2_WOFF2_DEC_H_ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace woff2 { 17 | 18 | // Compute the size of the final uncompressed font, or 0 on error. 19 | size_t ComputeWOFF2FinalSize(const uint8_t *data, size_t length); 20 | 21 | // Decompresses the font into the target buffer. The result_length should 22 | // be the same as determined by ComputeFinalSize(). Returns true on successful 23 | // decompression. 24 | // DEPRECATED; please prefer the version that takes a WOFF2Out* 25 | bool ConvertWOFF2ToTTF(uint8_t *result, size_t result_length, 26 | const uint8_t *data, size_t length); 27 | 28 | // Decompresses the font into out. Returns true on success. 29 | // Works even if WOFF2Header totalSfntSize is wrong. 30 | // Please prefer this API. 31 | bool ConvertWOFF2ToTTF(const uint8_t *data, size_t length, 32 | WOFF2Out* out); 33 | 34 | } // namespace woff2 35 | 36 | #endif // WOFF2_WOFF2_DEC_H_ 37 | -------------------------------------------------------------------------------- /libs/woff2/include/woff2/encode.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2014 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Library for converting WOFF2 format font files to their TTF versions. */ 8 | 9 | #ifndef WOFF2_WOFF2_ENC_H_ 10 | #define WOFF2_WOFF2_ENC_H_ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace woff2 { 17 | 18 | struct WOFF2Params { 19 | WOFF2Params() : extended_metadata(""), brotli_quality(11), 20 | allow_transforms(true) {} 21 | 22 | std::string extended_metadata; 23 | int brotli_quality; 24 | bool allow_transforms; 25 | }; 26 | 27 | // Returns an upper bound on the size of the compressed file. 28 | size_t MaxWOFF2CompressedSize(const uint8_t* data, size_t length); 29 | size_t MaxWOFF2CompressedSize(const uint8_t *data, size_t length, 30 | const std::string &extended_metadata); 31 | 32 | // Compresses the font into the target buffer. *result_length should be at least 33 | // the value returned by MaxWOFF2CompressedSize(), upon return, it is set to the 34 | // actual compressed size. Returns true on successful compression. 35 | bool ConvertTTFToWOFF2(const uint8_t *data, size_t length, 36 | uint8_t *result, size_t *result_length); 37 | bool ConvertTTFToWOFF2(const uint8_t *data, size_t length, 38 | uint8_t *result, size_t *result_length, 39 | const WOFF2Params& params); 40 | 41 | } // namespace woff2 42 | 43 | #endif // WOFF2_WOFF2_ENC_H_ 44 | -------------------------------------------------------------------------------- /libs/woff2/include/woff2/version.h: -------------------------------------------------------------------------------- 1 | #ifndef WOFF2_WOFF2_VERSION_H_ 2 | #define WOFF2_WOFF2_VERSION_H_ 3 | 4 | namespace woff2 { 5 | constexpr const int version = 0x010002; 6 | } 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libs/woff2/src/glyph.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Data model and I/O for glyph data within sfnt format files for the purpose of 8 | performing the preprocessing step of the WOFF 2.0 conversion. */ 9 | 10 | #ifndef WOFF2_GLYPH_H_ 11 | #define WOFF2_GLYPH_H_ 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | namespace woff2 { 20 | 21 | // Represents a parsed simple or composite glyph. The composite glyph data and 22 | // instructions are un-parsed and we keep only pointers to the raw data, 23 | // therefore the glyph is valid only so long the data from which it was parsed 24 | // is around. 25 | class Glyph { 26 | public: 27 | Glyph() 28 | : instructions_size(0), 29 | overlap_simple_flag_set(false), 30 | composite_data_size(0) {} 31 | 32 | // Bounding box. 33 | int16_t x_min; 34 | int16_t x_max; 35 | int16_t y_min; 36 | int16_t y_max; 37 | 38 | // Instructions. 39 | uint16_t instructions_size; 40 | const uint8_t* instructions_data; 41 | 42 | // Flags. 43 | bool overlap_simple_flag_set; 44 | 45 | // Data model for simple glyphs. 46 | struct Point { 47 | int x; 48 | int y; 49 | bool on_curve; 50 | }; 51 | std::vector > contours; 52 | 53 | // Data for composite glyphs. 54 | const uint8_t* composite_data; 55 | uint32_t composite_data_size; 56 | bool have_instructions; 57 | }; 58 | 59 | // Parses the glyph from the given data. Returns false on parsing failure or 60 | // buffer overflow. The glyph is valid only so long the input data pointer is 61 | // valid. 62 | bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph); 63 | 64 | // Stores the glyph into the specified dst buffer. The *dst_size is the buffer 65 | // size on entry and is set to the actual (unpadded) stored size on exit. 66 | // Returns false on buffer overflow. 67 | bool StoreGlyph(const Glyph& glyph, uint8_t* dst, size_t* dst_size); 68 | 69 | } // namespace woff2 70 | 71 | #endif // WOFF2_GLYPH_H_ 72 | -------------------------------------------------------------------------------- /libs/woff2/src/normalize.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Functions for normalizing fonts. Since the WOFF 2.0 decoder creates font 8 | files in normalized form, the WOFF 2.0 conversion is guaranteed to be 9 | lossless (in a bitwise sense) only for normalized font files. */ 10 | 11 | #ifndef WOFF2_NORMALIZE_H_ 12 | #define WOFF2_NORMALIZE_H_ 13 | 14 | namespace woff2 { 15 | 16 | struct Font; 17 | struct FontCollection; 18 | 19 | // Changes the offset fields of the table headers so that the data for the 20 | // tables will be written in order of increasing tag values, without any gaps 21 | // other than the 4-byte padding. 22 | bool NormalizeOffsets(Font* font); 23 | 24 | // Changes the checksum fields of the table headers and the checksum field of 25 | // the head table so that it matches the current data. 26 | bool FixChecksums(Font* font); 27 | 28 | // Parses each of the glyphs in the font and writes them again to the glyf 29 | // table in normalized form, as defined by the StoreGlyph() function. Changes 30 | // the loca table accordigly. 31 | bool NormalizeGlyphs(Font* font); 32 | 33 | // Performs all of the normalization steps above. 34 | bool NormalizeFont(Font* font); 35 | bool NormalizeFontCollection(FontCollection* font_collection); 36 | 37 | } // namespace woff2 38 | 39 | #endif // WOFF2_NORMALIZE_H_ 40 | -------------------------------------------------------------------------------- /libs/woff2/src/port.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Helper function for bit twiddling and macros for branch prediction. */ 8 | 9 | #ifndef WOFF2_PORT_H_ 10 | #define WOFF2_PORT_H_ 11 | 12 | #include 13 | 14 | namespace woff2 { 15 | 16 | typedef unsigned int uint32; 17 | 18 | inline int Log2Floor(uint32 n) { 19 | #if defined(__GNUC__) 20 | return n == 0 ? -1 : 31 ^ __builtin_clz(n); 21 | #else 22 | if (n == 0) 23 | return -1; 24 | int log = 0; 25 | uint32 value = n; 26 | for (int i = 4; i >= 0; --i) { 27 | int shift = (1 << i); 28 | uint32 x = value >> shift; 29 | if (x != 0) { 30 | value = x; 31 | log += shift; 32 | } 33 | } 34 | assert(value == 1); 35 | return log; 36 | #endif 37 | } 38 | 39 | } // namespace woff2 40 | 41 | /* Compatibility with non-clang compilers. */ 42 | #ifndef __has_builtin 43 | #define __has_builtin(x) 0 44 | #endif 45 | 46 | #if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 95) || \ 47 | (defined(__llvm__) && __has_builtin(__builtin_expect)) 48 | #define PREDICT_FALSE(x) (__builtin_expect(x, 0)) 49 | #define PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) 50 | #else 51 | #define PREDICT_FALSE(x) (x) 52 | #define PREDICT_TRUE(x) (x) 53 | #endif 54 | 55 | #if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \ 56 | (defined(M_ARM) && (M_ARM == 7)) || \ 57 | defined(__aarch64__) || defined(__ARM64_ARCH_8__) || defined(__i386) || \ 58 | defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) 59 | #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 60 | #define WOFF_LITTLE_ENDIAN 61 | #elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 62 | #define WOFF_BIG_ENDIAN 63 | #endif /* endianness */ 64 | #endif /* CPU whitelist */ 65 | 66 | #endif // WOFF2_PORT_H_ 67 | -------------------------------------------------------------------------------- /libs/woff2/src/round.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Helper for rounding */ 8 | 9 | #ifndef WOFF2_ROUND_H_ 10 | #define WOFF2_ROUND_H_ 11 | 12 | #include 13 | 14 | namespace woff2 { 15 | 16 | // Round a value up to the nearest multiple of 4. Don't round the value in the 17 | // case that rounding up overflows. 18 | template T Round4(T value) { 19 | if (std::numeric_limits::max() - value < 3) { 20 | return value; 21 | } 22 | return (value + 3) & ~3; 23 | } 24 | 25 | } // namespace woff2 26 | 27 | #endif // WOFF2_ROUND_H_ 28 | -------------------------------------------------------------------------------- /libs/woff2/src/store_bytes.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Helper functions for storing integer values into byte streams. 8 | No bounds checking is performed, that is the responsibility of the caller. */ 9 | 10 | #ifndef WOFF2_STORE_BYTES_H_ 11 | #define WOFF2_STORE_BYTES_H_ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "./port.h" 18 | 19 | namespace woff2 { 20 | 21 | inline size_t StoreU32(uint8_t* dst, size_t offset, uint32_t x) { 22 | dst[offset] = x >> 24; 23 | dst[offset + 1] = x >> 16; 24 | dst[offset + 2] = x >> 8; 25 | dst[offset + 3] = x; 26 | return offset + 4; 27 | } 28 | 29 | inline size_t Store16(uint8_t* dst, size_t offset, int x) { 30 | dst[offset] = x >> 8; 31 | dst[offset + 1] = x; 32 | return offset + 2; 33 | } 34 | 35 | inline void StoreU32(uint32_t val, size_t* offset, uint8_t* dst) { 36 | dst[(*offset)++] = val >> 24; 37 | dst[(*offset)++] = val >> 16; 38 | dst[(*offset)++] = val >> 8; 39 | dst[(*offset)++] = val; 40 | } 41 | 42 | inline void Store16(int val, size_t* offset, uint8_t* dst) { 43 | dst[(*offset)++] = val >> 8; 44 | dst[(*offset)++] = val; 45 | } 46 | 47 | inline void StoreBytes(const uint8_t* data, size_t len, 48 | size_t* offset, uint8_t* dst) { 49 | memcpy(&dst[*offset], data, len); 50 | *offset += len; 51 | } 52 | 53 | } // namespace woff2 54 | 55 | #endif // WOFF2_STORE_BYTES_H_ 56 | -------------------------------------------------------------------------------- /libs/woff2/src/table_tags.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2014 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Font table tags */ 8 | 9 | #ifndef WOFF2_TABLE_TAGS_H_ 10 | #define WOFF2_TABLE_TAGS_H_ 11 | 12 | #include 13 | 14 | namespace woff2 { 15 | 16 | // Tags of popular tables. 17 | static const uint32_t kGlyfTableTag = 0x676c7966; 18 | static const uint32_t kHeadTableTag = 0x68656164; 19 | static const uint32_t kLocaTableTag = 0x6c6f6361; 20 | static const uint32_t kDsigTableTag = 0x44534947; 21 | static const uint32_t kCffTableTag = 0x43464620; 22 | static const uint32_t kHmtxTableTag = 0x686d7478; 23 | static const uint32_t kHheaTableTag = 0x68686561; 24 | static const uint32_t kMaxpTableTag = 0x6d617870; 25 | 26 | extern const uint32_t kKnownTags[]; 27 | 28 | } // namespace woff2 29 | 30 | #endif // WOFF2_TABLE_TAGS_H_ 31 | -------------------------------------------------------------------------------- /libs/woff2/src/transform.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2014 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Library for preprocessing fonts as part of the WOFF 2.0 conversion. */ 8 | 9 | #ifndef WOFF2_TRANSFORM_H_ 10 | #define WOFF2_TRANSFORM_H_ 11 | 12 | #include "./font.h" 13 | 14 | namespace woff2 { 15 | 16 | // Adds the transformed versions of the glyf and loca tables to the font. The 17 | // transformed loca table has zero length. The tag of the transformed tables is 18 | // derived from the original tag by flipping the MSBs of every byte. 19 | bool TransformGlyfAndLocaTables(Font* font); 20 | 21 | // Apply transformation to hmtx table if applicable for this font. 22 | bool TransformHmtxTable(Font* font); 23 | 24 | } // namespace woff2 25 | 26 | #endif // WOFF2_TRANSFORM_H_ 27 | -------------------------------------------------------------------------------- /libs/woff2/src/variable_length.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Helper functions for woff2 variable length types: 255UInt16 and UIntBase128 */ 8 | 9 | #ifndef WOFF2_VARIABLE_LENGTH_H_ 10 | #define WOFF2_VARIABLE_LENGTH_H_ 11 | 12 | #include 13 | #include 14 | #include "./buffer.h" 15 | 16 | namespace woff2 { 17 | 18 | size_t Size255UShort(uint16_t value); 19 | bool Read255UShort(Buffer* buf, unsigned int* value); 20 | void Write255UShort(std::vector* out, int value); 21 | void Store255UShort(int val, size_t* offset, uint8_t* dst); 22 | 23 | size_t Base128Size(size_t n); 24 | bool ReadBase128(Buffer* buf, uint32_t* value); 25 | void StoreBase128(size_t len, size_t* offset, uint8_t* dst); 26 | 27 | } // namespace woff2 28 | 29 | #endif // WOFF2_VARIABLE_LENGTH_H_ 30 | 31 | -------------------------------------------------------------------------------- /libs/woff2/src/woff2_common.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Helpers common across multiple parts of woff2 */ 8 | 9 | #include 10 | 11 | #include "./woff2_common.h" 12 | 13 | #include "./port.h" 14 | 15 | namespace woff2 { 16 | 17 | 18 | uint32_t ComputeULongSum(const uint8_t* buf, size_t size) { 19 | uint32_t checksum = 0; 20 | size_t aligned_size = size & ~3; 21 | for (size_t i = 0; i < aligned_size; i += 4) { 22 | checksum += 23 | (buf[i] << 24) | (buf[i + 1] << 16) | (buf[i + 2] << 8) | buf[i + 3]; 24 | } 25 | 26 | // treat size not aligned on 4 as if it were padded to 4 with 0's 27 | if (size != aligned_size) { 28 | uint32_t v = 0; 29 | for (size_t i = aligned_size; i < size; ++i) { 30 | v |= buf[i] << (24 - 8 * (i & 3)); 31 | } 32 | checksum += v; 33 | } 34 | 35 | return checksum; 36 | } 37 | 38 | size_t CollectionHeaderSize(uint32_t header_version, uint32_t num_fonts) { 39 | size_t size = 0; 40 | if (header_version == 0x00020000) { 41 | size += 12; // ulDsig{Tag,Length,Offset} 42 | } 43 | if (header_version == 0x00010000 || header_version == 0x00020000) { 44 | size += 12 // TTCTag, Version, numFonts 45 | + 4 * num_fonts; // OffsetTable[numFonts] 46 | } 47 | return size; 48 | } 49 | 50 | } // namespace woff2 51 | -------------------------------------------------------------------------------- /libs/woff2/src/woff2_common.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2014 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Common definition for WOFF2 encoding/decoding */ 8 | 9 | #ifndef WOFF2_WOFF2_COMMON_H_ 10 | #define WOFF2_WOFF2_COMMON_H_ 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | namespace woff2 { 18 | 19 | static const uint32_t kWoff2Signature = 0x774f4632; // "wOF2" 20 | 21 | // Leave the first byte open to store flag_byte 22 | const unsigned int kWoff2FlagsTransform = 1 << 8; 23 | 24 | // TrueType Collection ID string: 'ttcf' 25 | static const uint32_t kTtcFontFlavor = 0x74746366; 26 | 27 | static const size_t kSfntHeaderSize = 12; 28 | static const size_t kSfntEntrySize = 16; 29 | 30 | struct Point { 31 | int x; 32 | int y; 33 | bool on_curve; 34 | }; 35 | 36 | struct Table { 37 | uint32_t tag; 38 | uint32_t flags; 39 | uint32_t src_offset; 40 | uint32_t src_length; 41 | 42 | uint32_t transform_length; 43 | 44 | uint32_t dst_offset; 45 | uint32_t dst_length; 46 | const uint8_t* dst_data; 47 | 48 | bool operator<(const Table& other) const { 49 | return tag < other.tag; 50 | } 51 | }; 52 | 53 | 54 | // Size of the collection header. 0 if version indicates this isn't a 55 | // collection. Ref http://www.microsoft.com/typography/otspec/otff.htm, 56 | // True Type Collections 57 | size_t CollectionHeaderSize(uint32_t header_version, uint32_t num_fonts); 58 | 59 | // Compute checksum over size bytes of buf 60 | uint32_t ComputeULongSum(const uint8_t* buf, size_t size); 61 | 62 | } // namespace woff2 63 | 64 | #endif // WOFF2_WOFF2_COMMON_H_ 65 | -------------------------------------------------------------------------------- /libs/woff2/src/woff2_out.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2014 Google Inc. All Rights Reserved. 2 | 3 | Distributed under MIT license. 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 | */ 6 | 7 | /* Output buffer for WOFF2 decompression. */ 8 | 9 | #include 10 | 11 | namespace woff2 { 12 | 13 | WOFF2StringOut::WOFF2StringOut(std::string *buf) 14 | : buf_(buf), max_size_(kDefaultMaxSize), offset_(0) {} 15 | 16 | bool WOFF2StringOut::Write(const void *buf, size_t n) { 17 | return Write(buf, offset_, n); 18 | } 19 | 20 | bool WOFF2StringOut::Write(const void *buf, size_t offset, size_t n) { 21 | if (offset > max_size_ || n > max_size_ - offset) { 22 | return false; 23 | } 24 | if (offset == buf_->size()) { 25 | buf_->append(static_cast(buf), n); 26 | } else { 27 | if (offset + n > buf_->size()) { 28 | buf_->append(offset + n - buf_->size(), 0); 29 | } 30 | buf_->replace(offset, n, static_cast(buf), n); 31 | } 32 | offset_ = std::max(offset_, offset + n); 33 | 34 | return true; 35 | } 36 | 37 | void WOFF2StringOut::SetMaxSize(size_t max_size) { 38 | max_size_ = max_size; 39 | if (offset_ > max_size_) { 40 | offset_ = max_size_; 41 | } 42 | } 43 | 44 | WOFF2MemoryOut::WOFF2MemoryOut(uint8_t* buf, size_t buf_size) 45 | : buf_(buf), 46 | buf_size_(buf_size), 47 | offset_(0) {} 48 | 49 | bool WOFF2MemoryOut::Write(const void *buf, size_t n) { 50 | return Write(buf, offset_, n); 51 | } 52 | 53 | bool WOFF2MemoryOut::Write(const void *buf, size_t offset, size_t n) { 54 | if (offset > buf_size_ || n > buf_size_ - offset) { 55 | return false; 56 | } 57 | std::memcpy(buf_ + offset, buf, n); 58 | offset_ = std::max(offset_, offset + n); 59 | 60 | return true; 61 | } 62 | 63 | } // namespace woff2 64 | -------------------------------------------------------------------------------- /libs/xxHash/LICENSE: -------------------------------------------------------------------------------- 1 | xxHash Library 2 | Copyright (c) 2012-2014, Yann Collet 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, this 12 | list of conditions and the following disclaimer in the documentation and/or 13 | other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /libs/xxHash/Makefile.am: -------------------------------------------------------------------------------- 1 | if !HAVE_XXHASH 2 | noinst_LIBRARIES = libxxhash.a 3 | 4 | libxxhash_a_SOURCES = xxhash.c xxhash.h xxh3.h 5 | AM_CXXFLAGS = -Wall 6 | 7 | xxhash.c: xxhash.h xxh3.h 8 | 9 | endif 10 | 11 | CLEANFILES = *.gcda *.gcno 12 | 13 | -------------------------------------------------------------------------------- /libs/xxHash/xxhash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * xxHash - Extremely Fast Hash algorithm 3 | * Copyright (C) 2012-2023 Yann Collet 4 | * 5 | * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php) 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * You can contact the author at: 31 | * - xxHash homepage: https://www.xxhash.com 32 | * - xxHash source repository: https://github.com/Cyan4973/xxHash 33 | */ 34 | 35 | /* 36 | * xxhash.c instantiates functions defined in xxhash.h 37 | */ 38 | 39 | #define XXH_STATIC_LINKING_ONLY /* access advanced declarations */ 40 | #define XXH_IMPLEMENTATION /* access definitions */ 41 | 42 | #include "xxhash.h" 43 | -------------------------------------------------------------------------------- /m4/ax_ac_append_to_file.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_ac_append_to_file.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_AC_APPEND_TO_FILE([FILE],[DATA]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Appends the specified data to the specified Autoconf is run. If you want 12 | # to append to a file when configure is run use AX_APPEND_TO_FILE instead. 13 | # 14 | # LICENSE 15 | # 16 | # Copyright (c) 2009 Allan Caffee 17 | # 18 | # Copying and distribution of this file, with or without modification, are 19 | # permitted in any medium without royalty provided the copyright notice 20 | # and this notice are preserved. This file is offered as-is, without any 21 | # warranty. 22 | 23 | #serial 10 24 | 25 | AC_DEFUN([AX_AC_APPEND_TO_FILE],[ 26 | AC_REQUIRE([AX_FILE_ESCAPES]) 27 | m4_esyscmd( 28 | AX_FILE_ESCAPES 29 | [ 30 | printf "%s" "$2" >> "$1" 31 | ]) 32 | ]) 33 | -------------------------------------------------------------------------------- /m4/ax_ac_print_to_file.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_ac_print_to_file.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_AC_PRINT_TO_FILE([FILE],[DATA]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Writes the specified data to the specified file when Autoconf is run. If 12 | # you want to print to a file when configure is run use AX_PRINT_TO_FILE 13 | # instead. 14 | # 15 | # LICENSE 16 | # 17 | # Copyright (c) 2009 Allan Caffee 18 | # 19 | # Copying and distribution of this file, with or without modification, are 20 | # permitted in any medium without royalty provided the copyright notice 21 | # and this notice are preserved. This file is offered as-is, without any 22 | # warranty. 23 | 24 | #serial 10 25 | 26 | AC_DEFUN([AX_AC_PRINT_TO_FILE],[ 27 | m4_esyscmd( 28 | AC_REQUIRE([AX_FILE_ESCAPES]) 29 | [ 30 | printf "%s" "$2" > "$1" 31 | ]) 32 | ]) 33 | -------------------------------------------------------------------------------- /m4/ax_add_am_macro_static.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_add_am_macro_static.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_ADD_AM_MACRO_STATIC([RULE]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Adds the specified rule to $AMINCLUDE. 12 | # 13 | # LICENSE 14 | # 15 | # Copyright (c) 2009 Tom Howard 16 | # Copyright (c) 2009 Allan Caffee 17 | # 18 | # Copying and distribution of this file, with or without modification, are 19 | # permitted in any medium without royalty provided the copyright notice 20 | # and this notice are preserved. This file is offered as-is, without any 21 | # warranty. 22 | 23 | #serial 8 24 | 25 | AC_DEFUN([AX_ADD_AM_MACRO_STATIC],[ 26 | AC_REQUIRE([AX_AM_MACROS_STATIC]) 27 | AX_AC_APPEND_TO_FILE(AMINCLUDE_STATIC,[$1]) 28 | ]) 29 | -------------------------------------------------------------------------------- /m4/ax_am_macros_static.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_am_macros_static.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_AM_MACROS_STATIC 8 | # 9 | # DESCRIPTION 10 | # 11 | # Adds support for macros that create Automake rules. You must manually 12 | # add the following line 13 | # 14 | # include $(top_srcdir)/aminclude_static.am 15 | # 16 | # to your Makefile.am files. 17 | # 18 | # LICENSE 19 | # 20 | # Copyright (c) 2009 Tom Howard 21 | # Copyright (c) 2009 Allan Caffee 22 | # 23 | # Copying and distribution of this file, with or without modification, are 24 | # permitted in any medium without royalty provided the copyright notice 25 | # and this notice are preserved. This file is offered as-is, without any 26 | # warranty. 27 | 28 | #serial 11 29 | 30 | AC_DEFUN([AMINCLUDE_STATIC],[aminclude_static.am]) 31 | 32 | AC_DEFUN([AX_AM_MACROS_STATIC], 33 | [ 34 | AX_AC_PRINT_TO_FILE(AMINCLUDE_STATIC,[ 35 | # ]AMINCLUDE_STATIC[ generated automatically by Autoconf 36 | # from AX_AM_MACROS_STATIC on ]m4_esyscmd([LC_ALL=C date])[ 37 | ]) 38 | ]) 39 | -------------------------------------------------------------------------------- /m4/ax_file_escapes.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_FILE_ESCAPES 8 | # 9 | # DESCRIPTION 10 | # 11 | # Writes the specified data to the specified file. 12 | # 13 | # LICENSE 14 | # 15 | # Copyright (c) 2008 Tom Howard 16 | # 17 | # Copying and distribution of this file, with or without modification, are 18 | # permitted in any medium without royalty provided the copyright notice 19 | # and this notice are preserved. This file is offered as-is, without any 20 | # warranty. 21 | 22 | #serial 8 23 | 24 | AC_DEFUN([AX_FILE_ESCAPES],[ 25 | AX_DOLLAR="\$" 26 | AX_SRB="\\135" 27 | AX_SLB="\\133" 28 | AX_BS="\\\\" 29 | AX_DQ="\"" 30 | ]) 31 | -------------------------------------------------------------------------------- /src/CharMapID.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** CharMapID.cpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #include "CharMapID.hpp" 22 | 23 | const CharMapID CharMapID::NONE(0, 0); 24 | const CharMapID CharMapID::WIN_SYMBOL(3, 0); 25 | const CharMapID CharMapID::WIN_UCS2(3, 1); 26 | const CharMapID CharMapID::WIN_SHIFTJIS(3, 2); 27 | const CharMapID CharMapID::WIN_PRC(3, 3); 28 | const CharMapID CharMapID::WIN_BIG5(3, 4); 29 | const CharMapID CharMapID::WIN_WANSUNG(3, 5); 30 | const CharMapID CharMapID::WIN_JOHAB(3, 6); 31 | const CharMapID CharMapID::WIN_UCS4(3, 10); 32 | 33 | const CharMapID CharMapID::MAC_JAPANESE(1, 1); 34 | const CharMapID CharMapID::MAC_TRADCHINESE(1, 2); 35 | const CharMapID CharMapID::MAC_KOREAN(1, 3); 36 | const CharMapID CharMapID::MAC_SIMPLCHINESE(1, 25); 37 | -------------------------------------------------------------------------------- /src/Character.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** Character.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef CHARACTER_HPP 22 | #define CHARACTER_HPP 23 | 24 | #include 25 | 26 | class Character { 27 | public: 28 | enum Type {CHRCODE, INDEX, NAME}; 29 | explicit Character (const char *name) : _type(NAME), _name(name) {} 30 | Character (Type type, uint32_t val) : _type(type), _number(val) {} 31 | Character (Type type, const Character &c) : _type(type), _number(c.type() != NAME ? c._number : 0) {} 32 | Type type () const {return _type;} 33 | const char* name () const {return _name;} 34 | uint32_t number () const {return _number;} 35 | 36 | private: 37 | Type _type; 38 | union { 39 | uint32_t _number; 40 | const char *_name; 41 | }; 42 | }; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /src/Directory.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** Directory.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef DIRECTORY_HPP 22 | #define DIRECTORY_HPP 23 | 24 | #include 25 | #ifdef _WIN32 26 | #include "windows.hpp" 27 | #else 28 | #include 29 | #endif 30 | 31 | class Directory { 32 | public: 33 | enum EntryType {ET_FILE, ET_DIR, ET_FILE_OR_DIR}; 34 | 35 | public: 36 | Directory (); 37 | explicit Directory (const std::string &path); 38 | ~Directory (); 39 | bool open (std::string path); 40 | void close (); 41 | const char* read (EntryType type=ET_FILE_OR_DIR); 42 | 43 | private: 44 | std::string _dirname; 45 | #ifdef _WIN32 46 | bool _firstread=true; 47 | HANDLE _handle=INVALID_HANDLE_VALUE; 48 | WIN32_FIND_DATA _fileData; 49 | #else 50 | DIR *_dir=nullptr; 51 | struct dirent *_dirent=nullptr; 52 | #endif 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/EPSFile.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** EPSFile.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef EPSFILE_HPP 22 | #define EPSFILE_HPP 23 | 24 | #include 25 | #include 26 | #include 27 | #include "BoundingBox.hpp" 28 | 29 | class EPSFile { 30 | public: 31 | explicit EPSFile (const std::string &fname); 32 | std::istream& istream () const; 33 | bool hasValidHeader () const {return _headerValid;} 34 | BoundingBox bbox () const; 35 | uint32_t pslength () const {return _pslength;} 36 | 37 | private: 38 | mutable std::ifstream _ifs; 39 | bool _headerValid=false; ///< true if file has a valid header 40 | uint32_t _offset=0; ///< stream offset where ASCII part of the file begins 41 | uint32_t _pslength=0; ///< length of PS section (in bytes) 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/EPSToSVG.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** EPSToSVG.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef EPSTOSVG_HPP 22 | #define EPSTOSVG_HPP 23 | 24 | #include "EPSFile.hpp" 25 | #include "ImageToSVG.hpp" 26 | 27 | class PsSpecialHandler; 28 | 29 | class EPSToSVG : public ImageToSVG { 30 | public: 31 | EPSToSVG (const std::string &fname, SVGOutputBase &out) : ImageToSVG(fname, out) {} 32 | bool isSinglePageFormat() const override {return true;} 33 | int totalPageCount() const override {return 1;} 34 | 35 | protected: 36 | std::string imageFormat () const override {return "EPS";} 37 | bool imageIsValid () const override {return EPSFile(filename()).hasValidHeader();} 38 | BoundingBox imageBBox () const override {return EPSFile(filename()).bbox();} 39 | std::string psSpecialCmd () const override {return "psfile=";} 40 | }; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /src/EncFile.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** EncFile.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef ENCFILE_HPP 22 | #define ENCFILE_HPP 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "FontEncoding.hpp" 29 | 30 | 31 | class EncFile : public NamedFontEncoding { 32 | public: 33 | explicit EncFile (std::string encname); 34 | void read (); 35 | void read (std::istream &is); 36 | int size () const {return _table.size();} 37 | const char* name () const override {return _encname.c_str();} 38 | const char* charName (uint32_t c) const; 39 | Character decode (uint32_t c) const override {return Character(charName(c));} 40 | bool mapsToCharIndex () const override {return false;} 41 | const char* path () const override; 42 | 43 | private: 44 | std::string _encname; 45 | std::vector _table; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/FixWord.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** FixWord.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef FIXWORD_HPP 22 | #define FIXWORD_HPP 23 | 24 | #include 25 | 26 | class FixWord { 27 | public: 28 | FixWord () =default; 29 | FixWord (int32_t fw) : _value(fw) {} 30 | explicit operator double () const {return double(_value)/(1 << 20);} 31 | bool operator < (FixWord fw) const {return _value < fw._value;} 32 | bool operator == (FixWord fw) const {return _value == fw._value;} 33 | 34 | private: 35 | int32_t _value=0; 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/FontStyle.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** FontStyle.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef FONTSTYLE 22 | #define FONTSTYLE 23 | 24 | struct FontStyle { 25 | FontStyle () =default; 26 | FontStyle (float b, float e, float s) : bold(b), extend(e), slant(s) {} 27 | double bold=0; ///< stroke width in pt used to draw the glyph outlines 28 | double extend=1; ///< factor to stretch/shrink the glyphs horizontally 29 | double slant=0; ///< horizontal slanting/skewing value (= tan(phi)) 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/GFTracer.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** GFTracer.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef GFTRACER_HPP 22 | #define GFTRACER_HPP 23 | 24 | #include 25 | #include "GFReader.hpp" 26 | 27 | class GFTracer : public GFReader { 28 | public: 29 | explicit GFTracer (std::istream &is) : GFReader(is) {} 30 | GFTracer (std::istream &is, double upp); 31 | virtual void moveTo (double x, double y) =0; 32 | virtual void lineTo (double x, double y) =0; 33 | virtual void curveTo (double c1x, double c1y, double c2x, double c2y, double x, double y) =0; 34 | virtual void closePath () =0; 35 | void beginChar (uint32_t c) override; 36 | void endChar (uint32_t c) override; 37 | 38 | protected: 39 | void unitsPerPoint(double upp) {_unitsPerPoint = upp;} 40 | 41 | private: 42 | double _unitsPerPoint=0; ///< target units per PS point 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/Glyph.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** Glyph.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef GLYPH_HPP 22 | #define GLYPH_HPP 23 | 24 | #include "GraphicsPath.hpp" 25 | 26 | using Glyph = GraphicsPath; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/MessageException.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** MessageException.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef MESSAGEEXCEPTION_HPP 22 | #define MESSAGEEXCEPTION_HPP 23 | 24 | #include 25 | #include 26 | 27 | 28 | class MessageException : public std::exception { 29 | public: 30 | explicit MessageException (std::string msg) : _message(std::move(msg)) {} 31 | const char* what () const noexcept override {return _message.c_str();} 32 | 33 | private: 34 | std::string _message; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/MetafontWrapper.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** MetafontWrapper.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef METAFONTWRAPPER_HPP 22 | #define METAFONTWRAPPER_HPP 23 | 24 | #include 25 | 26 | 27 | class FileFinder; 28 | 29 | class MetafontWrapper { 30 | public: 31 | MetafontWrapper (std::string fname, std::string dir); 32 | bool call (const std::string &mode, double mag) const; 33 | bool make (const std::string &mode, double mag) const; 34 | bool success () const; 35 | 36 | protected: 37 | int getResolution (const std::string &mfMessage) const; 38 | 39 | private: 40 | std::string _fontname; 41 | std::string _dir; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/MiKTeXCom.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** MiKTeXCom.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef MIKTEXCOM_HPP 22 | #define MIKTEXCOM_HPP 23 | 24 | #include 25 | #include "windows.hpp" 26 | 27 | #ifdef _MSC_VER 28 | #import 29 | using namespace MiKTeXSession2_9; 30 | #else 31 | #include "miktex-session.h" 32 | #endif 33 | 34 | class MiKTeXCom { 35 | public: 36 | MiKTeXCom (); 37 | ~MiKTeXCom (); 38 | std::string getBinDir () const; 39 | std::string getVersion () const; 40 | const char* findFile (const char* fname) const; 41 | 42 | private: 43 | #ifdef _MSC_VER 44 | ISession2Ptr _session; 45 | #else 46 | ISession2 *_session; 47 | #endif 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/NoPsSpecialHandler.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** NoPsSpecialHandler.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef NOPSSPECIALHANDLER_HPP 22 | #define NOPSSPECIALHANDLER_HPP 23 | 24 | #include "SpecialHandler.hpp" 25 | 26 | class NoPsSpecialHandler : public SpecialHandler { 27 | public: 28 | bool process (const std::string &prefix, std::istream &is, SpecialActions &actions) override; 29 | const char* info () const override {return nullptr;} 30 | const char* name () const override {return nullptr;} 31 | static const char* handlerName () {return nullptr;} 32 | std::vector prefixes () const override; 33 | 34 | protected: 35 | void dviEndPage (unsigned pageno, SpecialActions &actions) override; 36 | 37 | private: 38 | size_t _ignoreCount=0; // number of PS specials skipped 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/PageRanges.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** PageRanges.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef PAGERANGES_HPP 22 | #define PAGERANGES_HPP 23 | 24 | #include 25 | #include "NumericRanges.hpp" 26 | 27 | class PageRanges : public NumericRanges { 28 | public: 29 | bool parse (const std::string &str, int max_page=0); 30 | PageRanges filter (bool (*filterFunc)(int)) const; 31 | size_t numberOfPages () const; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/PageSize.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** PageSize.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef PAGESIZE_HPP 22 | #define PAGESIZE_HPP 23 | 24 | #include "Length.hpp" 25 | #include "MessageException.hpp" 26 | 27 | struct PageSizeException : public MessageException { 28 | explicit PageSizeException (const std::string &msg) : MessageException(msg) {} 29 | }; 30 | 31 | class PageSize { 32 | public: 33 | PageSize () =default; 34 | PageSize (Length w, Length h) : _width(w), _height(h) {} 35 | explicit PageSize (const std::string &name); 36 | void resize (std:: string name); 37 | void resize (Length w, Length h); 38 | Length width () const {return _width;} 39 | Length height () const {return _height;} 40 | bool valid () const {return _width.pt() > 0 && _height.pt() > 0;} 41 | 42 | private: 43 | Length _width, _height; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/PreScanDVIReader.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** PreScanDVIReader.cpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #include "DVIActions.hpp" 22 | #include "PreScanDVIReader.hpp" 23 | 24 | using namespace std; 25 | 26 | 27 | PreScanDVIReader::PreScanDVIReader (std::istream &is, DVIActions *actions) 28 | : BasicDVIReader(is), _actions(actions) 29 | { 30 | } 31 | 32 | 33 | void PreScanDVIReader::cmdBop (int) { 34 | _currentPageNumber++; 35 | BasicDVIReader::cmdBop(0); 36 | } 37 | 38 | 39 | void PreScanDVIReader::cmdXXX (int len) { 40 | uint32_t numBytes = readUnsigned(len); 41 | string s = readString(numBytes); 42 | if (_actions) 43 | _actions->special(s, 0, true); // pre-process special 44 | } 45 | -------------------------------------------------------------------------------- /src/PreScanDVIReader.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** PreScanDVIReader.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef PRESCANDVIREADER_HPP 22 | #define PRESCANDVIREADER_HPP 23 | 24 | #include "BasicDVIReader.hpp" 25 | 26 | struct DVIActions; 27 | 28 | class PreScanDVIReader : public BasicDVIReader { 29 | public: 30 | PreScanDVIReader (std::istream &is, DVIActions *actions); 31 | unsigned currentPageNumber () const override {return _currentPageNumber;} 32 | 33 | protected: 34 | void cmdBop (int) override; 35 | void cmdXXX (int len) override; 36 | 37 | private: 38 | DVIActions *_actions; 39 | unsigned _currentPageNumber=0; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/PsSpecialHandlerProxy.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** PsSpecialHandlerProxy.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include "SpecialHandler.hpp" 24 | 25 | class PsSpecialHandlerProxy : public SpecialHandler { 26 | public: 27 | explicit PsSpecialHandlerProxy (bool pswarning) : _pswarning(pswarning) {} 28 | void preprocess (const std::string &prefix, std::istream &is, SpecialActions &actions) override; 29 | bool process (const std::string &prefix, std::istream &is, SpecialActions &actions) override; 30 | const char* name () const override {return "ps";} 31 | const char* info () const override; 32 | std::vector prefixes () const override; 33 | 34 | protected: 35 | SpecialHandler* replaceHandler () const; 36 | 37 | private: 38 | bool _pswarning; 39 | }; 40 | -------------------------------------------------------------------------------- /src/SVGCharHandlerFactory.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** SVGCharHandlerFactory.cpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #include "SVGCharHandlerFactory.hpp" 22 | #include "SVGCharPathHandler.hpp" 23 | #include "SVGSingleCharTextHandler.hpp" 24 | #include "SVGCharTspanTextHandler.hpp" 25 | #include "SVGTree.hpp" 26 | #include "utility.hpp" 27 | 28 | using namespace std; 29 | 30 | unique_ptr SVGCharHandlerFactory::createHandler () { 31 | if (!SVGTree::USE_FONTS) 32 | return util::make_unique(SVGTree::CREATE_USE_ELEMENTS, SVGTree::RELATIVE_PATH_CMDS); 33 | if (SVGTree::MERGE_CHARS) 34 | return util::make_unique(SVGTree::CREATE_CSS); 35 | return util::make_unique(SVGTree::CREATE_CSS); 36 | } 37 | -------------------------------------------------------------------------------- /src/SVGCharHandlerFactory.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** SVGCharHandlerFactory.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef SVGCHARHANDLERFACTORY_HPP 22 | #define SVGCHARHANDLERFACTORY_HPP 23 | 24 | #include 25 | #include "SVGCharHandler.hpp" 26 | 27 | struct SVGCharHandlerFactory { 28 | static std::unique_ptr createHandler (); 29 | }; 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /src/SVGCharTspanTextHandler.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** SVGCharTspanTextHandler.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef SVGCHARTSPANTEXTHANDLER_HPP 22 | #define SVGCHARTSPANTEXTHANDLER_HPP 23 | 24 | #include "SVGCharHandler.hpp" 25 | 26 | class SVGCharTspanTextHandler : public SVGCharTextHandler { 27 | public: 28 | explicit SVGCharTspanTextHandler (bool selectFontByClass); 29 | void notifyXAdjusted () override {_xchanged = true;} 30 | void notifyYAdjusted() override {_ychanged = true;} 31 | void appendChar (uint32_t c, double x, double y) override; 32 | void setInitialContextNode (SVGElement *node) override; 33 | 34 | protected: 35 | void resetContextNode () override; 36 | 37 | private: 38 | bool _xchanged, _ychanged; 39 | SVGElement *_textNode; 40 | SVGElement *_tspanNode; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/SVGSingleCharTextHandler.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** SVGSingleCharTextHandler.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef SVGSINGLECHARTEXTHANDLER_HPP 22 | #define SVGSINGLECHARTEXTHANDLER_HPP 23 | 24 | #include "SVGCharHandler.hpp" 25 | 26 | 27 | class SVGSingleCharTextHandler : public SVGCharTextHandler { 28 | public: 29 | explicit SVGSingleCharTextHandler (bool createStyleElements) : SVGCharTextHandler(createStyleElements) {} 30 | void appendChar (uint32_t c, double x, double y) override; 31 | }; 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /src/System.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** System.cpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #include 22 | #include 23 | #include "System.hpp" 24 | 25 | #if defined (HAVE_SYS_TIME_H) 26 | #include 27 | #elif defined (HAVE_SYS_TIMEB_H) 28 | #include 29 | #endif 30 | 31 | 32 | using namespace std; 33 | 34 | 35 | /** Returns timestamp (wall time) in seconds. */ 36 | double System::time () { 37 | #if defined (HAVE_SYS_TIME_H) 38 | struct timeval tv; 39 | gettimeofday(&tv, nullptr); 40 | return tv.tv_sec + tv.tv_usec/1000000.0; 41 | #elif defined (HAVE_SYS_TIMEB_H) 42 | struct timeb tb; 43 | ftime(&tb); 44 | return tb.time + tb.millitm/1000.0; 45 | #else 46 | clock_t myclock = clock(); 47 | return double(myclock)/CLOCKS_PER_SEC; 48 | #endif 49 | } 50 | -------------------------------------------------------------------------------- /src/System.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** System.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef SYSTEM_HPP 22 | #define SYSTEM_HPP 23 | 24 | namespace System 25 | { 26 | double time (); 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/ToUnicodeMap.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** ToUnicodeMap.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef TOUNICODEMAP_HPP 22 | #define TOUNICODEMAP_HPP 23 | 24 | #include "NumericRanges.hpp" 25 | #include "RangeMap.hpp" 26 | 27 | 28 | /** Represents a mapping from character indexes to Unicode points. */ 29 | class ToUnicodeMap : public RangeMap { 30 | public: 31 | ToUnicodeMap () = default; 32 | ToUnicodeMap (RangeMap &&charmap) : RangeMap(std::move(charmap)) {} 33 | bool addMissingMappings (uint32_t maxIndex); 34 | 35 | protected: 36 | bool fillRange (uint32_t minIndex, uint32_t maxIndex, uint32_t ucp, NumericRanges &used_ucps, bool ascending); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/Unicode.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** Unicode.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef UNICODE_HPP 22 | #define UNICODE_HPP 23 | 24 | #include 25 | #include 26 | 27 | struct Unicode { 28 | static bool isValidCodepoint (uint32_t code); 29 | static uint32_t charToCodepoint (uint32_t c, bool permitSpace=false); 30 | static std::string utf8 (int32_t c); 31 | static uint32_t utf8ToCodepoint (const std::string &utf8); 32 | static uint32_t fromSurrogate (uint32_t high, uint32_t low); 33 | static uint32_t fromSurrogate (uint32_t cp); 34 | static uint32_t toSurrogate (uint32_t cp); 35 | static uint32_t toLigature (const std::string &nonlig); 36 | static int32_t aglNameToCodepoint (const std::string &name); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/VFActions.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** VFActions.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef VFACTIONS_HPP 22 | #define VFACTIONS_HPP 23 | 24 | #include 25 | #include 26 | 27 | 28 | struct VFActions { 29 | virtual ~VFActions () =default; 30 | virtual void vfPreamble (const std::string &comment, uint32_t checksum, double dsize) {} 31 | virtual void vfPostamble () {} 32 | virtual void defineVFFont (uint32_t fontnum, const std::string &path, const std::string &name, uint32_t checksum, double dsize, double ssize) {} 33 | virtual void defineVFChar (uint32_t c, std::vector dvi) {} 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/XMLDocument.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** XMLDocument.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef XMLDOCUMENT_HPP 22 | #define XMLDOCUMENT_HPP 23 | 24 | #include 25 | #include 26 | #include "XMLNode.hpp" 27 | 28 | class XMLDocument { 29 | public: 30 | XMLDocument () =default; 31 | explicit XMLDocument(std::unique_ptr root); 32 | void clear (); 33 | void append (std::unique_ptr node); 34 | void append (std::unique_ptr node); 35 | void setRootNode (std::unique_ptr root); 36 | const XMLElement* getRootElement () const {return _rootElement.get();} 37 | std::ostream& write (std::ostream &os) const; 38 | 39 | private: 40 | std::vector> _nodes; 41 | std::unique_ptr _rootElement; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/XMLString.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** XMLString.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef XMLSTRING_HPP 22 | #define XMLSTRING_HPP 23 | 24 | #include 25 | 26 | 27 | class XMLString : public std::string { 28 | public: 29 | XMLString () : std::string() {} 30 | explicit XMLString (const char *str, bool plain=false); 31 | explicit XMLString (const std::string &str, bool plain=false); 32 | explicit XMLString (int n, bool cast=true); 33 | explicit XMLString (double x); 34 | 35 | static int DECIMAL_PLACES; ///< number of decimal places applied to floating point values (0-6) 36 | }; 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/fonts/Base14Fonts.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** Base14Fonts.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | 26 | struct MemoryFontData { 27 | MemoryFontData () =delete; 28 | const char *data; 29 | size_t size; 30 | }; 31 | 32 | const MemoryFontData* find_base14_font (const std::string &name); 33 | -------------------------------------------------------------------------------- /src/fonts/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libbase14fonts.la 2 | 3 | libbase14fonts_la_SOURCES = \ 4 | Base14Fonts.cpp \ 5 | Base14Fonts.hpp \ 6 | Dingbats.cff.cpp \ 7 | NimbusMonoPS-Bold.cff.cpp \ 8 | NimbusMonoPS-BoldItalic.cff.cpp \ 9 | NimbusMonoPS-Italic.cff.cpp \ 10 | NimbusMonoPS-Regular.cff.cpp \ 11 | NimbusRoman-Bold.cff.cpp \ 12 | NimbusRoman-BoldItalic.cff.cpp \ 13 | NimbusRoman-Italic.cff.cpp \ 14 | NimbusRoman-Regular.cff.cpp \ 15 | NimbusSans-Bold.cff.cpp \ 16 | NimbusSans-BoldItalic.cff.cpp \ 17 | NimbusSans-Italic.cff.cpp \ 18 | NimbusSans-Regular.cff.cpp \ 19 | StandardSymbolsPS.cff.cpp 20 | -------------------------------------------------------------------------------- /src/macros.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** macros.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef MACROS_HPP 22 | #define MACROS_HPP 23 | 24 | #define IMPLEMENT_ARITHMETIC_OPERATOR(class, op) \ 25 | inline class operator op (class a, const class &b) { \ 26 | return a op##= b; \ 27 | } 28 | 29 | #define IMPLEMENT_ARITHMETIC_OPERATOR2(class, scalar, op) \ 30 | inline class operator op (class a, scalar b) { \ 31 | return a op##= b; \ 32 | } 33 | 34 | #define IMPLEMENT_OUTPUT_OPERATOR(class) \ 35 | inline std::ostream& operator << (std::ostream &os, class obj) { \ 36 | return obj.write(os); \ 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/optimizer/ClipPathReassigner.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** ClipPathReassigner.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include "OptimizerModule.hpp" 26 | 27 | class ClipPathReassigner : public OptimizerModule { 28 | struct NamedPathString { 29 | NamedPathString () =default; 30 | NamedPathString (const std::string &svgPathName, const char *svgPathString) : name(svgPathName), pathString(svgPathString) {} 31 | std::string name; 32 | const char *pathString = nullptr; 33 | }; 34 | 35 | public: 36 | void execute (XMLElement*, XMLElement *context) override; 37 | const char* info () const override; 38 | 39 | private: 40 | std::vector _namedPathStrings; 41 | 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /src/optimizer/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = liboptimizer.la 2 | 3 | liboptimizer_la_SOURCES = \ 4 | AttributeExtractor.hpp AttributeExtractor.cpp \ 5 | ClipPathReassigner.hpp ClipPathReassigner.cpp \ 6 | DependencyGraph.hpp \ 7 | GroupCollapser.hpp GroupCollapser.cpp \ 8 | OptimizerModule.hpp \ 9 | RedundantElementRemover.hpp RedundantElementRemover.cpp \ 10 | SVGOptimizer.hpp SVGOptimizer.cpp \ 11 | TextSimplifier.hpp TextSimplifier.cpp \ 12 | TransformSimplifier.hpp TransformSimplifier.cpp \ 13 | WSNodeRemover.hpp WSNodeRemover.cpp 14 | 15 | include ../../libs/defs.am 16 | 17 | AM_CXXFLAGS = -I$(dvisvgm_srcdir)/libs/variant/include $(XXHASH_CFLAGS) 18 | 19 | -------------------------------------------------------------------------------- /src/optimizer/OptimizerModule.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** OptimizerModule.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | class XMLElement; 24 | 25 | class OptimizerModule { 26 | public: 27 | virtual ~OptimizerModule () =default; 28 | virtual void execute (XMLElement *defs, XMLElement *context) =0; 29 | virtual const char* info () const =0; 30 | }; 31 | -------------------------------------------------------------------------------- /src/optimizer/RedundantElementRemover.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** RedundantElementRemover.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include "OptimizerModule.hpp" 24 | 25 | class RedundantElementRemover : public OptimizerModule { 26 | public: 27 | void execute (XMLElement *defs, XMLElement *context) override; 28 | const char* info () const override; 29 | }; 30 | -------------------------------------------------------------------------------- /src/optimizer/TextSimplifier.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** TextSimplifier.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include "OptimizerModule.hpp" 24 | 25 | class TextSimplifier : public OptimizerModule { 26 | public: 27 | void execute (XMLElement *defs, XMLElement *context) override {execute(context);} 28 | static void execute (XMLElement *context); 29 | const char *info () const override; 30 | }; 31 | -------------------------------------------------------------------------------- /src/optimizer/TransformSimplifier.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** TransformSimplifier.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include "OptimizerModule.hpp" 25 | 26 | class Matrix; 27 | 28 | class TransformSimplifier : public OptimizerModule { 29 | public: 30 | void execute (XMLElement*, XMLElement *context) override {execute(context);} 31 | void execute (XMLElement *context); 32 | const char* info () const override; 33 | 34 | protected: 35 | bool incorporateTransform (XMLElement *elem, const Matrix &matrix); 36 | std::string decompose (const Matrix &matrix); 37 | }; 38 | -------------------------------------------------------------------------------- /src/optimizer/WSNodeRemover.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** WSNodeRemover.cpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #include "WSNodeRemover.hpp" 22 | #include "../XMLNode.hpp" 23 | 24 | const char* WSNodeRemover::info () const { 25 | return "remove redundant whitespace nodes"; 26 | } 27 | 28 | 29 | void WSNodeRemover::execute (XMLElement *context) { 30 | if (!context) 31 | return; 32 | bool removeWS = context->name() != "text" && context->name() != "tspan"; 33 | XMLNode *child = context->firstChild(); 34 | while (child) { 35 | if (removeWS && child->toWSNode()) { 36 | XMLNode *next = child->next(); 37 | XMLElement::detach(child); 38 | child = next; 39 | continue; 40 | } 41 | if (XMLElement *elem = child->toElement()) 42 | execute(elem); 43 | child = child->next(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/optimizer/WSNodeRemover.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** WSNodeRemover.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include "OptimizerModule.hpp" 24 | 25 | class WSNodeRemover : public OptimizerModule { 26 | public: 27 | void execute (XMLElement*, XMLElement *context) override {execute(context);}; 28 | void execute (XMLElement *context); 29 | const char* info () const override; 30 | }; 31 | -------------------------------------------------------------------------------- /src/options.dtd: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 41 | 42 | 43 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/ttf/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libttf.la 2 | 3 | libttf_la_SOURCES = \ 4 | CmapTable.hpp CmapTable.cpp \ 5 | GlyfTable.hpp GlyfTable.cpp \ 6 | HeadTable.hpp HeadTable.cpp \ 7 | HheaTable.hpp HheaTable.cpp \ 8 | HmtxTable.hpp HmtxTable.cpp \ 9 | LocaTable.hpp MaxpTable.cpp \ 10 | MaxpTable.hpp NameTable.cpp \ 11 | NameTable.hpp OS2Table.cpp \ 12 | OS2Table.hpp PostTable.cpp \ 13 | PostTable.hpp \ 14 | TTFAutohint.hpp TTFAutohint.cpp \ 15 | TTFTable.hpp TTFTable.cpp \ 16 | TTFWriter.hpp TTFWriter.cpp \ 17 | VheaTable.hpp VheaTable.cpp \ 18 | VmtxTable.hpp VmtxTable.cpp 19 | 20 | include ../../libs/defs.am 21 | 22 | AM_CXXFLAGS = \ 23 | -I$(dvisvgm_srcdir)/libs/boost \ 24 | -I$(dvisvgm_srcdir)/libs/variant/include \ 25 | $(BROTLI_CFLAGS) $(WOFF2_CFLAGS) 26 | -------------------------------------------------------------------------------- /src/ttf/MaxpTable.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** MaxpTable.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | #include "TTFTable.hpp" 23 | 24 | namespace ttf { 25 | 26 | /** This class provides the functions required to write the maximum profile table of a TTF/OTF font. 27 | * https://www.microsoft.com/typography/otspec/maxp.htm */ 28 | class MaxpTable : public TTFTable { 29 | friend class TTFWriter; 30 | public: 31 | uint32_t tag () const override {return name2id("maxp");} 32 | void write(std::ostream &os) const override; 33 | 34 | protected: 35 | void updateContourInfo (uint16_t maxPoints, uint16_t maxContours); 36 | 37 | private: 38 | uint16_t _maxPoints=0; ///< maximum number of points used by a contour 39 | uint16_t _maxContours=0; ///< maximum number of contours used by a glyph 40 | }; 41 | 42 | } // namespace ttf 43 | -------------------------------------------------------------------------------- /src/ttf/NameTable.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** NameTable.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include "TTFTable.hpp" 26 | 27 | namespace ttf { 28 | 29 | /** This class provides the functions required to write the naming table of a TTF/OTF font. 30 | * https://www.microsoft.com/typography/otspec/name.htm */ 31 | class NameTable : public TTFTable { 32 | public: 33 | uint32_t tag () const override {return name2id("name");} 34 | void write (std::ostream &os) const override; 35 | }; 36 | 37 | } // namespace ttf -------------------------------------------------------------------------------- /src/ttf/OS2Table.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** OS2Table.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include "TTFTable.hpp" 25 | 26 | namespace ttf { 27 | 28 | /** This class provides the functions required to write the OS/2 and Windows metrics 29 | * table of a TTF/OTF font. 30 | * https://www.microsoft.com/typography/otspec/os2.htm */ 31 | class OS2Table : public TTFTable { 32 | friend class TTFWriter; 33 | public: 34 | uint32_t tag () const override {return name2id("OS/2");} 35 | void write (std::ostream &os) const override; 36 | 37 | protected: 38 | int16_t averageCharWidth () const; 39 | void updateXMinMax (int16_t xmin, int16_t xmax) {_xmax = xmax;} 40 | void updateYMinMax (int16_t ymin, int16_t ymax) {} 41 | 42 | private: 43 | int16_t _xmax=0; 44 | }; 45 | 46 | } // namespace ttf -------------------------------------------------------------------------------- /src/ttf/PostTable.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** PostTable.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #pragma once 22 | 23 | #include "TTFTable.hpp" 24 | 25 | namespace ttf { 26 | 27 | /** This class provides the functions required to write the PostScript table of a TTF/OTF font. 28 | * https://www.microsoft.com/typography/otspec/post.htm */ 29 | class PostTable : public TTFTable { 30 | public: 31 | uint32_t tag () const override {return name2id("post");} 32 | void write (std::ostream &os) const override; 33 | }; 34 | 35 | } // namespace ttf -------------------------------------------------------------------------------- /src/version.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** version.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef VERSION_HPP 22 | #define VERSION_HPP 23 | 24 | constexpr const char *PROGRAM_NAME = "dvisvgm"; 25 | constexpr const char *PROGRAM_VERSION = "3.5"; 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /src/version.hpp.in: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** version.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef VERSION_HPP 22 | #define VERSION_HPP 23 | 24 | constexpr const char *PROGRAM_NAME = "dvisvgm"; 25 | constexpr const char *PROGRAM_VERSION = "@VERSION@"; 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /src/windows.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** windows.hpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #ifndef WINDOWS_HPP 22 | #define WINDOWS_HPP 23 | 24 | // Prevent defining the macros min and max present in windows.h 25 | #ifndef NOMINMAX 26 | #define NOMINMAX 27 | #endif 28 | 29 | #include 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /tests/GhostscriptTest.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** GhostscriptTest.cpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #include 22 | #include "Ghostscript.hpp" 23 | 24 | 25 | TEST(GhostscriptTest, available1) { 26 | const char *args[] = {"test", "-q", "-dNODISPLAY"}; 27 | Ghostscript gs(3, args); 28 | ASSERT_TRUE(gs.available()); 29 | } 30 | 31 | 32 | TEST(GhostscriptTest, available2) { 33 | Ghostscript gs; 34 | ASSERT_TRUE(gs.available()); 35 | } 36 | 37 | 38 | TEST(GhostscriptTest, revision) { 39 | Ghostscript gs; 40 | ASSERT_GT(gs.revision(), 0); 41 | ASSERT_FALSE(gs.revisionstr().empty()); 42 | } 43 | 44 | 45 | TEST(Ghostscript, error_name) { 46 | Ghostscript gs; 47 | ASSERT_EQ(gs.error_name(0), (const char*)0); 48 | ASSERT_STREQ(gs.error_name(-1), "unknownerror"); 49 | ASSERT_STREQ(gs.error_name(1), "unknownerror"); 50 | ASSERT_STREQ(gs.error_name(2), "dictfull"); 51 | } 52 | -------------------------------------------------------------------------------- /tests/check-conv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is part of the dvisvgm package and published under the 3 | # terms of the GNU General Public License version 3 or later. 4 | # See file COPYING for further details. 5 | # Copyright (C) 2009-2025 Martin Gieseking 6 | 7 | 8 | files=(sample frktest) 9 | state=0 10 | 11 | BLUE="\E[0;34m" 12 | GREEN="\E[0;32m" 13 | RED="\E[0;31m" 14 | COLOR_OFF="\E[0m" 15 | 16 | if [ \! -e enable-check-conv ]; then 17 | echo -e "${BLUE}conversion checks skipped${COLOR_OFF}" 18 | exit 0 19 | fi 20 | 21 | for f in ${files[@]}; do 22 | for m in "wf" "nf"; do 23 | infile=${srcdir}/$f 24 | outfile=$f-$m.svg 25 | cmpfile=${srcdir}/$f-$m-cmp.svg 26 | if [ $m = "wf" ]; then 27 | ../src/dvisvgm -v0 -o$outfile $infile 28 | else 29 | ../src/dvisvgm -v0 -n -o$outfile $infile 30 | fi 31 | xsltproc --novalid ${srcdir}/normalize.xsl $outfile | xmllint --format - >tmp1.svg 32 | xsltproc --novalid ${srcdir}/normalize.xsl $cmpfile | xmllint --format - >tmp2.svg 33 | mv tmp1.svg $outfile 34 | 35 | diff $outfile tmp2.svg >$f-$m.diff #>/dev/null 36 | if [ $? -ne 0 ]; then 37 | echo -en "${RED}FAILED $COLOR_OFF" 38 | state=1 39 | else 40 | echo -en "${GREEN}PASSED $COLOR_OFF" 41 | rm $outfile 42 | fi 43 | echo "converting $f.dvi (mode $m)" 44 | if [ \! -s $f-$m.diff ]; then 45 | rm $f-$m.diff 46 | fi 47 | rm tmp2.svg 48 | done 49 | done 50 | exit $state 51 | -------------------------------------------------------------------------------- /tests/data/Makefile.am: -------------------------------------------------------------------------------- 1 | ## This file is part of dvisvgm 2 | ## Copyright (C) 2016-2025 Martin Gieseking 3 | ## 4 | ## Process this file with automake. 5 | 6 | EXTRA_DIST = \ 7 | cidjmgr0-h.tfm \ 8 | cmr10.600gf \ 9 | cmr10.pfb \ 10 | cmr10.tfm \ 11 | dvipdfm_test.map \ 12 | dvips_test.map \ 13 | frktest.dvi \ 14 | frktest-nf-cmp.svg \ 15 | frktest-wf-cmp.svg \ 16 | lmmono12-regular.otf \ 17 | omarab.ofm \ 18 | ot1.cmap \ 19 | sample.dvi \ 20 | sample-nf-cmp.svg \ 21 | sample.sfd \ 22 | sample-wf-cmp.svg \ 23 | sample_v2.dvi \ 24 | sample_v3.dvi \ 25 | upjf-g.ofm 26 | 27 | -------------------------------------------------------------------------------- /tests/data/cidjmgr0-h.tfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/cidjmgr0-h.tfm -------------------------------------------------------------------------------- /tests/data/cmr10.600gf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/cmr10.600gf -------------------------------------------------------------------------------- /tests/data/cmr10.pfb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/cmr10.pfb -------------------------------------------------------------------------------- /tests/data/cmr10.tfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/cmr10.tfm -------------------------------------------------------------------------------- /tests/data/frktest.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/frktest.dvi -------------------------------------------------------------------------------- /tests/data/lmmono12-regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/lmmono12-regular.otf -------------------------------------------------------------------------------- /tests/data/omarab.ofm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/omarab.ofm -------------------------------------------------------------------------------- /tests/data/ot1.cmap: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-3.0 Resource-CMap 2 | %%DocumentNeededResources: ProcSet (CIDInit) 3 | %%IncludeResource: ProcSet (CIDInit) 4 | %%BeginResource: CMap (TeX-OT1-0) 5 | %%Title: (TeX-OT1-0 TeX OT1 0) 6 | %%Version: 1.000 7 | %%EndComments 8 | /CIDInit /ProcSet findresource begin 9 | 12 dict begin 10 | begincmap 11 | /CIDSystemInfo 12 | << /Registry (TeX) 13 | /Ordering (OT1) 14 | /Supplement 0 15 | >> def 16 | /CMapName /TeX-OT1-0 def 17 | /CMapType 2 def 18 | 1 begincodespacerange 19 | <00> <7F> 20 | endcodespacerange 21 | 8 beginbfrange 22 | <00> <01> <0393> 23 | <09> <0A> <03A8> 24 | <23> <26> <0023> 25 | <28> <3B> <0028> 26 | <3F> <5B> <003F> 27 | <5D> <5E> <005D> 28 | <61> <7A> <0061> 29 | <7B> <7C> <2013> 30 | endbfrange 31 | 40 beginbfchar 32 | <02> <0398> 33 | <03> <039B> 34 | <04> <039E> 35 | <05> <03A0> 36 | <06> <03A3> 37 | <07> <03D2> 38 | <08> <03A6> 39 | <0B> <00660066> 40 | <0C> <00660069> 41 | <0D> <0066006C> 42 | <0E> <006600660069> 43 | <0F> <00660066006C> 44 | <10> <0131> 45 | <11> <0237> 46 | <12> <0060> 47 | <13> <00B4> 48 | <14> <02C7> 49 | <15> <02D8> 50 | <16> <00AF> 51 | <17> <02DA> 52 | <18> <00B8> 53 | <19> <00DF> 54 | <1A> <00E6> 55 | <1B> <0153> 56 | <1C> <00F8> 57 | <1D> <00C6> 58 | <1E> <0152> 59 | <1F> <00D8> 60 | <21> <0021> 61 | <22> <201D> 62 | <27> <2019> 63 | <3C> <00A1> 64 | <3D> <003D> 65 | <3E> <00BF> 66 | <5C> <201C> 67 | <5F> <02D9> 68 | <60> <2018> 69 | <7D> <02DD> 70 | <7E> <02DC> 71 | <7F> <00A8> 72 | endbfchar 73 | endcmap 74 | CMapName currentdict /CMap defineresource pop 75 | end 76 | end 77 | %%EndResource 78 | %%EOF 79 | -------------------------------------------------------------------------------- /tests/data/sample.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/sample.dvi -------------------------------------------------------------------------------- /tests/data/sample_v2.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/sample_v2.dvi -------------------------------------------------------------------------------- /tests/data/sample_v3.dvi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/sample_v3.dvi -------------------------------------------------------------------------------- /tests/data/upjf-g.ofm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgieseki/dvisvgm/02d69eea4c68789d8185f4acda43e684745ddd21/tests/data/upjf-g.ofm -------------------------------------------------------------------------------- /tests/gtest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /tests/gtest/include/gtest/internal/custom/gtest-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 38 | -------------------------------------------------------------------------------- /tests/gtest/include/gtest/internal/custom/gtest-printers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This file provides an injection point for custom printers in a local 31 | // installation of gTest. 32 | // It will be included from gtest-printers.h and the overrides in this file 33 | // will be visible to everyone. 34 | // 35 | // Injection point for custom user configurations. See README for details 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /tests/gtest/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 38 | -------------------------------------------------------------------------------- /tests/gtest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | #if GTEST_OS_ESP8266 || GTEST_OS_ESP32 35 | #if GTEST_OS_ESP8266 36 | extern "C" { 37 | #endif 38 | void setup() { testing::InitGoogleTest(); } 39 | 40 | void loop() { RUN_ALL_TESTS(); } 41 | 42 | #if GTEST_OS_ESP8266 43 | } 44 | #endif 45 | 46 | #else 47 | 48 | GTEST_API_ int main(int argc, char **argv) { 49 | printf("Running main() from %s\n", __FILE__); 50 | testing::InitGoogleTest(&argc, argv); 51 | return RUN_ALL_TESTS(); 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /tests/testmain.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** testmain.cpp ** 3 | ** ** 4 | ** This file is part of dvisvgm -- a fast DVI to SVG converter ** 5 | ** Copyright (C) 2005-2025 Martin Gieseking ** 6 | ** ** 7 | ** This program is free software; you can redistribute it and/or ** 8 | ** modify it under the terms of the GNU General Public License as ** 9 | ** published by the Free Software Foundation; either version 3 of ** 10 | ** the License, or (at your option) any later version. ** 11 | ** ** 12 | ** This program is distributed in the hope that it will be useful, but ** 13 | ** WITHOUT ANY WARRANTY; without even the implied warranty of ** 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 15 | ** GNU General Public License for more details. ** 16 | ** ** 17 | ** You should have received a copy of the GNU General Public License ** 18 | ** along with this program; if not, see . ** 19 | *************************************************************************/ 20 | 21 | #include 22 | #include 23 | #include "FileFinder.hpp" 24 | 25 | #ifndef SRCDIR 26 | #define SRCDIR "." 27 | #endif 28 | 29 | std::string TEST_ARGV0; 30 | 31 | struct TestEnvironment : public testing::Environment { 32 | void SetUp () override { 33 | FileFinder::init(TEST_ARGV0, "dvisvgm-test", false); 34 | FileFinder::instance().addLookupDir(SRCDIR); 35 | FileFinder::instance().addLookupDir(SRCDIR"/data"); 36 | } 37 | }; 38 | 39 | GTEST_API_ int main (int argc, char **argv) { 40 | TEST_ARGV0 = argv[0]; 41 | testing::InitGoogleTest(&argc, argv); 42 | testing::AddGlobalTestEnvironment(new TestEnvironment); 43 | return RUN_ALL_TESTS(); 44 | } 45 | -------------------------------------------------------------------------------- /tests/testutil.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "gtest/internal/gtest-port.h" 3 | 4 | namespace testing::internal { 5 | enum class GTestColor { kDefault, kRed, kGreen, kYellow }; 6 | 7 | GTEST_ATTRIBUTE_PRINTF_(2, 3) 8 | void ColoredPrintf(GTestColor color, const char* fmt, ...); 9 | } 10 | 11 | 12 | #define WARNING(...) \ 13 | ColoredPrintf(testing::internal::GTestColor::kYellow, "[ WARNING ] "), \ 14 | ColoredPrintf(testing::internal::GTestColor::kYellow, __VA_ARGS__), \ 15 | printf("\n") 16 | 17 | -------------------------------------------------------------------------------- /vc/README: -------------------------------------------------------------------------------- 1 | In order to build dvisvgm for MiKTeX with Microsoft Visual Studio 2022 you 2 | need to download the source code archives of the following libraries 3 | which are not bundled with the dvisvgm sources: 4 | 5 | FreeType: https://freetype.org 6 | zlib: http://zlib.net 7 | ttfautohint: https://github.com/mgieseki/ttfautohint-dll 8 | 9 | Extract the contents of the usually versioned root folders present in the 10 | library archives to the corresponding subfolders in the "vc" directory, e.g. 11 | the contents of zlib-1.2.13, should go to vc\zlib. 12 | 13 | The contents of the ttfautohint-dll release archive including the subfolders 14 | must be extracted to vc\ttfautohint. 15 | 16 | Now open the Visual Studio IDE, load dvisvgm.sln, and start the build process. 17 | 18 | Alternatively, you can trigger the build process on the command-line with 19 | msbuild /p:Configuration=Release /p:Platform= dvisvgm.sln 20 | where is either "win32" or "x64" for the 32- and 64-bit binaries, 21 | respectively. 22 | 23 | -------------------------------------------------------------------------------- /vc/clipper/clipper.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | h;hh;hpp;hxx;hm;inl;inc;xsd 7 | 8 | 9 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 10 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 11 | 12 | 13 | 14 | 15 | Header Files 16 | 17 | 18 | 19 | 20 | Source Files 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /vc/config.h: -------------------------------------------------------------------------------- 1 | /* Basic header file used to compile dvisvgm on Windows. */ 2 | #if !defined(DVISVGM_CONFIG_H) && defined(__cplusplus) 3 | #define DVISVGM_CONFIG_H 4 | #include "../src/version.hpp" 5 | 6 | /* Name of package */ 7 | #define PACKAGE PROGRAM_NAME 8 | 9 | /* Define to the address where bug reports for this package should be sent. */ 10 | #define PACKAGE_BUGREPORT "martin.gieseking@uos.de" 11 | 12 | /* Define to the full name of this package. */ 13 | #define PACKAGE_NAME PROGRAM_NAME 14 | 15 | /* Version number of package */ 16 | #define VERSION PROGRAM_VERSION 17 | 18 | /* Define to the full name and version of this package. */ 19 | #define PACKAGE_STRING PROGRAM_NAME+std::string(" ")+PROGRAM_VERSION 20 | 21 | /* Define to the one symbol short name of this package. */ 22 | #define PACKAGE_TARNAME PROGRAM_NAME 23 | 24 | /* Define to the version of this package. */ 25 | #define PACKAGE_VERSION VERSION 26 | 27 | #define HAVE_STRING_H 1 28 | 29 | #ifdef _WIN64 30 | #define HOST_SYSTEM "x86_64-pc-win64" 31 | #else 32 | #define HOST_SYSTEM "i686-pc-win32" 33 | #endif 34 | #endif 35 | -------------------------------------------------------------------------------- /vc/dvisvgm.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define DVISVGM_VERSION 3,5,0,0 4 | #define DVISVGM_VERSION_STR "3.5\0" 5 | 6 | VS_VERSION_INFO VERSIONINFO 7 | FILEVERSION DVISVGM_VERSION 8 | PRODUCTVERSION DVISVGM_VERSION 9 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 10 | FILEFLAGS 0 11 | FILEOS VOS__WINDOWS32 12 | FILETYPE VFT_APP 13 | FILESUBTYPE 0 14 | BEGIN 15 | BLOCK "StringFileInfo" 16 | BEGIN 17 | BLOCK "040904E4" // US English (0x409), ANSI codepage (1252) 18 | BEGIN 19 | VALUE "FileDescription", "Converts DVI, EPS, and PDF files to SVG\0" 20 | VALUE "FileVersion", DVISVGM_VERSION_STR 21 | VALUE "InternalName", "dvisvgm\0" 22 | VALUE "LegalCopyright", "\251 2005\2262025 Martin Gieseking\0" 23 | VALUE "OriginalFilename", "dvisvgm.exe\0" 24 | VALUE "ProductName", "dvisvgm\0" 25 | VALUE "ProductVersion", DVISVGM_VERSION_STR 26 | VALUE "Comments", "For more information visit https://dvisvgm.de\0" 27 | END 28 | END 29 | BLOCK "VarFileInfo" 30 | BEGIN 31 | VALUE "Translation", 0x409, 1252 32 | END 33 | END 34 | 35 | -------------------------------------------------------------------------------- /vc/md5/md5.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Headerdateien 20 | 21 | 22 | 23 | 24 | Quelldateien 25 | 26 | 27 | -------------------------------------------------------------------------------- /vc/miktex-com/miktex-com.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Quelldateien 20 | 21 | 22 | Quelldateien 23 | 24 | 25 | -------------------------------------------------------------------------------- /vc/miktex-com/miktexidl.idl: -------------------------------------------------------------------------------- 1 | /* miktexidl.idl: 2 | 3 | Copyright (C) 2006-2007 Christian Schenk 4 | 5 | This file is part of the MiKTeX Core Library. 6 | 7 | The MiKTeX Core Library is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License 9 | as published by the Free Software Foundation; either version 2, or 10 | (at your option) any later version. 11 | 12 | The MiKTeX Core Library is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with the MiKTeX Core Library; if not, write to the Free 19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA 20 | 02111-1307, USA. */ 21 | 22 | /// @file miktexidl.idl 23 | /// @brief Common data types. 24 | 25 | import "oaidl.idl"; 26 | import "ocidl.idl"; 27 | 28 | /* _________________________________________________________________________ 29 | 30 | ErrorInfo 31 | _________________________________________________________________________ */ 32 | 33 | /// @brief Information about a MiKTeX error. 34 | typedef [uuid(6AEC83E4-BF9A-4C21-8CC4-151D3E5A7C38)] struct ErrorInfo 35 | { 36 | /// @brief The error message. 37 | BSTR message; 38 | /// Additional information. 39 | BSTR info; 40 | /// @brief The name of the source file. 41 | BSTR sourceFile; 42 | /// @brief The line number in the source file. 43 | LONG sourceLine; 44 | } ErrorInfo; 45 | 46 | -------------------------------------------------------------------------------- /vc/potrace/libpotrace.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {cd909116-5008-4ff1-8d69-0be4cbd05f90} 6 | 7 | 8 | {2533df69-1701-41b5-9d5c-40e0fc3f36cc} 9 | 10 | 11 | 12 | 13 | Source Files 14 | 15 | 16 | Source Files 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | -------------------------------------------------------------------------------- /vc/xxHash/xxhash.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Headerdateien 16 | 17 | 18 | Headerdateien 19 | 20 | 21 | 22 | 23 | Quelldateien 24 | 25 | 26 | --------------------------------------------------------------------------------