Skip to content

Commit

Permalink
add support for filled conum glyphs in default theme
Browse files Browse the repository at this point in the history
- add filled (negative) circled numbers to M+ 1mn Regular font
- use correct unicode values for filled conums
- add test for specifying filled conum glyphs
  • Loading branch information
mojavelinux committed Jul 19, 2019
1 parent 2d7d8e1 commit b7b07e5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
Binary file modified data/fonts/mplus1mn-regular-ascii-conums.ttf
Binary file not shown.
3 changes: 2 additions & 1 deletion docs/theming-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,8 @@ The keys in this category are used to control the style of callout numbers (i.e.
. Currently, the font must contain the circle numbers starting at glyph U+2460.
. font-family, font-size, font-style, and line-height are only used for markers in a colist.
These properties are inherited for conums inside a verbatim block.
. The glyphs can be specified as a comma-separated list of ranges, where the range values are Unicode numbers (e.g., \u2460).
. The font must provide the required glyphs.
The glyphs can be specified as a comma-separated list of ranges, where the range values are Unicode numbers (e.g., \u2460).

[#keys-button]
=== Button
Expand Down
4 changes: 1 addition & 3 deletions lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ class Converter < ::Prawn::Document
}
ConumSets = {
'circled' => (?\u2460..?\u2473).to_a,
# 'double-circled' => ...,
'filled' => (?\u278a..?\u2793).to_a + (?\u24eb..?\u24f4).to_a,
# 'parenthesized' => ...,
'filled' => (?\u2776..?\u277f).to_a + (?\u24eb..?\u24f4).to_a,
}
SimpleAttributeRefRx = /(?<!\\)\{\w+(?:[\-]\w+)*\}/
MeasurementRxt = '\\d+(?:\\.\\d+)?(?:in|cm|mm|p[txc])?'
Expand Down
5 changes: 4 additions & 1 deletion scripts/subset-fonts.pe
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,11 @@ while (fi < num_code_fonts)
# Box drawing symbols for unix `tree` output
SelectMore(0u2500,0u257f)
if (new_basename == "mplus1mn-regular")
# Enclosed numbers (1-20)
# Enclosed numbers (1-20 circled and filled)
SelectMore(0u2460,0u2473)
SelectMore(0u2776,0u277f)
SelectMore(0u24eb,0u24f4)
SelectMore(0u278a,0u2793)
new_suffix = "-ascii-conums.ttf"
endif
SelectInvert()
Expand Down
23 changes: 22 additions & 1 deletion spec/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,28 @@
end
end

it 'should allow conum glyphs to be customized' do
it 'should support filled conum glyphs if specified in theme' do
pdf = to_pdf <<~'EOS', pdf_theme: { conum_glyphs: 'filled' }, analyze: true
....
line one <1>
line two
line three <2>
....
<1> First line
<2> Last line
EOS

one_text = pdf.find_text ?\u2776
two_text = pdf.find_text ?\u2777
(expect one_text).to have_size 2
(expect two_text).to have_size 2
(one_text + two_text).each do |text|
(expect text[:font_name]).to eql 'mplus1mn-regular'
(expect text[:font_color]).to eql 'B12146'
end
end

it 'should allow conum glyphs to be specified explicitly' do
pdf = to_pdf <<~'EOS', pdf_theme: { conum_glyphs: '\u0031-\u0039' }, analyze: true
....
line one <1>
Expand Down

0 comments on commit b7b07e5

Please sign in to comment.