|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TFONT_H
|
|
Toshihiro Shimizu |
890ddd |
#define TFONT_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if _MSC_VER > 1000
|
|
Toshihiro Shimizu |
890ddd |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
#endif // _MSC_VER > 1000
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Toonz includes
|
|
Toshihiro Shimizu |
890ddd |
#include "trastercm.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//STL includes
|
|
Toshihiro Shimizu |
890ddd |
#include <string></string>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TVRENDER_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
class TVectorImageP;
|
|
Toshihiro Shimizu |
890ddd |
class TFont;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//TFont declaration. The class is currently not directly available under 64-bit MAC OSX.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef __LP64__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
#include <applicationservices applicationservices.h=""></applicationservices>
|
|
Toshihiro Shimizu |
890ddd |
#include <carbon carbon.h=""></carbon>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=================================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Class to manage loading and rendering of fonts.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TFont
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
struct Impl;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
friend class TFontManager;
|
|
Toshihiro Shimizu |
890ddd |
Impl *m_pimpl;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
TFont(const LOGFONTW &, HDC hdc);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
TFont(ATSUFontID, int size);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
~TFont();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TVectorImageP &outImage, wchar_t charcode, wchar_t nextCode = 0) const;
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TRasterGR8P &outImage, TPoint &glyphOrigin, wchar_t charcode, wchar_t nextCode = 0) const;
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TRasterCM32P &outImage, TPoint &glyphOrigin, int inkId, wchar_t charcode, wchar_t nextCode = 0) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//brief get kerning distance between two characters
|
|
Toshihiro Shimizu |
890ddd |
TPoint getDistance(wchar_t firstChar, wchar_t secondChar) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getMaxHeight() const;
|
|
Toshihiro Shimizu |
890ddd |
int getMaxWidth() const;
|
|
Toshihiro Shimizu |
890ddd |
//void disableKerning();
|
|
Toshihiro Shimizu |
890ddd |
//void enableKerning();
|
|
Toshihiro Shimizu |
890ddd |
bool hasKerning() const;
|
|
Toshihiro Shimizu |
890ddd |
int getLineAscender() const;
|
|
Toshihiro Shimizu |
890ddd |
int getLineDescender() const;
|
|
Toshihiro Shimizu |
890ddd |
bool hasVertical() const;
|
|
Toshihiro Shimizu |
890ddd |
wstring getFamily() const;
|
|
Toshihiro Shimizu |
890ddd |
wstring getTypeface() const;
|
|
Toshihiro Shimizu |
890ddd |
//bool isValidCode( wchar_t code ) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
// not implemented
|
|
Toshihiro Shimizu |
890ddd |
TFont(const TFont &);
|
|
Toshihiro Shimizu |
890ddd |
TFont &operator=(const TFont &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //!__LP64__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFontCreationError : public TException
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TFontCreationError()
|
|
Toshihiro Shimizu |
890ddd |
: TException("E_CanNotUseSelectedFont")
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFontLibraryLoadingError : public TException
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TFontLibraryLoadingError()
|
|
Toshihiro Shimizu |
890ddd |
: TException("E_CanNotLoadFonts")
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//singleton
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TFontManager
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
struct Impl;
|
|
Toshihiro Shimizu |
890ddd |
Impl *m_pimpl;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFontManager();
|
|
Toshihiro Shimizu |
890ddd |
~TFontManager();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
static TFontManager *instance();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFont *getCurrentFont();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!throws TFontLibraryLoadingError if can not load fonts
|
|
Toshihiro Shimizu |
890ddd |
void loadFontNames();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! if can not create font, throws TFontCreationError and leave as current the old one
|
|
Toshihiro Shimizu |
890ddd |
void setFamily(const wstring family);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!if can not create font, throws TFontCreationError and leave as current the old one
|
|
Toshihiro Shimizu |
890ddd |
void setTypeface(const wstring typeface);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
wstring getCurrentFamily() const;
|
|
Toshihiro Shimizu |
890ddd |
wstring getCurrentTypeface() const;
|
|
Toshihiro Shimizu |
890ddd |
void getAllFamilies(vector<wstring> &families) const;</wstring>
|
|
Toshihiro Shimizu |
890ddd |
void getAllTypefaces(vector<wstring> &typefaces) const;</wstring>
|
|
Toshihiro Shimizu |
890ddd |
void setVertical(bool vertical);
|
|
Toshihiro Shimizu |
890ddd |
void setSize(int size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// --------- TFont methods called on curren font -----------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef __LP64__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TVectorImageP &outImage, wchar_t charcode, wchar_t nextCode = 0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return getCurrentFont()->drawChar(outImage, charcode, nextCode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TRasterGR8P &outImage, TPoint &glyphOrigin, wchar_t charcode, wchar_t nextCode = 0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return getCurrentFont()->drawChar(outImage, glyphOrigin, charcode, nextCode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TRasterCM32P &outImage, TPoint &glyphOrigin, int inkId, wchar_t charcode, wchar_t nextCode = 0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return getCurrentFont()->drawChar(outImage, glyphOrigin, inkId, charcode, nextCode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint getDistance(wchar_t firstChar, wchar_t secondChar)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return getCurrentFont()->getDistance(firstChar, secondChar);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getMaxHeight() { return getCurrentFont()->getMaxHeight(); }
|
|
Toshihiro Shimizu |
890ddd |
int getMaxWidth() { return getCurrentFont()->getMaxWidth(); }
|
|
Toshihiro Shimizu |
890ddd |
bool hasKerning() { return getCurrentFont()->hasKerning(); }
|
|
Toshihiro Shimizu |
890ddd |
int getLineAscender() { return getCurrentFont()->getLineAscender(); }
|
|
Toshihiro Shimizu |
890ddd |
int getLineDescender() { return getCurrentFont()->getLineDescender(); }
|
|
Toshihiro Shimizu |
890ddd |
bool hasVertical() { return getCurrentFont()->hasVertical(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#else //__LP64__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TVectorImageP &outImage, wchar_t charcode, wchar_t nextCode = 0);
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TRasterGR8P &outImage, TPoint &glyphOrigin, wchar_t charcode, wchar_t nextCode = 0);
|
|
Toshihiro Shimizu |
890ddd |
TPoint drawChar(TRasterCM32P &outImage, TPoint &glyphOrigin, int inkId, wchar_t charcode, wchar_t nextCode = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint getDistance(wchar_t firstChar, wchar_t secondChar);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getMaxHeight();
|
|
Toshihiro Shimizu |
890ddd |
int getMaxWidth();
|
|
Toshihiro Shimizu |
890ddd |
bool hasKerning();
|
|
Toshihiro Shimizu |
890ddd |
int getLineAscender();
|
|
Toshihiro Shimizu |
890ddd |
int getLineDescender();
|
|
Toshihiro Shimizu |
890ddd |
bool hasVertical();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //__LP64__
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|