記事: SATySFiで素敵な文字を出力する(Qiita:zr_Tex8r)
Last active
December 8, 2018 11:21
-
-
Save zr-tex8r/2c1ce5f6ded16a55d1ccb0462c7f4da6 to your computer and use it in GitHub Desktop.
SATySFiで素敵な文字を出力する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdja | |
% '☃'(U+2603)を含むインラインテキスト | |
%※解説の都合上, 出力テキストをマクロに切り出した | |
let-inline \my-test = {少年老い易く☃成り難し} | |
% あとはいつものStdJa.documentの通り | |
in | |
document (| | |
title = {\SATySFi;でゆきだるま文字したい話}; | |
author = {某ゆきだるま者}; | |
show-title = false; show-toc = false; | |
|) '< % 先のマクロを使用 | |
+p {\my-test;} | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdja | |
%% my-set-for-each-script: (script -> context -> context) -> context -> context | |
% setf scr が文脈更新函数値である場合に, my-set-for-each-script setf は | |
% "全てのscript値 scr について setf scr による更新を行う"という更新を行う. | |
let my-set-for-each-script setf ctx = | |
ctx |> setf HanIdeographic |> setf Kana | |
|> setf Latin |> setf OtherScript | |
%% my-set-all-fonts: (script * float * float) -> context -> context | |
% my-set-all-fonts fspec で全ての文字体系に対するフォントを fspec に更新する. | |
% (fspec はフォントを表す3つ組.) | |
let my-set-all-fonts fspec = | |
my-set-for-each-script (fun scr -> set-font scr fspec) | |
%% \my-font: [string; inline-text] inline-cmd | |
% \my-font(fname){...} は引数のテキストをフォント fname で出力する. | |
% ※fname はフォント名で, スケールは1, ベースライン補正は0で決め打ち. | |
let-inline ctx \my-font fname it = | |
let ctx1 = my-set-all-fonts (fname, 1., 0.) ctx in | |
read-inline ctx1 it | |
% 明示的にフォント'ipaexm'を指定した | |
let-inline \my-test = {少年老い易く\my-font(`ipaexm`){☃}成り難し} | |
in | |
document (| | |
title = {\SATySFi;でゆきだるま文字したい話}; | |
author = {某ゆきだるま者}; | |
show-title = false; show-toc = false; | |
|) '< % 先のマクロを使用 | |
+p {\my-test;} | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdja | |
% - $LIBROOT/dist/fonts/ にGenShinGothic-Regular.ttfを置く. | |
% - $LIBROOT/dist/hash/fonts.satysfi-hash に以下の行を追加. | |
%----------------------------------------------------------- | |
% "GenShinGothic": <Single: {"src-dist": "GenShinGothic-Regular.ttf"}>, | |
%----------------------------------------------------------- | |
%% my-set-for-each-script: (script -> context -> context) -> context -> context | |
% setf scr が文脈更新函数値である場合に, my-set-for-each-script setf は | |
% "全てのscript値 scr について setf scr による更新を行う"という更新を行う. | |
let my-set-for-each-script setf ctx = | |
ctx |> setf HanIdeographic |> setf Kana | |
|> setf Latin |> setf OtherScript | |
%% my-set-all-fonts: (script * float * float) -> context -> context | |
% my-set-all-fonts fspec で全ての文字体系に対するフォントを fspec に更新する. | |
% (fspec はフォントを表す3つ組.) | |
let my-set-all-fonts fspec = | |
my-set-for-each-script (fun scr -> set-font scr fspec) | |
%% \my-font: [string; inline-text] inline-cmd | |
% \my-font(fname){...} は引数のテキストをフォント fname で出力する. | |
% ※fname はフォント名で, スケールは1, ベースライン補正は0で決め打ち. | |
let-inline ctx \my-font fname it = | |
let ctx1 = my-set-all-fonts (fname, 1., 0.) ctx in | |
read-inline ctx1 it | |
% \my-test のフォントを'GenShinGothic'に変更する. | |
let-inline \my-test = {少年老い易く\my-font(`GenShinGothic`){☃}成り難し} | |
in | |
document (| | |
title = {\SATySFi;でゆきだるま文字したい話}; | |
author = {某ゆきだるま者}; | |
show-title = false; show-toc = false; | |
|) '< % 先のマクロを使用 | |
+p {\my-test;} | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdja | |
%% my-set-for-each-script: (script -> context -> context) -> context -> context | |
% setf scr が文脈更新函数値である場合に, my-set-for-each-script setf は | |
% "全てのscript値 scr について setf scr による更新を行う"という更新を行う. | |
let my-set-for-each-script setf ctx = | |
ctx |> setf HanIdeographic |> setf Kana | |
|> setf Latin |> setf OtherScript | |
%% my-set-all-fonts: (script * float * float) -> context -> context | |
% my-set-all-fonts fspec で全ての文字体系に対するフォントを fspec に更新する. | |
% (fspec はフォントを表す3つ組.) | |
let my-set-all-fonts fspec = | |
my-set-for-each-script (fun scr -> set-font scr fspec) | |
%% \my-font-script [script; inline-text] inline-cmd | |
% \my-font-script(scr){...} は引数のテキストを"文字体系 scr 用のフォント"で出力する. | |
let-inline ctx \my-font-script scr it = | |
let ctx1 = my-set-all-fonts (get-font scr ctx) ctx in | |
read-inline ctx1 it | |
% "和文(Kana)用と同じフォント"で出力する | |
let-inline \my-test = {少年老い易く\my-font-script(Kana){☃}成り難し} | |
in | |
document (| | |
title = {\SATySFi;でゆきだるま文字したい話}; | |
author = {某ゆきだるま者}; | |
show-title = false; show-toc = false; | |
|) '< % 先のマクロを使用 | |
+p {\my-test;} | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdja | |
%% my-set-for-each-script: (script -> context -> context) -> context -> context | |
% setf scr が文脈更新函数値である場合に, my-set-for-each-script setf は | |
% "全てのscript値 scr について setf scr による更新を行う"という更新を行う. | |
let my-set-for-each-script setf ctx = | |
ctx |> setf HanIdeographic |> setf Kana | |
|> setf Latin |> setf OtherScript | |
%% my-set-all-fonts: (script * float * float) -> context -> context | |
% my-set-all-fonts fspec で全ての文字体系に対するフォントを fspec に更新する. | |
% (fspec はフォントを表す3つ組.) | |
let my-set-all-fonts fspec = | |
my-set-for-each-script (fun scr -> set-font scr fspec) | |
%% \my-force-script [script; inline-text] inline-cmd | |
% \my-force-script(scr){...} は引数のテキストを"文字体系 scr のテキストと同じ扱い"を | |
% 適用した上で出力する. | |
let-inline ctx \my-force-script scr it = | |
let ctx1 = my-set-all-fonts (get-font scr ctx) ctx in | |
script-guard scr (read-inline ctx1 it) | |
%% \my-ja{...}: テキストを"和文扱い"で出力する. | |
let-inline \my-ja it = {\my-force-script(Kana){#it;}} | |
%% \my-al{...}: テキストを"欧文扱い"で出力する. | |
let-inline \my-al it = {\my-force-script(Latin){#it;}} | |
% "和文扱い"で出力する | |
let-inline \my-test = {少年老い易く\my-ja{☃}成り難し} | |
in | |
document (| | |
title = {\SATySFi;でゆきだるま文字したい話}; | |
author = {某ゆきだるま者}; | |
show-title = false; show-toc = false; | |
|) '< % 先のマクロを使用 | |
+p {\my-test;} | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment