{"id":15051941,"url":"https://github.com/tlabaltoh/opengl_sdf_font_rendering","last_synced_at":"2026-01-15T22:56:41.688Z","repository":{"id":255614999,"uuid":"850857336","full_name":"TLabAltoh/opengl_sdf_font_rendering","owner":"TLabAltoh","description":"Tiny example of rendering font (.ttf, .otf) as SDF using OpenGL","archived":false,"fork":false,"pushed_at":"2024-09-22T20:25:38.000Z","size":136,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T22:36:20.071Z","etag":null,"topics":["fonttools","opengl","otf","python","sdf","ttf"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TLabAltoh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2024-09-02T00:47:02.000Z","updated_at":"2024-09-22T20:25:41.000Z","dependencies_parsed_at":"2024-11-19T19:46:07.333Z","dependency_job_id":"a2c20fe1-492d-4a06-b264-5ea0c1f37af1","html_url":"https://github.com/TLabAltoh/opengl_sdf_font_rendering","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":"0.11111111111111116","last_synced_commit":"a0af269fa2dedf15ce7c60b615297339aa3801d9"},"previous_names":["tlabaltoh/opengl_sdf_font_rendering"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLabAltoh%2Fopengl_sdf_font_rendering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLabAltoh%2Fopengl_sdf_font_rendering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLabAltoh%2Fopengl_sdf_font_rendering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TLabAltoh%2Fopengl_sdf_font_rendering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TLabAltoh","download_url":"https://codeload.github.com/TLabAltoh/opengl_sdf_font_rendering/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254496297,"owners_count":22080688,"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":["fonttools","opengl","otf","python","sdf","ttf"],"created_at":"2024-09-24T21:37:07.417Z","updated_at":"2026-01-15T22:56:41.645Z","avatar_url":"https://github.com/TLabAltoh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# opengl_sdf_font_rendering\nTiny example of rendering font (```.ttf```, ```.otf```) as SDF using OpenGL\n\n## Overview\nIn this example, the approach is to [detect the edge path](https://github.com/fonttools/fonttools/blob/main/Lib/fontTools/ttLib/removeOverlaps.py) of the font and [fill by distance](https://www.shadertoy.com/view/dls3Wr).\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth scope=\"col\"\u003e\n        \u003cimg src=\"media/a_sdf_blur.png\" height=\"256\"\u003e\u003c/img\u003e\n        \u003c/th\u003e\n        \u003cth scope=\"col\"\u003e\n        \u003cimg src=\"media/a_sdf.png\" height=\"256\"\u003e\u003c/img\u003e\n        \u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003cth scope=\"col\"\u003e\n        BLUR: 100, EXPAND: 50\n        \u003c/th\u003e\n        \u003cth scope=\"col\"\u003e\n        BLUR: 0, EXPAND: 0\n        \u003c/th\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n```glsl\n// shader code: ./shaders/font.frag\n\n#define BLUR (...)\n#define EXPAND (...)\n\n// (get distance from shape ...)\n\n// (render with distance ...)\ndist *= winding;\nfloat delta = fwidth(dist) * 0.5;\nfloat alpha = 1-saturate(-delta + EXPAND - BLUR, delta + EXPAND, dist);\nout_color = vec4(alpha, alpha, alpha, alpha);\n```\n\n## Operating Environment\n|        |          |\n| ------ | -------- |\n| OS     | Windows  |\n| Python | 3.11     |\n| IDE    | anaconda |\n\n## Dependencies\n- [PyOpenGL](https://pypi.org/project/PyOpenGL/)\n- [glfw](https://pypi.org/project/glfw/)\n- [matplotlib](https://pypi.org/project/matplotlib/)\n- [numpy](https://pypi.org/project/numpy/)\n- [fonttools](https://pypi.org/project/fonttools/)\n- [skia-pathops](https://pypi.org/project/skia-pathops/)\n\n## Getting started\n- Clone the repository with the following command\n```cmd\ngit clone https://github.com/TLabAltoh/opengl_sdf_font_rendering.git\n```\n- Run ```main.py``` with the following command\n```cmd\ncd opengl_sdf_font_rendering\n\npython main.py %{FONT_PATH} %{CHAR} %{FONT_SIZE}\n@rem ex. python main.py font.ttf A 35\n```\n\n## TODO\nUse the dictionarized glyph buffer on the shader side to reduce the size of the gl compute buffer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlabaltoh%2Fopengl_sdf_font_rendering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftlabaltoh%2Fopengl_sdf_font_rendering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlabaltoh%2Fopengl_sdf_font_rendering/lists"}