add Page::setTTFont

This commit is contained in:
Alex Fabijanic
2017-11-26 21:46:30 -06:00
parent 36b39d0623
commit 92087fae18
2 changed files with 12 additions and 3 deletions

View File

@@ -203,7 +203,11 @@ public:
/// Sets the font. /// Sets the font.
void setFont(const std::string& fontName, float size, const std::string& encoding = ""); void setFont(const std::string& fontName, float size, const std::string& encoding = "");
/// Sets the font. /// Sets the font. The name must be a valid Base14 PDF internal font.
void setTTFont(const std::string& name, float size, const std::string& encoding = "UTF-8", bool embed = true);
/// Sets the external true type font. Name must be a valid path to .ttf file.
/// If embed is tru, font will be embedded int othe document.
float textWidth(const std::string& text); float textWidth(const std::string& text);
/// Returns the width of the supplied text. /// Returns the width of the supplied text.

View File

@@ -108,8 +108,13 @@ float Page::textWidth(const std::string& text)
void Page::setFont(const std::string& name, float size, const std::string& encoding) void Page::setFont(const std::string& name, float size, const std::string& encoding)
{ {
Font font(&_pDocument->handle(), HPDF_GetFont(_pDocument->handle(), name.c_str(), encoding.empty() ? 0 : encoding.c_str())); setFont(_pDocument->font(name, encoding), size);
setFont(font, size); }
void Page::setTTFont(const std::string& name, float size, const std::string& encoding, bool embed)
{
setFont(_pDocument->font(_pDocument->loadTTFont(name, embed), encoding), size);
} }