LibreOffice Macro to search a text typed in specific font and replace it with a specific font

I want macro code to find text typed in Kruti Dev Font and Replace the font of the same text to Lohit Marathi so that the text found which is typed in different font should not get disturbed. I know that I can find text typed in a font and replace it by another font but I already created a macro which used to find a letter and replace it with another letter. But it used to find and replace text in English fonts also. I wish it should not replace text typed in English. It should only find and replace text in Hindi or Marathi language

Why a macro? You can Find text with a font format, and apply a different one.

Related answers:

If you have correctly set the languages in document, you can try this macro. The example is for latin script, maybe you have to change the property CharFontName to CharFontNameAsian or CharFontNameComplex, I don’t know what property is used for Hindi or Marathi.

Sub findReplaceInLaguages1
	dim oDoc as object, oText as object, oEnum as object, oEnum2 as object, o as object, o2 as object
	oDoc=ThisComponent
	rem enumerate the text
	oText=oDoc.Text
	oEnum=oText.createEnumeration
	do while oEnum.hasMoreElements 'enumerate all elements in text
		o=oEnum.nextElement
		oEnum2=o.createEnumeration
		do while oEnum2.hasMoreElements 'enumerate all parts of element with different formatting
			o2=oEnum2.nextElement
			if o2.CharLocale.Language<>"en" then 'for no English part
				'there is used the property CharFontName for latin script, but it can be also CharFontAsian or CharFontComplex
				if o2.CharFontName="Liberation Serif" then
					o2.CharFontName="Liberation Sans"
				end if
			end if
		loop
	loop
End Sub

The macro is included also in example ODS findReplForLangs.odt (60.0 kB)

or maybe 2nd way:
I don’t know what letters are in Hindi or Marathi language, but if there are different letters than in latin script, then you can use the ascii codes for these different letters in regular expression → no [a-z] or .+ but something like [\u… - \u…] and use it in classical createReplaceDescriptor() with method findAll() and then test found items and change ones.