CREATE OR REPLACE FUNCTION test.plot_japanese()
RETURNS void LANGUAGE plr IMMUTABLE AS
$$
library(showtext)
font.paths('R:/') # システムフォルダ以外のフォントを使う
font.add('hana', 'HanaMinA.ttf')
lab = paste(collapse='\n', c(
    '好きな日本語書体で',
    'PostgreSQLとPL/Rから',
    'グラフに書き込み',
    '',
    '(フォント:花園明朝)'))

pdf('R:/japanese_from_plr.pdf')
par(lheight=1.6)
plot(type='n', x=1)

showtext.begin()
text(cex=3,
    family='hana',
    label=lab,
    x=1, y=1)
showtext.end()

graphics.off()
$$;

-- Execute
SELECT test.plot_japanese();