Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
e12ba2ed
Kaydet (Commit)
e12ba2ed
authored
Eki 20, 2014
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Resolves: fdo#85006 limit script stripping to known suffixes
Change-Id: I276535b007bbb55555148d5937076b86da5de825
üst
eb7aa9f1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
64 deletions
+48
-64
fontdefs.hxx
include/unotools/fontdefs.hxx
+9
-0
fontdefs.cxx
unotools/source/misc/fontdefs.cxx
+38
-29
PhysicalFontCollection.cxx
vcl/source/font/PhysicalFontCollection.cxx
+1
-35
No files found.
include/unotools/fontdefs.hxx
Dosyayı görüntüle @
e12ba2ed
...
...
@@ -83,6 +83,15 @@ UNOTOOLS_DLLPUBLIC OUString GetNextFontToken( const OUString& rTokenStr, sal_Int
UNOTOOLS_DLLPUBLIC
OUString
GetEnglishSearchFontName
(
const
OUString
&
rName
);
/** Strip any "script font suffix" from the font name
Related: fdo#49271 RTF files often contain weird-ass
Win 3.1/Win95 style fontnames which attempt to put the
charset encoding into the filename
http://www.webcenter.ru/~kazarn/eng/fonts_ttf.htm
*/
UNOTOOLS_DLLPUBLIC
OUString
StripScriptFromName
(
const
OUString
&
rName
);
/** Determine if the font is the special Star|Open Symbol font
@param rFontName
...
...
unotools/source/misc/fontdefs.cxx
Dosyayı görüntüle @
e12ba2ed
...
...
@@ -320,9 +320,43 @@ static ImplLocalizedFontName aImplLocalizedNamesList[] =
{
NULL
,
NULL
},
};
OUString
GetEnglishSearchFontName
(
const
OUString
&
rInName
)
OUString
StripScriptFromName
(
const
OUString
&
_aName
)
{
OUStringBuffer
rName
(
rInName
.
getStr
());
// I worry that someone will have a font which *does* have
// e.g. "Greek" legitimately at the end of its name :-(
const
char
*
suffixes
[]
=
{
" baltic"
,
" ce"
,
" cyr"
,
" greek"
,
" tur"
,
" (arabic)"
,
" (hebrew)"
,
" (thai)"
,
" (vietnamese)"
};
OUString
aName
=
_aName
;
// These can be crazily piled up, e.g. Times New Roman CYR Greek
bool
bFinished
=
false
;
while
(
!
bFinished
)
{
bFinished
=
true
;
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
suffixes
);
++
i
)
{
size_t
nLen
=
strlen
(
suffixes
[
i
]);
if
(
aName
.
endsWithIgnoreAsciiCaseAsciiL
(
suffixes
[
i
],
nLen
))
{
bFinished
=
false
;
aName
=
aName
.
copy
(
0
,
aName
.
getLength
()
-
nLen
);
}
}
}
return
aName
;
}
OUString
GetEnglishSearchFontName
(
const
OUString
&
rInName
)
{
OUStringBuffer
rName
(
rInName
);
bool
bNeedTranslation
=
false
;
sal_Int32
nLen
=
rName
.
getLength
();
...
...
@@ -334,33 +368,8 @@ OUString GetEnglishSearchFontName( const OUString& rInName )
rName
.
truncate
(
i
);
// Remove Script at the end
// Scriptname must be the last part of the fontname and
// looks like "fontname (scriptname)". So there can only be a
// script name at the end of the fontname, when the last char is ')'
if
(
(
nLen
>=
3
)
&&
rName
[
nLen
-
1
]
==
')'
)
{
int
nOpen
=
1
;
sal_Int32
nTempLen
=
nLen
-
2
;
while
(
nTempLen
)
{
if
(
rName
[
nTempLen
]
==
'('
)
{
nOpen
--
;
if
(
!
nOpen
)
{
// Remove Space at the end
if
(
nTempLen
&&
(
rName
[
nTempLen
-
1
]
==
' '
)
)
nTempLen
--
;
rName
.
truncate
(
nTempLen
);
nLen
=
nTempLen
;
break
;
}
}
if
(
rName
[
nTempLen
]
==
')'
)
nOpen
++
;
nTempLen
--
;
}
}
rName
=
StripScriptFromName
(
rName
.
toString
());
nLen
=
rName
.
getLength
();
// remove all whitespaces and converts to lower case ASCII
// TODO: better transliteration to ASCII e.g. all digits
...
...
vcl/source/font/PhysicalFontCollection.cxx
Dosyayı görüntüle @
e12ba2ed
...
...
@@ -36,40 +36,6 @@
#include "PhysicalFontCollection.hxx"
static
OUString
lcl_stripCharSetFromName
(
const
OUString
&
_aName
)
{
// I worry that someone will have a font which *does* have
// e.g. "Greek" legitimately at the end of its name :-(
const
char
*
suffixes
[]
=
{
" baltic"
,
" ce"
,
" cyr"
,
" greek"
,
" tur"
,
" (arabic)"
,
" (hebrew)"
,
" (thai)"
,
" (vietnamese)"
};
OUString
aName
=
_aName
;
// These can be crazily piled up, e.g. Times New Roman CYR Greek
bool
bFinished
=
false
;
while
(
!
bFinished
)
{
bFinished
=
true
;
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
suffixes
);
++
i
)
{
size_t
nLen
=
strlen
(
suffixes
[
i
]);
if
(
aName
.
endsWithIgnoreAsciiCaseAsciiL
(
suffixes
[
i
],
nLen
))
{
bFinished
=
false
;
aName
=
aName
.
copy
(
0
,
aName
.
getLength
()
-
nLen
);
}
}
}
return
aName
;
}
static
unsigned
lcl_IsCJKFont
(
const
OUString
&
rFontName
)
{
// Test, if Fontname includes CJK characters --> In this case we
...
...
@@ -1113,7 +1079,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindByFont( FontSelectPattern& r
// Win 3.1/Win95 style fontnames which attempt to put the
// charset encoding into the filename
// http://www.webcenter.ru/~kazarn/eng/fonts_ttf.htm
OUString
sStrippedName
=
lcl_stripCharSe
tFromName
(
rFSD
.
maTargetName
);
OUString
sStrippedName
=
StripScrip
tFromName
(
rFSD
.
maTargetName
);
if
(
sStrippedName
!=
rFSD
.
maTargetName
)
{
rFSD
.
maTargetName
=
sStrippedName
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment