{"id":21435542,"url":"https://github.com/mountain/metafont-glyphs","last_synced_at":"2025-07-14T14:32:19.000Z","repository":{"id":65535559,"uuid":"594212656","full_name":"mountain/metafont-glyphs","owner":"mountain","description":"A metafont-glyphs dataset which facilitate people to define CJK-like glyphs with their metafont scripts by machine learning","archived":false,"fork":false,"pushed_at":"2024-05-22T16:32:26.000Z","size":5599,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-22T16:37:46.114Z","etag":null,"topics":["ancient-languages","dataset","glyphs","machine-learning","metafont"],"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/mountain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-01-27T21:35:27.000Z","updated_at":"2024-05-22T16:37:47.722Z","dependencies_parsed_at":"2024-05-22T16:52:35.164Z","dependency_job_id":null,"html_url":"https://github.com/mountain/metafont-glyphs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mountain/metafont-glyphs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fmetafont-glyphs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fmetafont-glyphs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fmetafont-glyphs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fmetafont-glyphs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mountain","download_url":"https://codeload.github.com/mountain/metafont-glyphs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountain%2Fmetafont-glyphs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265305746,"owners_count":23743894,"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":["ancient-languages","dataset","glyphs","machine-learning","metafont"],"created_at":"2024-11-22T23:44:33.620Z","updated_at":"2025-07-14T14:32:18.148Z","avatar_url":"https://github.com/mountain.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metafont-glyphs dataset\n\nThis repository contains a dataset of glyph images generated from random metafont scripts.\n\nWe have many variant characters from ancient literature, such as oracle-bone inscriptions, bronze inscriptions etc.\nThe main difficulty is that these characters are not standardized, and in order to digitize them, we need to collect a large number of glyph images,\nand then use machine learning to generate metafont scripts from glyph images.\nIt is a different problem from OCR, which is focused on recognizing and transcribing written text from images.\nThe goal is to develop models that can generate accurate geometric descriptions of these glyphs, \nwhich can then be used in typesetting systems such as Metafont and Tex.\n\n## gallery\n\u003cdiv\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/01.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/02.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/03.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/04.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/05.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/06.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/07.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/08.png\" width=\"96px\"\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/09.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/10.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/11.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/12.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/13.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/14.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/15.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/16.png\" width=\"96px\"\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/17.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/18.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/19.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/20.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/21.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/22.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/23.png\" width=\"96px\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/24.png\" width=\"96px\"\u003e\n\u003c/div\u003e\n\n## An example\n\nThe following glyph is generated from the following metafont script.\n\n\u003cimg src=\"https://raw.githubusercontent.com/mountain/metafont-glyphs/main/demo/00.png\" width=\"96px\"\u003e\n\n```metafont\n% file name: bcdylw.mf\n% mode_setup;\n% Define a random shape for the training corpus\n\nbeginchar(\"bcdylw\",12pt#,12pt#,0);\n  % Setup coordinates as an equation system\n  x12 = 1 * w / 10;\n  x14 = 1 * w / 10;\n  x32 = 3 * w / 10;\n  x34 = 3 * w / 10;\n  x36 = 3 * w / 10;\n  x38 = 3 * w / 10;\n  x45 = 4 * w / 10;\n  x68 = 6 * w / 10;\n\n  y12 = 2 * w / 10;\n  y14 = 4 * w / 10;\n  y32 = 2 * w / 10;\n  y34 = 4 * w / 10;\n  y36 = 6 * w / 10;\n  y38 = 8 * w / 10;\n  y45 = 5 * w / 10;\n  y68 = 8 * w / 10;\n\n  % Draw the character curve\n  % z1 is the same as (x1, y1)\n  pickup pencircle xscaled 0.06w yscaled 0.02w rotated 243;\n  draw z36..z38;\n  draw z36..z38;\n  draw z12..z14;\n  draw z45..z68..z34;\n  draw z32..z34;\nendchar;\n\nend\n```\n\nTo facilitate machine learning, we also provide the following csv file for the sequence of coordinates of the control points.\n\n```csv\n-0.1666, +0.5750\n-0.5000, +0.2497\n-0.8333, +0.6750\n+0.3000, +0.6000\n+0.3000, +0.8000\n-0.5000, -0.5000\n+0.3000, +0.6000\n+0.3000, +0.8000\n-0.5000, -0.5000\n+0.1000, +0.2000\n+0.1000, +0.4000\n-0.5000, -0.5000\n+0.4000, +0.5000\n+0.6000, +0.8000\n+0.3000, +0.4000\n-0.5000, -0.5000\n+0.3000, +0.2000\n+0.3000, +0.4000\n-0.5000, -0.5000\n```\n\nLines with negative coordinates are special\n  * `-0.1666, +0.5750` means the xscale of the pen is 0.0575\n  * `-0.5000, +0.2497` means the yscale of the pen is 0.02497\n  * `-0.8333, +0.6750` means the rotation of the pen is 0.675 * 360 degrees, i.e. 243 degrees\n  * `-0.5000, -0.5000` means the pen is lifted up, i.e. the pen is not drawing and hence the end of the curve\n\n## How to use\n\n### Install texlive\n\n```bash\nsudo apt install texlive-full # for Debian and Ubuntu\nbrew install texlive # for macOS\n```\n\n### Install python3, ninja and imagemagick\n\n```bash\nsudo apt install python3 # for Debian and Ubuntu\nsudo apt install ninja-build # for Debian and Ubuntu\nsudo apt install imagemagick # for Debian and Ubuntu\nbrew install python3 # for macOS\nbrew install ninja # for macOS\nbrew install imagemagick # for macOS\npip3 install -r requirements.txt # for any platform\n```\n\n### Fire the tests\n\n```bash\ngit clone https://github.com/mountain/metafont-glyphs.git\ncd metafont-glyphs\nbin/meg fontg 48\nbin/meg build\n```\n\nYou should see the glyphs in the `data/glyph` folder.\n\n### Make dataset\n\n```bash\ncd metafont-glyphs\nbin/meg clean-all\nbin/meg fontg 100000\nbin/meg build\nbin/meg dsmk\n```\n\nYou should see three parquet files in the `data/dataset` folder.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmountain%2Fmetafont-glyphs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmountain%2Fmetafont-glyphs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmountain%2Fmetafont-glyphs/lists"}