Determine the CTLine containg specific character

I am developing an Application in which I am using Core Text for layout purpose. I have used CTFrameSetter to draw the text.I have inserted a blank character '\ufffc' in my text. Now what i want is to determine the position of this blank character i.e. its x, y coordinates. I have not been able to find any function to determine the position of any specific character.

I tried using CTLineGetOffsetForStringIndex( CTLineRef line, CFIndex charIndex, CGFloat* secondaryOffset ); for finding the position, but I couldn't fully understand the working of this method.

Can anyone provide me some pointers on this issue?

-------------Problems Reply------------

you can loop all the CTLines of the current CTFrameRef, and for each ctline, get the CTRun and check if that CTRun is yours. simple code

NSArray *lines = (NSArray*)CTFrameGetLines(workFrame);
NSInteger count = [lines count];
CGPoint *origins = (CGPoint*)malloc(count * sizeof(CGPoint));
CTFrameGetLineOrigins(workFrame, CFRangeMake(0, count), origins);

for (int i = 0; i < lines.count; i++) {
CTLineRef line = (CTLineRef)[lines objectAtIndex:i];
CFRange cfRange = CTLineGetStringRange(line);//the string-range

NSArray * runArray = (NSArray *)CTLineGetGlyphRuns(line);

int runIndex = 0;
for (id runObj in runArray) {
CTRunRef run = (CTRunRef)runObj;
CFRange runRange = CTRunGetStringRange(run);
CGFloat xOffset = CTLineGetOffsetForStringIndex(line, runRange.location + runRange.length, NULL);
//checks if the crrun's text is your space
}
}

Category:iphone Views:0 Time:2010-07-23

Related post

  • Determining Word Frequency of Specific Terms 2008-11-24

    I'm a non-computer science student doing a history thesis that involves determining the frequency of specific terms in a number of texts and then plotting these frequencies over time to determine changes and trends. While I have figured out how to de

  • What is the most efficient way to count all the occurrences of a specific character in a PHP string? 2009-06-01

    What is the most efficient way to count all the occurrences of a specific character in a PHP string? --------------Solutions------------- use this: echo substr_count("abca", "a"); // will echo 2 Can you not feed the character to preg_match_all? Not s

  • How can I use IndexOf to pick a specific Character when there are more than one of them? 2010-04-13

    How can I use IndexOf with SubString to pick a specific Character when there are more than one of them? Here's my issue. I want to take the path "C:\Users\Jim\AppData\Local\Temp\" and remove the "Temp\" part. Leaving just "C:\Users\Jim\AppData\Local\

  • Regex to find words that start with a specific character 2010-04-20

    I am trying to find words starts with a specific character like: Lorem ipsum #text Second lorem ipsum. How #are You. It's ok. Done. Something #else now. I need to get all words starts with "#". so my expected results are #text, #are, #else Any ideas?

  • How to find the first and last occurrences of a specific character inside a string in PostgreSQL 2010-06-03

    I want to find the first and the last occurrences of a specific character inside a string. As an example, consider a string named "2010-####-3434", and suppose the character to be searched for is "#". The first occurrence of hash inside the string is

  • Select a specific character in a string and offset it (visually) with Jquery 2010-07-19

    I'm trying to use Jquery/Javascript to mimic a broken typewriter font (since I could not find one). But I want to make it random which letter gets broken. I was able to split the string of the id that I wanted and use a bit of code I found to get a r

  • Find location of specific character in NSString 2010-07-23

    How can I find the location of a specific character in an NSString? I have tried this but it returns an empty range (I want to find the location of the '?'): NSRange range = [@"This is a ? test to see if it works" rangeOfCharacterFromSet:[NSCharacter

  • How can I remove a specific character from a string in Perl? 2010-10-25

    I'm trying to remove a specific character from a string in Perl: my $string="MATTHATBAT"; substr($string, 2, 1, ''); EDIT: This does work, sorry. Leaving this here in case someone needs to know how to do this. Also, is there a more efficient way of d

  • count the occurrences of a specific character in the input 2010-11-01

    Possible Duplicate: How do I count the number of occurrences of a char in a String? I am looking to count the occurrences of a specific character, for example "i" that occurs in the input. Example, from standard input: Lorem ipsum dolor sit amet, con

  • Returning first letter when it is language specific character 2011-01-09

    I have problem with returning first letter from string, when that letter is language specific character. Reason of that situation is simple: specific character saved in string takes more than one character, and decoding takes place only on display in

  • Check for a specific character string using javascript 2011-02-14

    How can I write ad check for a specific character string in a text field? If someone types in this identification number in a textfield. Upon submit, it will look if it starts with "D" IE: D959344843 If it does, display a DIV on the page. If not, pro

  • Count specific character occurrences in string 2011-03-04

    What is the simplest way to count the number of occurrences of a specific character in a string? i.e. I need to write a function countTheCharacters() so that str="the little red hen" count=countTheCharacters(str,"e") 'count should equal 4 count=count

  • Oracle PL/SQL - Remove Last Instance of a specific Character 2011-04-06

    enter code hereI'm working on building a group of functions that return a json string based on the parameters and an internal select. The problem that I'm running into is as i'm looping through the cursor in pl/sql, building the structure of the json

  • How to use jQuery to select all text inside paragraph after specific character 2011-04-19

    I would like to use jQuery to find specific character, in this case "#" inside one or more paragraphs, remove that character, and wrap everything after in span tag. Here is HTML example: <p>Lorem ipsum dolor sit amet # consectetur adipiscing el

  • Substring starting at specific character count 2011-04-20

    How would you select the last part of a string starting at a specific character count. For example I would like to get all text after the 3rd comma. but I get an error saying "StartIndex cannot be less than zero." Dim testString As String = "part, de

  • insert a space after a specific character with awk? 2011-05-05

    How do I insert a space after a specific character with awk? The test data <>jhjashdhasdkh I want to insert a space " " after > so the data string would become... The modifyed test data now becomes... <> jhjashdhasdkh Does anyone know

  • Delete the all the lines in a file that contains a specific character 2011-05-31

    Hi I want to delete all the rows/lines in a file that has specific character, '?' in my case. I hope there is a single line command in Bash or AWK or Perl. Thanks --------------Solutions------------- Here are already grep, sed and perl solutions - on

  • Coordinates of a specific character in a multi-lined WPF FormattedText 2011-09-02

    How to get the position (x y coordinates) of a specific character in a multi-lined WPF FormattedText ? My text could contain italic parts, bold parts, different fonts, different font sizes, different alignments, etc. and I need to get the coordinates

  • Replace text in string within an element after a specific character? 2011-11-17

    very new to JQuery I'm trying to strip out text in a string within an element that that appears after a specific character. I'm getting this: <h3>Lorem ipsum dolor sit amet: consectetur adipisicing</h3> And I need this: <h3>Lorem ip

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.082 (s). 11 q(s)