diff options
author | Christof Pintaske <cp@openoffice.org> | 2001-10-25 16:31:55 +0000 |
---|---|---|
committer | Christof Pintaske <cp@openoffice.org> | 2001-10-25 16:31:55 +0000 |
commit | 20166fe5e39a667ae833c26e0eb8f7877821d507 (patch) | |
tree | a498fc38ffddb1d84289a4af11df13b35f11d79e /vcl/unx/source/gdi/xlfd_smpl.cxx | |
parent | 63511a648d5a82317fcbd19d10e786371e6eacb1 (diff) |
#93803# check for xlfd conformance
Diffstat (limited to 'vcl/unx/source/gdi/xlfd_smpl.cxx')
-rw-r--r-- | vcl/unx/source/gdi/xlfd_smpl.cxx | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/vcl/unx/source/gdi/xlfd_smpl.cxx b/vcl/unx/source/gdi/xlfd_smpl.cxx index 500b2251dcce..982ff7271a56 100644 --- a/vcl/unx/source/gdi/xlfd_smpl.cxx +++ b/vcl/unx/source/gdi/xlfd_smpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xlfd_smpl.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: cp $ $Date: 2001-03-23 16:24:12 $ + * last change: $Author: cp $ $Date: 2001-10-25 17:31:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -177,22 +177,41 @@ Advance( const char** pFrom, const char** pTo ) *pTo = pTmp; } +Bool +Xlfd::IsConformant (const char* pXlfd) const +{ + // X FontNameRegistry prefix "-" + if (*pXlfd++ != '-') + return False; + + // All Xlfd FontName fields are defined + int nNumFields = 1; + while (*pXlfd != '\0') + { + if (*pXlfd++ == '-') + nNumFields++; + } + // enough entries ? + if (nNumFields != 14) + return False; + // and the last one is not empty as well ? + if (*(pXlfd - 1) == '-') + return False; + + return True; +} + // this is the real workhorse function. Since this is called for every font // in the fontpath it has to be as fast a possible Bool Xlfd::FromString( const char* pXlfdstring, AttributeProvider *pFactory ) { - mpFactory = pFactory; - - const char* pTo; - const char* pFrom; - - pFrom = pXlfdstring; - // first char must be '-' - if(*pFrom++ != '-') + if (!IsConformant(pXlfdstring)) return False; - pTo = pFrom; + const char* pFrom = pXlfdstring + 1; + const char* pTo = pFrom; + mpFactory = pFactory; Advance( &pFrom, &pTo ); //-foundry-* mnFoundry = mpFactory->InsertFoundry( pFrom, pTo - pFrom - 1 ); |