diff options
author | Herbert Duerr [hdu] <duerr@sun.com> | 2010-04-12 17:02:34 +0200 |
---|---|---|
committer | Herbert Duerr [hdu] <duerr@sun.com> | 2010-04-12 17:02:34 +0200 |
commit | 38f4d323100037df1c2cb89087781a7677d44278 (patch) | |
tree | 290dbf591d758ce523d7bac5081b66b7cc5f97c8 /vcl/source/fontsubset | |
parent | 4f7764d914a321127b8cadbda5b72ab700e62a46 (diff) |
#i110387# replace dummy implementation of cff dbl2str
Diffstat (limited to 'vcl/source/fontsubset')
-rw-r--r-- | vcl/source/fontsubset/cff.cxx | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx index a901a4744fda..9d329755baeb 100644 --- a/vcl/source/fontsubset/cff.cxx +++ b/vcl/source/fontsubset/cff.cxx @@ -2027,15 +2027,36 @@ void Type1Emitter::emitAllCrypted( void) // -------------------------------------------------------------------- -// #i110387# double->ascii conversion -// sprintf/ecvt/etc. cannot be used here because of LC_NUMERIC -// also strip off trailing zeros while we are at it -int dbl2str( char* pOut, double fVal, int /*nPrecision*/=6) +// #i110387# quick-and-dirty double->ascii conversion +// needed because sprintf/ecvt/etc. alone are too localized (LC_NUMERIC) +// also strip off trailing zeros in fraction while we are at it +int dbl2str( char* pOut, double fVal, int nPrecision=6) { - int nLen = sprintf( pOut, "%g", fVal); + char* pBuf = pOut; + // TODO: avoid LC_NUMERIC based API + pOut += sprintf( pOut, "%.*g", nPrecision, fVal); + // ignore the number sign if any + char* p = pBuf; + if( (*p == '-') || (*p == '+')) + ++p; + for(; p < pOut; ++p) { + if( (*p >= '0') || (*p <= '9')) + continue; + // fixup fractional char + *(p++) = '.'; + break; + } + // ignore trailing zeros in fractional part + for( char* pEnd = pOut; p < pEnd; ++p) + if( *p != '0') + pOut = p; + // calculate the length of the number string + const int nLen = pOut - pBuf; return nLen; } +// -------------------------------------------------------------------- + void Type1Emitter::emitValVector( const char* pLineHead, const char* pLineTail, const ValVector& rVector) { @@ -2276,6 +2297,7 @@ bool CffSubsetterContext::emitAsType1( Type1Emitter& rEmitter, // emit used GlobalSubr charstrings // these are the just the default subrs + // TODO: do we need them as the flex hints are resolved differently? static const char aSubrs[] = "/Subrs 5 array\n" "dup 0 15 RD \x5F\x3D\x6B\xAC\x3C\xBD\x74\x3D\x3E\x17\xA0\x86\x58\x08\x85 NP\n" |