├── LICENSE.md ├── README.md ├── bin ├── _bz2.pyd ├── _ctypes.pyd ├── _decimal.pyd ├── _elementtree.pyd ├── _hashlib.pyd ├── _lzma.pyd ├── _socket.pyd ├── _ssl.pyd ├── fonttools_LICENSE.txt ├── freetype6.dll ├── getKerningPairsFromOTF.exe ├── getKerningPairsFromOTF.py ├── msdfgen.exe ├── msdfgen_LICENSE.txt ├── pyexpat.pyd ├── python34.dll ├── select.pyd ├── unicodedata.pyd ├── wiggle.exe └── zlib1.dll ├── demo ├── game.c ├── main.c ├── make.bat ├── render.c ├── shaders.h └── textSample.h ├── example_files ├── SourceSerifPro-Bold.otf ├── SourceSerifPro-Light.otf ├── SourceSerifPro-Regular.otf ├── SourceSerif_LICENSE.txt ├── background.png └── sprites.png ├── example_usage.bat ├── make.bat ├── src ├── freetype27.lib ├── include │ ├── FTL.txt │ ├── freetype │ │ ├── config │ │ │ ├── ftconfig.h │ │ │ ├── ftheader.h │ │ │ ├── ftmodule.h │ │ │ ├── ftoption.h │ │ │ └── ftstdlib.h │ │ ├── freetype.h │ │ ├── ftadvanc.h │ │ ├── ftautoh.h │ │ ├── ftbbox.h │ │ ├── ftbdf.h │ │ ├── ftbitmap.h │ │ ├── ftbzip2.h │ │ ├── ftcache.h │ │ ├── ftcffdrv.h │ │ ├── ftchapters.h │ │ ├── ftcid.h │ │ ├── fterrdef.h │ │ ├── fterrors.h │ │ ├── ftfntfmt.h │ │ ├── ftgasp.h │ │ ├── ftglyph.h │ │ ├── ftgxval.h │ │ ├── ftgzip.h │ │ ├── ftimage.h │ │ ├── ftincrem.h │ │ ├── ftlcdfil.h │ │ ├── ftlist.h │ │ ├── ftlzw.h │ │ ├── ftmac.h │ │ ├── ftmm.h │ │ ├── ftmodapi.h │ │ ├── ftmoderr.h │ │ ├── ftotval.h │ │ ├── ftoutln.h │ │ ├── ftpfr.h │ │ ├── ftrender.h │ │ ├── ftsizes.h │ │ ├── ftsnames.h │ │ ├── ftstroke.h │ │ ├── ftsynth.h │ │ ├── ftsystem.h │ │ ├── fttrigon.h │ │ ├── ftttdrv.h │ │ ├── fttypes.h │ │ ├── ftwinfnt.h │ │ ├── internal │ │ │ ├── autohint.h │ │ │ ├── ftcalc.h │ │ │ ├── ftdebug.h │ │ │ ├── ftdriver.h │ │ │ ├── ftgloadr.h │ │ │ ├── fthash.h │ │ │ ├── ftmemory.h │ │ │ ├── ftobjs.h │ │ │ ├── ftpic.h │ │ │ ├── ftrfork.h │ │ │ ├── ftserv.h │ │ │ ├── ftstream.h │ │ │ ├── fttrace.h │ │ │ ├── ftvalid.h │ │ │ ├── internal.h │ │ │ ├── psaux.h │ │ │ ├── pshints.h │ │ │ ├── services │ │ │ │ ├── svbdf.h │ │ │ │ ├── svcid.h │ │ │ │ ├── svfntfmt.h │ │ │ │ ├── svgldict.h │ │ │ │ ├── svgxval.h │ │ │ │ ├── svkern.h │ │ │ │ ├── svmm.h │ │ │ │ ├── svotval.h │ │ │ │ ├── svpfr.h │ │ │ │ ├── svpostnm.h │ │ │ │ ├── svprop.h │ │ │ │ ├── svpscmap.h │ │ │ │ ├── svpsinfo.h │ │ │ │ ├── svsfnt.h │ │ │ │ ├── svttcmap.h │ │ │ │ ├── svtteng.h │ │ │ │ ├── svttglyf.h │ │ │ │ └── svwinfnt.h │ │ │ ├── sfnt.h │ │ │ ├── t1types.h │ │ │ └── tttypes.h │ │ ├── t1tables.h │ │ ├── ttnameid.h │ │ ├── tttables.h │ │ ├── tttags.h │ │ └── ttunpat.h │ └── ft2build.h ├── main.cc ├── stb_image.h ├── stb_image_write.h ├── stb_rect_pack.h ├── stuff.cc ├── whereami.c ├── whereami.h ├── wiggle_atlas.cc └── wiggle_fontgen.cc └── wiggle_types.h /LICENSE.md: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Wiggle 2 | ### A one-stop solution for SDF font atlas generation 3 | #### (it's a bit of a mess, but it works!) 4 | 5 | ## Build instructions 6 | 7 | Wiggle comes with all its dependencies. Wiggle is currently 64-bit Windows only. 8 | 9 | 1. Have Visual Studio installed 10 | 2. Run make.bat in a developer prompt 11 | 3. Wiggle.exe should work if it's in bin/ 12 | 4. Run `example_usage.bat` 13 | 5. Run the make.bat in the demo folder to build the demo. 14 | 15 | ## Description 16 | 17 | Wiggle is the result of a week of quick-and-dirty coding in an attempt to build some tooling to aid with making nicer looking text in small games. If you think that is a heavily qualified sentence, you're correct. This utility is largely cobbled together from parts, behaves more like a function than a program, and probably crashes if you feed it invalid input. However, it does work; it wraps msdfgen, freetype, and Adobe's kerndump script to generate image atlases of fonts using stb_image with a only a few invocations. 18 | 19 | eg: 20 | ```bat 21 | set wiggle=bin\wiggle 22 | %wiggle% fontgen font1.otf font1.wfi font1.png 128 96 4 8 4 8 1 23 | %wiggle% fontgen font2.otf font2.wfi font2.png 128 96 4 8 4 8 1 24 | %wiggle% atlas fonts.png 1024 font1.png font1.wfi font2.png font2.wfi 25 | %wiggle% rgba fonts.png fonts.rgba 26 | ``` 27 | 28 | In detail, the `fontgen` command is the star of the show: it calls out to the other programs to render glyphs, generate metrics, and gather kerning, then it atlases the results and writes it out. 29 | 30 | Once each font has been rendered to its own atlas, `atlas` gathers all the existing font atlases and writes them to a bigger atlas, along with any other images you add. This makes it easier to ship a project using only a single texture. 31 | 32 | Finally, the `rgba` command converts an encoded image (anything supported by stb_image should work) to raw 32-bit rgba data, for ease of loading in minimal applications. 33 | 34 | ## Demo 35 | 36 | Text Invaders--the name's influence should be clear--shows off the quality of the rendered text in a little game, built with no external libraries. It uses the results from `example_usage.bat`, so run that first. 37 | 38 | ## License 39 | 40 | All my code and graphics are "unlicensed" into the public domain, to be used how you see fit. msdfgen, fonttools, and kerndump are all under the MIT license, and FreeType is under the FreeType licence, which can be found in src/include/FTL.txt. Internally, I use stb_image, stb_image_write, stb_rect_pack, and whereami, which are all in the public domain. The Source Serif fonts supplied are under the Open Font License. 41 | 42 | ## Notes 43 | 44 | This thing is a mess; it uses a lot of other programs through `system(...)` calls, and won't work if it's separated from them. It'll overwrite the file `kerning.txt` and things in the folder `wiggleTemp/`. -------------------------------------------------------------------------------- /bin/_bz2.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/_bz2.pyd -------------------------------------------------------------------------------- /bin/_ctypes.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/_ctypes.pyd -------------------------------------------------------------------------------- /bin/_decimal.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/_decimal.pyd -------------------------------------------------------------------------------- /bin/_elementtree.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/_elementtree.pyd -------------------------------------------------------------------------------- /bin/_hashlib.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/_hashlib.pyd -------------------------------------------------------------------------------- /bin/_lzma.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/_lzma.pyd -------------------------------------------------------------------------------- /bin/_socket.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/_socket.pyd -------------------------------------------------------------------------------- /bin/_ssl.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/_ssl.pyd -------------------------------------------------------------------------------- /bin/fonttools_LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Just van Rossum 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/freetype6.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/freetype6.dll -------------------------------------------------------------------------------- /bin/getKerningPairsFromOTF.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/getKerningPairsFromOTF.exe -------------------------------------------------------------------------------- /bin/msdfgen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/msdfgen.exe -------------------------------------------------------------------------------- /bin/msdfgen_LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Viktor Chlumsky 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/pyexpat.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/pyexpat.pyd -------------------------------------------------------------------------------- /bin/python34.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/python34.dll -------------------------------------------------------------------------------- /bin/select.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/select.pyd -------------------------------------------------------------------------------- /bin/unicodedata.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/unicodedata.pyd -------------------------------------------------------------------------------- /bin/wiggle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/wiggle.exe -------------------------------------------------------------------------------- /bin/zlib1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/bin/zlib1.dll -------------------------------------------------------------------------------- /demo/make.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set msvcdir="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\" 4 | if not defined DevEnvDir call %msvcdir%vcvars64.bat >nul 5 | 6 | cl /nologo ^ 7 | /TC ^ 8 | /EHsc ^ 9 | /Zi ^ 10 | /W3 ^ 11 | /Gs16777216 ^ 12 | /GS- ^ 13 | /Gm- ^ 14 | /fp:fast ^ 15 | /wd4477 ^ 16 | /wd4244 ^ 17 | /wd4267 ^ 18 | /wd4334 ^ 19 | /wd4305 ^ 20 | /wd4101 ^ 21 | main.c ^ 22 | /Fe"TextInvaders.exe" ^ 23 | /Fd"TextInvaders.pdb" ^ 24 | /link ^ 25 | /nologo ^ 26 | /STACK:16777216,16777216 ^ 27 | /entry:TextInvadersMain ^ 28 | /NODEFAULTLIB ^ 29 | kernel32.lib gdi32.lib user32.lib opengl32.lib ^ 30 | /SUBSYSTEM:WINDOWS ^ 31 | /INCREMENTAL:NO 32 | 33 | del *.obj 2>&1 >nul 34 | 35 | -------------------------------------------------------------------------------- /demo/shaders.h: -------------------------------------------------------------------------------- 1 | // The shader is based on the one from 2 | // https://github.com/libgdx/libgdx/wiki/Distance-field-fonts 3 | // and 4 | // https://github.com/Chlumsky/msdfgen 5 | 6 | const char* GLES2_frag = "" "#version 100\n" 7 | "precision mediump float;\n" 8 | "varying float fKind;\n" 9 | "varying vec2 fScale;\n" 10 | "varying vec2 fUV;\n" 11 | "varying vec4 fColor;\n" 12 | "uniform float uPxRange;\n" 13 | "uniform vec2 uInvTextureSize;\n" 14 | "uniform vec4 uTint;\n" 15 | "uniform sampler2D uTexture;\n" 16 | "float median(float a, float b, float c)\n" 17 | "{\n" 18 | " return max(min(a, b), min(max(a, b), c));\n" 19 | "}\n" 20 | "vec2 subpixelAA(vec2 pixel, float zoom)\n" 21 | "{\n" 22 | " vec2 uv = floor(pixel) + 0.5;\n" 23 | " return uv + 1.0 - clamp((1.0 - fract(pixel)) * zoom, 0.0, 1.0);\n" 24 | "}\n" 25 | "void main()\n" 26 | "{\n" 27 | " if(fKind < 10.0) {\n" 28 | " //vec4 dist = texture2D(uTexture, fUV * uInvTextureSize);\n" 29 | " //float m = median(dist.x, dist.y, dist.z);\n" 30 | " //float smoothing = 0.25 / (uPxRange * fScale.x);\n" 31 | " //float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, m);\n" 32 | " //gl_FragColor = vec4(1, 1, 1, alpha) * uTint * fColor;\n" 33 | " vec2 msdfUnit = uPxRange * uInvTextureSize;\n" 34 | " vec4 sdfVal = texture2D(uTexture, fUV * uInvTextureSize);\n" 35 | " float sigDist = median(sdfVal.r, sdfVal.g, sdfVal.b) - 0.5;\n" 36 | " sigDist *= dot(msdfUnit, 0.5/vec2(fKind / 1000.0));\n" 37 | " float opacity = clamp(sigDist + 0.5, 0.0, 1.0);\n" 38 | " gl_FragColor = vec4(1, 1, 1, opacity) * uTint * fColor;\n" 39 | " } else {\n" 40 | " vec4 lcolor = fColor;\n" 41 | " if(fKind < 20.0) {\n" 42 | " vec2 uv;\n" 43 | " if(fKind > 15.0) {\n" 44 | " uv = subpixelAA(fUV, fScale.x);\n" 45 | " } else {\n" 46 | " uv = floor(fUV) + 0.5;\n" 47 | " }\n" 48 | " lcolor *= texture2D(uTexture, uv * uInvTextureSize);\n" 49 | " }\n" 50 | " gl_FragColor = lcolor * uTint;\n" 51 | " }\n" 52 | "}\n" 53 | ; 54 | const char* GLES2_vert = "" "#version 100\n" 55 | "attribute float vKind;\n" 56 | "attribute vec2 vPos;\n" 57 | "attribute vec2 vUV;\n" 58 | "attribute vec2 vScale;\n" 59 | "attribute vec4 vColor;\n" 60 | "varying float fKind;\n" 61 | "varying vec2 fScale;\n" 62 | "varying vec2 fUV;\n" 63 | "varying vec4 fColor;\n" 64 | "void main()\n" 65 | "{\n" 66 | " gl_Position = vec4(vPos, 0, 1);\n" 67 | " fUV = vUV;\n" 68 | " fScale = vScale;\n" 69 | " fKind = vKind;\n" 70 | " fColor = vColor.wzyx;\n" 71 | "}\n" 72 | ; 73 | 74 | -------------------------------------------------------------------------------- /demo/textSample.h: -------------------------------------------------------------------------------- 1 | 2 | /* The first paragraph of "The War of the Worlds", by HG Wells 3 | * What could be more fitting for a Space Invaders clone? 4 | */ 5 | const char* textSample = "No one would have believed in the last years of the nineteenth century\n" 6 | "that this world was being watched keenly and closely by intelligences\n" 7 | "greater than man's and yet as mortal as his own; that as men busied\n" 8 | "themselves about their various concerns they were scrutinised and studied,\n" 9 | "perhaps almost as narrowly as a man with a microscope might scrutinize the\n" 10 | "transient creatures that swarm and multiply in a drop of water. With\n" 11 | "infinite complacency men went to and fro over this globe about their\n" 12 | "little affairs, serene in their assurance of their empire over matter. It\n" 13 | "is possible that the infusoria under the microscope do the same. No one\n" 14 | "gave a thought to the older worlds of space as sources of human danger, or\n" 15 | "thought of them only to dismiss the idea of life upon them as impossible\n" 16 | "or improbable. It is curious to recall some of the mental habits of those\n" 17 | "departed days. At most terrestrial men fancied there might be other men\n" 18 | "upon Mars, perhaps inferior to themselves and ready to welcome\n" 19 | "a missionary enterprise. Yet across the gulf of space, minds that are to\n" 20 | "our minds as ours are to those of the beasts that perish, intellects vast\n" 21 | "and cool and unsympathetic, regarded this earth with envious eyes, and\n" 22 | "slowly and surely drew their plans against us. And early in the twentieth\n" 23 | "century came the great disillusionment.\n" 24 | ; 25 | 26 | 27 | /* 28 | The Project Gutenberg EBook of The War of the Worlds, by H. G. Wells 29 | 30 | This eBook is for the use of anyone anywhere at no cost and with 31 | almost no restrictions whatsoever. You may copy it, give it away or 32 | re-use it under the terms of the Project Gutenberg License included 33 | with this eBook or online at www.gutenberg.net 34 | */ 35 | -------------------------------------------------------------------------------- /example_files/SourceSerifPro-Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/example_files/SourceSerifPro-Bold.otf -------------------------------------------------------------------------------- /example_files/SourceSerifPro-Light.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/example_files/SourceSerifPro-Light.otf -------------------------------------------------------------------------------- /example_files/SourceSerifPro-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/example_files/SourceSerifPro-Regular.otf -------------------------------------------------------------------------------- /example_files/SourceSerif_LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 - 2017 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | 5 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /example_files/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/example_files/background.png -------------------------------------------------------------------------------- /example_files/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/example_files/sprites.png -------------------------------------------------------------------------------- /example_usage.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set wiggle=bin\wiggle.exe 3 | 4 | set sspr=example_files\SourceSerifPro-Regular.otf 5 | set sspl=example_files\SourceSerifPro-Light.otf 6 | set sspb=example_files\SourceSerifPro-Bold.otf 7 | 8 | rem width height scale x y pxrange render 9 | %wiggle% fontgen %sspr% sspr.wfi sspr.png 128 96 4 8 4 8 1 10 | %wiggle% fontgen %sspl% sspl.wfi sspl.png 128 96 4 8 4 8 1 11 | %wiggle% fontgen %sspb% sspb.wfi sspb.png 128 96 4 8 4 8 1 12 | 13 | %wiggle% atlas game_atlas.png 2048 ^ 14 | example_files\sprites.png 0 ^ 15 | example_files\background.png 0 ^ 16 | sspr.png sspr.wfi ^ 17 | sspl.png sspl.wfi ^ 18 | sspb.png sspb.wfi ^ 19 | > atlas.txt 20 | 21 | %wiggle% rgba game_atlas.png game_atlas.rgba 22 | 23 | copy game_atlas.rgba demo\ 24 | copy sspr.wfi demo\ 25 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | 2 | @echo off 3 | set msvcdir="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\" 4 | if not defined DevEnvDir call %msvcdir%vcvars64.bat >nul 5 | cl /nologo /TP /W3 /wd4244 /EHsc /I"src/include" /MD /O2 src\main.cc /Fe"bin/wiggle.exe" /link /nologo src\freetype27.lib shlwapi.lib /INCREMENTAL:NO /SUBSYSTEM:CONSOLE 6 | 7 | del *.obj 2>&1 >nul 8 | 9 | rem start wiggle DejaVuSansCondensed.ttf dvsc.wgd 10 | -------------------------------------------------------------------------------- /src/freetype27.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WilliamBundy/wiggle/420890efe221875e98cf6772248d88f76d1f9e06/src/freetype27.lib -------------------------------------------------------------------------------- /src/include/FTL.txt: -------------------------------------------------------------------------------- 1 | The FreeType Project LICENSE 2 | ---------------------------- 3 | 4 | 2006-Jan-27 5 | 6 | Copyright 1996-2002, 2006 by 7 | David Turner, Robert Wilhelm, and Werner Lemberg 8 | 9 | 10 | 11 | Introduction 12 | ============ 13 | 14 | The FreeType Project is distributed in several archive packages; 15 | some of them may contain, in addition to the FreeType font engine, 16 | various tools and contributions which rely on, or relate to, the 17 | FreeType Project. 18 | 19 | This license applies to all files found in such packages, and 20 | which do not fall under their own explicit license. The license 21 | affects thus the FreeType font engine, the test programs, 22 | documentation and makefiles, at the very least. 23 | 24 | This license was inspired by the BSD, Artistic, and IJG 25 | (Independent JPEG Group) licenses, which all encourage inclusion 26 | and use of free software in commercial and freeware products 27 | alike. As a consequence, its main points are that: 28 | 29 | o We don't promise that this software works. However, we will be 30 | interested in any kind of bug reports. (`as is' distribution) 31 | 32 | o You can use this software for whatever you want, in parts or 33 | full form, without having to pay us. (`royalty-free' usage) 34 | 35 | o You may not pretend that you wrote this software. If you use 36 | it, or only parts of it, in a program, you must acknowledge 37 | somewhere in your documentation that you have used the 38 | FreeType code. (`credits') 39 | 40 | We specifically permit and encourage the inclusion of this 41 | software, with or without modifications, in commercial products. 42 | We disclaim all warranties covering The FreeType Project and 43 | assume no liability related to The FreeType Project. 44 | 45 | 46 | Finally, many people asked us for a preferred form for a 47 | credit/disclaimer to use in compliance with this license. We thus 48 | encourage you to use the following text: 49 | 50 | """ 51 | Portions of this software are copyright © The FreeType 52 | Project (www.freetype.org). All rights reserved. 53 | """ 54 | 55 | Please replace with the value from the FreeType version you 56 | actually use. 57 | 58 | 59 | Legal Terms 60 | =========== 61 | 62 | 0. Definitions 63 | -------------- 64 | 65 | Throughout this license, the terms `package', `FreeType Project', 66 | and `FreeType archive' refer to the set of files originally 67 | distributed by the authors (David Turner, Robert Wilhelm, and 68 | Werner Lemberg) as the `FreeType Project', be they named as alpha, 69 | beta or final release. 70 | 71 | `You' refers to the licensee, or person using the project, where 72 | `using' is a generic term including compiling the project's source 73 | code as well as linking it to form a `program' or `executable'. 74 | This program is referred to as `a program using the FreeType 75 | engine'. 76 | 77 | This license applies to all files distributed in the original 78 | FreeType Project, including all source code, binaries and 79 | documentation, unless otherwise stated in the file in its 80 | original, unmodified form as distributed in the original archive. 81 | If you are unsure whether or not a particular file is covered by 82 | this license, you must contact us to verify this. 83 | 84 | The FreeType Project is copyright (C) 1996-2000 by David Turner, 85 | Robert Wilhelm, and Werner Lemberg. All rights reserved except as 86 | specified below. 87 | 88 | 1. No Warranty 89 | -------------- 90 | 91 | THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY 92 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 93 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 94 | PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS 95 | BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO 96 | USE, OF THE FREETYPE PROJECT. 97 | 98 | 2. Redistribution 99 | ----------------- 100 | 101 | This license grants a worldwide, royalty-free, perpetual and 102 | irrevocable right and license to use, execute, perform, compile, 103 | display, copy, create derivative works of, distribute and 104 | sublicense the FreeType Project (in both source and object code 105 | forms) and derivative works thereof for any purpose; and to 106 | authorize others to exercise some or all of the rights granted 107 | herein, subject to the following conditions: 108 | 109 | o Redistribution of source code must retain this license file 110 | (`FTL.TXT') unaltered; any additions, deletions or changes to 111 | the original files must be clearly indicated in accompanying 112 | documentation. The copyright notices of the unaltered, 113 | original files must be preserved in all copies of source 114 | files. 115 | 116 | o Redistribution in binary form must provide a disclaimer that 117 | states that the software is based in part of the work of the 118 | FreeType Team, in the distribution documentation. We also 119 | encourage you to put an URL to the FreeType web page in your 120 | documentation, though this isn't mandatory. 121 | 122 | These conditions apply to any software derived from or based on 123 | the FreeType Project, not just the unmodified files. If you use 124 | our work, you must acknowledge us. However, no fee need be paid 125 | to us. 126 | 127 | 3. Advertising 128 | -------------- 129 | 130 | Neither the FreeType authors and contributors nor you shall use 131 | the name of the other for commercial, advertising, or promotional 132 | purposes without specific prior written permission. 133 | 134 | We suggest, but do not require, that you use one or more of the 135 | following phrases to refer to this software in your documentation 136 | or advertising materials: `FreeType Project', `FreeType Engine', 137 | `FreeType library', or `FreeType Distribution'. 138 | 139 | As you have not signed this license, you are not required to 140 | accept it. However, as the FreeType Project is copyrighted 141 | material, only this license, or another one contracted with the 142 | authors, grants you the right to use, distribute, and modify it. 143 | Therefore, by using, distributing, or modifying the FreeType 144 | Project, you indicate that you understand and accept all the terms 145 | of this license. 146 | 147 | 4. Contacts 148 | ----------- 149 | 150 | There are two mailing lists related to FreeType: 151 | 152 | o freetype@nongnu.org 153 | 154 | Discusses general use and applications of FreeType, as well as 155 | future and wanted additions to the library and distribution. 156 | If you are looking for support, start in this list if you 157 | haven't found anything to help you in the documentation. 158 | 159 | o freetype-devel@nongnu.org 160 | 161 | Discusses bugs, as well as engine internals, design issues, 162 | specific licenses, porting, etc. 163 | 164 | Our home page can be found at 165 | 166 | https://www.freetype.org 167 | 168 | 169 | --- end of FTL.TXT --- 170 | -------------------------------------------------------------------------------- /src/include/freetype/config/ftmodule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file registers the FreeType modules compiled into the library. 3 | * 4 | * If you use GNU make, this file IS NOT USED! Instead, it is created in 5 | * the objects directory (normally `/objs/') based on information 6 | * from `/modules.cfg'. 7 | * 8 | * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile 9 | * FreeType without GNU make. 10 | * 11 | */ 12 | 13 | FT_USE_MODULE( FT_Module_Class, autofit_module_class ) 14 | FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) 15 | FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) 16 | FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) 17 | FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) 18 | FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) 19 | FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) 20 | FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) 21 | FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) 22 | FT_USE_MODULE( FT_Module_Class, psaux_module_class ) 23 | FT_USE_MODULE( FT_Module_Class, psnames_module_class ) 24 | FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) 25 | FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) 26 | FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) 27 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) 28 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) 29 | FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) 30 | FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) 31 | 32 | /* EOF */ 33 | -------------------------------------------------------------------------------- /src/include/freetype/config/ftstdlib.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftstdlib.h */ 4 | /* */ 5 | /* ANSI-specific library and header configuration file (specification */ 6 | /* only). */ 7 | /* */ 8 | /* Copyright 2002-2016 by */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* This file is part of the FreeType project, and may only be used, */ 12 | /* modified, and distributed under the terms of the FreeType project */ 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 | /* this file you indicate that you have read the license and */ 15 | /* understand and accept it fully. */ 16 | /* */ 17 | /***************************************************************************/ 18 | 19 | 20 | /*************************************************************************/ 21 | /* */ 22 | /* This file is used to group all #includes to the ANSI C library that */ 23 | /* FreeType normally requires. It also defines macros to rename the */ 24 | /* standard functions within the FreeType source code. */ 25 | /* */ 26 | /* Load a file which defines FTSTDLIB_H_ before this one to override it. */ 27 | /* */ 28 | /*************************************************************************/ 29 | 30 | 31 | #ifndef FTSTDLIB_H_ 32 | #define FTSTDLIB_H_ 33 | 34 | 35 | #include 36 | 37 | #define ft_ptrdiff_t ptrdiff_t 38 | 39 | 40 | /**********************************************************************/ 41 | /* */ 42 | /* integer limits */ 43 | /* */ 44 | /* UINT_MAX and ULONG_MAX are used to automatically compute the size */ 45 | /* of `int' and `long' in bytes at compile-time. So far, this works */ 46 | /* for all platforms the library has been tested on. */ 47 | /* */ 48 | /* Note that on the extremely rare platforms that do not provide */ 49 | /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */ 50 | /* old Crays where `int' is 36 bits), we do not make any guarantee */ 51 | /* about the correct behaviour of FT2 with all fonts. */ 52 | /* */ 53 | /* In these case, `ftconfig.h' will refuse to compile anyway with a */ 54 | /* message like `couldn't find 32-bit type' or something similar. */ 55 | /* */ 56 | /**********************************************************************/ 57 | 58 | 59 | #include 60 | 61 | #define FT_CHAR_BIT CHAR_BIT 62 | #define FT_USHORT_MAX USHRT_MAX 63 | #define FT_INT_MAX INT_MAX 64 | #define FT_INT_MIN INT_MIN 65 | #define FT_UINT_MAX UINT_MAX 66 | #define FT_LONG_MIN LONG_MIN 67 | #define FT_LONG_MAX LONG_MAX 68 | #define FT_ULONG_MAX ULONG_MAX 69 | 70 | 71 | /**********************************************************************/ 72 | /* */ 73 | /* character and string processing */ 74 | /* */ 75 | /**********************************************************************/ 76 | 77 | 78 | #include 79 | 80 | #define ft_memchr memchr 81 | #define ft_memcmp memcmp 82 | #define ft_memcpy memcpy 83 | #define ft_memmove memmove 84 | #define ft_memset memset 85 | #define ft_strcat strcat 86 | #define ft_strcmp strcmp 87 | #define ft_strcpy strcpy 88 | #define ft_strlen strlen 89 | #define ft_strncmp strncmp 90 | #define ft_strncpy strncpy 91 | #define ft_strrchr strrchr 92 | #define ft_strstr strstr 93 | 94 | 95 | /**********************************************************************/ 96 | /* */ 97 | /* file handling */ 98 | /* */ 99 | /**********************************************************************/ 100 | 101 | 102 | #include 103 | 104 | #define FT_FILE FILE 105 | #define ft_fclose fclose 106 | #define ft_fopen fopen 107 | #define ft_fread fread 108 | #define ft_fseek fseek 109 | #define ft_ftell ftell 110 | #define ft_sprintf sprintf 111 | 112 | 113 | /**********************************************************************/ 114 | /* */ 115 | /* sorting */ 116 | /* */ 117 | /**********************************************************************/ 118 | 119 | 120 | #include 121 | 122 | #define ft_qsort qsort 123 | 124 | 125 | /**********************************************************************/ 126 | /* */ 127 | /* memory allocation */ 128 | /* */ 129 | /**********************************************************************/ 130 | 131 | 132 | #define ft_scalloc calloc 133 | #define ft_sfree free 134 | #define ft_smalloc malloc 135 | #define ft_srealloc realloc 136 | 137 | 138 | /**********************************************************************/ 139 | /* */ 140 | /* miscellaneous */ 141 | /* */ 142 | /**********************************************************************/ 143 | 144 | 145 | #define ft_strtol strtol 146 | #define ft_getenv getenv 147 | 148 | 149 | /**********************************************************************/ 150 | /* */ 151 | /* execution control */ 152 | /* */ 153 | /**********************************************************************/ 154 | 155 | 156 | #include 157 | 158 | #define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ 159 | /* jmp_buf is defined as a macro */ 160 | /* on certain platforms */ 161 | 162 | #define ft_longjmp longjmp 163 | #define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ 164 | 165 | 166 | /* the following is only used for debugging purposes, i.e., if */ 167 | /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ 168 | 169 | #include 170 | 171 | 172 | #endif /* FTSTDLIB_H_ */ 173 | 174 | 175 | /* END */ 176 | -------------------------------------------------------------------------------- /src/include/freetype/ftbbox.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftbbox.h */ 4 | /* */ 5 | /* FreeType exact bbox computation (specification). */ 6 | /* */ 7 | /* Copyright 1996-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /*************************************************************************/ 20 | /* */ 21 | /* This component has a _single_ role: to compute exact outline bounding */ 22 | /* boxes. */ 23 | /* */ 24 | /* It is separated from the rest of the engine for various technical */ 25 | /* reasons. It may well be integrated in `ftoutln' later. */ 26 | /* */ 27 | /*************************************************************************/ 28 | 29 | 30 | #ifndef FTBBOX_H_ 31 | #define FTBBOX_H_ 32 | 33 | 34 | #include 35 | #include FT_FREETYPE_H 36 | 37 | #ifdef FREETYPE_H 38 | #error "freetype.h of FreeType 1 has been loaded!" 39 | #error "Please fix the directory search order for header files" 40 | #error "so that freetype.h of FreeType 2 is found first." 41 | #endif 42 | 43 | 44 | FT_BEGIN_HEADER 45 | 46 | 47 | /*************************************************************************/ 48 | /* */ 49 | /*
*/ 50 | /* outline_processing */ 51 | /* */ 52 | /*************************************************************************/ 53 | 54 | 55 | /*************************************************************************/ 56 | /* */ 57 | /* */ 58 | /* FT_Outline_Get_BBox */ 59 | /* */ 60 | /* */ 61 | /* Compute the exact bounding box of an outline. This is slower */ 62 | /* than computing the control box. However, it uses an advanced */ 63 | /* algorithm that returns _very_ quickly when the two boxes */ 64 | /* coincide. Otherwise, the outline Bézier arcs are traversed to */ 65 | /* extract their extrema. */ 66 | /* */ 67 | /* */ 68 | /* outline :: A pointer to the source outline. */ 69 | /* */ 70 | /* */ 71 | /* abbox :: The outline's exact bounding box. */ 72 | /* */ 73 | /* */ 74 | /* FreeType error code. 0~means success. */ 75 | /* */ 76 | /* */ 77 | /* If the font is tricky and the glyph has been loaded with */ 78 | /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */ 79 | /* reasonable values for the BBox it is necessary to load the glyph */ 80 | /* at a large ppem value (so that the hinting instructions can */ 81 | /* properly shift and scale the subglyphs), then extracting the BBox, */ 82 | /* which can be eventually converted back to font units. */ 83 | /* */ 84 | FT_EXPORT( FT_Error ) 85 | FT_Outline_Get_BBox( FT_Outline* outline, 86 | FT_BBox *abbox ); 87 | 88 | /* */ 89 | 90 | 91 | FT_END_HEADER 92 | 93 | #endif /* FTBBOX_H_ */ 94 | 95 | 96 | /* END */ 97 | 98 | 99 | /* Local Variables: */ 100 | /* coding: utf-8 */ 101 | /* End: */ 102 | -------------------------------------------------------------------------------- /src/include/freetype/ftbdf.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftbdf.h */ 4 | /* */ 5 | /* FreeType API for accessing BDF-specific strings (specification). */ 6 | /* */ 7 | /* Copyright 2002-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTBDF_H_ 20 | #define FTBDF_H_ 21 | 22 | #include 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /*
*/ 38 | /* bdf_fonts */ 39 | /* */ 40 | /* */ 41 | /* BDF and PCF Files */ 42 | /* */ 43 | /* <Abstract> */ 44 | /* BDF and PCF specific API. */ 45 | /* */ 46 | /* <Description> */ 47 | /* This section contains the declaration of functions specific to BDF */ 48 | /* and PCF fonts. */ 49 | /* */ 50 | /*************************************************************************/ 51 | 52 | 53 | /********************************************************************** 54 | * 55 | * @enum: 56 | * BDF_PropertyType 57 | * 58 | * @description: 59 | * A list of BDF property types. 60 | * 61 | * @values: 62 | * BDF_PROPERTY_TYPE_NONE :: 63 | * Value~0 is used to indicate a missing property. 64 | * 65 | * BDF_PROPERTY_TYPE_ATOM :: 66 | * Property is a string atom. 67 | * 68 | * BDF_PROPERTY_TYPE_INTEGER :: 69 | * Property is a 32-bit signed integer. 70 | * 71 | * BDF_PROPERTY_TYPE_CARDINAL :: 72 | * Property is a 32-bit unsigned integer. 73 | */ 74 | typedef enum BDF_PropertyType_ 75 | { 76 | BDF_PROPERTY_TYPE_NONE = 0, 77 | BDF_PROPERTY_TYPE_ATOM = 1, 78 | BDF_PROPERTY_TYPE_INTEGER = 2, 79 | BDF_PROPERTY_TYPE_CARDINAL = 3 80 | 81 | } BDF_PropertyType; 82 | 83 | 84 | /********************************************************************** 85 | * 86 | * @type: 87 | * BDF_Property 88 | * 89 | * @description: 90 | * A handle to a @BDF_PropertyRec structure to model a given 91 | * BDF/PCF property. 92 | */ 93 | typedef struct BDF_PropertyRec_* BDF_Property; 94 | 95 | 96 | /********************************************************************** 97 | * 98 | * @struct: 99 | * BDF_PropertyRec 100 | * 101 | * @description: 102 | * This structure models a given BDF/PCF property. 103 | * 104 | * @fields: 105 | * type :: 106 | * The property type. 107 | * 108 | * u.atom :: 109 | * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be 110 | * NULL, indicating an empty string. 111 | * 112 | * u.integer :: 113 | * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. 114 | * 115 | * u.cardinal :: 116 | * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. 117 | */ 118 | typedef struct BDF_PropertyRec_ 119 | { 120 | BDF_PropertyType type; 121 | union { 122 | const char* atom; 123 | FT_Int32 integer; 124 | FT_UInt32 cardinal; 125 | 126 | } u; 127 | 128 | } BDF_PropertyRec; 129 | 130 | 131 | /********************************************************************** 132 | * 133 | * @function: 134 | * FT_Get_BDF_Charset_ID 135 | * 136 | * @description: 137 | * Retrieve a BDF font character set identity, according to 138 | * the BDF specification. 139 | * 140 | * @input: 141 | * face :: 142 | * A handle to the input face. 143 | * 144 | * @output: 145 | * acharset_encoding :: 146 | * Charset encoding, as a C~string, owned by the face. 147 | * 148 | * acharset_registry :: 149 | * Charset registry, as a C~string, owned by the face. 150 | * 151 | * @return: 152 | * FreeType error code. 0~means success. 153 | * 154 | * @note: 155 | * This function only works with BDF faces, returning an error otherwise. 156 | */ 157 | FT_EXPORT( FT_Error ) 158 | FT_Get_BDF_Charset_ID( FT_Face face, 159 | const char* *acharset_encoding, 160 | const char* *acharset_registry ); 161 | 162 | 163 | /********************************************************************** 164 | * 165 | * @function: 166 | * FT_Get_BDF_Property 167 | * 168 | * @description: 169 | * Retrieve a BDF property from a BDF or PCF font file. 170 | * 171 | * @input: 172 | * face :: A handle to the input face. 173 | * 174 | * name :: The property name. 175 | * 176 | * @output: 177 | * aproperty :: The property. 178 | * 179 | * @return: 180 | * FreeType error code. 0~means success. 181 | * 182 | * @note: 183 | * This function works with BDF _and_ PCF fonts. It returns an error 184 | * otherwise. It also returns an error if the property is not in the 185 | * font. 186 | * 187 | * A `property' is a either key-value pair within the STARTPROPERTIES 188 | * ... ENDPROPERTIES block of a BDF font or a key-value pair from the 189 | * `info->props' array within a `FontRec' structure of a PCF font. 190 | * 191 | * Integer properties are always stored as `signed' within PCF fonts; 192 | * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value 193 | * for BDF fonts only. 194 | * 195 | * In case of error, `aproperty->type' is always set to 196 | * @BDF_PROPERTY_TYPE_NONE. 197 | */ 198 | FT_EXPORT( FT_Error ) 199 | FT_Get_BDF_Property( FT_Face face, 200 | const char* prop_name, 201 | BDF_PropertyRec *aproperty ); 202 | 203 | /* */ 204 | 205 | FT_END_HEADER 206 | 207 | #endif /* FTBDF_H_ */ 208 | 209 | 210 | /* END */ 211 | -------------------------------------------------------------------------------- /src/include/freetype/ftbzip2.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftbzip2.h */ 4 | /* */ 5 | /* Bzip2-compressed stream support. */ 6 | /* */ 7 | /* Copyright 2010-2016 by */ 8 | /* Joel Klinghed. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTBZIP2_H_ 20 | #define FTBZIP2_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | /*************************************************************************/ 35 | /* */ 36 | /* <Section> */ 37 | /* bzip2 */ 38 | /* */ 39 | /* <Title> */ 40 | /* BZIP2 Streams */ 41 | /* */ 42 | /* <Abstract> */ 43 | /* Using bzip2-compressed font files. */ 44 | /* */ 45 | /* <Description> */ 46 | /* This section contains the declaration of Bzip2-specific functions. */ 47 | /* */ 48 | /*************************************************************************/ 49 | 50 | 51 | /************************************************************************ 52 | * 53 | * @function: 54 | * FT_Stream_OpenBzip2 55 | * 56 | * @description: 57 | * Open a new stream to parse bzip2-compressed font files. This is 58 | * mainly used to support the compressed `*.pcf.bz2' fonts that come 59 | * with XFree86. 60 | * 61 | * @input: 62 | * stream :: 63 | * The target embedding stream. 64 | * 65 | * source :: 66 | * The source stream. 67 | * 68 | * @return: 69 | * FreeType error code. 0~means success. 70 | * 71 | * @note: 72 | * The source stream must be opened _before_ calling this function. 73 | * 74 | * Calling the internal function `FT_Stream_Close' on the new stream will 75 | * *not* call `FT_Stream_Close' on the source stream. None of the stream 76 | * objects will be released to the heap. 77 | * 78 | * The stream implementation is very basic and resets the decompression 79 | * process each time seeking backwards is needed within the stream. 80 | * 81 | * In certain builds of the library, bzip2 compression recognition is 82 | * automatically handled when calling @FT_New_Face or @FT_Open_Face. 83 | * This means that if no font driver is capable of handling the raw 84 | * compressed file, the library will try to open a bzip2 compressed stream 85 | * from it and re-open the face with it. 86 | * 87 | * This function may return `FT_Err_Unimplemented_Feature' if your build 88 | * of FreeType was not compiled with bzip2 support. 89 | */ 90 | FT_EXPORT( FT_Error ) 91 | FT_Stream_OpenBzip2( FT_Stream stream, 92 | FT_Stream source ); 93 | 94 | /* */ 95 | 96 | 97 | FT_END_HEADER 98 | 99 | #endif /* FTBZIP2_H_ */ 100 | 101 | 102 | /* END */ 103 | -------------------------------------------------------------------------------- /src/include/freetype/ftcid.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftcid.h */ 4 | /* */ 5 | /* FreeType API for accessing CID font information (specification). */ 6 | /* */ 7 | /* Copyright 2007-2016 by */ 8 | /* Dereg Clegg and Michael Toftdal. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTCID_H_ 20 | #define FTCID_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /* <Section> */ 38 | /* cid_fonts */ 39 | /* */ 40 | /* <Title> */ 41 | /* CID Fonts */ 42 | /* */ 43 | /* <Abstract> */ 44 | /* CID-keyed font specific API. */ 45 | /* */ 46 | /* <Description> */ 47 | /* This section contains the declaration of CID-keyed font specific */ 48 | /* functions. */ 49 | /* */ 50 | /*************************************************************************/ 51 | 52 | 53 | /********************************************************************** 54 | * 55 | * @function: 56 | * FT_Get_CID_Registry_Ordering_Supplement 57 | * 58 | * @description: 59 | * Retrieve the Registry/Ordering/Supplement triple (also known as the 60 | * "R/O/S") from a CID-keyed font. 61 | * 62 | * @input: 63 | * face :: 64 | * A handle to the input face. 65 | * 66 | * @output: 67 | * registry :: 68 | * The registry, as a C~string, owned by the face. 69 | * 70 | * ordering :: 71 | * The ordering, as a C~string, owned by the face. 72 | * 73 | * supplement :: 74 | * The supplement. 75 | * 76 | * @return: 77 | * FreeType error code. 0~means success. 78 | * 79 | * @note: 80 | * This function only works with CID faces, returning an error 81 | * otherwise. 82 | * 83 | * @since: 84 | * 2.3.6 85 | */ 86 | FT_EXPORT( FT_Error ) 87 | FT_Get_CID_Registry_Ordering_Supplement( FT_Face face, 88 | const char* *registry, 89 | const char* *ordering, 90 | FT_Int *supplement); 91 | 92 | 93 | /********************************************************************** 94 | * 95 | * @function: 96 | * FT_Get_CID_Is_Internally_CID_Keyed 97 | * 98 | * @description: 99 | * Retrieve the type of the input face, CID keyed or not. In 100 | * contrast to the @FT_IS_CID_KEYED macro this function returns 101 | * successfully also for CID-keyed fonts in an SFNT wrapper. 102 | * 103 | * @input: 104 | * face :: 105 | * A handle to the input face. 106 | * 107 | * @output: 108 | * is_cid :: 109 | * The type of the face as an @FT_Bool. 110 | * 111 | * @return: 112 | * FreeType error code. 0~means success. 113 | * 114 | * @note: 115 | * This function only works with CID faces and OpenType fonts, 116 | * returning an error otherwise. 117 | * 118 | * @since: 119 | * 2.3.9 120 | */ 121 | FT_EXPORT( FT_Error ) 122 | FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, 123 | FT_Bool *is_cid ); 124 | 125 | 126 | /********************************************************************** 127 | * 128 | * @function: 129 | * FT_Get_CID_From_Glyph_Index 130 | * 131 | * @description: 132 | * Retrieve the CID of the input glyph index. 133 | * 134 | * @input: 135 | * face :: 136 | * A handle to the input face. 137 | * 138 | * glyph_index :: 139 | * The input glyph index. 140 | * 141 | * @output: 142 | * cid :: 143 | * The CID as an @FT_UInt. 144 | * 145 | * @return: 146 | * FreeType error code. 0~means success. 147 | * 148 | * @note: 149 | * This function only works with CID faces and OpenType fonts, 150 | * returning an error otherwise. 151 | * 152 | * @since: 153 | * 2.3.9 154 | */ 155 | FT_EXPORT( FT_Error ) 156 | FT_Get_CID_From_Glyph_Index( FT_Face face, 157 | FT_UInt glyph_index, 158 | FT_UInt *cid ); 159 | 160 | /* */ 161 | 162 | 163 | FT_END_HEADER 164 | 165 | #endif /* FTCID_H_ */ 166 | 167 | 168 | /* END */ 169 | -------------------------------------------------------------------------------- /src/include/freetype/ftfntfmt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftfntfmt.h */ 4 | /* */ 5 | /* Support functions for font formats. */ 6 | /* */ 7 | /* Copyright 2002-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTFNTFMT_H_ 20 | #define FTFNTFMT_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /* <Section> */ 38 | /* font_formats */ 39 | /* */ 40 | /* <Title> */ 41 | /* Font Formats */ 42 | /* */ 43 | /* <Abstract> */ 44 | /* Getting the font format. */ 45 | /* */ 46 | /* <Description> */ 47 | /* The single function in this section can be used to get the font */ 48 | /* format. Note that this information is not needed normally; */ 49 | /* however, there are special cases (like in PDF devices) where it is */ 50 | /* important to differentiate, in spite of FreeType's uniform API. */ 51 | /* */ 52 | /*************************************************************************/ 53 | 54 | 55 | /*************************************************************************/ 56 | /* */ 57 | /* <Function> */ 58 | /* FT_Get_Font_Format */ 59 | /* */ 60 | /* <Description> */ 61 | /* Return a string describing the format of a given face. Possible */ 62 | /* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */ 63 | /* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */ 64 | /* */ 65 | /* The return value is suitable to be used as an X11 FONT_PROPERTY. */ 66 | /* */ 67 | /* <Input> */ 68 | /* face :: */ 69 | /* Input face handle. */ 70 | /* */ 71 | /* <Return> */ 72 | /* Font format string. NULL in case of error. */ 73 | /* */ 74 | /* <Note> */ 75 | /* A deprecated name for the same function is */ 76 | /* `FT_Get_X11_Font_Format'. */ 77 | /* */ 78 | FT_EXPORT( const char* ) 79 | FT_Get_Font_Format( FT_Face face ); 80 | 81 | 82 | /* deprecated */ 83 | FT_EXPORT( const char* ) 84 | FT_Get_X11_Font_Format( FT_Face face ); 85 | 86 | 87 | /* */ 88 | 89 | 90 | FT_END_HEADER 91 | 92 | #endif /* FTFNTFMT_H_ */ 93 | 94 | 95 | /* END */ 96 | -------------------------------------------------------------------------------- /src/include/freetype/ftgasp.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftgasp.h */ 4 | /* */ 5 | /* Access of TrueType's `gasp' table (specification). */ 6 | /* */ 7 | /* Copyright 2007-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTGASP_H_ 20 | #define FTGASP_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | /*************************************************************************** 33 | * 34 | * @section: 35 | * gasp_table 36 | * 37 | * @title: 38 | * Gasp Table 39 | * 40 | * @abstract: 41 | * Retrieving TrueType `gasp' table entries. 42 | * 43 | * @description: 44 | * The function @FT_Get_Gasp can be used to query a TrueType or OpenType 45 | * font for specific entries in its `gasp' table, if any. This is 46 | * mainly useful when implementing native TrueType hinting with the 47 | * bytecode interpreter to duplicate the Windows text rendering results. 48 | */ 49 | 50 | /************************************************************************* 51 | * 52 | * @enum: 53 | * FT_GASP_XXX 54 | * 55 | * @description: 56 | * A list of values and/or bit-flags returned by the @FT_Get_Gasp 57 | * function. 58 | * 59 | * @values: 60 | * FT_GASP_NO_TABLE :: 61 | * This special value means that there is no GASP table in this face. 62 | * It is up to the client to decide what to do. 63 | * 64 | * FT_GASP_DO_GRIDFIT :: 65 | * Grid-fitting and hinting should be performed at the specified ppem. 66 | * This *really* means TrueType bytecode interpretation. If this bit 67 | * is not set, no hinting gets applied. 68 | * 69 | * FT_GASP_DO_GRAY :: 70 | * Anti-aliased rendering should be performed at the specified ppem. 71 | * If not set, do monochrome rendering. 72 | * 73 | * FT_GASP_SYMMETRIC_SMOOTHING :: 74 | * If set, smoothing along multiple axes must be used with ClearType. 75 | * 76 | * FT_GASP_SYMMETRIC_GRIDFIT :: 77 | * Grid-fitting must be used with ClearType's symmetric smoothing. 78 | * 79 | * @note: 80 | * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be 81 | * used for standard font rasterization only. Independently of that, 82 | * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to 83 | * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and 84 | * `FT_GASP_DO_GRAY' are consequently ignored). 85 | * 86 | * `ClearType' is Microsoft's implementation of LCD rendering, partly 87 | * protected by patents. 88 | * 89 | * @since: 90 | * 2.3.0 91 | */ 92 | #define FT_GASP_NO_TABLE -1 93 | #define FT_GASP_DO_GRIDFIT 0x01 94 | #define FT_GASP_DO_GRAY 0x02 95 | #define FT_GASP_SYMMETRIC_SMOOTHING 0x08 96 | #define FT_GASP_SYMMETRIC_GRIDFIT 0x10 97 | 98 | 99 | /************************************************************************* 100 | * 101 | * @func: 102 | * FT_Get_Gasp 103 | * 104 | * @description: 105 | * Read the `gasp' table from a TrueType or OpenType font file and 106 | * return the entry corresponding to a given character pixel size. 107 | * 108 | * @input: 109 | * face :: The source face handle. 110 | * ppem :: The vertical character pixel size. 111 | * 112 | * @return: 113 | * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no 114 | * `gasp' table in the face. 115 | * 116 | * @since: 117 | * 2.3.0 118 | */ 119 | FT_EXPORT( FT_Int ) 120 | FT_Get_Gasp( FT_Face face, 121 | FT_UInt ppem ); 122 | 123 | /* */ 124 | 125 | 126 | #endif /* FTGASP_H_ */ 127 | 128 | 129 | /* END */ 130 | -------------------------------------------------------------------------------- /src/include/freetype/ftgzip.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftgzip.h */ 4 | /* */ 5 | /* Gzip-compressed stream support. */ 6 | /* */ 7 | /* Copyright 2002-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTGZIP_H_ 20 | #define FTGZIP_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | /*************************************************************************/ 35 | /* */ 36 | /* <Section> */ 37 | /* gzip */ 38 | /* */ 39 | /* <Title> */ 40 | /* GZIP Streams */ 41 | /* */ 42 | /* <Abstract> */ 43 | /* Using gzip-compressed font files. */ 44 | /* */ 45 | /* <Description> */ 46 | /* This section contains the declaration of Gzip-specific functions. */ 47 | /* */ 48 | /*************************************************************************/ 49 | 50 | 51 | /************************************************************************ 52 | * 53 | * @function: 54 | * FT_Stream_OpenGzip 55 | * 56 | * @description: 57 | * Open a new stream to parse gzip-compressed font files. This is 58 | * mainly used to support the compressed `*.pcf.gz' fonts that come 59 | * with XFree86. 60 | * 61 | * @input: 62 | * stream :: 63 | * The target embedding stream. 64 | * 65 | * source :: 66 | * The source stream. 67 | * 68 | * @return: 69 | * FreeType error code. 0~means success. 70 | * 71 | * @note: 72 | * The source stream must be opened _before_ calling this function. 73 | * 74 | * Calling the internal function `FT_Stream_Close' on the new stream will 75 | * *not* call `FT_Stream_Close' on the source stream. None of the stream 76 | * objects will be released to the heap. 77 | * 78 | * The stream implementation is very basic and resets the decompression 79 | * process each time seeking backwards is needed within the stream. 80 | * 81 | * In certain builds of the library, gzip compression recognition is 82 | * automatically handled when calling @FT_New_Face or @FT_Open_Face. 83 | * This means that if no font driver is capable of handling the raw 84 | * compressed file, the library will try to open a gzipped stream from 85 | * it and re-open the face with it. 86 | * 87 | * This function may return `FT_Err_Unimplemented_Feature' if your build 88 | * of FreeType was not compiled with zlib support. 89 | */ 90 | FT_EXPORT( FT_Error ) 91 | FT_Stream_OpenGzip( FT_Stream stream, 92 | FT_Stream source ); 93 | 94 | 95 | /************************************************************************ 96 | * 97 | * @function: 98 | * FT_Gzip_Uncompress 99 | * 100 | * @description: 101 | * Decompress a zipped input buffer into an output buffer. This function 102 | * is modeled after zlib's `uncompress' function. 103 | * 104 | * @input: 105 | * memory :: 106 | * A FreeType memory handle. 107 | * 108 | * input :: 109 | * The input buffer. 110 | * 111 | * input_len :: 112 | * The length of the input buffer. 113 | * 114 | * @output: 115 | * output:: 116 | * The output buffer. 117 | * 118 | * @inout: 119 | * output_len :: 120 | * Before calling the function, this is the total size of the output 121 | * buffer, which must be large enough to hold the entire uncompressed 122 | * data (so the size of the uncompressed data must be known in 123 | * advance). After calling the function, `output_len' is the size of 124 | * the used data in `output'. 125 | * 126 | * @return: 127 | * FreeType error code. 0~means success. 128 | * 129 | * @note: 130 | * This function may return `FT_Err_Unimplemented_Feature' if your build 131 | * of FreeType was not compiled with zlib support. 132 | */ 133 | FT_EXPORT( FT_Error ) 134 | FT_Gzip_Uncompress( FT_Memory memory, 135 | FT_Byte* output, 136 | FT_ULong* output_len, 137 | const FT_Byte* input, 138 | FT_ULong input_len ); 139 | 140 | /* */ 141 | 142 | 143 | FT_END_HEADER 144 | 145 | #endif /* FTGZIP_H_ */ 146 | 147 | 148 | /* END */ 149 | -------------------------------------------------------------------------------- /src/include/freetype/ftlzw.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftlzw.h */ 4 | /* */ 5 | /* LZW-compressed stream support. */ 6 | /* */ 7 | /* Copyright 2004-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTLZW_H_ 20 | #define FTLZW_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | /*************************************************************************/ 35 | /* */ 36 | /* <Section> */ 37 | /* lzw */ 38 | /* */ 39 | /* <Title> */ 40 | /* LZW Streams */ 41 | /* */ 42 | /* <Abstract> */ 43 | /* Using LZW-compressed font files. */ 44 | /* */ 45 | /* <Description> */ 46 | /* This section contains the declaration of LZW-specific functions. */ 47 | /* */ 48 | /*************************************************************************/ 49 | 50 | /************************************************************************ 51 | * 52 | * @function: 53 | * FT_Stream_OpenLZW 54 | * 55 | * @description: 56 | * Open a new stream to parse LZW-compressed font files. This is 57 | * mainly used to support the compressed `*.pcf.Z' fonts that come 58 | * with XFree86. 59 | * 60 | * @input: 61 | * stream :: The target embedding stream. 62 | * 63 | * source :: The source stream. 64 | * 65 | * @return: 66 | * FreeType error code. 0~means success. 67 | * 68 | * @note: 69 | * The source stream must be opened _before_ calling this function. 70 | * 71 | * Calling the internal function `FT_Stream_Close' on the new stream will 72 | * *not* call `FT_Stream_Close' on the source stream. None of the stream 73 | * objects will be released to the heap. 74 | * 75 | * The stream implementation is very basic and resets the decompression 76 | * process each time seeking backwards is needed within the stream 77 | * 78 | * In certain builds of the library, LZW compression recognition is 79 | * automatically handled when calling @FT_New_Face or @FT_Open_Face. 80 | * This means that if no font driver is capable of handling the raw 81 | * compressed file, the library will try to open a LZW stream from it 82 | * and re-open the face with it. 83 | * 84 | * This function may return `FT_Err_Unimplemented_Feature' if your build 85 | * of FreeType was not compiled with LZW support. 86 | */ 87 | FT_EXPORT( FT_Error ) 88 | FT_Stream_OpenLZW( FT_Stream stream, 89 | FT_Stream source ); 90 | 91 | /* */ 92 | 93 | 94 | FT_END_HEADER 95 | 96 | #endif /* FTLZW_H_ */ 97 | 98 | 99 | /* END */ 100 | -------------------------------------------------------------------------------- /src/include/freetype/ftpfr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftpfr.h */ 4 | /* */ 5 | /* FreeType API for accessing PFR-specific data (specification only). */ 6 | /* */ 7 | /* Copyright 2002-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTPFR_H_ 20 | #define FTPFR_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_FREETYPE_H 24 | 25 | #ifdef FREETYPE_H 26 | #error "freetype.h of FreeType 1 has been loaded!" 27 | #error "Please fix the directory search order for header files" 28 | #error "so that freetype.h of FreeType 2 is found first." 29 | #endif 30 | 31 | 32 | FT_BEGIN_HEADER 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /* <Section> */ 38 | /* pfr_fonts */ 39 | /* */ 40 | /* <Title> */ 41 | /* PFR Fonts */ 42 | /* */ 43 | /* <Abstract> */ 44 | /* PFR/TrueDoc specific API. */ 45 | /* */ 46 | /* <Description> */ 47 | /* This section contains the declaration of PFR-specific functions. */ 48 | /* */ 49 | /*************************************************************************/ 50 | 51 | 52 | /********************************************************************** 53 | * 54 | * @function: 55 | * FT_Get_PFR_Metrics 56 | * 57 | * @description: 58 | * Return the outline and metrics resolutions of a given PFR face. 59 | * 60 | * @input: 61 | * face :: Handle to the input face. It can be a non-PFR face. 62 | * 63 | * @output: 64 | * aoutline_resolution :: 65 | * Outline resolution. This is equivalent to `face->units_per_EM' 66 | * for non-PFR fonts. Optional (parameter can be NULL). 67 | * 68 | * ametrics_resolution :: 69 | * Metrics resolution. This is equivalent to `outline_resolution' 70 | * for non-PFR fonts. Optional (parameter can be NULL). 71 | * 72 | * ametrics_x_scale :: 73 | * A 16.16 fixed-point number used to scale distance expressed 74 | * in metrics units to device sub-pixels. This is equivalent to 75 | * `face->size->x_scale', but for metrics only. Optional (parameter 76 | * can be NULL). 77 | * 78 | * ametrics_y_scale :: 79 | * Same as `ametrics_x_scale' but for the vertical direction. 80 | * optional (parameter can be NULL). 81 | * 82 | * @return: 83 | * FreeType error code. 0~means success. 84 | * 85 | * @note: 86 | * If the input face is not a PFR, this function will return an error. 87 | * However, in all cases, it will return valid values. 88 | */ 89 | FT_EXPORT( FT_Error ) 90 | FT_Get_PFR_Metrics( FT_Face face, 91 | FT_UInt *aoutline_resolution, 92 | FT_UInt *ametrics_resolution, 93 | FT_Fixed *ametrics_x_scale, 94 | FT_Fixed *ametrics_y_scale ); 95 | 96 | 97 | /********************************************************************** 98 | * 99 | * @function: 100 | * FT_Get_PFR_Kerning 101 | * 102 | * @description: 103 | * Return the kerning pair corresponding to two glyphs in a PFR face. 104 | * The distance is expressed in metrics units, unlike the result of 105 | * @FT_Get_Kerning. 106 | * 107 | * @input: 108 | * face :: A handle to the input face. 109 | * 110 | * left :: Index of the left glyph. 111 | * 112 | * right :: Index of the right glyph. 113 | * 114 | * @output: 115 | * avector :: A kerning vector. 116 | * 117 | * @return: 118 | * FreeType error code. 0~means success. 119 | * 120 | * @note: 121 | * This function always return distances in original PFR metrics 122 | * units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED 123 | * mode, which always returns distances converted to outline units. 124 | * 125 | * You can use the value of the `x_scale' and `y_scale' parameters 126 | * returned by @FT_Get_PFR_Metrics to scale these to device sub-pixels. 127 | */ 128 | FT_EXPORT( FT_Error ) 129 | FT_Get_PFR_Kerning( FT_Face face, 130 | FT_UInt left, 131 | FT_UInt right, 132 | FT_Vector *avector ); 133 | 134 | 135 | /********************************************************************** 136 | * 137 | * @function: 138 | * FT_Get_PFR_Advance 139 | * 140 | * @description: 141 | * Return a given glyph advance, expressed in original metrics units, 142 | * from a PFR font. 143 | * 144 | * @input: 145 | * face :: A handle to the input face. 146 | * 147 | * gindex :: The glyph index. 148 | * 149 | * @output: 150 | * aadvance :: The glyph advance in metrics units. 151 | * 152 | * @return: 153 | * FreeType error code. 0~means success. 154 | * 155 | * @note: 156 | * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics 157 | * to convert the advance to device sub-pixels (i.e., 1/64th of pixels). 158 | */ 159 | FT_EXPORT( FT_Error ) 160 | FT_Get_PFR_Advance( FT_Face face, 161 | FT_UInt gindex, 162 | FT_Pos *aadvance ); 163 | 164 | /* */ 165 | 166 | 167 | FT_END_HEADER 168 | 169 | #endif /* FTPFR_H_ */ 170 | 171 | 172 | /* END */ 173 | -------------------------------------------------------------------------------- /src/include/freetype/ftsynth.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftsynth.h */ 4 | /* */ 5 | /* FreeType synthesizing code for emboldening and slanting */ 6 | /* (specification). */ 7 | /* */ 8 | /* Copyright 2000-2016 by */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* This file is part of the FreeType project, and may only be used, */ 12 | /* modified, and distributed under the terms of the FreeType project */ 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 | /* this file you indicate that you have read the license and */ 15 | /* understand and accept it fully. */ 16 | /* */ 17 | /***************************************************************************/ 18 | 19 | 20 | /*************************************************************************/ 21 | /*************************************************************************/ 22 | /*************************************************************************/ 23 | /*************************************************************************/ 24 | /*************************************************************************/ 25 | /********* *********/ 26 | /********* WARNING, THIS IS ALPHA CODE! THIS API *********/ 27 | /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/ 28 | /********* FREETYPE DEVELOPMENT TEAM *********/ 29 | /********* *********/ 30 | /*************************************************************************/ 31 | /*************************************************************************/ 32 | /*************************************************************************/ 33 | /*************************************************************************/ 34 | /*************************************************************************/ 35 | 36 | 37 | /* Main reason for not lifting the functions in this module to a */ 38 | /* `standard' API is that the used parameters for emboldening and */ 39 | /* slanting are not configurable. Consider the functions as a */ 40 | /* code resource that should be copied into the application and */ 41 | /* adapted to the particular needs. */ 42 | 43 | 44 | #ifndef FTSYNTH_H_ 45 | #define FTSYNTH_H_ 46 | 47 | 48 | #include <ft2build.h> 49 | #include FT_FREETYPE_H 50 | 51 | #ifdef FREETYPE_H 52 | #error "freetype.h of FreeType 1 has been loaded!" 53 | #error "Please fix the directory search order for header files" 54 | #error "so that freetype.h of FreeType 2 is found first." 55 | #endif 56 | 57 | 58 | FT_BEGIN_HEADER 59 | 60 | /* Embolden a glyph by a `reasonable' value (which is highly a matter of */ 61 | /* taste). This function is actually a convenience function, providing */ 62 | /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ 63 | /* */ 64 | /* For emboldened outlines the height, width, and advance metrics are */ 65 | /* increased by the strength of the emboldening -- this even affects */ 66 | /* mono-width fonts! */ 67 | /* */ 68 | /* You can also call @FT_Outline_Get_CBox to get precise values. */ 69 | FT_EXPORT( void ) 70 | FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); 71 | 72 | /* Slant an outline glyph to the right by about 12 degrees. */ 73 | FT_EXPORT( void ) 74 | FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); 75 | 76 | /* */ 77 | 78 | 79 | FT_END_HEADER 80 | 81 | #endif /* FTSYNTH_H_ */ 82 | 83 | 84 | /* END */ 85 | -------------------------------------------------------------------------------- /src/include/freetype/internal/ftgloadr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftgloadr.h */ 4 | /* */ 5 | /* The FreeType glyph loader (specification). */ 6 | /* */ 7 | /* Copyright 2002-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTGLOADR_H_ 20 | #define FTGLOADR_H_ 21 | 22 | 23 | #include <ft2build.h> 24 | #include FT_FREETYPE_H 25 | 26 | 27 | FT_BEGIN_HEADER 28 | 29 | 30 | /*************************************************************************/ 31 | /* */ 32 | /* <Struct> */ 33 | /* FT_GlyphLoader */ 34 | /* */ 35 | /* <Description> */ 36 | /* The glyph loader is an internal object used to load several glyphs */ 37 | /* together (for example, in the case of composites). */ 38 | /* */ 39 | typedef struct FT_SubGlyphRec_ 40 | { 41 | FT_Int index; 42 | FT_UShort flags; 43 | FT_Int arg1; 44 | FT_Int arg2; 45 | FT_Matrix transform; 46 | 47 | } FT_SubGlyphRec; 48 | 49 | 50 | typedef struct FT_GlyphLoadRec_ 51 | { 52 | FT_Outline outline; /* outline */ 53 | FT_Vector* extra_points; /* extra points table */ 54 | FT_Vector* extra_points2; /* second extra points table */ 55 | FT_UInt num_subglyphs; /* number of subglyphs */ 56 | FT_SubGlyph subglyphs; /* subglyphs */ 57 | 58 | } FT_GlyphLoadRec, *FT_GlyphLoad; 59 | 60 | 61 | typedef struct FT_GlyphLoaderRec_ 62 | { 63 | FT_Memory memory; 64 | FT_UInt max_points; 65 | FT_UInt max_contours; 66 | FT_UInt max_subglyphs; 67 | FT_Bool use_extra; 68 | 69 | FT_GlyphLoadRec base; 70 | FT_GlyphLoadRec current; 71 | 72 | void* other; /* for possible future extension? */ 73 | 74 | } FT_GlyphLoaderRec, *FT_GlyphLoader; 75 | 76 | 77 | /* create new empty glyph loader */ 78 | FT_BASE( FT_Error ) 79 | FT_GlyphLoader_New( FT_Memory memory, 80 | FT_GlyphLoader *aloader ); 81 | 82 | /* add an extra points table to a glyph loader */ 83 | FT_BASE( FT_Error ) 84 | FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader ); 85 | 86 | /* destroy a glyph loader */ 87 | FT_BASE( void ) 88 | FT_GlyphLoader_Done( FT_GlyphLoader loader ); 89 | 90 | /* reset a glyph loader (frees everything int it) */ 91 | FT_BASE( void ) 92 | FT_GlyphLoader_Reset( FT_GlyphLoader loader ); 93 | 94 | /* rewind a glyph loader */ 95 | FT_BASE( void ) 96 | FT_GlyphLoader_Rewind( FT_GlyphLoader loader ); 97 | 98 | /* check that there is enough space to add `n_points' and `n_contours' */ 99 | /* to the glyph loader */ 100 | FT_BASE( FT_Error ) 101 | FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader, 102 | FT_UInt n_points, 103 | FT_UInt n_contours ); 104 | 105 | 106 | #define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \ 107 | ( (_count) == 0 || \ 108 | ( (FT_UInt)(_loader)->base.outline.n_points + \ 109 | (FT_UInt)(_loader)->current.outline.n_points + \ 110 | (FT_UInt)(_count) ) <= (_loader)->max_points ) 111 | 112 | #define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \ 113 | ( (_count) == 0 || \ 114 | ( (FT_UInt)(_loader)->base.outline.n_contours + \ 115 | (FT_UInt)(_loader)->current.outline.n_contours + \ 116 | (FT_UInt)(_count) ) <= (_loader)->max_contours ) 117 | 118 | #define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours ) \ 119 | ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \ 120 | FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \ 121 | ? 0 \ 122 | : FT_GlyphLoader_CheckPoints( (_loader), \ 123 | (FT_UInt)(_points), \ 124 | (FT_UInt)(_contours) ) ) 125 | 126 | 127 | /* check that there is enough space to add `n_subs' sub-glyphs to */ 128 | /* a glyph loader */ 129 | FT_BASE( FT_Error ) 130 | FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader, 131 | FT_UInt n_subs ); 132 | 133 | /* prepare a glyph loader, i.e. empty the current glyph */ 134 | FT_BASE( void ) 135 | FT_GlyphLoader_Prepare( FT_GlyphLoader loader ); 136 | 137 | /* add the current glyph to the base glyph */ 138 | FT_BASE( void ) 139 | FT_GlyphLoader_Add( FT_GlyphLoader loader ); 140 | 141 | /* copy points from one glyph loader to another */ 142 | FT_BASE( FT_Error ) 143 | FT_GlyphLoader_CopyPoints( FT_GlyphLoader target, 144 | FT_GlyphLoader source ); 145 | 146 | /* */ 147 | 148 | 149 | FT_END_HEADER 150 | 151 | #endif /* FTGLOADR_H_ */ 152 | 153 | 154 | /* END */ 155 | -------------------------------------------------------------------------------- /src/include/freetype/internal/fthash.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* fthash.h */ 4 | /* */ 5 | /* Hashing functions (specification). */ 6 | /* */ 7 | /***************************************************************************/ 8 | 9 | /* 10 | * Copyright 2000 Computing Research Labs, New Mexico State University 11 | * Copyright 2001-2015 12 | * Francesco Zappa Nardelli 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a 15 | * copy of this software and associated documentation files (the "Software"), 16 | * to deal in the Software without restriction, including without limitation 17 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY 28 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 29 | * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 30 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | /*************************************************************************/ 34 | /* */ 35 | /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */ 36 | /* */ 37 | /* taken from Mark Leisher's xmbdfed package */ 38 | /* */ 39 | /*************************************************************************/ 40 | 41 | 42 | #ifndef FTHASH_H_ 43 | #define FTHASH_H_ 44 | 45 | 46 | #include <ft2build.h> 47 | #include FT_FREETYPE_H 48 | 49 | 50 | FT_BEGIN_HEADER 51 | 52 | 53 | typedef union FT_Hashkey_ 54 | { 55 | FT_Int num; 56 | const char* str; 57 | 58 | } FT_Hashkey; 59 | 60 | 61 | typedef struct FT_HashnodeRec_ 62 | { 63 | FT_Hashkey key; 64 | size_t data; 65 | 66 | } FT_HashnodeRec; 67 | 68 | typedef struct FT_HashnodeRec_ *FT_Hashnode; 69 | 70 | 71 | typedef FT_ULong 72 | (*FT_Hash_LookupFunc)( FT_Hashkey* key ); 73 | 74 | typedef FT_Bool 75 | (*FT_Hash_CompareFunc)( FT_Hashkey* a, 76 | FT_Hashkey* b ); 77 | 78 | 79 | typedef struct FT_HashRec_ 80 | { 81 | FT_UInt limit; 82 | FT_UInt size; 83 | FT_UInt used; 84 | 85 | FT_Hash_LookupFunc lookup; 86 | FT_Hash_CompareFunc compare; 87 | 88 | FT_Hashnode* table; 89 | 90 | } FT_HashRec; 91 | 92 | typedef struct FT_HashRec_ *FT_Hash; 93 | 94 | 95 | FT_Error 96 | ft_hash_str_init( FT_Hash hash, 97 | FT_Memory memory ); 98 | 99 | FT_Error 100 | ft_hash_num_init( FT_Hash hash, 101 | FT_Memory memory ); 102 | 103 | void 104 | ft_hash_str_free( FT_Hash hash, 105 | FT_Memory memory ); 106 | 107 | #define ft_hash_num_free ft_hash_str_free 108 | 109 | FT_Error 110 | ft_hash_str_insert( const char* key, 111 | size_t data, 112 | FT_Hash hash, 113 | FT_Memory memory ); 114 | 115 | FT_Error 116 | ft_hash_num_insert( FT_Int num, 117 | size_t data, 118 | FT_Hash hash, 119 | FT_Memory memory ); 120 | 121 | size_t* 122 | ft_hash_str_lookup( const char* key, 123 | FT_Hash hash ); 124 | 125 | size_t* 126 | ft_hash_num_lookup( FT_Int num, 127 | FT_Hash hash ); 128 | 129 | 130 | FT_END_HEADER 131 | 132 | 133 | #endif /* FTHASH_H_ */ 134 | 135 | 136 | /* END */ 137 | -------------------------------------------------------------------------------- /src/include/freetype/internal/ftpic.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftpic.h */ 4 | /* */ 5 | /* The FreeType position independent code services (declaration). */ 6 | /* */ 7 | /* Copyright 2009-2016 by */ 8 | /* Oran Agra and Mickey Gabel. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | /*************************************************************************/ 19 | /* */ 20 | /* Modules that ordinarily have const global data that need address */ 21 | /* can instead define pointers here. */ 22 | /* */ 23 | /*************************************************************************/ 24 | 25 | 26 | #ifndef FTPIC_H_ 27 | #define FTPIC_H_ 28 | 29 | 30 | FT_BEGIN_HEADER 31 | 32 | #ifdef FT_CONFIG_OPTION_PIC 33 | 34 | typedef struct FT_PIC_Container_ 35 | { 36 | /* pic containers for base */ 37 | void* base; 38 | 39 | /* pic containers for modules */ 40 | void* autofit; 41 | void* cff; 42 | void* pshinter; 43 | void* psnames; 44 | void* raster; 45 | void* sfnt; 46 | void* smooth; 47 | void* truetype; 48 | 49 | } FT_PIC_Container; 50 | 51 | 52 | /* Initialize the various function tables, structs, etc. */ 53 | /* stored in the container. */ 54 | FT_BASE( FT_Error ) 55 | ft_pic_container_init( FT_Library library ); 56 | 57 | 58 | /* Destroy the contents of the container. */ 59 | FT_BASE( void ) 60 | ft_pic_container_destroy( FT_Library library ); 61 | 62 | #endif /* FT_CONFIG_OPTION_PIC */ 63 | 64 | /* */ 65 | 66 | FT_END_HEADER 67 | 68 | #endif /* FTPIC_H_ */ 69 | 70 | 71 | /* END */ 72 | -------------------------------------------------------------------------------- /src/include/freetype/internal/fttrace.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* fttrace.h */ 4 | /* */ 5 | /* Tracing handling (specification only). */ 6 | /* */ 7 | /* Copyright 2002-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /* definitions of trace levels for FreeType 2 */ 20 | 21 | /* the first level must always be `trace_any' */ 22 | FT_TRACE_DEF( any ) 23 | 24 | /* base components */ 25 | FT_TRACE_DEF( calc ) /* calculations (ftcalc.c) */ 26 | FT_TRACE_DEF( memory ) /* memory manager (ftobjs.c) */ 27 | FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */ 28 | FT_TRACE_DEF( io ) /* i/o interface (ftsystem.c) */ 29 | FT_TRACE_DEF( list ) /* list management (ftlist.c) */ 30 | FT_TRACE_DEF( init ) /* initialization (ftinit.c) */ 31 | FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */ 32 | FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */ 33 | FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ 34 | FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */ 35 | 36 | FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ 37 | FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ 38 | FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */ 39 | FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */ 40 | FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */ 41 | FT_TRACE_DEF( bitmap ) /* bitmap checksum (ftobjs.c) */ 42 | 43 | /* Cache sub-system */ 44 | FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */ 45 | 46 | /* SFNT driver components */ 47 | FT_TRACE_DEF( sfdriver ) /* SFNT font driver (sfdriver.c) */ 48 | FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */ 49 | FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */ 50 | FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */ 51 | FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */ 52 | FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */ 53 | FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */ 54 | FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */ 55 | FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */ 56 | 57 | /* TrueType driver components */ 58 | FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */ 59 | FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */ 60 | FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */ 61 | FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */ 62 | FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */ 63 | FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */ 64 | 65 | /* Type 1 driver components */ 66 | FT_TRACE_DEF( t1afm ) 67 | FT_TRACE_DEF( t1driver ) 68 | FT_TRACE_DEF( t1gload ) 69 | FT_TRACE_DEF( t1hint ) 70 | FT_TRACE_DEF( t1load ) 71 | FT_TRACE_DEF( t1objs ) 72 | FT_TRACE_DEF( t1parse ) 73 | 74 | /* PostScript helper module `psaux' */ 75 | FT_TRACE_DEF( t1decode ) 76 | FT_TRACE_DEF( psobjs ) 77 | FT_TRACE_DEF( psconv ) 78 | 79 | /* PostScript hinting module `pshinter' */ 80 | FT_TRACE_DEF( pshrec ) 81 | FT_TRACE_DEF( pshalgo1 ) 82 | FT_TRACE_DEF( pshalgo2 ) 83 | 84 | /* Type 2 driver components */ 85 | FT_TRACE_DEF( cffdriver ) 86 | FT_TRACE_DEF( cffgload ) 87 | FT_TRACE_DEF( cffload ) 88 | FT_TRACE_DEF( cffobjs ) 89 | FT_TRACE_DEF( cffparse ) 90 | 91 | FT_TRACE_DEF( cf2blues ) 92 | FT_TRACE_DEF( cf2hints ) 93 | FT_TRACE_DEF( cf2interp ) 94 | 95 | /* Type 42 driver component */ 96 | FT_TRACE_DEF( t42 ) 97 | 98 | /* CID driver components */ 99 | FT_TRACE_DEF( cidafm ) 100 | FT_TRACE_DEF( ciddriver ) 101 | FT_TRACE_DEF( cidgload ) 102 | FT_TRACE_DEF( cidload ) 103 | FT_TRACE_DEF( cidobjs ) 104 | FT_TRACE_DEF( cidparse ) 105 | 106 | /* Windows font component */ 107 | FT_TRACE_DEF( winfnt ) 108 | 109 | /* PCF font components */ 110 | FT_TRACE_DEF( pcfdriver ) 111 | FT_TRACE_DEF( pcfread ) 112 | 113 | /* BDF font components */ 114 | FT_TRACE_DEF( bdfdriver ) 115 | FT_TRACE_DEF( bdflib ) 116 | 117 | /* PFR font component */ 118 | FT_TRACE_DEF( pfr ) 119 | 120 | /* OpenType validation components */ 121 | FT_TRACE_DEF( otvmodule ) 122 | FT_TRACE_DEF( otvcommon ) 123 | FT_TRACE_DEF( otvbase ) 124 | FT_TRACE_DEF( otvgdef ) 125 | FT_TRACE_DEF( otvgpos ) 126 | FT_TRACE_DEF( otvgsub ) 127 | FT_TRACE_DEF( otvjstf ) 128 | FT_TRACE_DEF( otvmath ) 129 | 130 | /* TrueTypeGX/AAT validation components */ 131 | FT_TRACE_DEF( gxvmodule ) 132 | FT_TRACE_DEF( gxvcommon ) 133 | FT_TRACE_DEF( gxvfeat ) 134 | FT_TRACE_DEF( gxvmort ) 135 | FT_TRACE_DEF( gxvmorx ) 136 | FT_TRACE_DEF( gxvbsln ) 137 | FT_TRACE_DEF( gxvjust ) 138 | FT_TRACE_DEF( gxvkern ) 139 | FT_TRACE_DEF( gxvopbd ) 140 | FT_TRACE_DEF( gxvtrak ) 141 | FT_TRACE_DEF( gxvprop ) 142 | FT_TRACE_DEF( gxvlcar ) 143 | 144 | /* autofit components */ 145 | FT_TRACE_DEF( afmodule ) 146 | FT_TRACE_DEF( afhints ) 147 | FT_TRACE_DEF( afcjk ) 148 | FT_TRACE_DEF( aflatin ) 149 | FT_TRACE_DEF( aflatin2 ) 150 | FT_TRACE_DEF( afwarp ) 151 | FT_TRACE_DEF( afshaper ) 152 | FT_TRACE_DEF( afglobal ) 153 | 154 | /* END */ 155 | -------------------------------------------------------------------------------- /src/include/freetype/internal/ftvalid.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ftvalid.h */ 4 | /* */ 5 | /* FreeType validation support (specification). */ 6 | /* */ 7 | /* Copyright 2004-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef FTVALID_H_ 20 | #define FTVALID_H_ 21 | 22 | #include <ft2build.h> 23 | #include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_setjmp and ft_longjmp */ 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | /*************************************************************************/ 30 | /*************************************************************************/ 31 | /*************************************************************************/ 32 | /**** ****/ 33 | /**** ****/ 34 | /**** V A L I D A T I O N ****/ 35 | /**** ****/ 36 | /**** ****/ 37 | /*************************************************************************/ 38 | /*************************************************************************/ 39 | /*************************************************************************/ 40 | 41 | /* handle to a validation object */ 42 | typedef struct FT_ValidatorRec_ volatile* FT_Validator; 43 | 44 | 45 | /*************************************************************************/ 46 | /* */ 47 | /* There are three distinct validation levels defined here: */ 48 | /* */ 49 | /* FT_VALIDATE_DEFAULT :: */ 50 | /* A table that passes this validation level can be used reliably by */ 51 | /* FreeType. It generally means that all offsets have been checked to */ 52 | /* prevent out-of-bound reads, that array counts are correct, etc. */ 53 | /* */ 54 | /* FT_VALIDATE_TIGHT :: */ 55 | /* A table that passes this validation level can be used reliably and */ 56 | /* doesn't contain invalid data. For example, a charmap table that */ 57 | /* returns invalid glyph indices will not pass, even though it can */ 58 | /* be used with FreeType in default mode (the library will simply */ 59 | /* return an error later when trying to load the glyph). */ 60 | /* */ 61 | /* It also checks that fields which must be a multiple of 2, 4, or 8, */ 62 | /* don't have incorrect values, etc. */ 63 | /* */ 64 | /* FT_VALIDATE_PARANOID :: */ 65 | /* Only for font debugging. Checks that a table follows the */ 66 | /* specification by 100%. Very few fonts will be able to pass this */ 67 | /* level anyway but it can be useful for certain tools like font */ 68 | /* editors/converters. */ 69 | /* */ 70 | typedef enum FT_ValidationLevel_ 71 | { 72 | FT_VALIDATE_DEFAULT = 0, 73 | FT_VALIDATE_TIGHT, 74 | FT_VALIDATE_PARANOID 75 | 76 | } FT_ValidationLevel; 77 | 78 | 79 | #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ 80 | /* We disable the warning `structure was padded due to */ 81 | /* __declspec(align())' in order to compile cleanly with */ 82 | /* the maximum level of warnings. */ 83 | #pragma warning( push ) 84 | #pragma warning( disable : 4324 ) 85 | #endif /* _MSC_VER */ 86 | 87 | /* validator structure */ 88 | typedef struct FT_ValidatorRec_ 89 | { 90 | ft_jmp_buf jump_buffer; /* used for exception handling */ 91 | 92 | const FT_Byte* base; /* address of table in memory */ 93 | const FT_Byte* limit; /* `base' + sizeof(table) in memory */ 94 | FT_ValidationLevel level; /* validation level */ 95 | FT_Error error; /* error returned. 0 means success */ 96 | 97 | } FT_ValidatorRec; 98 | 99 | #if defined( _MSC_VER ) 100 | #pragma warning( pop ) 101 | #endif 102 | 103 | #define FT_VALIDATOR( x ) ( (FT_Validator)( x ) ) 104 | 105 | 106 | FT_BASE( void ) 107 | ft_validator_init( FT_Validator valid, 108 | const FT_Byte* base, 109 | const FT_Byte* limit, 110 | FT_ValidationLevel level ); 111 | 112 | /* Do not use this. It's broken and will cause your validator to crash */ 113 | /* if you run it on an invalid font. */ 114 | FT_BASE( FT_Int ) 115 | ft_validator_run( FT_Validator valid ); 116 | 117 | /* Sets the error field in a validator, then calls `longjmp' to return */ 118 | /* to high-level caller. Using `setjmp/longjmp' avoids many stupid */ 119 | /* error checks within the validation routines. */ 120 | /* */ 121 | FT_BASE( void ) 122 | ft_validator_error( FT_Validator valid, 123 | FT_Error error ); 124 | 125 | 126 | /* Calls ft_validate_error. Assumes that the `valid' local variable */ 127 | /* holds a pointer to the current validator object. */ 128 | /* */ 129 | #define FT_INVALID( _error ) FT_INVALID_( _error ) 130 | #define FT_INVALID_( _error ) \ 131 | ft_validator_error( valid, FT_THROW( _error ) ) 132 | 133 | /* called when a broken table is detected */ 134 | #define FT_INVALID_TOO_SHORT \ 135 | FT_INVALID( Invalid_Table ) 136 | 137 | /* called when an invalid offset is detected */ 138 | #define FT_INVALID_OFFSET \ 139 | FT_INVALID( Invalid_Offset ) 140 | 141 | /* called when an invalid format/value is detected */ 142 | #define FT_INVALID_FORMAT \ 143 | FT_INVALID( Invalid_Table ) 144 | 145 | /* called when an invalid glyph index is detected */ 146 | #define FT_INVALID_GLYPH_ID \ 147 | FT_INVALID( Invalid_Glyph_Index ) 148 | 149 | /* called when an invalid field value is detected */ 150 | #define FT_INVALID_DATA \ 151 | FT_INVALID( Invalid_Table ) 152 | 153 | 154 | FT_END_HEADER 155 | 156 | #endif /* FTVALID_H_ */ 157 | 158 | 159 | /* END */ 160 | -------------------------------------------------------------------------------- /src/include/freetype/internal/internal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* internal.h */ 4 | /* */ 5 | /* Internal header files (specification only). */ 6 | /* */ 7 | /* Copyright 1996-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /*************************************************************************/ 20 | /* */ 21 | /* This file is automatically included by `ft2build.h'. */ 22 | /* Do not include it manually! */ 23 | /* */ 24 | /*************************************************************************/ 25 | 26 | 27 | #define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h> 28 | #define FT_INTERNAL_PIC_H <freetype/internal/ftpic.h> 29 | #define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h> 30 | #define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h> 31 | #define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h> 32 | #define FT_INTERNAL_CALC_H <freetype/internal/ftcalc.h> 33 | #define FT_INTERNAL_HASH_H <freetype/internal/fthash.h> 34 | #define FT_INTERNAL_DRIVER_H <freetype/internal/ftdriver.h> 35 | #define FT_INTERNAL_TRACE_H <freetype/internal/fttrace.h> 36 | #define FT_INTERNAL_GLYPH_LOADER_H <freetype/internal/ftgloadr.h> 37 | #define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.h> 38 | #define FT_INTERNAL_SERVICE_H <freetype/internal/ftserv.h> 39 | #define FT_INTERNAL_RFORK_H <freetype/internal/ftrfork.h> 40 | #define FT_INTERNAL_VALIDATE_H <freetype/internal/ftvalid.h> 41 | 42 | #define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h> 43 | #define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h> 44 | 45 | #define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h> 46 | #define FT_INTERNAL_POSTSCRIPT_HINTS_H <freetype/internal/pshints.h> 47 | 48 | #define FT_INTERNAL_AUTOHINT_H <freetype/internal/autohint.h> 49 | 50 | 51 | #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ 52 | 53 | /* We disable the warning `conditional expression is constant' here */ 54 | /* in order to compile cleanly with the maximum level of warnings. */ 55 | /* In particular, the warning complains about stuff like `while(0)' */ 56 | /* which is very useful in macro definitions. There is no benefit */ 57 | /* in having it enabled. */ 58 | #pragma warning( disable : 4127 ) 59 | 60 | #endif /* _MSC_VER */ 61 | 62 | 63 | /* END */ 64 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svbdf.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svbdf.h */ 4 | /* */ 5 | /* The FreeType BDF services (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVBDF_H_ 20 | #define SVBDF_H_ 21 | 22 | #include FT_BDF_H 23 | #include FT_INTERNAL_SERVICE_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | #define FT_SERVICE_ID_BDF "bdf" 30 | 31 | typedef FT_Error 32 | (*FT_BDF_GetCharsetIdFunc)( FT_Face face, 33 | const char* *acharset_encoding, 34 | const char* *acharset_registry ); 35 | 36 | typedef FT_Error 37 | (*FT_BDF_GetPropertyFunc)( FT_Face face, 38 | const char* prop_name, 39 | BDF_PropertyRec *aproperty ); 40 | 41 | 42 | FT_DEFINE_SERVICE( BDF ) 43 | { 44 | FT_BDF_GetCharsetIdFunc get_charset_id; 45 | FT_BDF_GetPropertyFunc get_property; 46 | }; 47 | 48 | 49 | #ifndef FT_CONFIG_OPTION_PIC 50 | 51 | #define FT_DEFINE_SERVICE_BDFRec( class_, \ 52 | get_charset_id_, \ 53 | get_property_ ) \ 54 | static const FT_Service_BDFRec class_ = \ 55 | { \ 56 | get_charset_id_, get_property_ \ 57 | }; 58 | 59 | #else /* FT_CONFIG_OPTION_PIC */ 60 | 61 | #define FT_DEFINE_SERVICE_BDFRec( class_, \ 62 | get_charset_id_, \ 63 | get_property_ ) \ 64 | void \ 65 | FT_Init_Class_ ## class_( FT_Service_BDFRec* clazz ) \ 66 | { \ 67 | clazz->get_charset_id = get_charset_id_; \ 68 | clazz->get_property = get_property_; \ 69 | } 70 | 71 | #endif /* FT_CONFIG_OPTION_PIC */ 72 | 73 | /* */ 74 | 75 | 76 | FT_END_HEADER 77 | 78 | 79 | #endif /* SVBDF_H_ */ 80 | 81 | 82 | /* END */ 83 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svcid.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svcid.h */ 4 | /* */ 5 | /* The FreeType CID font services (specification). */ 6 | /* */ 7 | /* Copyright 2007-2016 by */ 8 | /* Derek Clegg and Michael Toftdal. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVCID_H_ 20 | #define SVCID_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | #define FT_SERVICE_ID_CID "CID" 29 | 30 | typedef FT_Error 31 | (*FT_CID_GetRegistryOrderingSupplementFunc)( FT_Face face, 32 | const char* *registry, 33 | const char* *ordering, 34 | FT_Int *supplement ); 35 | typedef FT_Error 36 | (*FT_CID_GetIsInternallyCIDKeyedFunc)( FT_Face face, 37 | FT_Bool *is_cid ); 38 | typedef FT_Error 39 | (*FT_CID_GetCIDFromGlyphIndexFunc)( FT_Face face, 40 | FT_UInt glyph_index, 41 | FT_UInt *cid ); 42 | 43 | FT_DEFINE_SERVICE( CID ) 44 | { 45 | FT_CID_GetRegistryOrderingSupplementFunc get_ros; 46 | FT_CID_GetIsInternallyCIDKeyedFunc get_is_cid; 47 | FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index; 48 | }; 49 | 50 | 51 | #ifndef FT_CONFIG_OPTION_PIC 52 | 53 | #define FT_DEFINE_SERVICE_CIDREC( class_, \ 54 | get_ros_, \ 55 | get_is_cid_, \ 56 | get_cid_from_glyph_index_ ) \ 57 | static const FT_Service_CIDRec class_ = \ 58 | { \ 59 | get_ros_, get_is_cid_, get_cid_from_glyph_index_ \ 60 | }; 61 | 62 | #else /* FT_CONFIG_OPTION_PIC */ 63 | 64 | #define FT_DEFINE_SERVICE_CIDREC( class_, \ 65 | get_ros_, \ 66 | get_is_cid_, \ 67 | get_cid_from_glyph_index_ ) \ 68 | void \ 69 | FT_Init_Class_ ## class_( FT_Library library, \ 70 | FT_Service_CIDRec* clazz ) \ 71 | { \ 72 | FT_UNUSED( library ); \ 73 | \ 74 | clazz->get_ros = get_ros_; \ 75 | clazz->get_is_cid = get_is_cid_; \ 76 | clazz->get_cid_from_glyph_index = get_cid_from_glyph_index_; \ 77 | } 78 | 79 | #endif /* FT_CONFIG_OPTION_PIC */ 80 | 81 | /* */ 82 | 83 | 84 | FT_END_HEADER 85 | 86 | 87 | #endif /* SVCID_H_ */ 88 | 89 | 90 | /* END */ 91 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svfntfmt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svfntfmt.h */ 4 | /* */ 5 | /* The FreeType font format service (specification only). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVFNTFMT_H_ 20 | #define SVFNTFMT_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | /* 29 | * A trivial service used to return the name of a face's font driver, 30 | * according to the XFree86 nomenclature. Note that the service data 31 | * is a simple constant string pointer. 32 | */ 33 | 34 | #define FT_SERVICE_ID_FONT_FORMAT "font-format" 35 | 36 | #define FT_FONT_FORMAT_TRUETYPE "TrueType" 37 | #define FT_FONT_FORMAT_TYPE_1 "Type 1" 38 | #define FT_FONT_FORMAT_BDF "BDF" 39 | #define FT_FONT_FORMAT_PCF "PCF" 40 | #define FT_FONT_FORMAT_TYPE_42 "Type 42" 41 | #define FT_FONT_FORMAT_CID "CID Type 1" 42 | #define FT_FONT_FORMAT_CFF "CFF" 43 | #define FT_FONT_FORMAT_PFR "PFR" 44 | #define FT_FONT_FORMAT_WINFNT "Windows FNT" 45 | 46 | /* */ 47 | 48 | 49 | FT_END_HEADER 50 | 51 | 52 | #endif /* SVFNTFMT_H_ */ 53 | 54 | 55 | /* END */ 56 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svgldict.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svgldict.h */ 4 | /* */ 5 | /* The FreeType glyph dictionary services (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVGLDICT_H_ 20 | #define SVGLDICT_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | /* 29 | * A service used to retrieve glyph names, as well as to find the 30 | * index of a given glyph name in a font. 31 | * 32 | */ 33 | 34 | #define FT_SERVICE_ID_GLYPH_DICT "glyph-dict" 35 | 36 | 37 | typedef FT_Error 38 | (*FT_GlyphDict_GetNameFunc)( FT_Face face, 39 | FT_UInt glyph_index, 40 | FT_Pointer buffer, 41 | FT_UInt buffer_max ); 42 | 43 | typedef FT_UInt 44 | (*FT_GlyphDict_NameIndexFunc)( FT_Face face, 45 | FT_String* glyph_name ); 46 | 47 | 48 | FT_DEFINE_SERVICE( GlyphDict ) 49 | { 50 | FT_GlyphDict_GetNameFunc get_name; 51 | FT_GlyphDict_NameIndexFunc name_index; /* optional */ 52 | }; 53 | 54 | 55 | #ifndef FT_CONFIG_OPTION_PIC 56 | 57 | #define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ 58 | get_name_, \ 59 | name_index_) \ 60 | static const FT_Service_GlyphDictRec class_ = \ 61 | { \ 62 | get_name_, name_index_ \ 63 | }; 64 | 65 | #else /* FT_CONFIG_OPTION_PIC */ 66 | 67 | #define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ 68 | get_name_, \ 69 | name_index_) \ 70 | void \ 71 | FT_Init_Class_ ## class_( FT_Library library, \ 72 | FT_Service_GlyphDictRec* clazz ) \ 73 | { \ 74 | FT_UNUSED( library ); \ 75 | \ 76 | clazz->get_name = get_name_; \ 77 | clazz->name_index = name_index_; \ 78 | } 79 | 80 | #endif /* FT_CONFIG_OPTION_PIC */ 81 | 82 | /* */ 83 | 84 | 85 | FT_END_HEADER 86 | 87 | 88 | #endif /* SVGLDICT_H_ */ 89 | 90 | 91 | /* END */ 92 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svgxval.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svgxval.h */ 4 | /* */ 5 | /* FreeType API for validating TrueTypeGX/AAT tables (specification). */ 6 | /* */ 7 | /* Copyright 2004-2016 by */ 8 | /* Masatake YAMATO, Red Hat K.K., */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* This file is part of the FreeType project, and may only be used, */ 12 | /* modified, and distributed under the terms of the FreeType project */ 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 | /* this file you indicate that you have read the license and */ 15 | /* understand and accept it fully. */ 16 | /* */ 17 | /***************************************************************************/ 18 | 19 | /***************************************************************************/ 20 | /* */ 21 | /* gxvalid is derived from both gxlayout module and otvalid module. */ 22 | /* Development of gxlayout is supported by the Information-technology */ 23 | /* Promotion Agency(IPA), Japan. */ 24 | /* */ 25 | /***************************************************************************/ 26 | 27 | 28 | #ifndef SVGXVAL_H_ 29 | #define SVGXVAL_H_ 30 | 31 | #include FT_GX_VALIDATE_H 32 | #include FT_INTERNAL_VALIDATE_H 33 | 34 | FT_BEGIN_HEADER 35 | 36 | 37 | #define FT_SERVICE_ID_GX_VALIDATE "truetypegx-validate" 38 | #define FT_SERVICE_ID_CLASSICKERN_VALIDATE "classickern-validate" 39 | 40 | typedef FT_Error 41 | (*gxv_validate_func)( FT_Face face, 42 | FT_UInt gx_flags, 43 | FT_Bytes tables[FT_VALIDATE_GX_LENGTH], 44 | FT_UInt table_length ); 45 | 46 | 47 | typedef FT_Error 48 | (*ckern_validate_func)( FT_Face face, 49 | FT_UInt ckern_flags, 50 | FT_Bytes *ckern_table ); 51 | 52 | 53 | FT_DEFINE_SERVICE( GXvalidate ) 54 | { 55 | gxv_validate_func validate; 56 | }; 57 | 58 | FT_DEFINE_SERVICE( CKERNvalidate ) 59 | { 60 | ckern_validate_func validate; 61 | }; 62 | 63 | /* */ 64 | 65 | 66 | FT_END_HEADER 67 | 68 | 69 | #endif /* SVGXVAL_H_ */ 70 | 71 | 72 | /* END */ 73 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svkern.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svkern.h */ 4 | /* */ 5 | /* The FreeType Kerning service (specification). */ 6 | /* */ 7 | /* Copyright 2006-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVKERN_H_ 20 | #define SVKERN_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_TRUETYPE_TABLES_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | #define FT_SERVICE_ID_KERNING "kerning" 29 | 30 | 31 | typedef FT_Error 32 | (*FT_Kerning_TrackGetFunc)( FT_Face face, 33 | FT_Fixed point_size, 34 | FT_Int degree, 35 | FT_Fixed* akerning ); 36 | 37 | FT_DEFINE_SERVICE( Kerning ) 38 | { 39 | FT_Kerning_TrackGetFunc get_track; 40 | }; 41 | 42 | /* */ 43 | 44 | 45 | FT_END_HEADER 46 | 47 | 48 | #endif /* SVKERN_H_ */ 49 | 50 | 51 | /* END */ 52 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svmm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svmm.h */ 4 | /* */ 5 | /* The FreeType Multiple Masters and GX var services (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVMM_H_ 20 | #define SVMM_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | /* 29 | * A service used to manage multiple-masters data in a given face. 30 | * 31 | * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H). 32 | * 33 | */ 34 | 35 | #define FT_SERVICE_ID_MULTI_MASTERS "multi-masters" 36 | 37 | 38 | typedef FT_Error 39 | (*FT_Get_MM_Func)( FT_Face face, 40 | FT_Multi_Master* master ); 41 | 42 | typedef FT_Error 43 | (*FT_Get_MM_Var_Func)( FT_Face face, 44 | FT_MM_Var* *master ); 45 | 46 | typedef FT_Error 47 | (*FT_Set_MM_Design_Func)( FT_Face face, 48 | FT_UInt num_coords, 49 | FT_Long* coords ); 50 | 51 | typedef FT_Error 52 | (*FT_Set_Var_Design_Func)( FT_Face face, 53 | FT_UInt num_coords, 54 | FT_Fixed* coords ); 55 | 56 | typedef FT_Error 57 | (*FT_Set_MM_Blend_Func)( FT_Face face, 58 | FT_UInt num_coords, 59 | FT_Long* coords ); 60 | 61 | typedef FT_Error 62 | (*FT_Get_MM_Blend_Func)( FT_Face face, 63 | FT_UInt num_coords, 64 | FT_Long* coords ); 65 | 66 | 67 | FT_DEFINE_SERVICE( MultiMasters ) 68 | { 69 | FT_Get_MM_Func get_mm; 70 | FT_Set_MM_Design_Func set_mm_design; 71 | FT_Set_MM_Blend_Func set_mm_blend; 72 | FT_Get_MM_Blend_Func get_mm_blend; 73 | FT_Get_MM_Var_Func get_mm_var; 74 | FT_Set_Var_Design_Func set_var_design; 75 | }; 76 | 77 | 78 | #ifndef FT_CONFIG_OPTION_PIC 79 | 80 | #define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ 81 | get_mm_, \ 82 | set_mm_design_, \ 83 | set_mm_blend_, \ 84 | get_mm_blend_, \ 85 | get_mm_var_, \ 86 | set_var_design_ ) \ 87 | static const FT_Service_MultiMastersRec class_ = \ 88 | { \ 89 | get_mm_, \ 90 | set_mm_design_, \ 91 | set_mm_blend_, \ 92 | get_mm_blend_, \ 93 | get_mm_var_, \ 94 | set_var_design_ \ 95 | }; 96 | 97 | #else /* FT_CONFIG_OPTION_PIC */ 98 | 99 | #define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ 100 | get_mm_, \ 101 | set_mm_design_, \ 102 | set_mm_blend_, \ 103 | get_mm_blend_, \ 104 | get_mm_var_, \ 105 | set_var_design_ ) \ 106 | void \ 107 | FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \ 108 | { \ 109 | clazz->get_mm = get_mm_; \ 110 | clazz->set_mm_design = set_mm_design_; \ 111 | clazz->set_mm_blend = set_mm_blend_; \ 112 | clazz->get_mm_blend = get_mm_blend_; \ 113 | clazz->get_mm_var = get_mm_var_; \ 114 | clazz->set_var_design = set_var_design_; \ 115 | } 116 | 117 | #endif /* FT_CONFIG_OPTION_PIC */ 118 | 119 | /* */ 120 | 121 | 122 | FT_END_HEADER 123 | 124 | #endif /* SVMM_H_ */ 125 | 126 | 127 | /* END */ 128 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svotval.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svotval.h */ 4 | /* */ 5 | /* The FreeType OpenType validation service (specification). */ 6 | /* */ 7 | /* Copyright 2004-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVOTVAL_H_ 20 | #define SVOTVAL_H_ 21 | 22 | #include FT_OPENTYPE_VALIDATE_H 23 | #include FT_INTERNAL_VALIDATE_H 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | #define FT_SERVICE_ID_OPENTYPE_VALIDATE "opentype-validate" 29 | 30 | 31 | typedef FT_Error 32 | (*otv_validate_func)( FT_Face volatile face, 33 | FT_UInt ot_flags, 34 | FT_Bytes *base, 35 | FT_Bytes *gdef, 36 | FT_Bytes *gpos, 37 | FT_Bytes *gsub, 38 | FT_Bytes *jstf ); 39 | 40 | 41 | FT_DEFINE_SERVICE( OTvalidate ) 42 | { 43 | otv_validate_func validate; 44 | }; 45 | 46 | /* */ 47 | 48 | 49 | FT_END_HEADER 50 | 51 | 52 | #endif /* SVOTVAL_H_ */ 53 | 54 | 55 | /* END */ 56 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svpfr.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svpfr.h */ 4 | /* */ 5 | /* Internal PFR service functions (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVPFR_H_ 20 | #define SVPFR_H_ 21 | 22 | #include FT_PFR_H 23 | #include FT_INTERNAL_SERVICE_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | #define FT_SERVICE_ID_PFR_METRICS "pfr-metrics" 30 | 31 | 32 | typedef FT_Error 33 | (*FT_PFR_GetMetricsFunc)( FT_Face face, 34 | FT_UInt *aoutline, 35 | FT_UInt *ametrics, 36 | FT_Fixed *ax_scale, 37 | FT_Fixed *ay_scale ); 38 | 39 | typedef FT_Error 40 | (*FT_PFR_GetKerningFunc)( FT_Face face, 41 | FT_UInt left, 42 | FT_UInt right, 43 | FT_Vector *avector ); 44 | 45 | typedef FT_Error 46 | (*FT_PFR_GetAdvanceFunc)( FT_Face face, 47 | FT_UInt gindex, 48 | FT_Pos *aadvance ); 49 | 50 | 51 | FT_DEFINE_SERVICE( PfrMetrics ) 52 | { 53 | FT_PFR_GetMetricsFunc get_metrics; 54 | FT_PFR_GetKerningFunc get_kerning; 55 | FT_PFR_GetAdvanceFunc get_advance; 56 | 57 | }; 58 | 59 | /* */ 60 | 61 | FT_END_HEADER 62 | 63 | #endif /* SVPFR_H_ */ 64 | 65 | 66 | /* END */ 67 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svpostnm.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svpostnm.h */ 4 | /* */ 5 | /* The FreeType PostScript name services (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVPOSTNM_H_ 20 | #define SVPOSTNM_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | /* 28 | * A trivial service used to retrieve the PostScript name of a given 29 | * font when available. The `get_name' field should never be NULL. 30 | * 31 | * The corresponding function can return NULL to indicate that the 32 | * PostScript name is not available. 33 | * 34 | * The name is owned by the face and will be destroyed with it. 35 | */ 36 | 37 | #define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME "postscript-font-name" 38 | 39 | 40 | typedef const char* 41 | (*FT_PsName_GetFunc)( FT_Face face ); 42 | 43 | 44 | FT_DEFINE_SERVICE( PsFontName ) 45 | { 46 | FT_PsName_GetFunc get_ps_font_name; 47 | }; 48 | 49 | 50 | #ifndef FT_CONFIG_OPTION_PIC 51 | 52 | #define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ 53 | static const FT_Service_PsFontNameRec class_ = \ 54 | { \ 55 | get_ps_font_name_ \ 56 | }; 57 | 58 | #else /* FT_CONFIG_OPTION_PIC */ 59 | 60 | #define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ 61 | void \ 62 | FT_Init_Class_ ## class_( FT_Library library, \ 63 | FT_Service_PsFontNameRec* clazz ) \ 64 | { \ 65 | FT_UNUSED( library ); \ 66 | \ 67 | clazz->get_ps_font_name = get_ps_font_name_; \ 68 | } 69 | 70 | #endif /* FT_CONFIG_OPTION_PIC */ 71 | 72 | /* */ 73 | 74 | 75 | FT_END_HEADER 76 | 77 | 78 | #endif /* SVPOSTNM_H_ */ 79 | 80 | 81 | /* END */ 82 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svprop.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svprop.h */ 4 | /* */ 5 | /* The FreeType property service (specification). */ 6 | /* */ 7 | /* Copyright 2012-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVPROP_H_ 20 | #define SVPROP_H_ 21 | 22 | 23 | FT_BEGIN_HEADER 24 | 25 | 26 | #define FT_SERVICE_ID_PROPERTIES "properties" 27 | 28 | 29 | typedef FT_Error 30 | (*FT_Properties_SetFunc)( FT_Module module, 31 | const char* property_name, 32 | const void* value, 33 | FT_Bool value_is_string ); 34 | 35 | typedef FT_Error 36 | (*FT_Properties_GetFunc)( FT_Module module, 37 | const char* property_name, 38 | void* value ); 39 | 40 | 41 | FT_DEFINE_SERVICE( Properties ) 42 | { 43 | FT_Properties_SetFunc set_property; 44 | FT_Properties_GetFunc get_property; 45 | }; 46 | 47 | 48 | #ifndef FT_CONFIG_OPTION_PIC 49 | 50 | #define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ 51 | set_property_, \ 52 | get_property_ ) \ 53 | static const FT_Service_PropertiesRec class_ = \ 54 | { \ 55 | set_property_, \ 56 | get_property_ \ 57 | }; 58 | 59 | #else /* FT_CONFIG_OPTION_PIC */ 60 | 61 | #define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ 62 | set_property_, \ 63 | get_property_ ) \ 64 | void \ 65 | FT_Init_Class_ ## class_( FT_Service_PropertiesRec* clazz ) \ 66 | { \ 67 | clazz->set_property = set_property_; \ 68 | clazz->get_property = get_property_; \ 69 | } 70 | 71 | #endif /* FT_CONFIG_OPTION_PIC */ 72 | 73 | /* */ 74 | 75 | 76 | FT_END_HEADER 77 | 78 | 79 | #endif /* SVPROP_H_ */ 80 | 81 | 82 | /* END */ 83 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svpscmap.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svpscmap.h */ 4 | /* */ 5 | /* The FreeType PostScript charmap service (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVPSCMAP_H_ 20 | #define SVPSCMAP_H_ 21 | 22 | #include FT_INTERNAL_OBJECTS_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | #define FT_SERVICE_ID_POSTSCRIPT_CMAPS "postscript-cmaps" 29 | 30 | 31 | /* 32 | * Adobe glyph name to unicode value. 33 | */ 34 | typedef FT_UInt32 35 | (*PS_Unicode_ValueFunc)( const char* glyph_name ); 36 | 37 | /* 38 | * Macintosh name id to glyph name. NULL if invalid index. 39 | */ 40 | typedef const char* 41 | (*PS_Macintosh_NameFunc)( FT_UInt name_index ); 42 | 43 | /* 44 | * Adobe standard string ID to glyph name. NULL if invalid index. 45 | */ 46 | typedef const char* 47 | (*PS_Adobe_Std_StringsFunc)( FT_UInt string_index ); 48 | 49 | 50 | /* 51 | * Simple unicode -> glyph index charmap built from font glyph names 52 | * table. 53 | */ 54 | typedef struct PS_UniMap_ 55 | { 56 | FT_UInt32 unicode; /* bit 31 set: is glyph variant */ 57 | FT_UInt glyph_index; 58 | 59 | } PS_UniMap; 60 | 61 | 62 | typedef struct PS_UnicodesRec_* PS_Unicodes; 63 | 64 | typedef struct PS_UnicodesRec_ 65 | { 66 | FT_CMapRec cmap; 67 | FT_UInt num_maps; 68 | PS_UniMap* maps; 69 | 70 | } PS_UnicodesRec; 71 | 72 | 73 | /* 74 | * A function which returns a glyph name for a given index. Returns 75 | * NULL if invalid index. 76 | */ 77 | typedef const char* 78 | (*PS_GetGlyphNameFunc)( FT_Pointer data, 79 | FT_UInt string_index ); 80 | 81 | /* 82 | * A function used to release the glyph name returned by 83 | * PS_GetGlyphNameFunc, when needed 84 | */ 85 | typedef void 86 | (*PS_FreeGlyphNameFunc)( FT_Pointer data, 87 | const char* name ); 88 | 89 | typedef FT_Error 90 | (*PS_Unicodes_InitFunc)( FT_Memory memory, 91 | PS_Unicodes unicodes, 92 | FT_UInt num_glyphs, 93 | PS_GetGlyphNameFunc get_glyph_name, 94 | PS_FreeGlyphNameFunc free_glyph_name, 95 | FT_Pointer glyph_data ); 96 | 97 | typedef FT_UInt 98 | (*PS_Unicodes_CharIndexFunc)( PS_Unicodes unicodes, 99 | FT_UInt32 unicode ); 100 | 101 | typedef FT_UInt32 102 | (*PS_Unicodes_CharNextFunc)( PS_Unicodes unicodes, 103 | FT_UInt32 *unicode ); 104 | 105 | 106 | FT_DEFINE_SERVICE( PsCMaps ) 107 | { 108 | PS_Unicode_ValueFunc unicode_value; 109 | 110 | PS_Unicodes_InitFunc unicodes_init; 111 | PS_Unicodes_CharIndexFunc unicodes_char_index; 112 | PS_Unicodes_CharNextFunc unicodes_char_next; 113 | 114 | PS_Macintosh_NameFunc macintosh_name; 115 | PS_Adobe_Std_StringsFunc adobe_std_strings; 116 | const unsigned short* adobe_std_encoding; 117 | const unsigned short* adobe_expert_encoding; 118 | }; 119 | 120 | 121 | #ifndef FT_CONFIG_OPTION_PIC 122 | 123 | #define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ 124 | unicode_value_, \ 125 | unicodes_init_, \ 126 | unicodes_char_index_, \ 127 | unicodes_char_next_, \ 128 | macintosh_name_, \ 129 | adobe_std_strings_, \ 130 | adobe_std_encoding_, \ 131 | adobe_expert_encoding_ ) \ 132 | static const FT_Service_PsCMapsRec class_ = \ 133 | { \ 134 | unicode_value_, unicodes_init_, \ 135 | unicodes_char_index_, unicodes_char_next_, macintosh_name_, \ 136 | adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_ \ 137 | }; 138 | 139 | #else /* FT_CONFIG_OPTION_PIC */ 140 | 141 | #define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ 142 | unicode_value_, \ 143 | unicodes_init_, \ 144 | unicodes_char_index_, \ 145 | unicodes_char_next_, \ 146 | macintosh_name_, \ 147 | adobe_std_strings_, \ 148 | adobe_std_encoding_, \ 149 | adobe_expert_encoding_ ) \ 150 | void \ 151 | FT_Init_Class_ ## class_( FT_Library library, \ 152 | FT_Service_PsCMapsRec* clazz ) \ 153 | { \ 154 | FT_UNUSED( library ); \ 155 | \ 156 | clazz->unicode_value = unicode_value_; \ 157 | clazz->unicodes_init = unicodes_init_; \ 158 | clazz->unicodes_char_index = unicodes_char_index_; \ 159 | clazz->unicodes_char_next = unicodes_char_next_; \ 160 | clazz->macintosh_name = macintosh_name_; \ 161 | clazz->adobe_std_strings = adobe_std_strings_; \ 162 | clazz->adobe_std_encoding = adobe_std_encoding_; \ 163 | clazz->adobe_expert_encoding = adobe_expert_encoding_; \ 164 | } 165 | 166 | #endif /* FT_CONFIG_OPTION_PIC */ 167 | 168 | /* */ 169 | 170 | 171 | FT_END_HEADER 172 | 173 | 174 | #endif /* SVPSCMAP_H_ */ 175 | 176 | 177 | /* END */ 178 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svpsinfo.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svpsinfo.h */ 4 | /* */ 5 | /* The FreeType PostScript info service (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVPSINFO_H_ 20 | #define SVPSINFO_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_INTERNAL_TYPE1_TYPES_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | #define FT_SERVICE_ID_POSTSCRIPT_INFO "postscript-info" 30 | 31 | 32 | typedef FT_Error 33 | (*PS_GetFontInfoFunc)( FT_Face face, 34 | PS_FontInfoRec* afont_info ); 35 | 36 | typedef FT_Error 37 | (*PS_GetFontExtraFunc)( FT_Face face, 38 | PS_FontExtraRec* afont_extra ); 39 | 40 | typedef FT_Int 41 | (*PS_HasGlyphNamesFunc)( FT_Face face ); 42 | 43 | typedef FT_Error 44 | (*PS_GetFontPrivateFunc)( FT_Face face, 45 | PS_PrivateRec* afont_private ); 46 | 47 | typedef FT_Long 48 | (*PS_GetFontValueFunc)( FT_Face face, 49 | PS_Dict_Keys key, 50 | FT_UInt idx, 51 | void *value, 52 | FT_Long value_len ); 53 | 54 | 55 | FT_DEFINE_SERVICE( PsInfo ) 56 | { 57 | PS_GetFontInfoFunc ps_get_font_info; 58 | PS_GetFontExtraFunc ps_get_font_extra; 59 | PS_HasGlyphNamesFunc ps_has_glyph_names; 60 | PS_GetFontPrivateFunc ps_get_font_private; 61 | PS_GetFontValueFunc ps_get_font_value; 62 | }; 63 | 64 | 65 | #ifndef FT_CONFIG_OPTION_PIC 66 | 67 | #define FT_DEFINE_SERVICE_PSINFOREC( class_, \ 68 | get_font_info_, \ 69 | ps_get_font_extra_, \ 70 | has_glyph_names_, \ 71 | get_font_private_, \ 72 | get_font_value_ ) \ 73 | static const FT_Service_PsInfoRec class_ = \ 74 | { \ 75 | get_font_info_, ps_get_font_extra_, has_glyph_names_, \ 76 | get_font_private_, get_font_value_ \ 77 | }; 78 | 79 | #else /* FT_CONFIG_OPTION_PIC */ 80 | 81 | #define FT_DEFINE_SERVICE_PSINFOREC( class_, \ 82 | get_font_info_, \ 83 | ps_get_font_extra_, \ 84 | has_glyph_names_, \ 85 | get_font_private_, \ 86 | get_font_value_ ) \ 87 | void \ 88 | FT_Init_Class_ ## class_( FT_Library library, \ 89 | FT_Service_PsInfoRec* clazz ) \ 90 | { \ 91 | FT_UNUSED( library ); \ 92 | \ 93 | clazz->ps_get_font_info = get_font_info_; \ 94 | clazz->ps_get_font_extra = ps_get_font_extra_; \ 95 | clazz->ps_has_glyph_names = has_glyph_names_; \ 96 | clazz->ps_get_font_private = get_font_private_; \ 97 | clazz->ps_get_font_value = get_font_value_; \ 98 | } 99 | 100 | #endif /* FT_CONFIG_OPTION_PIC */ 101 | 102 | /* */ 103 | 104 | 105 | FT_END_HEADER 106 | 107 | 108 | #endif /* SVPSINFO_H_ */ 109 | 110 | 111 | /* END */ 112 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svsfnt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svsfnt.h */ 4 | /* */ 5 | /* The FreeType SFNT table loading service (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVSFNT_H_ 20 | #define SVSFNT_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_TRUETYPE_TABLES_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | /* 30 | * SFNT table loading service. 31 | */ 32 | 33 | #define FT_SERVICE_ID_SFNT_TABLE "sfnt-table" 34 | 35 | 36 | /* 37 | * Used to implement FT_Load_Sfnt_Table(). 38 | */ 39 | typedef FT_Error 40 | (*FT_SFNT_TableLoadFunc)( FT_Face face, 41 | FT_ULong tag, 42 | FT_Long offset, 43 | FT_Byte* buffer, 44 | FT_ULong* length ); 45 | 46 | /* 47 | * Used to implement FT_Get_Sfnt_Table(). 48 | */ 49 | typedef void* 50 | (*FT_SFNT_TableGetFunc)( FT_Face face, 51 | FT_Sfnt_Tag tag ); 52 | 53 | 54 | /* 55 | * Used to implement FT_Sfnt_Table_Info(). 56 | */ 57 | typedef FT_Error 58 | (*FT_SFNT_TableInfoFunc)( FT_Face face, 59 | FT_UInt idx, 60 | FT_ULong *tag, 61 | FT_ULong *offset, 62 | FT_ULong *length ); 63 | 64 | 65 | FT_DEFINE_SERVICE( SFNT_Table ) 66 | { 67 | FT_SFNT_TableLoadFunc load_table; 68 | FT_SFNT_TableGetFunc get_table; 69 | FT_SFNT_TableInfoFunc table_info; 70 | }; 71 | 72 | 73 | #ifndef FT_CONFIG_OPTION_PIC 74 | 75 | #define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ 76 | static const FT_Service_SFNT_TableRec class_ = \ 77 | { \ 78 | load_, get_, info_ \ 79 | }; 80 | 81 | #else /* FT_CONFIG_OPTION_PIC */ 82 | 83 | #define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ 84 | void \ 85 | FT_Init_Class_ ## class_( FT_Service_SFNT_TableRec* clazz ) \ 86 | { \ 87 | clazz->load_table = load_; \ 88 | clazz->get_table = get_; \ 89 | clazz->table_info = info_; \ 90 | } 91 | 92 | #endif /* FT_CONFIG_OPTION_PIC */ 93 | 94 | /* */ 95 | 96 | 97 | FT_END_HEADER 98 | 99 | 100 | #endif /* SVSFNT_H_ */ 101 | 102 | 103 | /* END */ 104 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svttcmap.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svttcmap.h */ 4 | /* */ 5 | /* The FreeType TrueType/sfnt cmap extra information service. */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* Masatake YAMATO, Redhat K.K., */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* This file is part of the FreeType project, and may only be used, */ 12 | /* modified, and distributed under the terms of the FreeType project */ 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 14 | /* this file you indicate that you have read the license and */ 15 | /* understand and accept it fully. */ 16 | /* */ 17 | /***************************************************************************/ 18 | 19 | /* Development of this service is support of 20 | Information-technology Promotion Agency, Japan. */ 21 | 22 | #ifndef SVTTCMAP_H_ 23 | #define SVTTCMAP_H_ 24 | 25 | #include FT_INTERNAL_SERVICE_H 26 | #include FT_TRUETYPE_TABLES_H 27 | 28 | 29 | FT_BEGIN_HEADER 30 | 31 | 32 | #define FT_SERVICE_ID_TT_CMAP "tt-cmaps" 33 | 34 | 35 | /*************************************************************************/ 36 | /* */ 37 | /* <Struct> */ 38 | /* TT_CMapInfo */ 39 | /* */ 40 | /* <Description> */ 41 | /* A structure used to store TrueType/sfnt specific cmap information */ 42 | /* which is not covered by the generic @FT_CharMap structure. This */ 43 | /* structure can be accessed with the @FT_Get_TT_CMap_Info function. */ 44 | /* */ 45 | /* <Fields> */ 46 | /* language :: */ 47 | /* The language ID used in Mac fonts. Definitions of values are in */ 48 | /* `ttnameid.h'. */ 49 | /* */ 50 | /* format :: */ 51 | /* The cmap format. OpenType 1.6 defines the formats 0 (byte */ 52 | /* encoding table), 2~(high-byte mapping through table), 4~(segment */ 53 | /* mapping to delta values), 6~(trimmed table mapping), 8~(mixed */ 54 | /* 16-bit and 32-bit coverage), 10~(trimmed array), 12~(segmented */ 55 | /* coverage), 13~(last resort font), and 14 (Unicode Variation */ 56 | /* Sequences). */ 57 | /* */ 58 | typedef struct TT_CMapInfo_ 59 | { 60 | FT_ULong language; 61 | FT_Long format; 62 | 63 | } TT_CMapInfo; 64 | 65 | 66 | typedef FT_Error 67 | (*TT_CMap_Info_GetFunc)( FT_CharMap charmap, 68 | TT_CMapInfo *cmap_info ); 69 | 70 | 71 | FT_DEFINE_SERVICE( TTCMaps ) 72 | { 73 | TT_CMap_Info_GetFunc get_cmap_info; 74 | }; 75 | 76 | #ifndef FT_CONFIG_OPTION_PIC 77 | 78 | #define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ 79 | static const FT_Service_TTCMapsRec class_ = \ 80 | { \ 81 | get_cmap_info_ \ 82 | }; 83 | 84 | #else /* FT_CONFIG_OPTION_PIC */ 85 | 86 | #define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ 87 | void \ 88 | FT_Init_Class_ ## class_( FT_Library library, \ 89 | FT_Service_TTCMapsRec* clazz ) \ 90 | { \ 91 | FT_UNUSED( library ); \ 92 | \ 93 | clazz->get_cmap_info = get_cmap_info_; \ 94 | } 95 | 96 | #endif /* FT_CONFIG_OPTION_PIC */ 97 | 98 | /* */ 99 | 100 | 101 | FT_END_HEADER 102 | 103 | #endif /* SVTTCMAP_H_ */ 104 | 105 | 106 | /* END */ 107 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svtteng.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svtteng.h */ 4 | /* */ 5 | /* The FreeType TrueType engine query service (specification). */ 6 | /* */ 7 | /* Copyright 2006-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVTTENG_H_ 20 | #define SVTTENG_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_MODULE_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | /* 30 | * SFNT table loading service. 31 | */ 32 | 33 | #define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine" 34 | 35 | /* 36 | * Used to implement FT_Get_TrueType_Engine_Type 37 | */ 38 | 39 | FT_DEFINE_SERVICE( TrueTypeEngine ) 40 | { 41 | FT_TrueTypeEngineType engine_type; 42 | }; 43 | 44 | /* */ 45 | 46 | 47 | FT_END_HEADER 48 | 49 | 50 | #endif /* SVTTENG_H_ */ 51 | 52 | 53 | /* END */ 54 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svttglyf.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svttglyf.h */ 4 | /* */ 5 | /* The FreeType TrueType glyph service. */ 6 | /* */ 7 | /* Copyright 2007-2016 by */ 8 | /* David Turner. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | #ifndef SVTTGLYF_H_ 19 | #define SVTTGLYF_H_ 20 | 21 | #include FT_INTERNAL_SERVICE_H 22 | #include FT_TRUETYPE_TABLES_H 23 | 24 | 25 | FT_BEGIN_HEADER 26 | 27 | 28 | #define FT_SERVICE_ID_TT_GLYF "tt-glyf" 29 | 30 | 31 | typedef FT_ULong 32 | (*TT_Glyf_GetLocationFunc)( FT_Face face, 33 | FT_UInt gindex, 34 | FT_ULong *psize ); 35 | 36 | FT_DEFINE_SERVICE( TTGlyf ) 37 | { 38 | TT_Glyf_GetLocationFunc get_location; 39 | }; 40 | 41 | 42 | #ifndef FT_CONFIG_OPTION_PIC 43 | 44 | #define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ 45 | static const FT_Service_TTGlyfRec class_ = \ 46 | { \ 47 | get_location_ \ 48 | }; 49 | 50 | #else /* FT_CONFIG_OPTION_PIC */ 51 | 52 | #define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ 53 | void \ 54 | FT_Init_Class_ ## class_( FT_Service_TTGlyfRec* clazz ) \ 55 | { \ 56 | clazz->get_location = get_location_; \ 57 | } 58 | 59 | #endif /* FT_CONFIG_OPTION_PIC */ 60 | 61 | /* */ 62 | 63 | 64 | FT_END_HEADER 65 | 66 | #endif /* SVTTGLYF_H_ */ 67 | 68 | 69 | /* END */ 70 | -------------------------------------------------------------------------------- /src/include/freetype/internal/services/svwinfnt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* svwinfnt.h */ 4 | /* */ 5 | /* The FreeType Windows FNT/FONT service (specification). */ 6 | /* */ 7 | /* Copyright 2003-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef SVWINFNT_H_ 20 | #define SVWINFNT_H_ 21 | 22 | #include FT_INTERNAL_SERVICE_H 23 | #include FT_WINFONTS_H 24 | 25 | 26 | FT_BEGIN_HEADER 27 | 28 | 29 | #define FT_SERVICE_ID_WINFNT "winfonts" 30 | 31 | typedef FT_Error 32 | (*FT_WinFnt_GetHeaderFunc)( FT_Face face, 33 | FT_WinFNT_HeaderRec *aheader ); 34 | 35 | 36 | FT_DEFINE_SERVICE( WinFnt ) 37 | { 38 | FT_WinFnt_GetHeaderFunc get_header; 39 | }; 40 | 41 | /* */ 42 | 43 | 44 | FT_END_HEADER 45 | 46 | 47 | #endif /* SVWINFNT_H_ */ 48 | 49 | 50 | /* END */ 51 | -------------------------------------------------------------------------------- /src/include/freetype/tttags.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* tttags.h */ 4 | /* */ 5 | /* Tags for TrueType and OpenType tables (specification only). */ 6 | /* */ 7 | /* Copyright 1996-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | #ifndef TTAGS_H_ 20 | #define TTAGS_H_ 21 | 22 | 23 | #include <ft2build.h> 24 | #include FT_FREETYPE_H 25 | 26 | #ifdef FREETYPE_H 27 | #error "freetype.h of FreeType 1 has been loaded!" 28 | #error "Please fix the directory search order for header files" 29 | #error "so that freetype.h of FreeType 2 is found first." 30 | #endif 31 | 32 | 33 | FT_BEGIN_HEADER 34 | 35 | 36 | #define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) 37 | #define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) 38 | #define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) 39 | #define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) 40 | #define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) 41 | #define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) 42 | #define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) 43 | #define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) 44 | #define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) 45 | #define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) 46 | #define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) 47 | #define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) 48 | #define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) 49 | #define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) 50 | #define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) 51 | #define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) 52 | #define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) 53 | #define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) 54 | #define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) 55 | #define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) 56 | #define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) 57 | #define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) 58 | #define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) 59 | #define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) 60 | #define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) 61 | #define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) 62 | #define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) 63 | #define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) 64 | #define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) 65 | #define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) 66 | #define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) 67 | #define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) 68 | #define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) 69 | #define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) 70 | #define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) 71 | #define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) 72 | #define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) 73 | #define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) 74 | #define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) 75 | #define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) 76 | #define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) 77 | #define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) 78 | #define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) 79 | #define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) 80 | #define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) 81 | #define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) 82 | #define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) 83 | #define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) 84 | #define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) 85 | #define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) 86 | #define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) 87 | #define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' ) 88 | #define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) 89 | #define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) 90 | #define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) 91 | #define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' ) 92 | #define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' ) 93 | #define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) 94 | #define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) 95 | #define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) 96 | #define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) 97 | #define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) 98 | #define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) 99 | #define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' ) 100 | #define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) 101 | #define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) 102 | #define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) 103 | #define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) 104 | 105 | 106 | FT_END_HEADER 107 | 108 | #endif /* TTAGS_H_ */ 109 | 110 | 111 | /* END */ 112 | -------------------------------------------------------------------------------- /src/include/freetype/ttunpat.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ttunpat.h */ 4 | /* */ 5 | /* Definitions for the unpatented TrueType hinting system. */ 6 | /* Obsolete, retained for backwards compatibility. */ 7 | /* */ 8 | /* Copyright 2003-2016 by */ 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 10 | /* */ 11 | /* Written by Graham Asher <graham.asher@btinternet.com> */ 12 | /* */ 13 | /* This file is part of the FreeType project, and may only be used, */ 14 | /* modified, and distributed under the terms of the FreeType project */ 15 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 16 | /* this file you indicate that you have read the license and */ 17 | /* understand and accept it fully. */ 18 | /* */ 19 | /***************************************************************************/ 20 | 21 | 22 | #ifndef TTUNPAT_H_ 23 | #define TTUNPAT_H_ 24 | 25 | 26 | #include <ft2build.h> 27 | #include FT_FREETYPE_H 28 | 29 | #ifdef FREETYPE_H 30 | #error "freetype.h of FreeType 1 has been loaded!" 31 | #error "Please fix the directory search order for header files" 32 | #error "so that freetype.h of FreeType 2 is found first." 33 | #endif 34 | 35 | 36 | FT_BEGIN_HEADER 37 | 38 | 39 | /*************************************************************************** 40 | * 41 | * @constant: 42 | * FT_PARAM_TAG_UNPATENTED_HINTING 43 | * 44 | * @description: 45 | * Deprecated. 46 | * 47 | * Previously: A constant used as the tag of an @FT_Parameter structure to 48 | * indicate that unpatented methods only should be used by the TrueType 49 | * bytecode interpreter for a typeface opened by @FT_Open_Face. 50 | * 51 | */ 52 | #define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) 53 | 54 | /* */ 55 | 56 | 57 | FT_END_HEADER 58 | 59 | 60 | #endif /* TTUNPAT_H_ */ 61 | 62 | 63 | /* END */ 64 | -------------------------------------------------------------------------------- /src/include/ft2build.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************/ 2 | /* */ 3 | /* ft2build.h */ 4 | /* */ 5 | /* FreeType 2 build and setup macros. */ 6 | /* */ 7 | /* Copyright 1996-2016 by */ 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9 | /* */ 10 | /* This file is part of the FreeType project, and may only be used, */ 11 | /* modified, and distributed under the terms of the FreeType project */ 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13 | /* this file you indicate that you have read the license and */ 14 | /* understand and accept it fully. */ 15 | /* */ 16 | /***************************************************************************/ 17 | 18 | 19 | /*************************************************************************/ 20 | /* */ 21 | /* This is the `entry point' for FreeType header file inclusions. It is */ 22 | /* the only header file which should be included directly; all other */ 23 | /* FreeType header files should be accessed with macro names (after */ 24 | /* including `ft2build.h'). */ 25 | /* */ 26 | /* A typical example is */ 27 | /* */ 28 | /* #include <ft2build.h> */ 29 | /* #include FT_FREETYPE_H */ 30 | /* */ 31 | /*************************************************************************/ 32 | 33 | 34 | #ifndef FT2BUILD_H_ 35 | #define FT2BUILD_H_ 36 | 37 | #include <freetype/config/ftheader.h> 38 | 39 | #endif /* FT2BUILD_H_ */ 40 | 41 | 42 | /* END */ 43 | -------------------------------------------------------------------------------- /src/stuff.cc: -------------------------------------------------------------------------------- 1 | 2 | #include <string.h> 3 | #include <stdarg.h> 4 | #include <stdint.h> 5 | #include <intrin.h> 6 | 7 | typedef const char* string; 8 | 9 | typedef int8_t i8; 10 | typedef int16_t i16; 11 | typedef int32_t i32; 12 | typedef int64_t i64; 13 | 14 | typedef uint8_t u8; 15 | typedef uint16_t u16; 16 | typedef uint32_t u32; 17 | typedef uint64_t u64; 18 | 19 | typedef float f32; 20 | typedef double f64; 21 | 22 | typedef size_t usize; 23 | typedef ptrdiff_t isize; 24 | #define FNV64_Basis 14695981039346656037UL 25 | #define FNV64_Prime 1099511628211UL 26 | 27 | u64 hashString(string s) 28 | { 29 | u64 hash = FNV64_Basis; 30 | while(*s != '\0') { 31 | hash ^= *s++; 32 | hash *= FNV64_Prime; 33 | } 34 | return hash; 35 | } 36 | 37 | void createdir(char* name) 38 | { 39 | if(!PathFileExists(name)) { 40 | CreateDirectory(name, NULL); 41 | } 42 | } 43 | 44 | char* loadFile(char* filename) 45 | { 46 | char* str = NULL; 47 | FILE* fp = fopen(filename, "rb"); 48 | if(fp != NULL) { 49 | fseek(fp, 0L, SEEK_END); 50 | isize size = ftell(fp); 51 | rewind(fp); 52 | str = (char*)malloc(size + 1); 53 | fread(str, sizeof(char), size, fp); 54 | str[size] = '\0'; 55 | fclose(fp); 56 | } else { 57 | fprintf(stderr, ">>> Could not open file %s\n", filename); 58 | } 59 | return str; 60 | } 61 | 62 | void writeFile(char* filename, void* data, isize size) 63 | { 64 | FILE* fp = fopen(filename, "wb"); 65 | if(fp != NULL) { 66 | fwrite(data, size, 1, fp); 67 | fclose(fp); 68 | } else { 69 | fprintf(stderr, ">>> Could not open file %s\n", filename); 70 | } 71 | } 72 | 73 | 74 | #define wplCopyMemory memcpy 75 | void wplCopyMemoryBlock(void* dest, const void* source, 76 | i32 sx, i32 sy, i32 sw, i32 sh, i32 stw, i32 sth, 77 | i32 dx, i32 dy, i32 dw, i32 dh, 78 | i32 size, i32 border) 79 | { 80 | u8* dst = (u8*)dest; 81 | const u8* src = (u8*)source; 82 | for(isize i = 0; i < sh; ++i) { 83 | wplCopyMemory( 84 | dst + ((i+dy) * dw + dx) * size, 85 | src + ((i+sy) * stw + sx) * size, 86 | sw * size); 87 | } 88 | 89 | if(border) { 90 | for(isize i = 0; i < sh; ++i) { 91 | wplCopyMemory( 92 | dst + ((i+dy) * dw + (dx-1)) * size, 93 | dst + ((i+sy) * dw + sx) * size, 94 | 1 * size); 95 | 96 | wplCopyMemory( 97 | dst + ((i+dy) * dw + (dx+sw)) * size, 98 | src + ((i+sy) * dw + (sx+sw-1)) * size, 99 | 1 * size); 100 | } 101 | 102 | wplCopyMemory( 103 | dst + ((dy-1) * (dw) + (dx-1)) * size, 104 | dst + ((dy) * (dw) + (dx-1)) * size, 105 | (sw+2) * size); 106 | 107 | wplCopyMemory( 108 | dst + ((dy+sh) * (dw) + (dx-1)) * size, 109 | dst + ((dy+sh-1) * (dw) + (dx-1)) * size, 110 | (sw+2) * size); 111 | } 112 | } 113 | 114 | union icvt 115 | { 116 | unsigned int u; 117 | int i; 118 | }; 119 | -------------------------------------------------------------------------------- /src/whereami.h: -------------------------------------------------------------------------------- 1 | // (‑●‑●)> released under the WTFPL v2 license, by Gregory Pakosz (@gpakosz) 2 | // https://github.com/gpakosz/whereami 3 | 4 | #ifndef WHEREAMI_H 5 | #define WHEREAMI_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #ifndef WAI_FUNCSPEC 12 | #define WAI_FUNCSPEC 13 | #endif 14 | #ifndef WAI_PREFIX 15 | #define WAI_PREFIX(function) wai_##function 16 | #endif 17 | 18 | /** 19 | * Returns the path to the current executable. 20 | * 21 | * Usage: 22 | * - first call `int length = wai_getExecutablePath(NULL, 0, NULL);` to 23 | * retrieve the length of the path 24 | * - allocate the destination buffer with `path = (char*)malloc(length + 1);` 25 | * - call `wai_getExecutablePath(path, length, NULL)` again to retrieve the 26 | * path 27 | * - add a terminal NUL character with `path[length] = '\0';` 28 | * 29 | * @param out destination buffer, optional 30 | * @param capacity destination buffer capacity 31 | * @param dirname_length optional recipient for the length of the dirname part 32 | * of the path. 33 | * 34 | * @return the length of the executable path on success (without a terminal NUL 35 | * character), otherwise `-1` 36 | */ 37 | WAI_FUNCSPEC 38 | int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length); 39 | 40 | /** 41 | * Returns the path to the current module 42 | * 43 | * Usage: 44 | * - first call `int length = wai_getModulePath(NULL, 0, NULL);` to retrieve 45 | * the length of the path 46 | * - allocate the destination buffer with `path = (char*)malloc(length + 1);` 47 | * - call `wai_getModulePath(path, length, NULL)` again to retrieve the path 48 | * - add a terminal NUL character with `path[length] = '\0';` 49 | * 50 | * @param out destination buffer, optional 51 | * @param capacity destination buffer capacity 52 | * @param dirname_length optional recipient for the length of the dirname part 53 | * of the path. 54 | * 55 | * @return the length of the module path on success (without a terminal NUL 56 | * character), otherwise `-1` 57 | */ 58 | WAI_FUNCSPEC 59 | int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif // #ifndef WHEREAMI_H 66 | -------------------------------------------------------------------------------- /src/wiggle_atlas.cc: -------------------------------------------------------------------------------- 1 | 2 | 3 | struct wiggleImg 4 | { 5 | int w, h, n; 6 | u8* data; 7 | int x, y; 8 | char* file; 9 | }; 10 | 11 | 12 | void wiggleGenAtlas(char* outfile, int size, char** files, int fcount) 13 | { 14 | wiggleImg* imgFiles = (wiggleImg*)calloc(sizeof(wiggleImg), fcount + 4); 15 | FontInfo** finfos = (FontInfo**)calloc(sizeof(FontInfo*), fcount + 4); 16 | stbrp_rect* rects = (stbrp_rect*)calloc(1, sizeof(stbrp_rect) * fcount + 16); 17 | stbrp_node* nodes = (stbrp_node*)malloc(sizeof(stbrp_node) * size * 2); 18 | fprintf(stderr, "Loading...\n"); 19 | for(isize i = 0; i < fcount; i += 2) { 20 | imgFiles[i].file = files[i]; 21 | imgFiles[i].data = stbi_load(files[i], 22 | &imgFiles[i].w, 23 | &imgFiles[i].h, 24 | &imgFiles[i].n, 25 | 4); 26 | stbrp_rect* r = rects + i; 27 | r->id = i; 28 | r->w = imgFiles[i].w; 29 | r->h = imgFiles[i].h; 30 | 31 | //also load font info 32 | char* fontfile = files[i+1]; 33 | fprintf(stderr, "%s\n", fontfile); 34 | if(fontfile[0] == '0') continue; 35 | finfos[i] = loadFontInfo(fontfile); 36 | gkt = *finfos[r->id]; 37 | } 38 | 39 | fprintf(stderr, "Packing...\n"); 40 | { 41 | stbrp_context ctx = {0}; 42 | stbrp_init_target(&ctx, size, size, nodes, size); 43 | int ret = stbrp_pack_rects(&ctx, rects, fcount); 44 | if(!ret) { 45 | fprintf(stderr, "Error: packing failed! Increase atlas size and re-run\n"); 46 | return; 47 | } 48 | } 49 | 50 | fprintf(stderr, "Rendering...\n"); 51 | u8* atlas = (u8*)calloc(4, size * size); 52 | int maxHeight = 0; 53 | for(isize i = 0; i < fcount; i+=2) { 54 | stbrp_rect* r = rects + i; 55 | wiggleImg* img = imgFiles + r->id; 56 | wplCopyMemoryBlock(atlas, img->data, 57 | 0, 0, img->w, img->h, img->w, img->h, 58 | r->x, r->y, size, size, 4, 0); 59 | if(r->y+1 + img->h > maxHeight) { 60 | maxHeight = r->y + img->h; 61 | } 62 | printf("%s %d %d\n", img->file, r->x, r->y); 63 | if(files[i+1][0] == '0') continue; 64 | finfos[r->id]->atlasX = r->x; 65 | finfos[r->id]->atlasY = r->y; 66 | 67 | gkt = *finfos[r->id]; 68 | writeFile(files[i+1], finfos[r->id], sizeof(FontInfo)); 69 | 70 | } 71 | 72 | fprintf(stderr, "Writing to file...\n"); 73 | stbi_write_png(outfile, size, maxHeight + 16, 4, atlas, size * 4); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/wiggle_fontgen.cc: -------------------------------------------------------------------------------- 1 | 2 | FontInfo gkt; 3 | unsigned char* glyphImages[96]; 4 | 5 | int wiggleGenFonts(string fontFile, string outFile, string atlasFile, 6 | int SizeX, int SizeY, int Scale, int OffsetX, int OffsetY, 7 | int PxRange, int doRender) 8 | { 9 | 10 | string enclosingFolder = getEnclosingFolder(); 11 | gkt.sizeX = SizeX; 12 | gkt.sizeY = SizeY; 13 | gkt.scale = Scale; 14 | gkt.offsetX = OffsetX; 15 | gkt.offsetY = OffsetY; 16 | gkt.pxRange = PxRange; 17 | 18 | int error = FT_Init_FreeType(&ft); 19 | if(error) { 20 | fprintf(stderr, "Error opening freetype\n"); 21 | return 1; 22 | } 23 | 24 | FT_Face face; 25 | error = FT_New_Face(ft, fontFile, 0, &face); 26 | if(error) { 27 | fprintf(stderr, "Error opening font\n"); 28 | return 1; 29 | } else { 30 | printf("[wiggle] Processing font %s\n", fontFile); 31 | } 32 | 33 | i32 needExtKern = 0; 34 | if(!FT_HAS_KERNING(face)) { 35 | needExtKern = 1; 36 | } 37 | 38 | printf("Gathering font metrics...\n"); 39 | gkt.lineSpacing = ptf(face->height); 40 | for(int i = 32; i <= 127; ++i) { 41 | FT_UInt a = FT_Get_Char_Index(face, i); 42 | FT_Load_Glyph(face, a, FT_LOAD_NO_SCALE); 43 | Glyph* t = gkt.glyphs + (i - 32); 44 | FT_Glyph_Metrics m = face->glyph->metrics; 45 | t->character = i; 46 | t->width = ptf(m.width); 47 | t->height = ptf(m.height); 48 | t->x = ptf(m.horiBearingX); 49 | t->y = ptf(m.horiBearingY); 50 | t->advance = ptf(m.horiAdvance); 51 | } 52 | 53 | printf("Gathering kerning data...\n"); 54 | if(needExtKern) { 55 | char buf[4096]; 56 | snprintf(buf, 4096, "%sgetKerningPairsFromOTF.exe %s > %skerning.txt", enclosingFolder, 57 | fontFile, enclosingFolder); 58 | system(buf); 59 | snprintf(buf, 4096, "%skerning.txt", enclosingFolder); 60 | char* kernInfo = loadFile(buf); 61 | isize len = strlen(kernInfo); 62 | char* text = kernInfo; 63 | char* end = "\0"; 64 | i64 lines = strtol(text, &end, 10); 65 | i64 kernScale = 1000; 66 | text = end; 67 | while(lines--) { 68 | i64 a = strtol(text, &end, 10); 69 | text = end; 70 | i64 b = strtol(text, &end, 10); 71 | text = end; 72 | i64 c = strtol(text, &end, 10); 73 | text = end; 74 | gkt.kerning[a-32][b-32] = (f32)c / (f32)kernScale; 75 | } 76 | } else { 77 | for(int i = 32; i <= 127; ++i) { 78 | FT_UInt a = FT_Get_Char_Index(face, i); 79 | for(int j = 32; j <= 127; ++j) { 80 | FT_UInt b = FT_Get_Char_Index(face, j); 81 | FT_Vector k; 82 | int error = FT_Get_Kerning(face, a, b, FT_KERNING_UNSCALED, &k); 83 | if(error) { 84 | fprintf(stderr, "%d\n", error); 85 | } 86 | 87 | icvt cc; 88 | cc.u = k.x; 89 | double f = (double)cc.i; 90 | f /= 2048.0; 91 | gkt.kerning[i-32][j-32] = (float)f; 92 | } 93 | } 94 | } 95 | 96 | printf("Rendering SDFs...\n"); 97 | if(doRender) { 98 | char buf[4096]; 99 | snprintf(buf, 4096, "%swiggleTemp", enclosingFolder); 100 | createdir(buf); 101 | for(int i = 32; i <= 127; ++i) { 102 | snprintf(buf, 4096, 103 | "start /b %smsdfgen msdf -scale %d -size %d %d " 104 | "-translate %d %d " 105 | "-font %s %d -pxrange %d -printmetrics -o %swiggleTemp/w%d.png " 106 | "> %swiggleTemp/w%dmetrics.txt", 107 | enclosingFolder, 108 | Scale, SizeX, SizeY, OffsetX, OffsetY, 109 | fontFile, i, PxRange, enclosingFolder, i, 110 | enclosingFolder, i); 111 | system(buf); 112 | printf("\rFinished %d", i - 32); 113 | } 114 | printf("\n"); 115 | Sleep(100); 116 | snprintf(buf, 4096, "%swiggleTemp/w127metrics.txt", enclosingFolder); 117 | while(!PathFileExists(buf)) { 118 | Sleep(100); 119 | } 120 | } else { 121 | printf("......Skipping!\n"); 122 | } 123 | 124 | 125 | 126 | 127 | printf("Loading images...\n"); 128 | int atlasSize = 1; 129 | { 130 | int w = SizeX; 131 | int h = SizeY; 132 | int wh = w; 133 | wh += 2; 134 | double ss = wh * 10; 135 | int tt = __lzcnt((unsigned int)ss - 1); 136 | atlasSize = 1 << (31 - tt); 137 | printf("%d \n", atlasSize); 138 | } 139 | 140 | PrintedMetrics mm[96]; 141 | 142 | { 143 | char buf[4096]; 144 | for(isize i = 33; i <= 127; ++i) { 145 | snprintf(buf, 1024, "%swiggleTemp/w%tdmetrics.txt", enclosingFolder, i); 146 | while(!PathFileExists(buf)) Sleep(100); 147 | char* text = loadFile(buf); 148 | 149 | text = parsePrintedMetrics(text, mm + i-32); 150 | Glyph* g = gkt.glyphs + i-32; 151 | g->l = mm[i-32].l; 152 | g->b = mm[i-32].b; 153 | g->r = mm[i-32].r; 154 | g->t = mm[i-32].t; 155 | } 156 | } 157 | /* 158 | { 159 | char buf[4096]; 160 | snprintf(buf, 1024, "%swiggleTemp/metrics.txt", enclosingFolder); 161 | FILE* ff = fopen(buf, "r"); 162 | char* file = NULL; 163 | if(ff) { 164 | fseek(ff, 0L, SEEK_END); 165 | isize size = ftell(ff); 166 | rewind(ff); 167 | file = (char*)malloc(size + 64); 168 | fread(file, 1, size, ff); 169 | file[size] = '\0'; 170 | fclose(ff); 171 | } 172 | 173 | if(file != NULL) { 174 | char* text = file; 175 | for(int i = 1; i < 96; ++i) { 176 | text = parsePrintedMetrics(text, mm + i); 177 | Glyph* g = gkt.glyphs + i; 178 | g->l = mm[i].l; 179 | g->b = mm[i].b; 180 | g->r = mm[i].r; 181 | g->t = mm[i].t; 182 | } 183 | } 184 | } 185 | */ 186 | 187 | stbrp_rect* rects = (stbrp_rect*)malloc(sizeof(stbrp_rect) * 100); 188 | stbrp_node* nodes = (stbrp_node*)malloc(sizeof(stbrp_node) * atlasSize + 2); 189 | for(int i = 32; i <= 127; ++i) { 190 | char buf[4096]; 191 | snprintf(buf, 1024, "%swiggleTemp/w%d.png", enclosingFolder, i); 192 | int w, h, n; 193 | unsigned char* data = stbi_load(buf, &w, &h, &n, 4); 194 | glyphImages[i-32] = data; 195 | float lw = mm[i-32].r - mm[i-32].l; 196 | float lh = mm[i-32].t - mm[i-32].b; 197 | lw *= Scale; 198 | lw += PxRange*2; 199 | lh *= Scale; 200 | lh += PxRange*2; 201 | #ifdef UseFullImage 202 | lw = SizeX; 203 | #endif 204 | lh = SizeY; 205 | gkt.images[i-32].w = (int)lw; 206 | gkt.images[i-32].h = (int)lh; 207 | stbrp_rect* r = rects + (i - 32); 208 | r->id = i - 32; 209 | r->w = (int)lw + 2; 210 | r->h = (int)lh + 2; 211 | 212 | } 213 | 214 | printf("Packing atlas...\n"); 215 | { 216 | stbrp_context ctx = {0}; 217 | stbrp_init_target(&ctx, atlasSize, atlasSize*2, nodes, atlasSize); 218 | int ret = stbrp_pack_rects(&ctx, rects, 96); 219 | if(!ret) { 220 | fprintf(stderr, "Error: packing failed! Increase atlas size and re-run\n"); 221 | } 222 | } 223 | 224 | printf("Rendering atlas... \n"); 225 | u8* atlas = (u8*)calloc(4, atlasSize * atlasSize * 2); 226 | int maxHeight = 0; 227 | for(int i = 1; i < 96; ++i) { 228 | stbrp_rect* r = rects + i; 229 | if(r->id > 96 || r->id < 0) continue; 230 | GlyphImage* g = gkt.images + r->id; 231 | g->x = r->x + 1; 232 | g->y = r->y + 1; 233 | 234 | if(glyphImages[i] == NULL) continue; 235 | 236 | float lw = g->w; 237 | float lh = g->h; 238 | float lx = (mm[i].l + OffsetX) * Scale; 239 | float ly = SizeY - (mm[i].t + OffsetY) * Scale; 240 | lx -= PxRange; 241 | ly -= PxRange; 242 | g->bbx = lx; 243 | g->bby = ly; 244 | 245 | #ifdef UseFullImage 246 | lx = 0; 247 | lw = SizeX; 248 | #endif 249 | ly = 0; 250 | lh = SizeY; 251 | wplCopyMemoryBlock(atlas, glyphImages[i], 252 | roundf(lx), roundf(ly), (int)lw, (int)lh, SizeX, SizeY, 253 | g->x, g->y, atlasSize, atlasSize, 254 | 4, 0); 255 | 256 | if(g->y + lh > maxHeight) { 257 | maxHeight = g->y + lh; 258 | } 259 | printf("\rFinished %d ", i); 260 | } 261 | 262 | printf("\nWriting atlas...\n"); 263 | stbi_write_png(atlasFile, atlasSize, maxHeight + 16, 4, atlas, atlasSize * 4); 264 | 265 | printf("Writing glyph data...\n"); 266 | FILE* fp = fopen(outFile, "wb"); 267 | if(fp) { 268 | fwrite(&gkt, sizeof(gkt), 1, fp); 269 | fclose(fp); 270 | } 271 | 272 | printf("Done! \n"); 273 | printf("%s and %s created\n\n", outFile, atlasFile); 274 | printf("[FontInfo] %s", outFile); 275 | printf("SizeX/Y %d %d\nScale %d\nOffsetX/Y %d %d\nPxRange %d\nLineSpacing %d\n", 276 | gkt.sizeX, gkt.sizeY, 277 | gkt.scale, 278 | gkt.offsetX, gkt.offsetY, 279 | gkt.pxRange, 280 | gkt.lineSpacing); 281 | 282 | return 0; 283 | } 284 | -------------------------------------------------------------------------------- /wiggle_types.h: -------------------------------------------------------------------------------- 1 | 2 | typedef struct wGlyph wGlyph; 3 | typedef struct wGlyphImage wGlyphImage; 4 | typedef struct wFontInfo wFontInfo; 5 | typedef struct wRgbaFileHeader wRgbaFileHeader; 6 | 7 | #ifndef WIGGLE_NO_TYPES 8 | #ifdef WIGGLE_USE_STDINT 9 | typedef float f32; 10 | typedef int32_t i32; 11 | typedef uint32_t u32; 12 | #else 13 | typedef float f32; 14 | typedef int i32; 15 | typedef unsigned int u32; 16 | #endif 17 | #endif 18 | 19 | #pragma pack(push, 4) 20 | struct wGlyph 21 | { 22 | i32 character; 23 | f32 width, height; 24 | f32 x, y; 25 | f32 advance; 26 | f32 l, b, r, t; 27 | }; 28 | 29 | struct wGlyphImage 30 | { 31 | i32 x, y, w, h; 32 | f32 bbx, bby; 33 | }; 34 | 35 | struct wFontInfo 36 | { 37 | i32 sizeX, sizeY; 38 | i32 scale; 39 | i32 offsetX, offsetY; 40 | i32 pxRange; 41 | i32 lineSpacing; 42 | i32 atlasX, atlasY; 43 | 44 | wGlyph glyphs[96]; 45 | wGlyphImage images[96]; 46 | f32 kerning[96][96]; 47 | }; 48 | 49 | struct wRgbaFileHeader 50 | { 51 | u32 unused[2]; 52 | u32 width, height; 53 | }; 54 | #pragma pack(pop) 55 | 56 | 57 | 58 | 59 | 60 | 61 | #if 0 62 | /* Some sample code, for working with these things 63 | * 64 | * You should really check out the demo program if you want examples of 65 | * this stuff working in action, though. 66 | * 67 | * Most of these are extracted from there, though with some changes; these have 68 | * had parts removed for simplicity 69 | */ 70 | 71 | /* Loading a .rgba file as written by wiggle 72 | * 73 | * The header is just there to help you understand how it works; you don't need 74 | * it to load the file. The demo program doesn't have access to fopen and kin, so 75 | * it uses the Win32 functions to do the same 76 | */ 77 | u32* exampleLoadRgba(char* filename, int* w, int* h) 78 | { 79 | FILE* fp = fopen(filename, "rb"); 80 | if(!fp) return NULL; 81 | 82 | wRgbaFileHeader header; 83 | fread(&header, sizeof(wRgbaFileHeader), 1, fp); 84 | 85 | u32* img = (u32*)malloc(header.width * header.height * 4); 86 | fread(img, 4, header.width * header.height, fp); 87 | 88 | *w = (int)header.width; 89 | *h = (int)header.height; 90 | 91 | return img; 92 | } 93 | 94 | /* Example "drawText" function 95 | * 96 | * This is pretty messy; I'm still not sure of all the units. The basic idea is the 97 | * same as always: loop over your characters, draw them, move right by that one's 98 | * advance, move left by the kerning pair with the previous one. 99 | */ 100 | 101 | void exampleRenderRect(f32 sdf, u32 color, 102 | //Screen position 103 | f32 x, f32 y, f32 w, f32, h, 104 | //Texture coords 105 | f32 tx, f32 ty, f32 tw, f32 th); 106 | 107 | void exampleDrawText(wFontInfo* info, 108 | f32 x, f32 y, 109 | char* text, isize count, 110 | f32 pointSize, u32 color, f32 sdfSharpness) 111 | { 112 | //offsets 113 | f32 ox = 0.0f, oy = 0.0f; 114 | 115 | //kept track of for kerning 116 | char last = 0; 117 | 118 | //slightly confused transformations 119 | //Converting to pixels from points; probably not quite accurate because 120 | //we're accidentally taking into account things like padding 121 | //Or, possibly, there's some confusion and disagreement coming from FreeType 122 | //and msdfgen about exactly what the units are. That might explain a lot of 123 | //the weird units and magic numbers in this function. 124 | f32 pixelSize = (pointSize * group->dpi) / 72.0f; 125 | f32 padding = (f32)info->pxRange; 126 | f32 fontScale = info->scale; 127 | 128 | //This might be part of the issue too; 'A' should be Npts tall, 129 | //but not everything else? Supposedly, wiggle outputs its metrics in ems 130 | //(I did the best I can there, not entirely sure to be honest) 131 | wGlyphImage* a = NULL; 132 | wGlyph* g = info->glyphs + ('A'-32); 133 | f32 glyphHeight = wabsf(g->t - g->b); 134 | f32 scaledHeight = glyphHeight * fontScale; 135 | f32 scaledRatio = pixelSize / scaledHeight; 136 | f32 heightRatio = pixelSize / glyphHeight; 137 | 138 | i32 newLine = 1; 139 | for(isize i = 0; i < count; ++i) { 140 | char c = text[i]; 141 | 142 | //Incredibly rudimentary handling of special characters 143 | switch(c) { 144 | case '\r': 145 | continue; 146 | 147 | case '\n': 148 | if(ox > maxX) maxX = ox; 149 | ox = 0; 150 | oy += info->lineSpacing * heightRatio; 151 | newLine = 1; 152 | continue; 153 | 154 | case '\t': 155 | ox += info->glyphs[0].advance * heightRatio * 8; 156 | continue; 157 | 158 | case ' ': 159 | ox += info->glyphs[0].advance * heightRatio; 160 | continue; 161 | } 162 | 163 | if(c <= 32 || c >= 127) continue; 164 | a = info->images + (c-32); 165 | g = info->glyphs + (c-32); 166 | 167 | if(last > 32 && last < 127) { 168 | info->kerning[last-32][c-32]; 169 | ox += info->kerning[last-32][c-32] * pixelSize * fontScale * 0.5f; 170 | } 171 | 172 | //Account for the extra padding added to the bounding box to ensure that 173 | //the SDF has enough room. 174 | f32 gx = (a->bbx - padding) * scaledRatio; 175 | //Because we pass the entire vertical area of the individual rendered 176 | //glyphs to the final atlas, you don't need to align them the same way 177 | //in Y. If you did decide to trim the glyphs, you would need to do 178 | //the same thing. I found this could lead to single pixel offset problems 179 | //(though, my math may have been wrong too), so I stuck to keeping the 180 | //entire glyph rendered. 181 | 182 | //We need to scoot the first glyph on each line backward somewhat so that 183 | //the glyph is close to the passed in X position 184 | //For some reason, multiplying by 1.25 works 185 | if(newLine) { 186 | ox -= gx * 1.25; 187 | newLine = 0; 188 | } 189 | 190 | //hey, at least these units make sense 191 | exampleDrawRect(sdfSharpness, color 192 | x + ox + gx, y + oy, a->w * scaledRatio, a->h * scaledRatio, 193 | a->x + info->atlasX, a->y + info->atlasY, a->w, a->h); 194 | 195 | //but this one doesn't? 196 | ox += g->advance * heightRatio; 197 | last = c; 198 | } 199 | } 200 | 201 | // 202 | //The SDF parameter in exampleDrawRect is, I don't know what the units should be, 203 | //but numbers around 0.001 seem to work? (in the demo, I divide by 1000) 204 | // 205 | //In the original shader, it's replaced by fwidth. 206 | // 207 | 208 | /* Sample (OpenGL 2.0) fragment shader. 209 | * 210 | * This is essentially the same as the msdf one, but with the sdfSharpness term 211 | * passed in, rather than just with fwidth. 212 | * 213 | */ 214 | #version 100 215 | 216 | varying float fSdfSharpness; 217 | varying vec2 fScale; 218 | varying vec2 fUV; 219 | varying vec4 fColor; 220 | 221 | uniform float uPxRange; 222 | uniform vec2 uInvTextureSize; 223 | uniform vec4 uTint; 224 | uniform sampler2D uTexture; 225 | 226 | float median(float a, float b, float c) 227 | { 228 | return max(min(a, b), min(max(a, b), c)); 229 | } 230 | 231 | void main() 232 | { 233 | vec2 msdfUnit = uPxRange * uInvTextureSize; 234 | vec4 sdfVal = texture2D(uTexture, fUV * uInvTextureSize); 235 | float sigDist = median(sdfVal.r, sdfVal.g, sdfVal.b) - 0.5; 236 | sigDist *= dot(msdfUnit, 0.5/vec2(fSdfSharpness)); 237 | float opacity = clamp(sigDist + 0.5, 0.0, 1.0); 238 | gl_FragColor = vec4(1, 1, 1, opacity) * uTint * fColor; 239 | } 240 | 241 | #endif 242 | --------------------------------------------------------------------------------