unotools/source/misc/fontdefs.cxx |   34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

New commits:
commit 55eeffe768c6a80c97ee4f2a58fb467872ddeb1d
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Jun 12 10:34:43 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Jun 12 18:31:22 2022 +0200

    split out the code that extracts a lower-ascii version of a fontname
    
    Change-Id: I77778ecd075712c41bd29324be090ab4a8351ab9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135677
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/unotools/source/misc/fontdefs.cxx 
b/unotools/source/misc/fontdefs.cxx
index 568110315f33..44147ffd0927 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -226,6 +226,25 @@ OUString StripScriptFromName(const OUString& _aName)
     return aName;
 }
 
+//return true if the character is stripped from the string
+static bool toOnlyLowerAscii(sal_Unicode c, OUStringBuffer &rName, sal_Int32 
nIndex, sal_Int32& rLen)
+{
+    // To Lowercase-Ascii
+    if ( (c >= 'A') && (c <= 'Z') )
+    {
+        c += 'a' - 'A';
+        rName[nIndex] = c;
+    }
+    else if( ((c < '0') || (c > '9')) && (c != ';') && (c != '(') && (c != 
')') ) // not 0-9, semicolon, or brackets
+    {
+        // Remove white spaces and special characters
+        rName.remove(nIndex, 1);
+        rLen--;
+        return true;
+    }
+    return false;
+}
+
 OUString GetEnglishSearchFontName(std::u16string_view rInName)
 {
     OUStringBuffer rName(rInName);
@@ -270,19 +289,8 @@ OUString GetEnglishSearchFontName(std::u16string_view 
rInName)
         // not lowercase Ascii
         else if ( (c < 'a') || (c > 'z') )
         {
-            // To Lowercase-Ascii
-            if ( (c >= 'A') && (c <= 'Z') )
-            {
-                c += 'a' - 'A';
-                rName[ i ] = c;
-            }
-            else if( ((c < '0') || (c > '9')) && (c != ';') && (c != '(') && 
(c != ')') ) // not 0-9, semicolon, or brackets
-            {
-                // Remove white spaces and special characters
-                rName.remove(i,1);
-                nLen--;
-                continue;
-            }
+            if (toOnlyLowerAscii(c, rName, i, nLen))
+               continue;
         }
 
         i++;

Reply via email to