Giter Club home page Giter Club logo

styledtextkit's People

Contributors

basthomas avatar davelyon avatar davidcyman-omicron avatar josepmedrano avatar marcuswu0814 avatar ocrickard avatar rnystrom avatar ryohey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

styledtextkit's Issues

Safer locking

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?

Is it possible to create a string with mixed fonts / font sizes?

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)

Make NSLinkAttribute to tappable and highlighting.

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?

CATiledLayer for large chunks of text

Idk how best to combine these, but would improve rendering huge chunks of text.

  • mmap bitmap from disk
  • All layers in memory defeats the purpose
  • LRUCache can store chunks?

Additional caching

In previous impls we also implemented the following caching layers in addition to the current bitmap and size cache:

  1. Renderer caching. Saves the layout managers, and is commonly lighter weight than the bitmaps that came from them.
  2. Attributed string caching. Saves the result of the build steps into a global cache so we avoid re-building attributed strings all the time.

CATextLayer?

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!

RubyText supported?

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?

Disable StyledTextView layer's contents transition with animation

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.

layer.contents = result.0

Suggested to change to:

   CATransaction.begin()
   CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions)
   layer.contents = result.0
   CATransaction.commit()

Needs better docblocks

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.

Separate render and style params from building

Love this blog post! Removing all color/font from building would be amazing. Instead:

  • Use "style builder" pattern that registers styles
    • Need to still be able to "push" and "pop" styles
    • Should all props be in one style (.font, .foregroundColor, etc), or should there be a style per prop? Latter seems harder to maintain
  • Remove UIContentSizeCategory from all params until render

Necessary 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).

Performance trade-off for using NSAttributedString with StyledTextBuilder

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?

Improved selection rect handling

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.

Add Swift Package Manager

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?

Add an example project

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?

ezgif-4-ebb48f83c0

And also ask a question here, is it possible to let .link used other styles?
Thanks again! ❤️

Library logo

Thinking a lot of text in the background. Then impose "StyledText" w/ a white-outline in the middle of all the text.

how to use it with autolayout?

Could i use it with autolayout?
How could i get the height of the textview or is there any limitations for autolayout? thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.