{"id":13805675,"url":"https://github.com/BindBC/bindbc-freetype","last_synced_at":"2025-05-13T19:31:45.839Z","repository":{"id":47211577,"uuid":"178420727","full_name":"BindBC/bindbc-freetype","owner":"BindBC","description":"Static \u0026 dynamic D bindings to the FreeType library, compatible with BetterC, @nogc, and nothrow.","archived":false,"fork":false,"pushed_at":"2024-06-26T11:24:13.000Z","size":183,"stargazers_count":14,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-04T01:05:19.370Z","etag":null,"topics":["bindbc","dlang","freetype","freetype-bindings"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BindBC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE_1_0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"BindBC"}},"created_at":"2019-03-29T14:29:48.000Z","updated_at":"2024-07-10T18:19:30.000Z","dependencies_parsed_at":"2023-12-07T19:26:27.895Z","dependency_job_id":"ec5c8556-a7c4-4ba5-b7ec-a18851a74bb4","html_url":"https://github.com/BindBC/bindbc-freetype","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BindBC%2Fbindbc-freetype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BindBC%2Fbindbc-freetype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BindBC%2Fbindbc-freetype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BindBC%2Fbindbc-freetype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BindBC","download_url":"https://codeload.github.com/BindBC/bindbc-freetype/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225254368,"owners_count":17445171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindbc","dlang","freetype","freetype-bindings"],"created_at":"2024-08-04T01:01:03.704Z","updated_at":"2024-11-18T21:31:32.564Z","avatar_url":"https://github.com/BindBC.png","language":"D","funding_links":["https://github.com/sponsors/BindBC"],"categories":["Game Bindings"],"sub_categories":["XML"],"readme":"\n# BindBC-FreeType\nThis project provides a set of both static and dynamic bindings to\n[the FreeType library](https://www.freetype.org/). They are compatible with `@nogc` and `nothrow`, and can be compiled with BetterC compatibility. This package is intended to replace [DerelictFT](https://github.com/DerelictOrg/DerelictFT), which does not provide the same level of compatibility.\n\n| Table of Contents |\n|-------------------|\n|[License](#license)|\n|[FreeType documentation](#freetype-documentation)|\n|[Quickstart guide](#quickstart-guide)|\n|[Configurations](#configurations)|\n|[Library versions](#library-versions)|\n\n## License\nBindBC-FreeType\u0026mdash;as well as every other binding in the [BindBC project](https://github.com/BindBC)\u0026mdash;is licensed under the [Boost Software License](https://www.boost.org/LICENSE_1_0.txt).\n\nBear in mind that you still need to abide by [one of FreeType's licenses](https://freetype.org/license.html) if you use it through these bindings.\n\n## FreeType documentation\nThis readme describes how to use BindBC-FreeType, *not* FreeType itself. BindBC-FreeType is a direct D binding to the FreeType API, so any existing FreeType documentation and tutorials can be adapted with only minor modifications.\n* [The FreeType API reference](https://freetype.org/freetype2/docs/reference/index.html) has official documentation of the FreeType API.\n* [The official FreeType tutorials](https://freetype.org/freetype2/docs/tutorial/index.html) provide good references for how to use the API.\n\n## Quickstart guide\nTo use BindBC-FreeType in your dub project, add it to the list of `dependencies` in your dub configuration file. The easiest way is by running `dub add bindbc-freetype` in your project folder. The result should look like this:\n\nExample __dub.json__\n```json\n\"dependencies\": {\n\t\"bindbc-freetype\": \"~\u003e1.2.0\",\n},\n```\nExample __dub.sdl__\n```sdl\ndependency \"bindbc-freetype\" version=\"~\u003e1.2.0\"\n```\n\nBy default, BindBC-FreeType is configured to compile as a dynamic binding that is not BetterC-compatible. If you prefer static bindings or need BetterC compatibility, they can be enabled via `subConfigurations` in your dub configuration file. For configuration naming \u0026 more details, see [Configurations](#configurations).\n\nExample __dub.json__\n```json\n\"subConfigurations\": {\n\t\"bindbc-freetype\": \"staticBC\",\n},\n```\nExample __dub.sdl__\n```sdl\nsubConfiguration \"bindbc-freetype\" \"staticBC\"\n```\n\nIf you need to use versions of FreeType newer than 2.6.X, then you will have to add the appropriate version identifiers to `versions` in your dub configuration. For a list of library version identifiers, see [Library versions](#library-versions).\n\nIf using static bindings, then you will also need to add FreeType to `libs`.\n\nExample __dub.json__\n```json\n\"versions\": [\n\t\"FT_2_13\",\n],\n\"libs\": [\n\t\"freetype\",\n],\n```\nExample __dub.sdl__\n```sdl\nversions \"FT_2_13\"\nlibs \"freetype\"\n```\n\n**If you're using static bindings**: `import bindbc.freetype` in your code, and then you can use all of FreeType just like you would in C. That's it!\n```d\nimport bindbc.freetype;\n\nvoid main(){\n\tFT_Library lib;\n\tFT_Init_FreeType(\u0026lib);\n\t\n\t//etc.\n\t\n\tFT_Done_FreeType(lib);\n}\n```\n\n**If you're using dynamic bindings**: you need to load FreeType with `loadFreeType()`. \n\nFor most use cases, it's best to use BindBC-Loader's [error handling API](https://github.com/BindBC/bindbc-loader#error-handling) to see if there were any errors while loading the library. This information can be written to a log file before aborting the program.\n\nThe load function will also return a member of the `LoadMsg` enum, which can be used for debugging:\n\n* `noLibrary` means the library couldn't be found.\n* `badLibrary` means there was an error while loading the library.\n* `success` means that FreeType was loaded without any errors.\n\nHere's a simple example using only the load function's return value:\n\n```d\nimport bindbc.freetype;\nimport bindbc.loader;\n\n/*\nThis code attempts to load the FreeType shared library using\nwell-known variations of the library name for the host system.\n*/\nLoadMsg ret = loadFreeType();\nif(ret != LoadMsg.success){\n\t/*\n\tError handling. For most use cases, it's best to use the error handling API in\n\tBindBC-Loader to retrieve error messages for logging and then abort.\n\tIf necessary, it's possible to determine the root cause via the return value:\n\t*/\n\tif(ret == LoadMsg.noLibrary){\n\t\t//The FreeType shared library failed to load\n\t}else if(ret == LoadMsg.badLibrary){\n\t\t/*\n\t\tOne or more symbols failed to load. The likely cause is\n\t\tthat the shared library is for a lower version than\n\t\tBindBC-FreeType was configured to load.\n\t\t*/\n\t}\n}\n\n/*\nThis code attempts to load the FreeType library using a user-supplied file name.\nUsually, the name and/or path used will be platform specific, as in this\nexample which attempts to load `FreeType.dll` from the `libs` subdirectory,\nrelative to the executable, only on Windows.\n*/\nversion(Windows) loadFreeType(\"libs/FreeType.dll\");\n```\n\n[The error handling API](https://github.com/BindBC/bindbc-loader#error-handling) in BindBC-Loader can be used to log error messages:\n```d\nimport bindbc.freetype;\n\n/*\nImport the sharedlib module for error handling. Assigning an alias ensures that the\nfunction names do not conflict with other public APIs. This isn't strictly necessary,\nbut the API names are common enough that they could appear in other packages.\n*/\nimport loader = bindbc.loader.sharedlib;\n\nbool loadLib(){\n\tLoadMsg ret = loadFreeType();\n\tif(ret != LoadMsg.success){\n\t\t//Log the error info\n\t\tforeach(info; loader.errors){\n\t\t\t/*\n\t\t\tA hypothetical logging function. Note that `info.error` and\n\t\t\t`info.message` are `const(char)*`, not `string`.\n\t\t\t*/\n\t\t\tlogError(info.error, info.message);\n\t\t}\n\t\t\n\t\t//Optionally construct a user-friendly error message for the user\n\t\tstring msg;\n\t\tif(ret == LoadMsg.noLibrary){\n\t\t\tmsg = \"This application requires the FreeType library.\";\n\t\t}\n\t\t//A hypothetical message box function\n\t\tshowMessageBox(msg);\n\t\treturn false;\n\t}\n\treturn true;\n}\n```\n\n## Configurations\nBindBC-FreeType has the following configurations:\n\n|      ┌      |  DRuntime  |   BetterC   |\n|-------------|------------|-------------|\n| **Dynamic** | `dynamic`  | `dynamicBC` |\n| **Static**  | `static`   | `staticBC`  |\n\nFor projects that don't use dub, if BindBC-FreeType is compiled for static bindings then the version identifier `BindFT_Static` must be passed to your compiler/linker when building your project.\n\n\u003e [!NOTE]\\\n\u003e The version identifier `BindBC_Static` can be used to configure all of the _official_ BindBC packages used in your program. (i.e. those maintained in [the BindBC GitHub organisation](https://github.com/BindBC)) Some third-party BindBC packages may support it as well.\n\n### Dynamic bindings\nThe dynamic bindings have no link-time dependency on the FreeType library, so the FreeType shared library must be manually loaded at runtime from the shared library search path of the user's system.\n\nThe function `isFreeTypeLoaded` returns `true` if any version of the shared library has been loaded and `false` if not. `unloadFreeType` can be used to unload a successfully loaded shared library.\n\n### Static bindings\nStatic _bindings_ do not require static _linking_. The static bindings have a link-time dependency on either the shared _or_ static FreeType library. On Windows, you can link with the static library or, to use the DLLs, the import library. On other systems, you can link with either the static library or directly with the shared library.\n\nStatic linking requires the FreeType development packages be installed on your system. You can build them yourself, or you can also install them via your system's package manager. For example, on Debian-based Linux distributions `sudo apt install libfreetype-dev` will install both the development and runtime packages.\n\nWhen linking with the shared (or import) library, there is a runtime dependency on the shared library just as there is when using the dynamic bindings. The difference is that the shared library is no longer loaded manually\u0026mdash;loading is handled automatically by the system when the program is launched. Attempting to call `loadFreeType` with the static bindings enabled will result in a compilation error.\n\n\n## Library versions\nThese are the supported versions of each FreeType, along with the corresponding version identifiers to add to your dub configuration or pass to the compiler.\n\n| Version |Version identifier|\n|---------|------------------|\n| 2.6.X   | (none; default)  |\n| 2.7.X   | `FT_27`          |\n| 2.8.X   | `FT_28`          |\n| 2.9.X   | `FT_29`          |\n| 2.10.X  | `FT_210`         |\n| 2.11.X  | `FT_211`         |\n| 2.12.X  | `FT_2_12`        |\n| 2.13.X  | `FT_2_13`        |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBindBC%2Fbindbc-freetype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBindBC%2Fbindbc-freetype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBindBC%2Fbindbc-freetype/lists"}