{"id":38488623,"url":"https://github.com/gerph/riscos-font-controls-python","last_synced_at":"2026-01-17T05:39:36.258Z","repository":{"id":128876826,"uuid":"420504506","full_name":"gerph/riscos-font-controls-python","owner":"gerph","description":"Parser for RISC OS Font control characters in Python","archived":false,"fork":false,"pushed_at":"2026-01-12T14:11:25.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-12T20:12:42.728Z","etag":null,"topics":["python","riscos"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gerph.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":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-10-23T19:28:06.000Z","updated_at":"2026-01-12T14:06:48.000Z","dependencies_parsed_at":"2023-04-29T18:45:52.020Z","dependency_job_id":null,"html_url":"https://github.com/gerph/riscos-font-controls-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gerph/riscos-font-controls-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerph%2Friscos-font-controls-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerph%2Friscos-font-controls-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerph%2Friscos-font-controls-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerph%2Friscos-font-controls-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gerph","download_url":"https://codeload.github.com/gerph/riscos-font-controls-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerph%2Friscos-font-controls-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28500584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T04:31:57.058Z","status":"ssl_error","status_checked_at":"2026-01-17T04:31:45.816Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["python","riscos"],"created_at":"2026-01-17T05:39:35.862Z","updated_at":"2026-01-17T05:39:36.254Z","avatar_url":"https://github.com/gerph.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RISC OS Font control parsing in Python\n\nThis repository contains a class (`FontControlParser`) for parsing font control codes from a\nbyte squence, in Python.\n\nIt is part of the RISC OS Pyromaniac font system, and provides support for the SWIs which operate\non the font strings:\n\n* `Font_Paint` - uses the controls to determine what should be rendered.\n* `Font_ScanString` - uses the controls to determine the size or break points of a string.\n\nAnd all the other calls which call on to `Font_ScanString`:\n\n* `Font_StringWidth` - reads the width of a string.\n* `Font_StringBBox` - reads the coverage of a string.\n* `Font_FindCaret` - finds the position of the caret within a string.\n* `Font_FindCaretJ` - a variant of the `Font_FindCaret` call.\n\nThe `FontContext` provides information which allows the operation of the following calls:\n\n* `Font_CurrentFont` - reads the current font.\n* `Font_FutureFont` - reads what the font would be after one of the sizing calls.\n* `Font_CurrentRGB` - reads the current colour.\n* `Font_FutureRGB` - reads what the colour would be after one of the sizing calls.\n\n\n## Usage\n\nInside RISC OS Pyromaniac...\n\n* The `FontControlParser` is subclassed to allow the memory access to occur within the\n  emulated memory, not using the bytes.\n* The `FontSpacing` is subclassed to create spacing from the memory blocks.\n* The `FontContext` is subclassed to allow the GCOL/RGB operations, font lookups, sizing and rendering operations to be performed on the RISC OS graphics system.\n\nA font context is created on initialisation, and will be updated by different operations:\n\n```\nself.context = FontContextPyromaniac(self.ro, self.fonts)\n```\n\nThe font parser is constructed and supplied the memory buffers to parse:\n\n```\nmemstring = self.ro.memory[regs[1]]\nfc = FontControlParserPyromaniac(self.ro)\nfc.debug_enable = self.debug_fontparser\nfc.parse(memstring, string_length)\n```\n\nOnce the other parameters for Font_Paint have been decoded and spacing and transformed written\nto the `FontContext`, the paint operation is called.\n\n```\nself.context.x = xmilli\nself.context.y = ymilli\nself.context.transform = transform\n\nwith self.ro.kernel.graphics.vducursor.disable():\n    self.context.paint(fc.sequence, spacing)\n\n    # Update OS_ChangedBox\n    x0 = int(self.context.bounds.x0 / riscos.graphics.font.FontConstants.Font_OSUnit) \u003e\u003e xeig\n    y0 = int(self.context.bounds.y0 / riscos.graphics.font.FontConstants.Font_OSUnit) \u003e\u003e xeig\n    x1 = int(self.context.bounds.x1 / riscos.graphics.font.FontConstants.Font_OSUnit) \u003e\u003e yeig\n    y1 = int(self.context.bounds.y1 / riscos.graphics.font.FontConstants.Font_OSUnit) \u003e\u003e yeig\n    self.ro.kernel.graphics.changedbox_update(x0, y0, x1, y1)\n```\n\n`Font_ScanString` is similar, but instead of operating on the current context, the future context is updated:\n\n```\nself.context.copy(to=self.future_context)\n...\nmemstring = self.ro.memory[regs[1]]\nfc = FontControlParserPyromaniac(self.ro)\nfc.debug_enable = self.debug_fontparser\nfc.parse(memstring, string_length)\n...\n(split_offset, splits) = self.future_context.size(fc.sequence, spacing=spacing, limits=(xmilli, ymilli),\n                                                  split_char=split_char)\n```\n\nThis allows all the `Font_Future*` calls to query the `self.future_context`\n\n## Tests\n\nTests exist to show that the module is working properly, intended for use on GitLab.\nCode coverage is reported as well.\n\nTo test, use:\n\n```\nmake tests PYTHON=python2\n```\n\nTests don't work on Python 3 yet, due to some problems with the processing of byte sequences.\n\nTo run coverage, use:\n\n```\nmake coverage\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerph%2Friscos-font-controls-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgerph%2Friscos-font-controls-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerph%2Friscos-font-controls-python/lists"}