Skip to content

Commit

Permalink
fix: null handeling in getFont encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
4silvertooth committed Feb 16, 2021
1 parent ef3d3c8 commit 0ac1000
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ sciter::value Doc::loadTTFontFromFile(sciter::astring path, HPDF_BOOL embed) {
return sciter::value::make_string(font_name);
}

sciter::value Doc::getFont(sciter::astring name, sciter::astring encoding) {
sciter::value Doc::getFont(sciter::astring name, sciter::value encoding) {
auto ret = new libharu::Font(pdf, name.c_str(), encoding);
return sciter::value::wrap_asset(ret);
}
Expand Down
10 changes: 5 additions & 5 deletions PDF.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Doc : public sciter::om::asset<Doc> {
int setPassword(sciter::astring, sciter::astring);
sciter::value loadJpegImageFromFile(sciter::astring);
sciter::value loadPngImageFromFile(sciter::astring);
sciter::value getFont(sciter::astring, sciter::astring);
sciter::value getFont(sciter::astring, sciter::value);

SOM_PASSPORT_BEGIN(Doc)
SOM_PASSPORT_FLAGS(SOM_EXTENDABLE_OBJECT)
Expand Down Expand Up @@ -191,12 +191,12 @@ class Font : public sciter::om::asset<Image> {

public:

Font(HPDF_Doc& pdf, const char* name, sciter::astring encoding) {
if(!encoding.empty()){
font = HPDF_GetFont(pdf, name, encoding.c_str());
Font(HPDF_Doc& pdf, const char* name, sciter::value encoding) {
if(encoding.is_null()){
font = HPDF_GetFont(pdf, name, NULL);
}
else {
font = HPDF_GetFont(pdf, name, NULL);
font = HPDF_GetFont(pdf, name, aux::w2a(encoding.to_string()));
}
}
virtual ~Font() {};
Expand Down
1 change: 1 addition & 0 deletions Page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ int Page::drawImage(sciter::value img, sciter::value rect) {
int Page::circle(HPDF_REAL x, HPDF_REAL y, HPDF_REAL radius) {
return HPDF_Page_Circle(page, x, y, radius);
}

}

0 comments on commit 0ac1000

Please sign in to comment.