Skip to content

Commit

Permalink
Fix #87 - make sure that filename is converted correctly to UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Oct 6, 2021
1 parent add0172 commit 9a6508c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
to devices that doesn't support alpha (notably jpeg) (#91)
* ragg now defers symbol font resolving to systemfonts which makes it possible
to register alternative symbol fonts using `register_font()` (#90)
* Filenames in UTF-8 are now treated correctly on Windows (#87)

# ragg 1.1.3

Expand Down
2 changes: 1 addition & 1 deletion src/jpeg_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SEXP agg_jpeg_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,

BEGIN_CPP
AggDeviceJpegNoAlpha* device = new AggDeviceJpegNoAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand Down
12 changes: 6 additions & 6 deletions src/png_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SEXP agg_png_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,
if (bit8) {
if (R_OPAQUE(bgCol)) { // Opaque bg... no need for alpha channel
AggDevicePngNoAlpha* device = new AggDevicePngNoAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand All @@ -24,7 +24,7 @@ SEXP agg_png_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,
makeDevice<AggDevicePngNoAlpha>(device, "agg_png");
} else {
AggDevicePngAlpha* device = new AggDevicePngAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand All @@ -37,7 +37,7 @@ SEXP agg_png_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,
} else {
if (R_OPAQUE(bgCol)) { // Opaque bg... no need for alpha channel
AggDevicePng16NoAlpha* device = new AggDevicePng16NoAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand All @@ -48,7 +48,7 @@ SEXP agg_png_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,
makeDevice<AggDevicePng16NoAlpha>(device, "agg_png");
} else {
AggDevicePng16Alpha* device = new AggDevicePng16Alpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand All @@ -71,7 +71,7 @@ SEXP agg_supertransparent_c(SEXP file, SEXP width, SEXP height, SEXP pointsize,
BEGIN_CPP
if (R_OPAQUE(bgCol)) { // Opaque bg... no need for alpha channel
AggDevicePng16NoAlpha* device = new AggDevicePng16NoAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand All @@ -83,7 +83,7 @@ SEXP agg_supertransparent_c(SEXP file, SEXP width, SEXP height, SEXP pointsize,
makeDevice<AggDevicePng16NoAlpha>(device, "agg_png");
} else {
AggDevicePng16Alpha* device = new AggDevicePng16Alpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand Down
2 changes: 1 addition & 1 deletion src/ppm_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SEXP agg_ppm_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,

BEGIN_CPP
AggDevicePpmNoAlpha* device = new AggDevicePpmNoAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand Down
8 changes: 4 additions & 4 deletions src/tiff_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SEXP agg_tiff_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,
if (bit8) {
if (R_OPAQUE(bgCol)) { // Opaque bg... no need for alpha channel
AggDeviceTiffNoAlpha* device = new AggDeviceTiffNoAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand All @@ -27,7 +27,7 @@ SEXP agg_tiff_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,
makeDevice<AggDeviceTiffNoAlpha>(device, "agg_tiff");
} else {
AggDeviceTiffAlpha* device = new AggDeviceTiffAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand All @@ -42,7 +42,7 @@ SEXP agg_tiff_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,
} else {
if (R_OPAQUE(bgCol)) { // Opaque bg... no need for alpha channel
AggDeviceTiff16NoAlpha* device = new AggDeviceTiff16NoAlpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand All @@ -55,7 +55,7 @@ SEXP agg_tiff_c(SEXP file, SEXP width, SEXP height, SEXP pointsize, SEXP bg,
makeDevice<AggDeviceTiff16NoAlpha>(device, "agg_png");
} else {
AggDeviceTiff16Alpha* device = new AggDeviceTiff16Alpha(
CHAR(STRING_ELT(file, 0)),
Rf_translateCharUTF8((STRING_ELT(file, 0))),
INTEGER(width)[0],
INTEGER(height)[0],
REAL(pointsize)[0],
Expand Down

0 comments on commit 9a6508c

Please sign in to comment.