Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text height and some other issues #8

Open
almousa1990 opened this issue Apr 15, 2013 · 30 comments
Open

Text height and some other issues #8

almousa1990 opened this issue Apr 15, 2013 · 30 comments

Comments

@almousa1990
Copy link

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.

Untitled

I am not sure why it happens but it seems to be a bug.

@almousa1990
Copy link
Author

I am using the library with core graphics.

@mta452
Copy link
Owner

mta452 commented Apr 16, 2013

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.

@almousa1990
Copy link
Author

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

@almousa1990
Copy link
Author

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

@mta452
Copy link
Owner

mta452 commented Apr 16, 2013

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.

@almousa1990
Copy link
Author

Thank you.

@mta452
Copy link
Owner

mta452 commented Apr 21, 2013

OK, just pushed the new version.
Let me know if you face any problem.

@almousa1990
Copy link
Author

Great, but seems it doesn't work with ARC enabled although i disabled it for the SSLabel files.

@mta452
Copy link
Owner

mta452 commented Apr 24, 2013

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.

@almousa1990
Copy link
Author

Everything seems to work great.

Thank you!

@ZainabA
Copy link

ZainabA commented May 4, 2013

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?

@almousa1990
Copy link
Author

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)

@ZainabA
Copy link

ZainabA commented May 5, 2013

thank you

it works but unfortunately as you said is not accurate

@almousa1990
Copy link
Author

I hope Mohammad can look at this issue.

@mta452
Copy link
Owner

mta452 commented May 5, 2013

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];

@ZainabA
Copy link

ZainabA commented May 5, 2013

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

@mta452
Copy link
Owner

mta452 commented May 6, 2013

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.

@almousa1990
Copy link
Author

Thank you Mohammad the problem was with the padding as you mentioned, it works as a charm now.

@mta452
Copy link
Owner

mta452 commented May 6, 2013

Glad to hear that :)

@ZainabA
Copy link

ZainabA commented May 7, 2013

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
screen shot 2013-05-07 at 6 11 54 pm
screen shot 2013-05-07 at 6 12 30 pm

and here 2 chars are missed in the end of word
screen shot 2013-05-07 at 6 12 53 pm

@almousa1990
Copy link
Author

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.

@ZainabA
Copy link

ZainabA commented May 7, 2013

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 !!

@almousa1990
Copy link
Author

Do you call getHeight after you set the font and the size?

@ZainabA
Copy link

ZainabA commented May 7, 2013

yes

@swatantrasingh
Copy link

Hi,
I have some issue with symbole of arabic text.
new

i am using KFGQPCUthmanTahaNaskh-Bold font ,
please help

Thanks
Swatantra

@mta452
Copy link
Owner

mta452 commented Jul 12, 2013

Please check the text in TextEdit with same font and let me know if it is different.

@swatantrasingh
Copy link

But when i choose other font it show correct like.
2

@mta452
Copy link
Owner

mta452 commented Jul 12, 2013

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.

@swatantrasingh
Copy link

Thanks ....

@swatantrasingh
Copy link

Hi Muhammad Tayyab Akram;
Can you suggest me any good font which have no issue with this library.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants