要約: | ドキュメントに組み込むことが可能な、カスタム テキスト書式を作成することができます。
カスタム テキスト書式は外部ファイルからインポートすることも可能です。 |
同一の製品、アプリケーションまたは会社に属する複数のドキュメントを作成する場合、外観の一貫性を保持するためには書式の共通テンプレートが必要となります。
- define-text-format は簡単に使用できます。独自の文字、段落および表テキストの書式を定義するのに使用します。テキストの書式設定のみを目的としています。
- define-text-proc は、これに比べて強力な機能を備えています。テキスト プロシージャを作成し、引数を取ってテキスト以外の戻り値を返すことができます。テキスト プロシージャは書式設定を実行し、さらにテキストの書式設定以上の機能を実行できます。
この章では
define-text-format の使用方法を説明します。
define-text-proc およびテキスト プロシージャの詳細は、「
テキスト プロシージャの定義」のセクションを参照してください。
次の構文を使います。
構文: | {define-text-format new-text-format as predefined-text-format
[with option-value-list]
}
|
説明: | - new-text-format は新たに定義するテキスト書式の名前です。
- predefined-text-format は、の新しい書式のベースとなる文字または段落書式です。
- option-value-list は、カンマで区切られたオプションと値のペアのリストで、新しい書式のオプション設定を定義します。new-text-format で使用できるオプションは、predefined-text-format でも使用できます。
|
次の例では文字の書式 emphasis を定義しています。使用されている基本書式は text で、font-style と font-family の文字オプションが設定されています。
例:
文字書式 |
|
{define-text-format emphasis as text with
font-style = "italic",
font-family = "serif"}
{paragraph Because {emphasis mom} said so.}
| |
次の例では文字書式 deprecated を定義しています。使用されている基本書式は monospace で、color と text-line-through? の文字オプションが設定されています。
例:
さまざまな文字書式 |
|
{define-text-format deprecated-code as monospace with
color="red",
text-line-through?=true}
{paragraph
MyClass, {deprecated-code MyHackClass}, MyNewClass}
| |
次の例では段落書式 red-heading および blue-body を定義しています。使用されている基本書式はコア段落書式 paragraph で、paragraph-justify、paragraph-line-spacing、font-weight と color のオプションが設定されています。
例:
段落書式 |
|
{define-text-format red-heading as paragraph with
paragraph-justify = "center",
font-weight = "bold",
color = {FillPattern.get-red}
}
{define-text-format blue-body as paragraph with
paragraph-line-spacing = 2pt,
color = {FillPattern.get-blue}
}
{red-heading THE GETTYSBURG ADDRESS}
{blue-body
Four score and seven years ago our fathers brought forth on this
continent a new nation, conceived in liberty and dedicated to the
proposition that all men are created equal. Now we are engaged in
a great civil war, testing whether that nation or any nation so
conceived and so dedicated can long endure. We are met on a great
battlefield of that war. We have come to dedicate a portion of
that field as a final resting-place for those who here gave their
lives that that nation might live. It is altogether fitting and
proper that we should do this. But in a larger sense, we cannot
dedicate, we cannot consecrate, we cannot hallow this ground. The
brave men, living and dead who struggled here have consecrated it
far above our poor power to add or detract. The world will little
note nor long remember what we say here, but it can never forget
what they did here. It is for us the living rather to be dedicated
here to the unfinished work which they who fought here have thus
far so nobly advanced. It is rather for us to be here dedicated to
the great task remaining before us{em-dash}that from these honored
dead we take increased devotion to that cause for which they gave
the last full measure of devotion{em-dash}that we here highly
resolve that these dead shall not have died in vain, that this
nation under God shall have a new birth of freedom, and that
government of the people, by the people, for the people shall not
perish from the earth.
}
| |
次の例では段落書式 hang-indented を定義しています。使用されている基本書式は paragraph で、paragraph-left-indent と paragraph-first-line-offset のオプションが設定されています。
例:
さまざまな段落書式 |
|
{define-text-format hang-indented as paragraph with
paragraph-left-indent = 0.25in,
paragraph-first-line-offset = -0.25in}
{hang-indented
{italic monster}:1 : an animal or plant of abnormal form
or structure
2 : a threatening force
3 : a living being found under beds in suburban homes
4 : something horrible that awakes by night, eats your food, and
crashes your computer
}
| |
事前定義されたテキスト書式では足りない場合があります。このような場合は新しいテキスト書式を定義するよりも、特定のドキュメント、またはこのドキュメントのすべてのインスタンスに対してテキスト書式を再定義します。
たとえば、斜体の Sans Serif フォントが気に入らないので {italic ...} が呼び出されるときは Serif フォントを使用するとします。
次に示すように、italic を完全に再定義します。
{define-text-format italic as text with
font-style = "italic",
font-family = "serif"}
Curl® 言語が提供する italic の元の定義は次のとおりです。
{define-text-format italic as text with
font-style = "italic"}
このような再定義を行なう場合、新旧両方の定義が同じパッケージ内に存在できないという 1 つの条件があります。この例ではこの条件は自動的に満たされています。「古い」italic 定義は内部パッケージにあり、「新しい」定義は異なるパッケージに確実に存在することになるためです。
このドキュメント内に定義が (呼び出される前に) 存在するか、他のパッケージの一部として
include または
import される限り、
italic を呼び出すと新しい定義が有効になります。
Copyright © 1998-2019 SCSK Corporation.
All rights reserved.
Curl, the Curl logo, Surge, and the Surge logo are trademarks of SCSK Corporation.
that are registered in the United States. Surge
Lab, the Surge Lab logo, and the Surge Lab Visual Layout Editor (VLE)
logo are trademarks of SCSK Corporation.