GithubHelp home page GithubHelp logo

liveui / ftcoretext Goto Github PK

View Code? Open in Web Editor NEW
782.0 45.0 125.0 1.2 MB

An open source Objective-C interface component that makes use of the CoreText framework to render static text content using a highly customisable markup syntax.

License: MIT License

Objective-C 98.80% Ruby 1.20%
objective-c html swift coretext ios

ftcoretext's People

Contributors

algal avatar cescofry avatar rafiki270 avatar rokgregoric avatar stowy 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ftcoretext's Issues

Performance in UITableView

FTCoreText is very cool, but performance is really low in UITableView. I found two ways to improve it:

  1. Regular expressions use a lot of resources, so I've changed - (void)processText method:
    replaced
    tagRange = [processedString rangeOfString:regEx options:NSRegularExpressionSearch range:remainingRange];
    with
    NSRange openSign = [processedString rangeOfString:@"<"];
    NSRange closeSign = [processedString rangeOfString:@">"];
    if (openSign.location != NSNotFound && closeSign.location != NSNotFound) {
    tagRange = NSMakeRange(openSign.location, closeSign.location - openSign.location + 1);
    } else {
    tagRange.location = NSNotFound;
    }
  2. CTFontCreateFromUIFont is also very heavy, so I save CTFontRef into FTCoreTextStyle. Also I changed FTCoreTextStyle property to retain (in FTCoreTextNode).

Hope this helped.

wrong height when the root controller is a UINavigationController

I change the code in FTCoreTextAppDelegate.m:

    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:articleVC];
    [self.window setRootViewController:nav];

The FTCoreText only display part text,because it's frame height is wrong.

How to create pages

Hi,
First of all thanks for this github.
Well I was just wondering how to create a pages.
I tried to add the tag but it still show all the text in the same page. As well as added code for the style;
//txt file
hey there new page < page/ >
I am on new page

//Style
FTCoreTextStyle *pageStyle = [FTCoreTextStyle styleWithName:@"_page"]; // using fast method pageStyle.name=FTCoreTextTagPage;
[result addObject:pageStyle];

Please guide me....
Thanks & Regards,
Zahur

allow different bullet tags

There's one default tag for bullets -- <_bullet>.

But I might want different kinds of bullet styles, which would require being able to define custom bullet tags. I could now workaround this by giving <_bullet> a different style in different FTCoreTextViews, but then I would not be able to mix different bullet styles in one view.

Allow CSS-like link stylings

It would be nice if when on touchesBegan you could set an alternate style for that tag (like underlining, textColor change, etc), which then reverts on touchesEnded.

appending

Is there an appropriate way to append text into an existing FTCoreTextView? Should I be keeping a separate buffer of the text and calling -setText every time I append something new to the buffer? Or does there need to be an -appendText method on FTCoreTextView that handles things more efficiently internally?

On Long press the link App crashes

Oct 16 14:48:36 users-iPod AppName[10049] : -[__NSSetI objectForKey:]: unrecognized selector sent to instance 0x1e57fb70
Oct 16 14:48:36 users-iPod AppName[10049] : *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSetI objectForKey:]: unrecognized selector sent to instance 0x1e57fb70'
*** First throw call stack:

touchedFrame (CGRect) issue for two links (or more) in one text line

Hi,

If we have two links which are appearing in one text line, touchedFrame (CGRect) of these links are always the same value. This rect value is the rect value of the last link in the line. It seems that the rect of first links are overridden by the rect value of last link.

The issue has been also found at #19

Links in centered text

I'm using a multiple line FTCoreTextview, with centered text and links that start on one line and continue on the next. The touchable area of the link seems to be calculated as if it's aligned to the left. This means that the second part of the link is unclickable - or very hard to click, depending on the distance of the left.
When I align to the left it works fine though.

Cool class, but has issue in a UITableView

Hi,
cool class, very lean and does the job. I encountered a small issue when using this in a UITableView.
Some random text seemed to be highlighted as link. It seems the markers are not cleared properly, so I added
[self.markers removeAllObjects];

in the "processtext" method (class FTCoreTextView).

undefined tag

when text has the "<" or ">" characters in string, the code identify them as undefined tag but crash because it's not closed or not opened .... I solved it by ignoring the undefined tags and continue processing from location after it.

what do you think.

Find some leaks

Leaked Object # Address Size Responsible Library Responsible Frame
__NSCFType,1 0x13d60dd0 48 Bytes ChildReadHD -[FTCoreTextView applyStyle:inRange:onString:]
Malloc 32 Bytes,1 0x13d60a50 32 Bytes ChildReadHD -[FTCoreTextView applyStyle:inRange:onString:]
Malloc 16 Bytes,1 0x13d60c60 16 Bytes ChildReadHD -[FTCoreTextView applyStyle:inRange:onString:]
Malloc 1.00 KB,2 < multiple > 2.00 KB ChildReadHD -[FTCoreTextView updateFramesetterIfNeeded]
__NSCFType,3 < multiple > 288 Bytes ChildReadHD CTFontCreateFromUIFont
__NSCFType,1 0x5e3ec10 96 Bytes ChildReadHD CTFontCreateFromUIFont
Malloc 1.00 KB,1 0x909aa00 1.00 KB ChildReadHD -[FTCoreTextView updateFramesetterIfNeeded]

let bullet tag define bullet glyph and separate, indented text style

Right now, the bullet tag defines one style that applies both to the bullet glyph and to the text associated with the bullet. For instance, font overrides bulletFont and color overrides bulletColor. After the following style, the bullet and the text are green and sixteen point:

FTCoreTextStyle *bulletStyle = [defaultStyle copy];
bulletStyle.name = FTCoreTextTagBullet;
bulletStyle.bulletFont = [UIFont fontWithName:@"TimesNewRomanPSMT" size:32.f];
bulletStyle.bulletColor = [UIColor orangeColor];
bulletStyle.bulletCharacter = @"❧";
bulletStyle.font = [UIFont fontWithName:@"Helvetica" size:16.0f];
bulletStyle.color = [UIColor greenColor];

It would be good if there could be two styles. Then you could use one font and colour for the bullet glyph (e.g., blue, Webdings) and the letter glyphs from another (e.g., black, Helvetica).

In addition, I may be wrong, but I think defining a separate style for the bullet text is necessary just to support the usual indentation of the non-initial lines of text associated with a list item, as it works for in HTML for instance. I'd be very interested in helping with this but I'm not sure where to start.

For instance, I am not sure how to use CoreText to produce this indentation style, or if what I've suggested is the approach that best fits the component's close fit to CoreText's own model

Performance against UIWebView

Although FTCoreText was not specifically created to substitute a UIWebView, some people asked me how it does compared to it.
The answer is I really do not know. So I set up a "Profiler" branch with all the convenient componentes to load the view first in FTCoreTExt and then in UIWebview. Once the view load you can see on the top left corner the number of characters loaded as a reference to how performance change with different text length.
It would be very helpful if someone can point out a way to do proper tests against it.

touched frame issues

I am using FTCoreTextView and have noticed two issues with the location of the link as received in the delegate function:

  • (void)coreTextView:(FTCoreTextView *)acoreTextView receivedTouchOnData:(NSDictionary *)data
    {
    ...
    CGRect touchedFrame = CGRectFromString([data objectForKey:FTCoreTextDataFrame]);
  1. The Y value is always too large, by about the font size. I may be miscalculating something, but that's what I'm seeing.
  2. If there are multiple links on a line, I always get the same frame.

I am using this in conjunction with a popup, so I really notice these issues. #1 I can work around, but #2 makes for an awkward UX.

(request) : be able to load remote images

Hi,
It would be awesome if we can load images remotely :) ! I tried to but it did not work. Maybe you can edit my code to implement it easier in the repo ? look at this : stackoverflow.com/questions/11927942/ios-core-text-loosing-context-when-drawing-image-inside-a-block

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.