What language is this? "\H\I'm a header\N\~" - markup

I am re-writing an ancient (20 yo) interface to meditech. It uses some kind of markup language that I can not find documentation for. Anyone know what it is called or where to find better documentation for it?
What I have figured out so far:
\H\Visible text\N\ => Visible Text in Bold
~ => A new line.
\ZHU\...\N\ => Bold Underline (not sure what z does here maybe indicate multiple flags are present?).
\ZHIU\...\N\ => Bold Italics Underline (not sure what z does).

Related

Prawn with some emojis for ttf-font not rendering text correctly

I have a ruby script to generate a pdf document with some text. The text contains emojis in it.
The problem with the first line of text is that it prints the three emojis separated by something that looks like a cross when they should be a single emoji(family of three members).
The problem with the second line is that it just prints a square instead of the intended emoji(shush face).
I've tried with some other fonts but it still won't work. These are the fonts:
DejaVuSans
ipam
NotoSans-Medium
I can't find the problem
Is there anything missing?
Am I doing something wrong?
The gems are installed and the fonts are in the right place
require "prawn"
require "prawn/emoji"
require "prawn/measurement_extensions"
$pdf = Prawn::Document.new(:page_size => [200.send(:mm),200], :margin => 0)
$pdf.font "./resources/Montserrat-Medium.ttf"
st = "\u{1F468}\u200D\u{1F469}\u200D\u{1F466}".encode("UTF-8")
st2="\u{1F92B}".encode("UTF-8")
$pdf.draw_text st,:at => [10, 100]
$pdf.draw_text st2,:at => [10, 80]
$pdf.render_file "test.pdf"
Turns out Prawn doesn't know how to parse the joined emojis (those formed by the a set of simple emojis joined by \u200D). Prawn/emoji is supposed to do that but there is a bug on the regex used to identify the emojis that causes the joined emojis to be drawn separately.
Also the index and the image gallery used is a little bit outdated.
The solution is to substitute #emoji_index.to_regexp in the class Drawer , in the prawn/emoji source code for a regex that can recognize the joined emojis and update the emoji gallery, after that run the task to update the index and you are good to go.
The fonts have nothing to do with it.
I'm creator of prawn-emoji.
Certainly prawn-emoji v2.1 or older can't draw joined-emojis like 👨‍👨‍👦 and 1️⃣.
https://github.com/hidakatsuya/prawn-emoji/issues/24
So today, i released prawn-emoji v3.0. This release includes support for joined emoji like 👨‍👨‍👦(ZWJ Sequence) and 1️⃣(Combining Sequence), and switch to Twemoji.
Please see below for further details.
https://github.com/hidakatsuya/prawn-emoji/blob/master/CHANGELOG.md
Please try to use prawn-emoji v3.0 if you'd like.
Hope this help.
It does work. You can look up the character codes for deja vu sans.
You can also search for which fonts support which Unicode characters. If you are seeing an empty box with Montserrat-Medium, that means that unicode character is not supported, for example the character, \u200D
Here is a helpful link to search which fonts support that character - http://www.fileformat.info/info/unicode/char/200d/fontsupport.htm
Here is another link for code \u{1F92B}, which is your shush emoji- http://www.fileformat.info/info/unicode/char/1F92B/fontsupport.htm
Both DejaVuSans and Montserrat-Medium dont support it.
require 'prawn'
require 'prawn/emoji'
Prawn::Document.generate 'foo.pdf' do
font "./resources/Montserrat-Medium.ttf"
text "For Montserrat-Medium"
text "\u{1F468}\u200D\u{1F469}\u200D\u{1F466}".encode("UTF-8")
text "\u{1F92B}"
text " "
font './resources/DejaVuSans.ttf'
text " For DejaVuSans"
text "\u{1F468}\u200D\u{1F469}\u200D\u{1F466}".encode("UTF-8")
text "\u{1F92B}"
end

RUBY plain text to Docx with specific formatting

I regularly have to produce word documents that are pretty standard. The content changes regarding certain parameters, but it's always a mix of pre-written stuff. So I decided to write some ruby code to do this more easily and it works pretty well on creating the txt file with the final text I need.
The problem is that I need this text converted to .docx and with specific formatting. So, I'm trying to find a way to indicate in the text file which text should be bold, italic, have different indentation, or be a footnote, to make it easy to interpret (like html does). For example:
<b>this text should be bold</b>
\t indentation works with the tabs
<i>hopefully this could be italic</i>
<f>and I wish this could be a footnote of the previous phrase</f>
However, I haven't been able to do this.
Does anybody know how this can be achieved? I've read about macros and pandoc, but haven't had any luck achieving this. Seems too complicated for macros. Maybe what I'm trying is not the best way. Perhaps with LaTeX or creating html and then converting to word? Can html create footnotes? (that seems to be the most complicated)
I have no idea, I just learned Ruby with a video tutorial, so my knowledge is very limited.
Thanks everybody!
EDIT: Arjun's answer solved almost the whole issue, but the gem he pointed out doesn't include a funcionality for footnotes, which unfortunately constitute a big part of my documents. So if anybody knows a gem that does, would be greatly appreciated. Thanks!
Ahh Ruby got gems for that ;)
https://github.com/trade-informatics/caracal
This would help you to write docs from Ruby code itself.
From the Readme
docx.p 'this text should be bold' do
style 'custom_style' # sets the paragraph style. generally used at the exclusion of other attributes.
align :left # sets the alignment. accepts :left, :center, :right, and :both.
color '333333' # sets the font color.
size 32 # sets the font size. units in 1/2 points.
bold true # sets whether or not to render the text with a bold weight.
italic false # sets whether or not render the text in italic style.
underline false # sets whether or not to underline the text.
bgcolor 'cccccc' # sets the background color.
vertical_align 'superscript' # sets the vertical alignment.
end
There is also this gem, https://github.com/nickfrandsen/htmltoword, which converts plain html to doc files. I haven't tried it though.

BlockComposer.ShowText() doesnt have an option to draw underline text?

I'm using blockComposer.ShowText("foo") to build texts but how to do an underline?
I don't see enough examples on underline text, how do you all make one?
Text decorations (underline, line-through, overline) haven't been supported yet: they are generally considered an ugly and discouraged typographic habit, so that even the PDF spec doesn't natively support them (it all ends up with cosmetic graphic lines placed somewhere near the text glyphs).
It's not that tough job to add them... I simply avoided them in abhorrence, but I fear there shall come the day when I am forced to deal with this ;) ... maybe in forthcoming 0.2.0 version?

How to change the spacing between letters in a NSFont?

I'm trying to change the letter spacing in a NSFont (such as Gill Sans). Is this possible or will I need to load my own custom font?
Though I suppose fonts might specify some kerning hints, kerning is really an attribute of rendered text. So the answer to your question depends on how you're going to render your text to the screen.
If you're using NSAttributedString, you can look at the NSKernAttributeName attribute (see the Constants section in the documentation. If you're using CoreText and CFAttributedString, you can look at the kCTKernAttributeName attribute (see the Constants section in the documentation.
If you're using something else to render text, then the answer (if there is one; not all text rendering methods support advanced customization) will be dependent on that something else.

how to outline a font character in prawn / ruby (pdf)

I would like to draw a character (TTF) as vector and wondering how to perhaps draw the outline of the character. It appears that characters are "filled" with color suggesting the possibility to outline. I've tried stroke_color to no avail. I am using ruby and prawn to render in pdf.
Thanks.
I've been needing this feature myself, so I just added it to prawn. With the caveat that the API may change slightly after feature review from the other devs, here's how it works:
Prawn::Document.generate "rendering_mode.pdf" do |pdf|
pdf.fill_color "00ff00"
pdf.stroke_color "0000ff"
pdf.text("Inline mode", :mode => 1, :size => 40)
end
For a list of valid values to mode, check the code docs for the text_rendering_mode method.
If you want to cherry pick the changes, the specific commit that adds support is at here.

Resources