//========================================================================
//
// FontOutputDev.h
//
// Copyright 1999 Emmanuel Lesueur
//
//========================================================================

#ifndef FONTOUTPUTDEV_H
#define FONTOUTPUTDEV_H

#ifdef __GNUC__
#pragma interface
#endif

#include <stdio.h>
#include "gtypes.h"
#include "OutputDev.h"
#include "GString.h"
#include "GfxFont.h"

class GfxState;
class GfxFont;

struct FontMapEntry {
  char *pdfFont;
  char *xFont;
  int mWidth;
  int style;
  int encoding;
};

extern FontMapEntry *userFontMap;
extern const char *defFontsNames[];
static const int numDefFonts = 12;//16;

void clearUserFontMap();
void resetUserFontMap();
const char* getAFont(GfxFont*,GfxFontEncoding*&,int&,double&,double&);


class FontOutputDev: public OutputDev {
public:

  FontOutputDev();

  // Destructor.
  virtual ~FontOutputDev();

  // Check if file was successfully created.
  virtual GBool isOk() { return gTrue; }

  //---- get info about output device

  // Does this device use upside-down coordinates?
  // (Upside-down means (0,0) is the top left corner of the page.)
  virtual GBool upsideDown() { return gTrue; }

  // Does this device use drawChar() or drawString()?
  virtual GBool useDrawChar() { return gTrue; }

  //----- update text state
  virtual void updateFont(GfxState *state);

  //----- special access
  int size() const { return cur - beg; }

  void get(int n,const char*& pdfFont,const char*& xFont,int& m,int& style,int& encoding) {
    Entry& e = beg[n];
    pdfFont = e.pdfFont->getCString();
    xFont = e.xFont;
    m = e.m;
    style = e.style;
    encoding = e.encoding;
  }

protected:
  struct Entry {
    GString* pdfFont;
    const char* xFont;
    int m;
    int style;
    int encoding;
  };
  Entry* beg;
  Entry* cur;
  Entry* end;
};

class DefaultFontOutputDev : public FontOutputDev {
public:
  DefaultFontOutputDev();
};

#endif

