OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Find and Replace Fonts
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
amida
General User
General User


Joined: 07 Jun 2005
Posts: 16

PostPosted: Tue Jun 07, 2005 10:10 am    Post subject: Find and Replace Fonts Reply with quote

Hi,
Is it possible to find and replace all text written in a specific font? I am having trouble doing this with the format option. What I am trying to do is remove text in a certain language (Trad Chinese) from a multi-language document by searching for all text written in its font and "replacing" it with nothing. Or is there another way to do this?
Thanks!
Back to top
View user's profile Send private message
bobharvey
Super User
Super User


Joined: 23 Apr 2004
Posts: 1075
Location: Lincolnshire

PostPosted: Tue Jun 07, 2005 11:55 am    Post subject: Reply with quote

This is one of the things character styles is for.

If, when you create the document, you use separate character styles for each, err, style of text, then you can alter the font centrally in the stylist.

It's a lot of work to do afterwards.
Back to top
View user's profile Send private message
hwtan
OOo Advocate
OOo Advocate


Joined: 24 Aug 2004
Posts: 320
Location: Singapore

PostPosted: Tue Jun 07, 2005 7:29 pm    Post subject: Reply with quote

It seems to be a bug in the Find Replace Format feature. I manage to get it to work for one occassion and not the other. It seems to work on other font except the default (Chinese) font.

Try this, use "[:print:]?" or "[:print:]*" (without the quote) in the search for box. Go to format and set the font that you are looking for. The help file has left out the "?".

The feature is there, but I suspect is buggy. Need more people to verify this.
Back to top
View user's profile Send private message
amida
General User
General User


Joined: 07 Jun 2005
Posts: 16

PostPosted: Tue Jun 07, 2005 10:08 pm    Post subject: [:print:] Reply with quote

I tried all the various wildcards--printable characters, etc. I think the feature must be buggy. I tried the same thing with Word, and was able to find and replace by language. I replaced all Chinese with nothing, and it worked like a charm. I don't want to switch back to Word to do that.
Any ideas on other ways to get OpenOffice to strip the Chinese out of a file? (I am a translator, so I need to do this a lot and with files I didn't create.)
Back to top
View user's profile Send private message
ftack
Moderator
Moderator


Joined: 27 Jan 2003
Posts: 3102
Location: Belgium

PostPosted: Wed Jun 08, 2005 3:23 am    Post subject: Reply with quote

It is a limitation in the implementation of search/replace combining content and characters. On the other hand, regular expressions are so complex that I would not know how you can specify "any" text.

You can "Find all" text of a specific font, then press the delete key. This will remove all text formatted with the specific font, but leave blank lines, that you subsequently can edit out with search-replace involving regular expressions.
Back to top
View user's profile Send private message
hwtan
OOo Advocate
OOo Advocate


Joined: 24 Aug 2004
Posts: 320
Location: Singapore

PostPosted: Wed Jun 08, 2005 5:31 pm    Post subject: Reply with quote

Quote:
On the other hand, regular expressions are so complex that I would not know how you can specify "any" text.


To find "any" text, you can use "[:print:]?" (without quotes) with the regular expressions checked. click the format button for specific format.

Quote:
You can "Find all" text of a specific font, then press the delete key. This will remove all text formatted with the specific font, but leave blank lines, that you subsequently can edit out with search-replace involving regular expressions.


Use the "Replace all" with the Replace with box empty will be more effective.

I notice one short fall in the development of OOo is that there is not enough people to test the "unicode support" aspect of the applications. Most of the time OOo works flawlessly with normal western text, but with little flaws here and there for Asian text. So we need more Asian users to contribute in the testing or even coding.

For the time being, can someone do more testing on this "bug". I presume that OOo has no problem finding fonts of the western text, but is unable to find the Asian text. Also, it seems like OOo just unable to find the default Asian text. Can someone help to confirm this before put it up as an issue.
Back to top
View user's profile Send private message
ftack
Moderator
Moderator


Joined: 27 Jan 2003
Posts: 3102
Location: Belgium

PostPosted: Wed Jun 08, 2005 11:00 pm    Post subject: Reply with quote

Quote:
Use the "Replace all" with the Replace with box empty will be more effective.

This won't work for replacing text with a specified font with nothing. It may not look so, but this issue is in fact very much related to this one
http://qa.openoffice.org/issues/show_bug.cgi?id=41193
Back to top
View user's profile Send private message
amida
General User
General User


Joined: 07 Jun 2005
Posts: 16

PostPosted: Thu Jun 09, 2005 6:54 pm    Post subject: Reply with quote

Just an update: I was using a document with Chinese in MingLiU font and English in Times New Roman. I searched for MingLiU, and nothing came up. As an experiment, I searched for Times New Roman, and everything came up! Even though the fonts showed up distinctly in the object bar when selecting text from the different languages in the document, the search function could not distinguish between the two.
If anybody could help me out with this I'd appreciate it as being able to take all the Chinese out of my documents automatically would save a lot of time.
Back to top
View user's profile Send private message
hwtan
OOo Advocate
OOo Advocate


Joined: 24 Aug 2004
Posts: 320
Location: Singapore

PostPosted: Thu Jun 09, 2005 10:02 pm    Post subject: Reply with quote

Quote:

This won't work for replacing text with a specified font with nothing. It may not look so, but this issue is in fact very much related to this one
http://qa.openoffice.org/issues/show_bug.cgi?id=41193


ftack, amida's concern was removing the whole text and not only the formating. The problem that we are having now is quite different from issue 41193. The problem at hand is that we even have problem 'finding' Asian fonts from the western fonts. See:

Quote:

I searched for MingLiU, and nothing came up. As an experiment, I searched for Times New Roman, and everything came up!



I personally is quite busy recently and may not have the time to confirm the bug. Can anyone help?

[/quote]
Back to top
View user's profile Send private message
ftack
Moderator
Moderator


Joined: 27 Jan 2003
Posts: 3102
Location: Belgium

PostPosted: Thu Jun 09, 2005 10:55 pm    Post subject: Reply with quote

Quote:
amida's concern was removing the whole text and not only the formating. The problem that we are having now is quite different from issue 41193. The problem at hand is that we even have problem 'finding' Asian fonts from the western fonts. See:


That's what I also understood. Reread all posts, try your suggestion, then try mine and see. I tried this on OOo 1.9.104

In top of the issues with the search replace mecahnism involving formatting, we might also have specific issues with the chinese font. That the MingLIU font, and probably other Asian fonts, is not at all found is not normal as it does not happen with standard fonts like Times New Roman.
Back to top
View user's profile Send private message
amida
General User
General User


Joined: 07 Jun 2005
Posts: 16

PostPosted: Thu Jun 09, 2005 11:45 pm    Post subject: Reply with quote

Sorry, I should clarify my previous post. I searched for Times New Roman, and all text--Times New Roman *and* MingLiU--was found (and replaced successfully with nothing, leaving a blank document). I have been experimenting with checking boxes in the Attributes section regarding Asian fonts but to no avail.
Back to top
View user's profile Send private message
hwtan
OOo Advocate
OOo Advocate


Joined: 24 Aug 2004
Posts: 320
Location: Singapore

PostPosted: Fri Jun 10, 2005 12:02 am    Post subject: Reply with quote

Quote:
ftack: You can "Find all" text of a specific font, then press the delete key. This will remove all text formatted with the specific font, but leave blank lines, that you subsequently can edit out with search-replace involving regular expressions.

Quote:
hwtan: Use the "Replace all" with the Replace with box empty will be more effective.

ftack: This won't work for replacing text with a specified font with nothing.



I hope I have understand you correctly, ftack.

Let me describe the whole procedure to get thing right. If one want to just change the format of a text, he should first "search for" the text ([:print:]? for any text, and checked the "Regular expression") with the format set inside the format box. The format to search for should appear below the "search for" box.
Second, with "regular expression" checked, input "&" (without quotes) into the "Replace with" box. With the cursor still in the "Replace with" box, click the format button again to set the desired format. This should replace the 'found' text with the same 'found' text but with the format specified in the format, which also should appear below the "Replacce with" box. This feature is able to change for example all bolded text to italic. theoretically, it should be able to solve amida's problem, since amida wants to remove all the Chinese characters, which most probably are using a different font from the western text.

The bug I suspect, is that while the above method is able to find western text, it is not able to identify the format of Chinese text, as described by amida:
Quote:
I searched for MingLiU, and nothing came up. As an experiment, I searched for Times New Roman, and everything came up!


I hope that everything is clear now.

Btw, I do understand the issue 41193, and you have a point there.
Back to top
View user's profile Send private message
helmerj
OOo Advocate
OOo Advocate


Joined: 12 Aug 2004
Posts: 235
Location: Germany

PostPosted: Fri Jun 10, 2005 4:06 am    Post subject: weird but works... Reply with quote

I had the same problem once and I did overcome it in a kinda unusual way...

All docs in OO is saved as a zip file with a different extension. So using unzip you can extract the contents of any OO file:

Code:

unzip -l file.sxw

Archive:  file.sxw
  Length     Date   Time    Name
 --------    ----   ----    ----
       30  06-10-05 11:58   mimetype
        0  06-10-05 11:58   Configurations2/
        0  06-10-05 11:58   Pictures/
     2849  06-10-05 11:58   content.xml
     7811  06-10-05 11:58   styles.xml
     1009  06-10-05 11:58   meta.xml
      538  06-10-05 11:58   Thumbnails/thumbnail.png
     6339  06-10-05 11:58   settings.xml
     1050  06-10-05 11:58   META-INF/manifest.xml
 --------                   -------
    19626                   9 files


The content of the document including font assignments is stored as xml data in content.xml:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0" office:class="text"><office:script/><office:font-decls><style:font-decl style:name="Bitstream Vera Sans" fo:font-family="&apos;Bitstream Vera Sans&apos;"/><style:font-decl style:name="Lucidasans1" fo:font-family="Lucidasans"/><style:font-decl style:name="Lucidasans" fo:font-family="Lucidasans" style:font-pitch="variable"/><style:font-decl style:name="Mincho" fo:font-family="Mincho" style:font-pitch="variable"/><style:font-decl style:name="Times New Roman" fo:font-family="&apos;Times New Roman&apos;" style:font-pitch="variable"/><style:font-decl style:name="Arial" fo:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/></office:font-decls><office:automatic-styles><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"><style:properties style:font-name="Arial"/></style:style><style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard"><style:properties style:font-name="Times New Roman"/></style:style></office:automatic-styles><office:body><office:forms form:automatic-focus="false" form:apply-design-mode="false"/><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:p text:style-name="P1">This is some text in Arial</text:p><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="P2">This is some text in Times New Roman</text:p></office:body></office:document-content>


Note the font selection for the two sentences is simple text now. E.g. search for
Code:

font-name="Arial"

and replace it with

Code:

font-name="Times New Roman"

in any text editor and save the file. Zip up all the contents and have the result you want. Looks a bit complicated I have to admit but at the time saved me a lot of time I would have spend trying to figure out them regular expressions...

Juergen
Back to top
View user's profile Send private message Visit poster's website
amida
General User
General User


Joined: 07 Jun 2005
Posts: 16

PostPosted: Sat Jun 11, 2005 11:12 am    Post subject: Inelegant solution Reply with quote

Here's an inelegant solution for what I am trying to do:
Copy the entire document. Paste it into Wordpad. Paste it back. Search for SimSun font, and replace it with nothing. Boom, Chinese gone.
Wordpad changes the Chinese text into SimSun (a font for GB, simplified Chinese, oddly enough), and leaves the English in Times New Roman. Perhaps someone knows why OpenOffice Writer can find SimSun no problem but thinks MingLiU is Times New Roman?
Back to top
View user's profile Send private message
hwtan
OOo Advocate
OOo Advocate


Joined: 24 Aug 2004
Posts: 320
Location: Singapore

PostPosted: Sun Jun 12, 2005 6:08 pm    Post subject: Reply with quote

That is quite good I must say. Very Happy

Quote:
Perhaps someone knows why OpenOffice Writer can find SimSun no problem but thinks MingLiU is Times New Roman?


In any word process application, there is something call font subsitution, when a font is not found. For example, in your computer the font MingLiu is not installed. If in a document created in another computer uses MingLiu, OOo in your computer has to decide whether to subsitute those characters using MingLiu with squares, or another font, that OOo thinks is close enough. That is a judgement call.

Nevertheless, the 'bug' is probably still there. Can someone confirm it?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group