|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TFONT_H
|
|
Toshihiro Shimizu |
890ddd |
#define TFONT_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Toonz includes
|
|
Toshihiro Shimizu |
890ddd |
#include "trastercm.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// 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 |
//! Class to manage loading and rendering of fonts.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TFont {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
struct Impl;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
friend class TFontManager;
|
|
Shinya Kitaoka |
120a6e |
Impl *m_pimpl;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
deffae |
TFont(const std::wstring family, const std::wstring face, int size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
~TFont();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPoint drawChar(TVectorImageP &outImage, wchar_t charcode,
|
|
Shinya Kitaoka |
120a6e |
wchar_t nextCode = 0) const;
|
|
shun_iwasawa |
df21fa |
TPoint drawChar(QImage &outImage, TPoint &glyphOrigin, wchar_t charcode,
|
|
Shinya Kitaoka |
120a6e |
wchar_t nextCode = 0) const;
|
|
Shinya Kitaoka |
120a6e |
TPoint drawChar(TRasterCM32P &outImage, TPoint &glyphOrigin, int inkId,
|
|
Shinya Kitaoka |
120a6e |
wchar_t charcode, wchar_t nextCode = 0) const;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// brief get kerning distance between two characters
|
|
Shinya Kitaoka |
120a6e |
TPoint getDistance(wchar_t firstChar, wchar_t secondChar) const;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int getMaxWidth() const;
|
|
Shinya Kitaoka |
120a6e |
// void disableKerning();
|
|
Shinya Kitaoka |
120a6e |
// void enableKerning();
|
|
Shinya Kitaoka |
120a6e |
bool hasKerning() const;
|
|
Shinya Kitaoka |
120a6e |
int getLineAscender() const;
|
|
Shinya Kitaoka |
120a6e |
int getLineDescender() const;
|
|
shun_iwasawa |
6c2748 |
int getLineSpacing() const;
|
|
shun_iwasawa |
6c2748 |
int getHeight() const;
|
|
shun_iwasawa |
6c2748 |
int getAverageCharWidth() const;
|
|
Shinya Kitaoka |
120a6e |
bool hasVertical() const;
|
|
Shinya Kitaoka |
120a6e |
std::wstring getFamily() const;
|
|
Shinya Kitaoka |
120a6e |
std::wstring getTypeface() const;
|
|
Shinya Kitaoka |
120a6e |
// bool isValidCode( wchar_t code ) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
// not implemented
|
|
Shinya Kitaoka |
120a6e |
TFont(const TFont &);
|
|
Shinya Kitaoka |
120a6e |
TFont &operator=(const TFont &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class TFontCreationError final : public TException {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TFontCreationError() : TException("E_CanNotUseSelectedFont") {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class TFontLibraryLoadingError final : public TException {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TFontLibraryLoadingError() : TException("E_CanNotLoadFonts") {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// singleton
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TFontManager {
|
|
Shinya Kitaoka |
120a6e |
struct Impl;
|
|
Shinya Kitaoka |
120a6e |
Impl *m_pimpl;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFontManager();
|
|
Shinya Kitaoka |
120a6e |
~TFontManager();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
static TFontManager *instance();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFont *getCurrentFont();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! throws TFontLibraryLoadingError if can not load fonts
|
|
Shinya Kitaoka |
120a6e |
void loadFontNames();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! if can not create font, throws TFontCreationError and leave as current the
|
|
Shinya Kitaoka |
120a6e |
//! old one
|
|
Shinya Kitaoka |
120a6e |
void setFamily(const std::wstring family);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! if can not create font, throws TFontCreationError and leave as current the
|
|
Shinya Kitaoka |
120a6e |
//! old one
|
|
Shinya Kitaoka |
120a6e |
void setTypeface(const std::wstring typeface);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring getCurrentFamily() const;
|
|
Shinya Kitaoka |
120a6e |
std::wstring getCurrentTypeface() const;
|
|
Shinya Kitaoka |
120a6e |
void getAllFamilies(std::vector<std::wstring> &families) const;</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
void getAllTypefaces(std::vector<std::wstring> &typefaces) const;</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
void setVertical(bool vertical);
|
|
Shinya Kitaoka |
120a6e |
void setSize(int size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
df21fa |
bool isBold(const QString &family, const QString &style);
|
|
shun_iwasawa |
df21fa |
bool isItalic(const QString &family, const QString &style);
|
|
Toshihiro Shimizu |
890ddd |
|
|
luz paz |
6454c4 |
// --------- TFont methods called on current font -----------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPoint drawChar(TVectorImageP &outImage, wchar_t charcode,
|
|
Shinya Kitaoka |
120a6e |
wchar_t nextCode = 0) {
|
|
Shinya Kitaoka |
120a6e |
return getCurrentFont()->drawChar(outImage, charcode, nextCode);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
shun_iwasawa |
df21fa |
TPoint drawChar(QImage &outImage, TPoint &glyphOrigin, wchar_t charcode,
|
|
Shinya Kitaoka |
120a6e |
wchar_t nextCode = 0) {
|
|
Shinya Kitaoka |
120a6e |
return getCurrentFont()->drawChar(outImage, glyphOrigin, charcode,
|
|
Shinya Kitaoka |
120a6e |
nextCode);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPoint drawChar(TRasterCM32P &outImage, TPoint &glyphOrigin, int inkId,
|
|
Shinya Kitaoka |
120a6e |
wchar_t charcode, wchar_t nextCode = 0) {
|
|
Shinya Kitaoka |
120a6e |
return getCurrentFont()->drawChar(outImage, glyphOrigin, inkId, charcode,
|
|
Shinya Kitaoka |
120a6e |
nextCode);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPoint getDistance(wchar_t firstChar, wchar_t secondChar) {
|
|
Shinya Kitaoka |
120a6e |
return getCurrentFont()->getDistance(firstChar, secondChar);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int getMaxWidth() { return getCurrentFont()->getMaxWidth(); }
|
|
Shinya Kitaoka |
120a6e |
bool hasKerning() { return getCurrentFont()->hasKerning(); }
|
|
Shinya Kitaoka |
120a6e |
int getLineAscender() { return getCurrentFont()->getLineAscender(); }
|
|
Shinya Kitaoka |
120a6e |
int getLineDescender() { return getCurrentFont()->getLineDescender(); }
|
|
shun_iwasawa |
6c2748 |
int getLineSpacing() { return getCurrentFont()->getLineSpacing(); }
|
|
shun_iwasawa |
6c2748 |
int getHeight() { return getCurrentFont()->getHeight(); }
|
|
shun_iwasawa |
6c2748 |
int getAverageCharWidth() { return getCurrentFont()->getAverageCharWidth(); }
|
|
Shinya Kitaoka |
120a6e |
bool hasVertical() { return getCurrentFont()->hasVertical(); }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|