{"id":18799518,"url":"https://github.com/vidarh/skrift","last_synced_at":"2025-04-13T17:30:42.853Z","repository":{"id":189190410,"uuid":"680243635","full_name":"vidarh/skrift","owner":"vidarh","description":"A pure Ruby conversion (*not* wrapper) of the libschrift TrueType font renderer","archived":false,"fork":false,"pushed_at":"2023-08-18T17:44:05.000Z","size":197,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T12:08:14.354Z","etag":null,"topics":["font-renderer","ruby","ttf"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vidarh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-18T17:41:38.000Z","updated_at":"2024-07-12T09:03:51.000Z","dependencies_parsed_at":"2023-08-18T18:17:30.523Z","dependency_job_id":null,"html_url":"https://github.com/vidarh/skrift","commit_stats":null,"previous_names":["vidarh/skrift"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidarh%2Fskrift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidarh%2Fskrift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidarh%2Fskrift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidarh%2Fskrift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vidarh","download_url":"https://codeload.github.com/vidarh/skrift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248752274,"owners_count":21156064,"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":["font-renderer","ruby","ttf"],"created_at":"2024-11-07T22:15:37.915Z","updated_at":"2025-04-13T17:30:42.568Z","avatar_url":"https://github.com/vidarh.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Skrift\n\nVidar Hokstad \u003cvidar@hokstad.com\u003e\n\nThis started out as a Ruby port of `libschrift`. If you need\nperformance, and don't mind a C dependency, consider that over this.\n\nIf you're fine with slower rendering (*cache* glyphs after rendering)\nand want *pure Ruby*, consider this gem, with the caveat that the\nrewrite is *new* and likely buggy.\n\n## Name\n\n\"Skrift\" is Norwegian for \"text\", \"writing\", or \"scripture\", and so a\nclose cognate of \"Schrift\". Since I'm Norwegian, it seemed like an\nappropriate way to set this apart from `libschrift` and ensure that if\nanyone want to do a gem directly wrapping the C librarly the name remains\navailable.\n\n## License\n\nWhile it's rewritten in Ruby and changed reasonably since, given it owes\nso much to `libschrift`, I decided to stick with the same license (the\nISC License), since it's very permissive. See `LICENSE.md`\n\n## This code is opinionated\n\nFirstly, the choice to start by rewriting `libschrift` is because that\nlibrary is an excellent demonstration of a minimalist feature set and\ncompact code that I wanted.\n\nHowever, on top of the structure inherited largely from `libschrift`,\nwhile working on this code, I've formed my own opinions on it which\napplies to *this library*, and which the author of `libschrift` may or\nmay not agree with. These are *my responsibility*:\n\n* Small code size is a virtue as long as it improves rather than hinders\n  understanding. Any feature will be weighed against complexity cost.\n\n* Features that add a lot of complexity may be better written as a\n  separate library (I will happily work with you to ensure it's easy for\n  users to combine your library with `Skrift`)\n\n* Hinting is predominantly important with low resolution. With the trend\n  firmly being towards 4K or 8K displays, putting a lot of effort into\n  hinting is pointless. I will *consider* hinting if someone wants to\n  contribute hinting code, but not at the cost of a lot of complexity (\n  unless you build it as a standalone extension)\n  \n* The current algo uses anti-aliasing. I will *consider* adding support\n  for monochrome rendering for the same reason as above, but currently, AA\n  is still *necessary* for best possible results at small sizes, at least\n  on FHD displays, so since it's already here, I'll *keep* the AA\n  support as long as lower resolution displays are still around.\n  \n* Feature \"completeness\" for the sake of completeness are not of interest.\n  E.g. I have no interest in parsing the parts of the TTF or OTF formats\n  this library won't use (but if you write a *compact*, well written\n  TTF/ OTF parser in pure Ruby, I *might* consider tearing out the\n  font parsing from this gem if using yours simplifies the `Skrift` code)\n  \n* Idiomatic Ruby is favoured over maximising efficiency (but\n  pathologically low performance is not good - I'm open to changes)\n\n* Lowering coupling is favoured (be it for testing, or ease of improving\n  the code), but architecture acrobatics should be avoided. That is,\n  make it *possible* to test or use individual stages of the rendering\n  pipeline, but don't force library users to care - setup should be\n  minimal, and defaults sane. Factories and abstract interfaces should\n  stay in Java or be used to scare small children, not be found in\n  Ruby code.\n\n  \n## Contributions and Potential Improvements\n\nContributions are welcome, keeping the above in mind. If your\ncontributions are potentially unrelated to the specific purpose of this\nlibrary, I might propose you put them in a separate gem instead, and\nmight then offer to help create easy integration points so your code can\nsafely extent this library if a user chooses to use both.\n\nSome possible areas for extension, and my current thoughts on them\n(*talk to me* if you want to work on something)\n\n### X11 or Wayland (or Windows, or Mac) integration\n\nNo.\n\nI will happily ensure there necessary APIs are there so that you can\n*wrap* or integrate with `Skrift`, or so that you can render to something\nthat makes it convenient. E.g. the current rendering to 8 bit\ngreyscale already makes `Skrift` (thanks to `libschrift` doing this from\nthe start) integrate easily with `XRender` for X11 support.\n\nI will not, however, put platform specific code in `Skrift` itself (I\n*will* accept code well-written code to make use of \"platform specific\"\ndata *from the font files*, however, because they can be useful on other\nplatforms)\n\nI use this code for rendering to `X11` myself. It does not require\npushing platform specific code into this library.\n\n\n### Performance\n\nPerformance improvements are welcome *but not if they add a lot of\ncomplexity*. C-extensions or similar will not be accepted - if you\nwant a C dependency, just use `libschrift`.\n\nIf you have a suggestion that involves using C in a limited way to speed\nup specifics, I'd suggest providing a *separate* gem to replace/extend\nthe appropriate code the same way `oily_png` provides code to speed up\n`chunky_png`. I'm happy to discuss specifics.\n\n### Grid snapping\n\nWhere I'm *most likely* to consider a hinter is a *limited* hinter\nto dynamically rescale glyphs to allow using a variable spaced font\nsnapped to a grid for e.g. terminal use in a somewhat intelligent way (I\ndon't expect this is likely to look good, but I'm open to be convinced\neven if it only works on some fonts, though it might well be better as a\nstandalone conversion tool unless it works well on a broad range of\nfonts)\n\n### Transformations\n\nThe current code already applies linear affine transformations to the\nglyphs. I'd be supportive of *compact* contributions to make it easier to\napply a broader set of transforms during rendering to allow for more\nflexible layout. Please discuss API first if you want anything merged, or\nif you just want stable extension points to do this in a separate\nlibrary.\n\n### Outlines\n\nYou can currently extract outlines, and so can of course replace the\nrendering stage and render unfilled outlines on your own. That said, I'd\nbe supportive both of low complexity changes to render the fonts as\noutlines *and* of low complexity changes to \"grow\" outlines (e.g. to\nbe able to render an outline in one colour and a filled version in the\ndesired size in another colour - you can't do this by just scaling). The\ncode that'd need to change to replace the rasteriser is tiny.\n\n### Text Layout\n\nSpecifically, *text layout* is perhaps out of scope of this library, but\nI'm happy to discuss it - if nothing else I'd be supportive of an\nextension in a separate gem and/or ensuring the basics is well\nsupported.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidarh%2Fskrift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvidarh%2Fskrift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidarh%2Fskrift/lists"}