SheenFigureLegacy
SheenFigureLegacy copied to clipboard
Text height and some other issues
Hello,
I would like to thank you again for this great library, i see how much effort you put in.
I am having two issues with the library. I need to get the actual height of rendered text to customized the super view based on the height of the text, seems there is no direct way to do that although it is extremely important.
The other issue was that in some situations the words at the end of the line are clipped.
I am not sure why it happens but it seems to be a bug.
I am using the library with core graphics.
Height is calculated at the end of -(void)drawRect method as (numLines * singleLineHeight). You can save it there.
Regarding the other issue, I cannot tell what's happening. will have to take a look at your sample project.
Thank you, but i think the problem is that drawRect is the view is first displayed so i cannot save the outcomes before the run time!. So i did something else by copying the drawRect body to another method that returns the numLines * singleLineHeight an then call it before the run time, it works but it doesn't give you the same numLines that drawRect gives (exactly the same implementation).
Finally i was a able to get the exact height by duplicating the drawRect as stated earlier, my code was ok but the call to init the frame was slightly wrong.
for the other issue, i have overridden your project by changing the font and the text and by setting the flags to use CG.
There is the link for the project: https://www.dropbox.com/c/shmodel?nsid=27338052&sjid=0&state=2&signature=a534cb0&path=/SFGC.zip&id=shmodel
Or you can just use font: https://www.dropbox.com/s/khtyr42rprpwqbn/UthmanicHafs.otf
and the text from here: http://ar.wikipedia.org/wiki/%D8%A2%D9%8A%D8%A9_%D8%A7%D9%84%D8%AF%D9%8A%D9%86
I really appreciate your help
Yes, its a bug. I'm currently working on new version which is free from this bug. will push it in few days.
You'll have to wait till then.
Thank you.
OK, just pushed the new version. Let me know if you face any problem.
Great, but seems it doesn't work with ARC enabled although i disabled it for the SSLabel files.
You don't need to disable ARC for SSLabel files. It's been written to support both ARC and non-ARC. There was a compile error while using CG version which has been fixed now. See the latest commit.
Everything seems to work great.
Thank you!
I need to get hight before display the view, I have try to take numLines * singleLineHeight from
- (void)generateCachedPages method but that doesn't work could you please show me how can I make it?
You could use [_ssText measureHeightForFrameWidth:self.frame.size.width]
I am not sure if it is the best thing to do, it works for me but sometimes it doesn't calculate the height correctly. (Ignores lines)
thank you
it works but unfortunately as you said is not accurate
I hope Mohammad can look at this issue.
Probably you are facing this issue because you are not subtracting padding from frame width. Try using this code: [_ssText measureHeightForFrameWidth:self.frame.size.width - (PADDING * 2)]; or simply [_ssText measureHeightForFrameWidth:self.frame.size.width - 6];
same thing still not accurate height specially in long text
also I faced same problem mentioned above some words at the end of the line are clipped or the last char was missed
I've tested with the above font and text and it has been working all right. almousa1990! Are you still facing the same problem?
ZainabA! I'll have to take a look at your font, text and modified class. Then I'll be able to say something.
Thank you Mohammad the problem was with the padding as you mentioned, it works as a charm now.
Glad to hear that :)
my font is (UthmanicHafs1 Ver09.otf ) I define the label like this
SSLabel *label = nil;
label = [[SSLabel alloc] initWithFrame:CGRectMake(0,0, CELL_CONTENT_WIDTH, 0)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
label.font = font;
label.textAlignment=NSTextAlignmentCenter;
label.text=text;
and I create getHeight method in SSLabel class and I use it to return the height of label to use it to draw the cell
-(int)getHeight{
return [_ssText measureHeightForFrameWidth:self.frame.size.width - (PADDING * 2)];
}
these are screen shots show how text exceed the cell
and here 2 chars are missed in the end of word
I use the same font and it works correctly, maybe the CELL_CONTENT_WIDTH is not correct.
For the other problem it is a bug that happens sometimes with words that ends with "ر", but you can solve the problem by adding a space after the word.
thats right the space fixed the missed char thanks :)
about CELL_CONTENT_WIDTH how may be incorrect? I try change the value but same thing
I read the return value from( getHight)and from( _measuredHeight inside generateCachedPages method in SSLabel class ) by NSLog
in getHight the value was 6785 whereas in _measuredHeight was 7242
there is big difference !!
Do you call getHeight after you set the font and the size?
yes
Hi,
I have some issue with symbole of arabic text.
i am using KFGQPCUthmanTahaNaskh-Bold font , please help
Thanks Swatantra
Please check the text in TextEdit with same font and let me know if it is different.
But when i choose other font it show correct like.
Positioning information is read from font file and every glyph is positioned according to that. Therefore your problem lies in the font and not in the code.
Thanks ....
Hi Muhammad Tayyab Akram; Can you suggest me any good font which have no issue with this library.
Thanks