right align does not work properly if there is a "W" or a parenthesis in the text
See original GitHub issueThank you for submitting an issue to jsPDF. Please read carefully.
Are you using the latest version of jsPDF?
using https://rawgit.com/MrRio/jsPDF/master/
Have you tried using jspdf.debug.js?
Steps to reproduce
Try with:
var doc = new jsPDF();
doc.text(10,10, "jspdf version " + jsPDF.version)
doc.setFont("helvetica");
doc.setFontType("bold");
doc.setFontSize(35)
doc.setFontStyle('bold')
doc.text(160,120, "aaaaa bbbbb cccc Wnnnnn\naaaa bbbb cccc nnnn", {align:'right'});
doc.text(160,150, "aaaaa bbbbb cccc wnnnnn\naaaa bbbb cccc nnnn", {align:'right'});
doc.text(160,180, "aaaaa bbbbb cccc wnnnnn\naaaa bbbb Wccc nnnn", {align:'right'});
doc.text(160, 40, ["...","III", "MMM", "M(M)M","M{i}M"],
{align:'right'})
doc.line(160, 0, 160, 190);
Ideally a link too. Try fork this http://jsbin.com/rilace/edit?html,js,output
What I saw
What I expected
In all cases the text lines should be right aligned properly. But it is only the case if there is no “W”.
Issue Analytics
- State:
- Created 5 years ago
- Comments:23 (10 by maintainers)
Top Results From Across the Web
right align does not work properly if there is a "W" or a ... - GitHub
In all cases the text lines should be right aligned properly. But it is only the case if there is no "W".
Read more >html - How to properly align numbers enclosed in parentheses?
One simple solution using html would be to use a table, and align the left most column to the right and the right...
Read more >Aligning Positive and Negative Whole Numbers in a Column
One solution, if you don't have many negative numbers, is to add a right parenthesis to the positive numbers and then simply format...
Read more >siunitx: Alignment Problems with numbers in parenthesis - TeX
The option table-align-text-post = false shifts the *** next to the numbers. In your example the *** and the minus in the column...
Read more >Easily insert a right aligned caption next to an equation in word
Manually insert a right aligned caption next to an equation with Tab · 1. Put the cursor right to the equation, and click...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I played around with patching the kerning tables for helvetica.
But of course this is a bad hack, and best would be indeed to have the right kerning information in src/modules/standard_fonts_metrics.js:317 But I could not find out how …
I dived a bit into the code and found, that somewhere
(
in text is replaced by\(
. The resulting string is used to compute the position in jspdf.debug.js line 13923var getStringUnitWidth = API.getStringUnitWidth = function (text, options) {
I could not find a proper place to fix it …