githawkapp / styledtextkit Goto Github PK
View Code? Open in Web Editor NEWDeclarative building and fast rendering attributed string library.
Home Page: http://githawk.com
License: MIT License
Declarative building and fast rendering attributed string library.
Home Page: http://githawk.com
License: MIT License
Does it support displaying html content?
I believe that the doubly-linked list in the LRUCache impl has a retain cycle in its nodes:
https://github.com/ocrickard/StyledTextKit/blob/master/Source/LRUCache.swift#L24
This blog post was great! We could get rid of all the hacky font-scaling math.
https://www.iosdev.recipes/fonts/ui-font-metrics-and-resizable-text/
I learned about the use of unfair locks from this library. Thanks!
Anyway, today I stumbled upon this StackOverflow answer that mentioned that the direct use of unfair locks in Swift can fail at runtime. The fix is really simple; a pointer wrapper that provides a stable memory address (the assumption the C API makes). Any thoughts about this?
I'm trying to create a string that has a mix of two font sizes, but I can't seem to make it work. Is this supported by StyledTextKit? (if not, would this be addressed by issue #61 ?)
Here's a sample of what I tried. Adding calls to save() / restore() don't affect the behavior, nor does changing the contentSizeCategory
let attrStr = StyledTextBuilder(text: "")
.add(text: "Foo", attributes: [.font: UIFont.systemFont(ofSize: 32)])
.add(text: "Bar", attributes: [.font: UIFont.systemFont(ofSize: 14)])
.build()
.render(contentSizeCategory: .unspecified)
Hi, Thank you for this amazing library.
I have a question about links and attributes.
StyledTextKit provides three attributes .tapable
, .tapHighlight
, .highlight
.
Are there use-cases for using these attributes separately?
These just increase complexity in my opinion.
As alternative for UITextView, Is it not enough to have only NSLinkAttribute?
Idk how best to combine these, but would improve rendering huge chunks of text.
mmap
bitmap from diskOnce you create the StyledTextRenderer, you would need to create an entirely new object to change one small attribute like font size. This is an expensive process
h/t @SD10 for the idea! Inspired by TTTAttributedLabel.
In previous impls we also implemented the following caching layers in addition to the current bitmap and size cache:
Hi @rnystrom
Could you please help to release a new version for Swift 5? It seems already done on master branch. 🙏
First, thanks for this amazing library.
This is a question though, not an issue.
Doesn't CATextLayer
provide a similar functionality? I specifically mean the async drawing bit, great work!
CATextLayer
has an inherited drawsAsynchronously
property. The docs says:
When this property is set to true, the graphics context used to draw the layer’s contents queues drawing commands and executes them on a background thread rather than executing them synchronously. Performing these commands asynchronously can improve performance in some apps. However, you should always measure the actual performance benefits before enabling this capability.
Aside from caching, what advantage does asynchronously outputting to a CGImage
have over what CATextLayer
provides?
Thanks!
Is there had any reason to set minimum deployment target to 10.0
? 😅
i'm working on a Japanese project , it has a feature to show/hide Hurigana(Ruby) text.
i've some knowledge that it uses kCTRubyAnnotation
but it is harsh on main thread..
so, is this library supports RubyText?
Is it possible to make StyledTextView selectable like UITextView ?
cc @BasThomas https://developer.apple.com/documentation/foundation/nsattributedstringkey
These accessibility keys are kind of incredible. It'd be really amazing to bake these into the framework somehow.
Can probably get away w/ enumerating all attributes on render()
and injecting mapped accessibility attributes? Most of them are straightforward:
Hi, Thank you for this amazing library.
When I use StyledTextView
in UICollectionViewCell
, I found a reuse problem when reloading renderer, and found that the animatable of layer’s contents caused the view content to follow the effect of an animation transition.
StyledTextKit/Source/StyledTextView.swift
Line 190 in fe3232c
Suggested to change to:
CATransaction.begin()
CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions)
layer.contents = result.0
CATransaction.commit()
Since this is a tool that people should use to build upon, we should have better docblocks to describe more advanced usages of API's.
Plus, I LOVE ASCII art.
Love this blog post! Removing all color/font from building would be amazing. Instead:
.font
, .foregroundColor
, etc), or should there be a style per prop? Latter seems harder to maintainUIContentSizeCategory
from all params until renderNecessary to make progress towards GitHawkApp/GitHawk#198 so you can have themes/styles and re-render (missing all caches) w/out having to rebuild everything (which you'd have to do today).
Just curious as if there is a performance tradeoff for creating an attributed string, and then using the convenience initializer of the StyledTextBuilder that takes in an attributed string vs just using the StyledTextedBuilder API to build up a string? Does this affect the background rendering as well?
CALayer
stuff is thread safe (IIRC from ASDK)Most text highlighting for large blocks break down into 3 parts, first line, body, and last line. This gives the selection a really nice outline, and also avoids the N^2 computation in the bezier path construction as more and more lines are selected.
Here's an example implementation that assumes the input rects were added to an array before the bezier path is computed:
https://gist.github.com/ocrickard/d07e30f9ba2c29fef7e491ab42c19d08
This can be done waaaaay more elegantly in Swift.
There's already a pod called StyledText
I would like to use this in some of my projects, is it possible to implement support to the Swift Package Manager by adding a Package.swift?
Hi @rnystrom, thanks for this library and let me build attributed string much easier than before. 🎉
I want to add an example project for it, can I make a PR?
And also ask a question here, is it possible to let .link
used other styles?
Thanks again! ❤️
Thinking a lot of text in the background. Then impose "StyledText" w/ a white-outline in the middle of all the text.
Could i use it with autolayout?
How could i get the height of the textview or is there any limitations for autolayout? thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.