Ignore:
Timestamp:
Apr 8, 2010, 10:16:54 AM (11 years ago)
Author:
dmik
Message:

Merged bramches/kmk (r294:365) to trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/poppler/fc-emulate-os2/fontconfig/fontconfig.cpp

    r272 r367  
    2222#define INCL_DOS
    2323#define INCL_WIN
     24#if defined(__EMX__)
     25#define OS2EMX_PLAIN_CHAR
     26#endif
    2427#include <os2.h>
    2528
     
    2932
    3033#include <stdio.h>
     34#include <string.h>
     35
     36#if defined( __WATCOMC__ )
    3137#include <dos.h>
    32 #include <string.h>
     38#else
     39#include <io.h>
     40#include <sys/stat.h>
     41#endif
    3342
    3443#include "fontconfig.h"
     
    247256
    248257    string key = familyName;
    249     if ( stricmp( styleName.c_str(), "regular" ) != 0 ) {
     258    if ( stricmp( styleName.c_str(), "regular" ) != 0 &&
     259         stricmp( styleName.c_str(), "book" ) != 0 ) {
    250260        key += ' ';
    251261        key += styleName;
     
    278288    char dir[ _MAX_DIR ];
    279289    char fname[ _MAX_FNAME ];
     290#if defined( __WATCOMC__ )
    280291    _splitpath( __argv[0], drive, dir, fname, NULL );
     292#else
     293    _execname( fullpath, sizeof(fullpath) );
     294    _splitpath( fullpath, drive, dir, fname, NULL );
     295#endif
    281296    strlwr( fname );
    282297    _makepath( fullpath, drive, dir, fname, ".fcf" );
     
    435450#define DEFAULT_SANSSERIF_FONT      "helvetica"
    436451#define DEFAULT_MONOSPACED_FONT     "courier"
     452#define DEFAULT_SYMBOL_FONT         "symbol set"
    437453
    438454static bool isSansserif( const char *family )
     
    445461}
    446462
    447 static string buildFontKey( FcPattern *p, bool useDefaultFonts )
     463static string buildFontKey( FcPattern *p )
    448464{
    449465    string key = p->family;
    450466
    451     if ( useDefaultFonts )
    452     {
     467    // From http://en.wikipedia.org/wiki/Portable_Document_Format:
     468    //
     469    // There are fourteen typefaces that have a special significance to PDF
     470    // documents:
     471    //
     472    //  * Times (v3) (in regular, italic, bold, and bold italic)
     473    //  * Courier (in regular, oblique, bold and bold oblique)
     474    //  * Helvetica (v3) (in regular, oblique, bold and bold oblique)
     475    //  * Symbol
     476    //  * Zapf Dingbats
     477    //
     478    // These fonts, sometimes referred to as the "base fourteen fonts" should
     479    // always be present (actually present or a close substitute) and so need
     480    // not be embedded in a PDF.[46]  PDF viewers must know about the metrics
     481    // of these fonts. Other fonts may be substituted if they are not embedded
     482    // in a PDF.
     483    //
     484    // The following code is based on this information and guarantees that we
     485    // always return a valid font for those (except Zapf Dingbats for which we
     486    // don't have a pre-installed OS/2 font).
     487
     488    bool ignoreStyle = false;
     489
     490    if ( fontmap->find( key ) == fontmap->end() ) {
     491        // not found: try substitutions
    453492        if ( p->spacing == FC_MONO ) {
    454493            key = DEFAULT_MONOSPACED_FONT;
    455         }
    456         else
    457         {
     494        } else {
    458495            if ( isSansserif( p->family ) ) {
    459496                key = DEFAULT_SANSSERIF_FONT;
     497            } else {
     498                if ( key == "symbol" ) {
     499                    ignoreStyle = true;
     500                    key = "opensymbol";
     501                    if ( fontmap->find( key ) == fontmap->end() )
     502                        key = DEFAULT_SYMBOL_FONT;
     503                } else if ( key == "zapfdingbats" || key == "zapf dingbats" ) {
     504                    ignoreStyle = true;
     505                    key = "dejavu sans";
     506                    // last resort, quite meaningless but we must provide something
     507                    if ( fontmap->find( key ) == fontmap->end() )
     508                        key = DEFAULT_SYMBOL_FONT;
     509                } else {
     510                    key = DEFAULT_SERIF_FONT;
     511                }
    460512            }
    461             else {
    462                 key = DEFAULT_SERIF_FONT;
    463             }
    464         }
    465     }
    466     else
    467     {
    468         // use 'Symbol Set' (SYMB.PFB) instead of 'Symbol'
    469         if ( strcmp( p->family, "symbol" ) == 0 ) {
    470             key = "symbol set";
    471         }
    472     }
    473 
    474     if ( p->weight > FC_WEIGHT_NORMAL ) {
    475         key += ' ';
    476         key += "bold";
    477     }
    478 
    479     if ( (p->slant == FC_SLANT_ITALIC) || (p->slant == FC_SLANT_OBLIQUE) ) {
    480         key += ' ';
    481         key += "italic";
     513        }
     514
     515    }
     516
     517    if ( !ignoreStyle ) {
     518        if ( p->weight > FC_WEIGHT_NORMAL ) {
     519            key += ' ';
     520            key += "bold";
     521        }
     522        if ( (p->slant == FC_SLANT_ITALIC) || (p->slant == FC_SLANT_OBLIQUE) ) {
     523            key += ' ';
     524            key += "italic";
     525        }
    482526    }
    483527
     
    497541    pat->filename = NULL;
    498542
    499     string key = buildFontKey( pat, false );
    500 
    501     if ( fontmap->find( key ) == fontmap->end() ) {
    502         key = buildFontKey( pat, true );
    503         pat->filename = newstrdup( (*fontmap)[ key ].c_str() );
    504     }
    505     else {
    506         pat->filename = newstrdup( (*fontmap)[ key ].c_str() );
    507     }
     543    string key = buildFontKey( pat );
     544    pat->filename = newstrdup( (*fontmap)[ key ].c_str() );
    508545
    509546//printf( "MATCHED STYLE: %s, FILENAME: %s\n", key.c_str(), pat->filename );
Note: See TracChangeset for help on using the changeset viewer.