doraTeX / TeX2img

TeX2img for macOS
https://tex2img.tech
Other
26 stars 2 forks source link

CUI版に --margins オプションを加える #49

Closed doraTeX closed 8 years ago

doraTeX commented 8 years ago

#48のコメントを受けて。

pdfcrop と同じ仕様の --margins オプションを加える。

pdfcrop のヘルプメッセージ:

  --margins "<left> <top> <right> <bottom>"                  (0 0 0 0)
                      add extra margins, unit is bp. If only one number is
                      given, then it is used for all margins, in the case
                      of two numbers they are also used for right and bottom.
doraTeX commented 8 years ago

なお、本件とは別ですが Windows 版は最近 --margins オプションが実装されています。 /margins=<VAL> 余白(一括/左右 上下/左 上 右 下) これは pdfcrop.pl と同じようにスマートに余白を指定できる機能です。Mac 版にも付くと嬉しいです。

GUIの設定項目は 左 右 上 下 の順番ですが,CUIの順番は pdfcrop や Windows 版に合わせて 左 上 右 下 でよろしいでしょうか。それともGUIの方を入れ替える?

doraTeX commented 8 years ago

一通り実装し,Ver. 2.0.5 beta 2 としました。

ヘルプメッセージ

  --margins "VALUE(S)"       : set the margins (default: "0 0 0 0")
   *VALUE types:
      a single value : used for all margins
      two values     : left/right top/bottom
      four values    : left top right bottom

これで意味が伝わるでしょうか?

変更点

ヘルプメッセージにおける従来のオプションの表示順序を,

  --left-margin    MARGIN    : set the left margin   (default: 0)
  --top-margin     MARGIN    : set the top margin    (default: 0)
  --right-margin   MARGIN    : set the right margin  (default: 0)
  --bottom-margin  MARGIN    : set the bottom margin (default: 0)

と,左 上 右 下 の順にしました。

同様に,設定値表示についても,

************************************
  TeX2img settings
************************************
Left   margin: 10px
Top    margin: 20px
Right  margin: 30px
Bottom margin: 40px

と,左 上 右 下 の順に変更しました。

一方,GUIのインターフェースは現状は 左 右 上 下 の順のままであり,出力ビューにおける設定値表示もこの順のままです。

doraTeX commented 8 years ago

おっと,上記 Ver. 2.0.5 beta 2 では,

--margins "10     20    30   40"

のように数値の間にスペースを2個以上入れると,認識に失敗するというしょぼいバグがありました。修正します。 (正規表現を使えばそんなこと朝飯前ですが,Snow Leopard でもサポートしようとすると NSRegularExpression が使えず,多少手間がかかるのです……。)

doraTeX commented 8 years ago

修正して Ver. 2.0.5 beta 3 としました。現在のヘルプメッセージは以下の通りです。

tex2img Ver.2.0.5b3
Usage: tex2img [options] InputFile OutputFile
Arguments:
  InputFile  : path of a TeX source or PDF/PS/EPS file
  OutputFile : path of an output file
               (*extension: eps/pdf/svg/jpg/png/gif/tiff/bmp)
Options:
  --latex      COMPILER      : set the LaTeX compiler (default: platex)
   *synonym: --compiler
  --kanji      ENCODING      : set the Japanese encoding (no|utf8|sjis|jis|euc) (default: no)
  --[no-]guess-compile       : disable/enable guessing the appropriate number of compilation (default: enabled)
  --num        NUMBER        : set the (maximal) number of compilation
  --dvidriver  DRIVER        : set the DVI driver    (default: dvipdfmx)
   *synonym: --dviware, --dvipdfmx
  --gs         GS            : set ghostscript (default: gs)
  --resolution RESOLUTION    : set the resolution level (default: 15)
  --margins    "VALUE"       : set the margins (default: "0 0 0 0")
   *VALUE format:
      a single value : used for all margins
      two values     : left/right and top/bottom margins
      four values    : left, top, right, and bottom margin respectively
  --left-margin    MARGIN    : set the left margin   (default: 0)
  --top-margin     MARGIN    : set the top margin    (default: 0)
  --right-margin   MARGIN    : set the right margin  (default: 0)
  --bottom-margin  MARGIN    : set the bottom margin (default: 0)
  --unit UNIT                : set the unit of margins to "px" or "bp" (default: px)
                               (*bp is always used for EPS/PDF/SVG)
  --[no-]transparent         : disable/enable transparent PNG/TIFF/GIF (default: enabled)
  --[no-]with-text           : disable/enable text-embedded PDF (default: disabled)
  --[no-]merge-output-files  : disable/enable merging products as a single file (PDF/TIFF) or animated GIF (default: disabled)
  --animation-delay TIME     : set the delay time (sec) of an animated GIF (default: 1)
  --animation-loop  NUMBER   : set the number of times to repeat an animated GIF (default: 0 (infinity))
  --[no-]delete-display-size : disable/enable deleting width and height attributes of SVG (default: disabled)
  --[no-]keep-page-size      : disable/enable keeping the original page size (default: disabled)
  --pagebox BOX              : set the page box type used as the page size (media|crop|bleed|trim|art) (default: crop)
  --[no-]ignore-errors       : disable/enable ignoring nonfatal errors (default: disabled)
  --[no-]utf-export          : disable/enable substitution of \UTF{xxxx} for non-JIS X 0208 characters (default: disabled)
  --[no-]quick               : disable/enable speed priority mode (default: disabled)
  --[no-]preview             : disable/enable opening products (default: disabled)
  --[no-]delete-tmpfiles     : disable/enable deleting temporary files (default: enabled)
  --[no-]embed-source        : disable/enable embedding of the source in products (default: enabled)
  --[no-]copy-to-clipboard   : disable/enable copying products to the clipboard (default: disabled)
  --[no-]quiet               : disable/enable quiet mode (default: disabled)
  --version                  : display version info
  --help                     : display this message
aminophen commented 8 years ago

CUI 版 2.0.5 beta 3 は正常に動きました。GUI についてはおまかせします。

GUI の「順」というのがなんのことだかしばらく分からなかったのですが、目盛りがあったのを思い出しました(普段余白設定をいじらないので忘れがちなのです)。

doraTeX commented 8 years ago

では,GUI 版はひとまずこのまま据え置き,CUI版はこの仕様で決定といきましょうか。 続いてこれを Snow Leopard 版にも移植します。