texifont.txi 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. \input texinfo.tex @c -*-texinfo-*-
  2. @setfilename texifont
  3. @settitle GNU Texinfo font subsystem
  4. @c Originally written by Oleg Katsidatze and Karl Berry, 2006.
  5. @c Public domain.
  6. @syncodeindex fn cp
  7. @titlepage
  8. @title GNU Texinfo font subsystem
  9. @end titlepage
  10. @contents
  11. @ifnottex
  12. @node Top
  13. @top GNU Texinfo font subsystem
  14. Unfinished chapter on GNU Texinfo font subsystem, also unfinished.
  15. @end ifnottex
  16. @menu
  17. * Font management:: Defining font families.
  18. * Index::
  19. @end menu
  20. @node Font management
  21. @chapter Font management
  22. Texinfo's font management macros allow customization of fonts used in
  23. the printed document.
  24. @menu
  25. * Introduction::
  26. * Font definition macros::
  27. * Font selection macros::
  28. * Font substitution macros::
  29. * Font collections::
  30. * Input encodings::
  31. * Font encodings::
  32. @end menu
  33. @node Introduction
  34. @section Introduction
  35. In this chapter we introduce the basic concepts of font management in
  36. Texinfo.
  37. @menu
  38. * Font features and attributes::
  39. * Current font attribute set::
  40. * Font substitution::
  41. @end menu
  42. @node Font features and attributes
  43. @subsection Font features and attributes
  44. @cindex font feature
  45. @cindex feature, of font
  46. @cindex font attribute
  47. @cindex attribute, of font
  48. Each font can be characterized by a number of @dfn{features}. For
  49. example, a font can be characterized by weight (boldness of glyph
  50. strokes), slant (inclination of glyph strokes), etc.
  51. Font @dfn{attribute} is a particular representation of a feature. For
  52. example, the ``weight'' feature can be represented by attributes
  53. ``light'', ``medium'', ``semibold'', ``bold'', etc.; the ``slant''
  54. feature by attributes ``upright'', ``slanted'', ``italic'', etc.
  55. Most font features describe physical appearance of a font. However,
  56. two special features describe organizational aspects of fonts---font
  57. family and font encoding.
  58. @cindex font family
  59. @cindex family, of font
  60. A collection of related fonts is grouped into a @dfn{font family}.
  61. All fonts in a font family generally have the same or similar design,
  62. representing variations on that particular design. For example, a
  63. font family may include an upright font, an italic font and a bold
  64. upright font. Examples of font families: Computer Modern Roman,
  65. Times, Helvetica.
  66. @cindex font encoding
  67. @cindex encoding, of font
  68. @dfn{Font encoding} specifies the set and the order of characters
  69. represented within a font. Examples of font encodings: OT1 (Latin
  70. upper- and lower-case characters, arabic numerals and some additional
  71. glyphs), T1 (characters of Western-European scripts), T2A (characters
  72. of Cyrillic scripts). For a guide to @TeX{} font encodings, see
  73. @url{http://@/www.ctan.org/@/tex-archive/@/help/@/Catalogue/@/entries/@/encguide.html}.
  74. @node Current font attribute set
  75. @subsection Current font attribute set
  76. At font definition time, each font is associated with a set of
  77. attributes. Naturally, only one attribute can be specified per
  78. feature, but not every feature has to be represented.
  79. A font then can be selected by specifying a list of attributes. At
  80. all times, Texinfo maintains a @dfn{current font attribute set}.
  81. Texinfo provides macros to initialize this set, as well as to modify
  82. it by adding attributes or removing attributes corresponding to
  83. certain features. If a font definition is found which matches every
  84. attribute in the resulting attribute set, the corresponding font is
  85. selected.
  86. For example, let's assume the current font attribute set consists of
  87. the following attributes:
  88. @table @samp
  89. @item CMRoman
  90. ``family'' feature
  91. @item OT1
  92. ``encoding'' feature
  93. @item bold
  94. ``weight'' feature
  95. @end table
  96. @noindent
  97. If now we instruct Texinfo to add attributes @samp{light} and
  98. @samp{italic} and to remove the @samp{encoding} feature, the font
  99. attribute set becomes:
  100. @table @samp
  101. @item CMRoman
  102. @item light
  103. replaces the @samp{bold} attribute of the ``weight'' feature
  104. @item italic
  105. ``slant'' feature
  106. @end table
  107. @noindent
  108. Of course, in order for this font change specification to be
  109. successful, a font must be associated previously with such font
  110. attribute set.
  111. @node Font substitution
  112. @subsection Font substitution
  113. Sometimes it can be convenient to replace some attributes when a font
  114. with a certain set of attributes is requested. For example, a font
  115. family may contain slanted but not italic fonts. If we only define
  116. slanted fonts, all macros explicitly requesting italic font will fail
  117. when such font family is used. But we may decide that it is
  118. acceptable to use slanted fonts wherever italic fonts are being used.
  119. To achieve this, one solution is to create fake italic font
  120. definitions by duplicating definitions of slanted fonts and replacing
  121. the @samp{slanted} attribute with @samp{italic}. An alternative,
  122. simpler solution is to define font substitution, indicating that all
  123. requests for a font with the @samp{italic} attribute should be
  124. satisfied with a font with the @samp{slanted} attribute and all other
  125. font attributes unchanged.
  126. It is possible to specify more complex font substitutions which
  127. replace/add several attributes and/or remove attributes corresponding
  128. to certain features. All defined substitutions are applied in turn,
  129. starting with the current font attribute set, with the later
  130. substitutions performed on the result of the previous, so that it's
  131. possible to define chains of substitutions. Note that font
  132. substitution works with attribute sets; only the final attribute set
  133. is used to look up the corresponding font, so intermediate sets do not
  134. have to be associated with any font.
  135. Unlike font selection, font substitution is ``permissive'', that is,
  136. in order for a font substitution to be applied, its attribute set
  137. doesn't need to match the current font attribute set exactly, it can
  138. just be a subset of the font attribute set. For example, if a font
  139. substitution is defined to apply to the set of two attributes
  140. @samp{CMRoman} and @samp{OT1}, the substitution will also apply to any
  141. of the following attribute sets:
  142. @itemize
  143. @item @samp{CMRoman}, @samp{OT1}, @samp{upright};
  144. @item @samp{CMRoman}, @samp{OT1}, @samp{bold};
  145. @item @samp{CMRoman}, @samp{OT1}, @samp{upright}, @samp{bold};
  146. @end itemize
  147. @noindent
  148. but to none of the following:
  149. @itemize
  150. @item @samp{CMRoman};
  151. @item @samp{OT1};
  152. @item @samp{CMRoman}, @samp{upright};
  153. @item @samp{OT1}, @samp{upright}.
  154. @end itemize
  155. ``Restrictive'' font substitutions, where attribute sets have to mach
  156. exactly, are (currently?) not supported.
  157. @node Other
  158. @subsection Other
  159. @dfn{Scaling factor} is an integer equal to magnification ratio
  160. times@tie{}1000.
  161. @node Font definition macros
  162. @section Font definition macros
  163. @findex newfontarrs
  164. Font attributes can be defined with the command
  165. @example
  166. @@newfontatrrs @var{feature} @var{attribute-list}
  167. @end example
  168. @noindent
  169. where @var{feature} is the font feature to associate the attributes
  170. with, @var{attribute-list} is a comma-separated list of one or more
  171. attributes to define. It is not an error to define an already defined
  172. attribute, as long as that attribute is associated with the same font
  173. feature as before.
  174. For example, the following command
  175. @example
  176. @@newfontattrs encoding OT1,OMS,OML,OMX
  177. @end example
  178. @noindent
  179. defines the classic @TeX{} font encodings. After the above
  180. definition, the following command will be valid:
  181. @example
  182. @@newfontattrs encoding OT1,T1
  183. @end example
  184. @noindent
  185. but the following command will generate an error (feature names are
  186. case-sensitive):
  187. @example
  188. @@newfontattrs Encoding OT1
  189. @end example
  190. @findex newfont
  191. A font can be defined with the command
  192. @example
  193. @@newfont @var{scale} @var{font} @var{size} @var{lskip}[,@var{reduced},@var{small},@var{smaller}] [@var{attr-list}]
  194. @end example
  195. @noindent
  196. Here optional parts are in square brackets. The arguments are as
  197. follows:
  198. @table @var
  199. @item scale
  200. Font's relative scaling factor (see below).
  201. @item font
  202. Font file name (e.g., @file{cmr10}).
  203. @item size
  204. Design size of the font (see below) specified as a @TeX{} dimension or
  205. a number (in which case @TeX{} points are assumed).
  206. @item lskip
  207. Recommended line skip scaling factor which will be multiplied by the
  208. selected font size to get the actual line skip.
  209. @item reduced
  210. Scaling factor for a reduced-size font (``one size smaller''), used
  211. for acronyms. Default is 909 (10/11).
  212. @item small
  213. Scaling factor for a small-size font (``two sizes smaller''), used
  214. for indices, footnotes, small examples, etc. Default is 818 (9/11).
  215. @item smaller
  216. Scaling factor for an even-smaller-size font (``three sizes
  217. smaller''), used for superscripts, subscripts, the @LaTeX{} logo, etc.
  218. Default is 727 (8/11).
  219. @item attr-list
  220. List of attributes to associate with the font. If omitted, attributes
  221. from the last @code{@@newfont} command are applied.
  222. @end table
  223. @i{This scheme doesn't provide for situation when we want different
  224. @var{reduced}, @var{small} and @var{smaller} settings for the same
  225. font for different size ranges.}
  226. @cindex scaling factor, of a font
  227. @cindex font scaling factor
  228. Different font families have different notions of font size. For
  229. example, Bera fonts at 10@dmn{pt} look much bigger than Computer
  230. Modern fonts at 10@dmn{pt}. When mixing fonts and font families,
  231. their sizes must be scaled to achieve visual uniformity. This is what
  232. the relative scaling factor (the first argument of @code{@@newfont})
  233. is for---it specifies the scaling factor which needs to be applied to
  234. a font to match a corresponding font from the Computer Modern
  235. collection of fonts (which are the default fonts of Texinfo).
  236. @i{Maybe it makes better sense to specify @var{scale} for the entire
  237. family and not for individual fonts. Not sure if fonts from the same
  238. family would ever need different scaling factors. One (hypothetical?)
  239. case I can think of is when a font family provides fonts at several
  240. design sizes, and those design sizes scale differently to the
  241. corresponding Computer Modern design sizes, so each design size has to
  242. be tweaked individually.}
  243. @cindex design size, of a font
  244. @cindex size, design, of a font
  245. @cindex font design size
  246. Each font has a @dfn{design size}, which is the size in which the
  247. designer intended the font to be displayed (the @var{size} argument of
  248. @code{@@newfont}). To produce a font in a size other than the design
  249. size, Texinfo can scale a font. Many font families provide fonts in
  250. only one design size, usually 10@dmn{pt}. When fonts are provided in
  251. several design sizes, it is best to define all the provided design
  252. sizes.
  253. For example, Computer Modern Roman font family provides five design
  254. sizes (7@dmn{pt}, 8@dmn{pt}, 9@dmn{pt}, 10@dmn{pt} and 12@dmn{pt}) for
  255. the italic medium-weight face, but only one design size (10@dmn{pt})
  256. for the upright caps and small caps face. The font encoding for both
  257. faces is @acronym{OT1}. Therefore, part of the definition of the
  258. CMRoman font family dealing with italic and caps and small caps faces
  259. might look like the following:
  260. @example
  261. @@newfontattrs family CMRoman
  262. @@newfontattrs encoding OT1
  263. @@newfontattrs slant upright,italic
  264. @@newfontattrs caps normalcaps,capssmallcaps
  265. @@newfont 1000 cmti7 7 1350 CMRoman,OT1,italic,normalcaps
  266. @@newfont 1000 cmti8 8 1300
  267. @@newfont 1000 cmti9 9 1250,1
  268. @@newfont 1000 cmti10 10 1200
  269. @@newfont 1000 cmti12 12 1150
  270. @@newfont 1000 cmcsc10 10 1200 CMRoman,OT1,upright,capssmallcaps
  271. @end example
  272. @node Font selection macros
  273. @section Font selection macros
  274. @findex setfont
  275. @cindex setting current attributes list
  276. @cindex current attributes list, setting
  277. @cindex setting a font
  278. @cindex selecting a font
  279. @cindex font, setting
  280. @cindex font, selecting
  281. The @code{@@setfont} command sets the current attribute list and then
  282. selects the font associated with that list:
  283. @example
  284. @@setfont@{@var{attribute-list}@}
  285. @end example
  286. @findex modfont
  287. If you don't want to specify all attributes but just want to add
  288. certain attributes to the current attribute list and/or remove
  289. attributes for certain features, use the command
  290. @example
  291. @@modfont@{@var{feature-list}@}@{@var{attribute-list}@}
  292. @end example
  293. @noindent
  294. Any attributes corresponding to features from @var{feature-list} will
  295. be removed from the current attribute list, attributes from
  296. @var{attribute-list} will be added to it, and the resulting attribute
  297. list will be used by Texinfo to select a font.
  298. @menu
  299. * Relative font scaling::
  300. @end menu
  301. @node Relative font scaling
  302. @subsection Relative font scaling
  303. @cindex scaling of fonts
  304. @findex fontbasescale
  305. By default, all fonts are scaled to match the Computer Modern fonts,
  306. and the Computer Modern fonts come out at their ``natural'' sizes.
  307. This happens when base font scaling factor is set to 1000, the
  308. relative scaling factor of the Computer Modern fonts. You can set a
  309. different base scaling factor using the command
  310. @example
  311. @@fontbasescale @var{scale}
  312. @end example
  313. @noindent
  314. If @var{scale} is omitted, the current font's relative scaling factor
  315. will be used.
  316. @node Font substitution macros
  317. @section Font substitution macros
  318. Each font substitution consists of three sets: filter (set of
  319. attributes), removed features (set of features) and added attributes
  320. (set of attributes). When selecting a font, Texinfo applies the list
  321. of defined substitutions to the current attribute list, and uses the
  322. resulting attribute list to selects a font.
  323. examines each substitution in turn, applying
  324. those whose filter matches the current attribute list (i.e., those
  325. whose filter contains each attribute from the list) to the result of
  326. the previous substitutions on the current attribute list. The
  327. resulting attribute list as used to select a font.
  328. To add a substitution to the head of the substitution list, use the
  329. command
  330. @example
  331. @@fontsubstpre =@var{filter} -@var{removed-features} +@var{added-attributes}
  332. @end example
  333. The following command adds a substitution to the tail of the
  334. substitution list:
  335. @example
  336. @@fontsubstpost =@var{filter} -@var{removed-features} +@var{added-attributes}
  337. @end example
  338. @node Font collections
  339. @section Font collections
  340. @code{@@declarefontcollection}
  341. @code{@@fontcollection}
  342. @menu
  343. * Font styles::
  344. * Font style selection::
  345. * Font styles for document elements::
  346. @end menu
  347. @node Font styles
  348. @subsection Font styles
  349. @cindex font styles
  350. @cindex styles, fonts
  351. Font styles are a way to apply one of the defined font families to the
  352. text. It is possible to specify font styles for the various elements
  353. of a document individually, such as body text, page headings and
  354. footings, table of contents, indexes, and chapter, section, subsection
  355. and sub-subsection titles.
  356. @menu
  357. * Font style selection::
  358. * Font styles for document elements::
  359. @end menu
  360. @node Font style selection
  361. @subsection Font style selection
  362. Below are the styles defined by Texinfo, with the corresponding
  363. default meanings and commands which select them. All the style
  364. commands take a single argument in braces and typeset it according to
  365. font attributes specified for the style.
  366. @table @samp
  367. @findex serif
  368. @item serif
  369. serifed fonts (CMRoman), applied with @code{@@serif}.
  370. @findex sansserif
  371. @item sans
  372. sans serif fonts (CMSans), applied with @code{@@sansserif}.
  373. @findex t
  374. @item mono
  375. monospace fonts (CMMono), applied with @code{@@t}.
  376. @findex r
  377. @item default
  378. fonts used in absence of any style switches, and applied with
  379. @code{@@r} (CMRoman).
  380. @item math
  381. fonts used in math mode (CMMath), no explicit switches.
  382. @end table
  383. For example, the command
  384. @example
  385. @@sansserif@{text@}
  386. @end example
  387. @noindent
  388. typesets @samp{text} using the @samp{sans} font style (which results
  389. in a sans serif font by default).
  390. @node Font styles for document elements
  391. @subsection Font styles for document elements
  392. It is possible to customize each of the above styles separately for
  393. each element of the document. Texinfo associates styles with the
  394. following elements:
  395. @table @samp
  396. @item *
  397. Default, used for body text. Attributes from this `element' are also
  398. inherited by other elements, unless those elements redefine them.
  399. @item heading
  400. @itemx footing
  401. Page headings and footings.
  402. @item toc
  403. The table of contents.
  404. @item shorttoc
  405. The short table of contents.
  406. @item shorttocchapter
  407. Chapters in the short table of contents.
  408. @item index
  409. Indexes.
  410. @item indexinitials
  411. Initials in the index.
  412. @item title
  413. Document title.
  414. @item chapter
  415. @itemx section
  416. @itemx subsection
  417. @itemx subsubsection
  418. Chapter, section, subsection and sub-subsection titles.
  419. @end table
  420. @findex fontfamily
  421. To associate a font family with a particular style for a particular
  422. document element, use the following command:
  423. @example
  424. @@fontfamily @var{element} @var{style} @var{family}
  425. @end example
  426. @findex fontaxes
  427. To specify which font axes should be used, use the command
  428. @example
  429. @@fontaxes @var{element} @var{style} @var{axes}
  430. @end example
  431. @noindent
  432. where @var{axes} is a comma-separated list of axes, or a single
  433. @samp{.} if none.
  434. @findex fontsize
  435. @findex fontshape
  436. @findex fontweight
  437. The following commands will set font size, shape and weight to be used
  438. for a document element:
  439. @example
  440. @@fontsize @var{element} @var{point-size}
  441. @@fontshape @var{element} @var{shape}
  442. @@fontweight @var{element} @var{weight}
  443. @end example
  444. @findex unsetfonts
  445. Before you start defining font attributes for the styles, it might be
  446. a good idea to @code{@@unsetfonts}, which unsets all font attribute
  447. definitions except the defaults, which are set as follows:
  448. @example
  449. @@fontfamily * default CMRoman
  450. @@fontfamily * serif CMRoman
  451. @@fontfamily * sans CMSans
  452. @@fontfamily * mono CMMono
  453. @@fontfamily * math CMMath
  454. @@fontaxes * default .
  455. @@fontaxes * serif .
  456. @@fontaxes * sans .
  457. @@fontaxes * mono .
  458. @@fontaxes * math .
  459. @@fontsize * 11
  460. @@fontweight * m
  461. @@fontshape * n
  462. @end example
  463. @findex setfonts
  464. @findex resetfonts
  465. After you have finished specifying font attributes for the styles, you
  466. should activate them with @code{@@setfonts}. To revert to the default
  467. styles, call @code{@@resetfonts}.
  468. Below is a complete example of a document style specification.
  469. @example
  470. @@c Use Computer Modern fonts with no axes (the defaults).
  471. @@unsetfonts
  472. @@c The body text will be 12pt medium-weight upright font.
  473. @@fontsize * 12
  474. @@c Page headings are in a smaller italic font; footings are in
  475. @@c smaller upright.
  476. @@fontsize heading 10
  477. @@fontshape heading it
  478. @@fontsize footing 10
  479. @@c TOC is in the default face and smaller; indexes are in the default
  480. @@c face and even smaller.
  481. @@fontsize toc 11
  482. @@fontsize index 10
  483. @@c Font attributes for the title. We are not going to use @@serif,
  484. @@c @@sans, etc., so we don't care about non-default styles.
  485. @@fontfamily title * SomeFunkyFontFamily
  486. @@fontaxes title * of,pf
  487. @@fontsize title 20
  488. @@fontweight title bx
  489. @@fontshape title it
  490. @@c Use sans fonts for chapters, sections and subsections. We exchange
  491. @@c the meanings of @@sans and @@serif.
  492. @@fontfamily chapter * CMSans
  493. @@fontfamily chapter serif CMSans
  494. @@fontfamily chapter sans CMRoman
  495. @@fontfamily chapter math CMBrightMath
  496. @@fontsize chapter 17
  497. @@fontfamily section * CMSans
  498. @@fontfamily section serif CMSans
  499. @@fontfamily section sans CMRoman
  500. @@fontfamily section math CMBrightMath
  501. @@fontsize section 14
  502. @@fontfamily subsection * CMSans
  503. @@fontfamily subsection serif CMSans
  504. @@fontfamily subsection sans CMRoman
  505. @@fontfamily subsection math CMBrightMath
  506. @@fontsize subsection 12
  507. @@c Don't forget to activate the styles.
  508. @@setfonts
  509. @end example
  510. @node Input encodings
  511. @section Input encodings
  512. @node Font encodings
  513. @section Font encodings
  514. @node Index
  515. @unnumbered Index
  516. @printindex cp
  517. @bye
  518. @c Local variables:
  519. @c compile-command: "texi2pdf texifont.txi && xpdf -remote key -raise -reload"
  520. @c End: