Title: Request: Text h_align = pixie.JUSTIFY_ALIGN · Issue #26 · treeform/pixie-python · GitHub
Open Graph Title: Request: Text h_align = pixie.JUSTIFY_ALIGN · Issue #26 · treeform/pixie-python
X Title: Request: Text h_align = pixie.JUSTIFY_ALIGN · Issue #26 · treeform/pixie-python
Description: Would be nice if add this alignment style, also give access to Arrangement attributes(selectionRects, lines, positions). I've made this little library for making this feature for me, it behaves like the Microsoft Word Office. import nimp...
Open Graph Description: Would be nice if add this alignment style, also give access to Arrangement attributes(selectionRects, lines, positions). I've made this little library for making this feature for me, it behaves lik...
X Description: Would be nice if add this alignment style, also give access to Arrangement attributes(selectionRects, lines, positions). I've made this little library for making this feature for me, it behaves...
Opengraph URL: https://github.com/treeform/pixie-python/issues/26
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Request: Text h_align = pixie.JUSTIFY_ALIGN","articleBody":"Would be nice if add this alignment style, also give access to Arrangement attributes(selectionRects, lines, positions).\r\n\r\nI've made this little library for making this feature for me, it behaves like the Microsoft Word Office.\r\n```nim\r\nimport\r\n nimpy,\r\n pixie,\r\n unicode\r\n\r\npyExportModule(\"pixie_utils\")\r\n\r\nconst\r\n LF = Rune(10)\r\n NR = Rune(0)\r\n\r\nproc justifyArrangement*(arrangement: Arrangement, maxWidth: float32) {.raises: [].} =\r\n proc right(rect: Rect): float32 =\r\n rect.x + rect.w\r\n\r\n let\r\n runes: ptr = arrangement.runes.addr\r\n positions: ptr = arrangement.positions.addr\r\n rects: ptr = arrangement.selectionRects.addr\r\n last_lineId: int = arrangement.lines.len-1\r\n var\r\n rune, last_rune: Rune\r\n last_wordRuneId: int\r\n spaces_idx: seq[int]\r\n inc_width, space_width, line_width, x_offset: float32\r\n \r\n for lineId, (start, stop) in arrangement.lines:\r\n last_rune = runes[stop]\r\n\r\n # This line must not be justified, if it is the last or if the last rune is a breakline char.\r\n if lineId == last_lineId or last_rune.uint32 == LF.uint32:\r\n continue\r\n\r\n echo runes[start..stop]\r\n # Get the spaces indexes of this line to increase their width, and get the line width.\r\n spaces_idx = @[]\r\n last_rune = NR\r\n for r_id in start..stop:\r\n rune = runes[r_id]\r\n if not rune.isWhiteSpace():\r\n if last_rune.isWhiteSpace():\r\n spaces_idx.add(r_id-1)\r\n last_wordRuneId = r_id\r\n last_rune = runes[r_id]\r\n\r\n line_width = rects[last_wordRuneId].right\r\n\r\n echo \"Line spaces: \", spaces_idx.len\r\n if spaces_idx.len > 0:\r\n # Get the amount of pixels/units to increase each space width in the middle of the line.\r\n inc_width = (maxWidth - line_width) / spaces_idx.len.float32\r\n\r\n if inc_width > 0:\r\n space_width = rects[spaces_idx[0]].w + inc_width\r\n\r\n # Adjust the runes X position\r\n x_offset = 0\r\n for r_id in spaces_idx[0]..stop:\r\n positions[r_id].x += x_offset\r\n\r\n if r_id in spaces_idx:\r\n rects[r_id].x += x_offset\r\n rects[r_id].w = space_width\r\n x_offset += inc_width\r\n else:\r\n rects[r_id].x += x_offset\r\n\r\nproc justifyArrangement(arrangement_ref: int, maxWidth: float32) {.exportpy: \"justifyArrangement\".} =\r\n justifyArrangement(cast[Arrangement](arrangement_ref), maxWidth)\r\n```","author":{"url":"https://github.com/IagoBeuller","@type":"Person","name":"IagoBeuller"},"datePublished":"2022-12-22T07:49:19Z","url":"https://github.com/treeform/pixie-python/issues/26"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:15eda7a4-82cd-723b-f3f6-86c8e0312242 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DF4:3A0E8F:B0745A:F07E96:6B048783 |
| html-safe-nonce | 5a1c441966b096c03f7a822596dbd19f7debb8a3cbad39275cab60a1bcaa6e0b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REY0OjNBMEU4RjpCMDc0NUE6RjA3RTk2OjZCMDQ4NzgzIiwidmlzaXRvcl9pZCI6IjY0NTI4MDQzNzY3NzkzMjczNjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | de2c1f27a1e9f2451a11c04eb9022cacb66d12905d0f59512d404f75f485ab78 |
| hovercard-subject-tag | issue:1507414048 |
| github-keyboard-shortcuts | repository,source-code,file-tree,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/treeform/pixie-python/26/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e67d78002765f9e8939ae22894284bbcd07f92a70bf3c64d6a63270830b427bf/treeform/pixie-python/issues/26 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e67d78002765f9e8939ae22894284bbcd07f92a70bf3c64d6a63270830b427bf/treeform/pixie-python/issues/26 |
| og:image:alt | Would be nice if add this alignment style, also give access to Arrangement attributes(selectionRects, lines, positions). I've made this little library for making this feature for me, it behaves lik... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | IagoBeuller |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1d5c152376e38b7d2e37f3d5179be29a73bee93b85110da28a4eebe1159cdc70 |
| turbo-cache-control | no-preview |
| go-import | github.com/treeform/pixie-python git https://github.com/treeform/pixie-python.git |
| octolytics-dimension-user_id | 125948 |
| octolytics-dimension-user_login | treeform |
| octolytics-dimension-repository_id | 399247825 |
| octolytics-dimension-repository_nwo | treeform/pixie-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 399247825 |
| octolytics-dimension-repository_network_root_nwo | treeform/pixie-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f5017e8ff4ea25a8011fcf0f2a0e430c60dc86c8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width