summaryrefslogtreecommitdiff
path: root/bk_paper.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2013-03-10 16:58:01 +0000
committerSimon Tatham <anakin@pobox.com>2013-03-10 16:58:01 +0000
commitdcf080aa0e011de37a154e9e8a97dd7546a4a1b1 (patch)
tree891d703334a6d4f4899f058234c52d56cb7bdb3b /bk_paper.c
parent1489dc15967970576d08f3f2b22c6e1c939bcbcf (diff)
downloadhalibut-dcf080aa0e011de37a154e9e8a97dd7546a4a1b1.zip
halibut-dcf080aa0e011de37a154e9e8a97dd7546a4a1b1.tar.gz
halibut-dcf080aa0e011de37a154e9e8a97dd7546a4a1b1.tar.bz2
halibut-dcf080aa0e011de37a154e9e8a97dd7546a4a1b1.tar.xz
Add \s for 'strong' text, i.e. bold rather than italics. I've missed
this a couple of times in Halibut markup recently (in particular, it's handy to have a typographical distinction between 'this term is emphasised because it's new' and 'this term is emphasised because I want you to pay attention to it'), so here's an implementation, basically parallel to \e. One slight oddity is that strong text in headings will not be distinguished in some output formats, since they already use bolded text for their headings. [originally from svn r9772]
Diffstat (limited to 'bk_paper.c')
-rw-r--r--bk_paper.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/bk_paper.c b/bk_paper.c
index 844962e..1ec6bc8 100644
--- a/bk_paper.c
+++ b/bk_paper.c
@@ -237,20 +237,26 @@ static paper_conf paper_configure(paragraph *source, font_list *fontlist) {
ret.fbase.font_size = 12;
ret.fbase.fonts[FONT_NORMAL] = make_std_font(fontlist, "Times-Roman");
ret.fbase.fonts[FONT_EMPH] = make_std_font(fontlist, "Times-Italic");
+ ret.fbase.fonts[FONT_STRONG] = make_std_font(fontlist, "Times-Bold");
ret.fbase.fonts[FONT_CODE] = make_std_font(fontlist, "Courier");
ret.fcode.font_size = 12;
ret.fcode.fonts[FONT_NORMAL] = make_std_font(fontlist, "Courier-Bold");
ret.fcode.fonts[FONT_EMPH] = make_std_font(fontlist, "Courier-Oblique");
+ ret.fcode.fonts[FONT_STRONG] = make_std_font(fontlist, "Courier-Bold");
ret.fcode.fonts[FONT_CODE] = make_std_font(fontlist, "Courier");
ret.ftitle.font_size = 24;
ret.ftitle.fonts[FONT_NORMAL] = make_std_font(fontlist, "Helvetica-Bold");
ret.ftitle.fonts[FONT_EMPH] =
make_std_font(fontlist, "Helvetica-BoldOblique");
+ ret.ftitle.fonts[FONT_STRONG] =
+ make_std_font(fontlist, "Helvetica-Bold");
ret.ftitle.fonts[FONT_CODE] = make_std_font(fontlist, "Courier-Bold");
ret.fchapter.font_size = 20;
ret.fchapter.fonts[FONT_NORMAL]= make_std_font(fontlist, "Helvetica-Bold");
ret.fchapter.fonts[FONT_EMPH] =
make_std_font(fontlist, "Helvetica-BoldOblique");
+ ret.fchapter.fonts[FONT_STRONG] =
+ make_std_font(fontlist, "Helvetica-Bold");
ret.fchapter.fonts[FONT_CODE] = make_std_font(fontlist, "Courier-Bold");
ret.nfsect = 3;
ret.fsect = snewn(ret.nfsect, font_cfg);
@@ -258,16 +264,22 @@ static paper_conf paper_configure(paragraph *source, font_list *fontlist) {
ret.fsect[0].fonts[FONT_NORMAL]= make_std_font(fontlist, "Helvetica-Bold");
ret.fsect[0].fonts[FONT_EMPH] =
make_std_font(fontlist, "Helvetica-BoldOblique");
+ ret.fsect[0].fonts[FONT_STRONG] =
+ make_std_font(fontlist, "Helvetica-Bold");
ret.fsect[0].fonts[FONT_CODE] = make_std_font(fontlist, "Courier-Bold");
ret.fsect[1].font_size = 14;
ret.fsect[1].fonts[FONT_NORMAL]= make_std_font(fontlist, "Helvetica-Bold");
ret.fsect[1].fonts[FONT_EMPH] =
make_std_font(fontlist, "Helvetica-BoldOblique");
+ ret.fsect[1].fonts[FONT_STRONG] =
+ make_std_font(fontlist, "Helvetica-Bold");
ret.fsect[1].fonts[FONT_CODE] = make_std_font(fontlist, "Courier-Bold");
ret.fsect[2].font_size = 13;
ret.fsect[2].fonts[FONT_NORMAL]= make_std_font(fontlist, "Helvetica-Bold");
ret.fsect[2].fonts[FONT_EMPH] =
make_std_font(fontlist, "Helvetica-BoldOblique");
+ ret.fsect[2].fonts[FONT_STRONG] =
+ make_std_font(fontlist, "Helvetica-Bold");
ret.fsect[2].fonts[FONT_CODE] = make_std_font(fontlist, "Courier-Bold");
ret.contents_indent_step = 24 * UNITS_PER_PT;
ret.contents_margin = 84 * UNITS_PER_PT;
@@ -465,24 +477,32 @@ static paper_conf paper_configure(paragraph *source, font_list *fontlist) {
if (fonts_ok(ret.lquote,
ret.fbase.fonts[FONT_NORMAL],
ret.fbase.fonts[FONT_EMPH],
+ ret.fbase.fonts[FONT_STRONG],
ret.ftitle.fonts[FONT_NORMAL],
ret.ftitle.fonts[FONT_EMPH],
+ ret.ftitle.fonts[FONT_STRONG],
ret.fchapter.fonts[FONT_NORMAL],
- ret.fchapter.fonts[FONT_EMPH], NULL) &&
+ ret.fchapter.fonts[FONT_EMPH],
+ ret.fchapter.fonts[FONT_STRONG], NULL) &&
fonts_ok(ret.rquote,
ret.fbase.fonts[FONT_NORMAL],
ret.fbase.fonts[FONT_EMPH],
+ ret.fbase.fonts[FONT_STRONG],
ret.ftitle.fonts[FONT_NORMAL],
ret.ftitle.fonts[FONT_EMPH],
+ ret.ftitle.fonts[FONT_STRONG],
ret.fchapter.fonts[FONT_NORMAL],
- ret.fchapter.fonts[FONT_EMPH], NULL)) {
+ ret.fchapter.fonts[FONT_EMPH],
+ ret.fchapter.fonts[FONT_STRONG], NULL)) {
for (n = 0; n < ret.nfsect; n++)
if (!fonts_ok(ret.lquote,
ret.fsect[n].fonts[FONT_NORMAL],
- ret.fsect[n].fonts[FONT_EMPH], NULL) ||
+ ret.fsect[n].fonts[FONT_EMPH],
+ ret.fsect[n].fonts[FONT_STRONG], NULL) ||
!fonts_ok(ret.rquote,
ret.fsect[n].fonts[FONT_NORMAL],
- ret.fsect[n].fonts[FONT_EMPH], NULL))
+ ret.fsect[n].fonts[FONT_EMPH],
+ ret.fsect[n].fonts[FONT_STRONG], NULL))
break;
if (n == ret.nfsect)
break;
@@ -1619,6 +1639,7 @@ static int paper_width_internal(void *vctx, word *word, int *nspaces)
findex = (style == word_Normal ? FONT_NORMAL :
style == word_Emph ? FONT_EMPH :
+ style == word_Strong ? FONT_STRONG :
FONT_CODE);
if (style == word_Code || style == word_WeakCode) flags |= RS_NOLIG;
@@ -2210,6 +2231,7 @@ static int render_text(page_data *page, para_data *pdata, line_data *ldata,
findex = (style == word_Normal ? FONT_NORMAL :
style == word_Emph ? FONT_EMPH :
+ style == word_Strong ? FONT_STRONG :
FONT_CODE);
if (style == word_Code || style == word_WeakCode) flags |= RS_NOLIG;
@@ -2640,14 +2662,17 @@ static void paper_rdaddw(rdstring *rs, word *text) {
case word_Normal:
case word_Emph:
+ case word_Strong:
case word_Code:
case word_WeakCode:
case word_WhiteSpace:
case word_EmphSpace:
+ case word_StrongSpace:
case word_CodeSpace:
case word_WkCodeSpace:
case word_Quote:
case word_EmphQuote:
+ case word_StrongQuote:
case word_CodeQuote:
case word_WkCodeQuote:
assert(text->type != word_CodeQuote &&
@@ -2656,6 +2681,10 @@ static void paper_rdaddw(rdstring *rs, word *text) {
(attraux(text->aux) == attr_First ||
attraux(text->aux) == attr_Only))
rdadd(rs, L'_'); /* FIXME: configurability */
+ else if (towordstyle(text->type) == word_Strong &&
+ (attraux(text->aux) == attr_First ||
+ attraux(text->aux) == attr_Only))
+ rdadd(rs, L'*'); /* FIXME: configurability */
else if (towordstyle(text->type) == word_Code &&
(attraux(text->aux) == attr_First ||
attraux(text->aux) == attr_Only))
@@ -2671,6 +2700,10 @@ static void paper_rdaddw(rdstring *rs, word *text) {
(attraux(text->aux) == attr_Last ||
attraux(text->aux) == attr_Only))
rdadd(rs, L'_'); /* FIXME: configurability */
+ else if (towordstyle(text->type) == word_Strong &&
+ (attraux(text->aux) == attr_Last ||
+ attraux(text->aux) == attr_Only))
+ rdadd(rs, L'*'); /* FIXME: configurability */
else if (towordstyle(text->type) == word_Code &&
(attraux(text->aux) == attr_Last ||
attraux(text->aux) == attr_Only))