{"id":16818398,"url":"https://github.com/ninjaprox/textcontour","last_synced_at":"2025-03-17T13:40:29.360Z","repository":{"id":71433582,"uuid":"80928703","full_name":"ninjaprox/TextContour","owner":"ninjaprox","description":"It is a tool to get contour of text in an image.","archived":false,"fork":false,"pushed_at":"2017-07-24T04:07:12.000Z","size":21803,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T23:29:59.327Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","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/ninjaprox.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":"2017-02-04T15:36:10.000Z","updated_at":"2017-04-18T07:04:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"22ed7ec6-523e-44a9-9127-f6d4b265378a","html_url":"https://github.com/ninjaprox/TextContour","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjaprox%2FTextContour","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjaprox%2FTextContour/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjaprox%2FTextContour/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjaprox%2FTextContour/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ninjaprox","download_url":"https://codeload.github.com/ninjaprox/TextContour/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244043340,"owners_count":20388566,"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":[],"created_at":"2024-10-13T10:50:00.882Z","updated_at":"2025-03-17T13:40:29.353Z","avatar_url":"https://github.com/ninjaprox.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"TextContour\n===========\n\n## What is it?\n\nIt is a tool to get contour of text in an image. Images may be from external source as input or created from `UITextView`.\n\nThis contour is then used to calibrate font due to difference of text rendering on multiple platforms.\n\n## Why?\n\nWhy should it run on iOS? By running on iOS, which is target of the calibration, it can directly and seamlessly create image from `UITextView` with arbitrary font and font size. The flow is described as below:\n\n1. Receive an image of text with specified size, font and font size, which is rendered and created by web engine.\n2. Create an `UITextView` with the same information as above.\n3. Capture image of the `UITextView`.\n4. Get contour of text in both images.\n5. Compare two contours, then use the difference to calibrate the font.\n\n## Prerequisite\n\nFor resources, i.e. fonts and images:\n\n- The background of image must be white.\n- The color of text must be black.\n- Only one paragraph is accepted, possibly one or multiple lines.\n\nFor resource provider, the folder structure must be as below.\n\n```\n[resource-provider] // Any name works.\n|\n|--- fonts\n|--- images\n\nTextContour // The TextContour folder mentioned below is this one.\n|\n|--- TextContour\n     |\n     |--- Fonts\n     |--- Images\n```\n\nOn the other hand, resource provider folder and `TextContour` folder are sibling. You do not need to worry about `TextContour` folder, it is already structured itself.\n\n## How does it work?\n\n### Local\n\nTo prepare for local run, do the following step:\n\n1. Change working directory to `TextContour`.\n2. Run `scripts/add-resources.sh` to add resources to the project.\n\nThere are two modes, debug and headless, with `TextContour` and `TextContourTests` scheme respectively. In debug mode, i.e. UI mode, there is only one font loaded, this can be changed by the index of the font in `TextContour/Fonts` folder.\n\nIn headless mode, it will go through all fonts in `TextContour/Fonts`, create both contours for iOS and web, and images from `UITextView`. All of these are stored in the path which is logged to the console. The output of headless mode includes:\n\n- `Images` folder contains images created from `UITextView`.\n- `contours-ios.json`\n- `contours-web.json`\n\nAfter use, there will be change in `TextContour/Info.plist` and `TextContour.xcodeproj/project.pbxproj`, do not commit these changes.\n\n### CI\n\n`TextContour` can be run on CI to create automation system to calibrate fonts. By default, it is set up with [Bitrise](https://www.bitrise.io) to use out of the box. There are environment variables needed to be set before use.\n\n- `FONT_IMAGE_SERVICE_REPO` // Where to clone resources.\n- `S3_BUCKET`\n- `S3_ACCESS_ID`\n- `S3_ACCESS_SECRET`\n\nThe output of this process will be uploaded to S3 bucket specified above, consisting of:\n\n- `offsets.json`\n- All images created from `UITextView`.\n\nThe same process running on CI can be run on local by using [Bitrise CLI](https://www.bitrise.io/cli).\n\n## Dependency\n\n- [GPUImage](https://github.com/BradLarson/GPUImage)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninjaprox%2Ftextcontour","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fninjaprox%2Ftextcontour","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninjaprox%2Ftextcontour/lists"}