you should start by trying. if that fails, you should come back and ask for help by showing what you tried, and what the result was. and probably not a horrible idea to show the string in question. If you want someone to do your homework you should at least show them the question.

you should start by trying. if that fails, you should come back and ask for help by showing what you tried, and what the result was. and probably not a horrible idea to show the string in question. If you want someone to do your homework you should at least show them the question.

Ouch! That's a slap on the wrist.

I have not found any help on the Internet to this question. All help seems to be focussed on checking whether a particular font is supported by the browser, which is no use to me.

I have tried to upload a file showing the string as an attachment, but can't do it -- I get the message "the extension doc not allowed" (or rtf or txt). So what do you suggest?

So to restate the problem -- I have a string containing characters with 7 different fonts. How do I make a list of the characters in each font? Is this possible to do in PHP?

.....I have a string containing characters with 7 different fonts. How do I make a list of the characters in each font? Is this possible to do in PHP?....

Not a slap..... BUT you should first understand what you are trying to do.PHP is a server side scripting langauge and the issues related to font happen on the client side, on the presentation side - in your browser.

You need to use javascript/jquery and maybe css to detect the font, make a list of it and sent it to php (maybe using ajax).

Not a slap..... BUT you should first understand what you are trying to do.PHP is a server side scripting langauge and the issues related to font happen on the client side, on the presentation side - in your browser.

Thanks for the input. The characters of different font are not on a webpage -- they are in a Word file. The php program loads the contents of the file. As it loads the characters I want it to sort them by their font.

In other words the program should load the characters and then look at them one by one to determine its font and then put the character into an appropriate array (or string).

If the file contained a list of numbers and I wanted to load them and sort them according toy whether they were odd or even, the programming is easy. Why am I having such trouble in finding a way to handle the fonts?

your best options are either to look for a way to read rich text with php as suggested before, or open it in word and save it out to html. if it preserves your formatting as it should, there are several easy ways to go from there

your best options are either to look for a way to read rich text with php as suggested before, or open it in word and save it out to html. if it preserves your formatting as it should, there are several easy ways to go from there

There's no problem in saving my multi-font string in a .htm document and then reading it with php code. Nor in viewing the source to reveal the characters of the string with their respective fonts. But this is a far cry from reading the characters one by one from the 'htm document, organising them according to font and displaying the result.

I can't believe that the latter is impossible -- but at the same time I don't know how to do it, and nor it seems does anyone else

Thanks for the input. The characters of different font are not on a webpage -- they are in a Word file. The php program loads the contents of the file. As it loads the characters I want it to sort them by their font.

It does not matter whether it is in a web page or word file. If it is a word file, as suggested, please convert your input to rtf and search for the font type using php

I successfully read a rtf file but the rtf coding is impenetrable and thus this route did not prove useful.

I then read the source of a htm file and the coding here is understandable, if lengthy. For example:

style='font-family:"Times New Roman";mso-fareast-font-family:"Times New Roman";mso-fareast-theme-font:minor-fareast;color:black'>R</span><span style='font-family:Arial;mso-fareast-font-family:"Times New Roman";mso-fareast-theme-font:minor-fareast;color:black'>R</span><span

I copied and pasted this coding into a text file and wrote a program to go through the text file, seek "Times New Roman" and then pick out the character between > and < that followed. Then do the same with Arial…

So I got the end result I wanted but not the way I wanted to do it. I was looking for (and still am looking for) a method that reads the character in a .doc file (or .rtf file) recognises the font and puts the character in an array of that type of font. I think I have to repeat my earlier assertion that I believe such a method must exist but nobody can tell me what it is. This time I will smile

If you're talking about an ocr that just recognizes the fonts, it's possible, but not the best solution any way you look at it. It's more work, would work a lot more slowly, and would be limited to the fonts that you're able to teach your program.

... I was looking for (and still am looking for) a method that reads the character in a .doc file (or .rtf file) recognises the font and puts the character in an array of that type of font. I think I have to repeat my earlier assertion that I believe such a method must exist but nobody can tell me what it is....

According to me what has been answered here is close to the best that PHP can do. You may want to use a programming language like Java or C# or something else which is more powerful to read doc format. I did tell you many times that PHP is a server side scripting language.

It seems to me that the problem I faced is that there is no asci ii code to represent the type of font and its size. Instead these parameters have to be written out to precede each character. For example the coding in a .htm page to represent the character ‘E’ in Arial is this mouthful:

In an .rtf document the coding is even more abstruse, including something like <pannose930402020402> to represent the font and its size.

In practice, the Browser or Word software seeks out these coded messages, interprets them and displays the type of font, and its size, accordingly for the letter(s) that follow. This is all done rapidly in the background and we don’t see it happening, we just get the result.

So when I started with my string containing characters with seven different fonts, I was in cloud cuckoo land when I thought I could read a character and at the same time know its font type and size. I ultimately realized that the solution was to write a PHP program that would read the parameters that precede each character, compare them to a master list to determine which array the letter should be placed in and then to pick up the character and put it in that array.

Did my program have to be written in PHP? No, not at all. Python, C, Java or Javascript would have done equally well. But I like programming in PHP, I like the expressions of the language and I like the fact that my programs can be run at my website.

Why did I want to analise the string of different fonts? Because the string was a cryptogram that I was trying to solve (and have now solved) and analysis of the fonts was an essential part of finding the solution.

I hope this little dissertation may be of use to anyone else who wants to muck around with fonts and is approaching this task for the first time.