Page 1 of 1

Entering Greek/Math Symbols in Label

Posted: Mon Sep 07, 2015 11:25 am
by algrass
You were right! My text included some math symbols and that was creating the SQL error.

Here is my question:
I have a need to edit some of the dimension settings using a Greek label rather than the measured numerical value. I know I can do this from the Property Editor> Specific Properties and then make the entry into the Label box. This works correctly if the label uses Latin characters but it does not seem to work for a Greek/Math character such as the symbols capital Phi or square root. I tried changing the font type from Helvetica to Arial as I know that Arial has the Greek unicode character set in its character font. However, it does not work.
Any suggestions why it accepts Latin characters, any alpha-numerical, and not Greek/Math characters?

Re: Entering Greek/Math Symbols in Label

Posted: Mon Sep 07, 2015 12:03 pm
by andrew
That's likely an encoding problem, i.e. a mismatch between the encoding of the entered or copy / pasted character and the font that is being used.

QCAD expects characters to be encoded as Unicode. You can enter a π as unicode character by either copying / pasting it from a web site in Unicode (e.g. Wikipedia) or by right-clicking into the text field and choosing Insert Symbol > Pi:
Screen Shot 2015-09-07 at 12.59.23.png
Screen Shot 2015-09-07 at 12.59.23.png (170.48 KiB) Viewed 14265 times

Re: Entering Greek/Math Symbols in Label

Posted: Tue Sep 08, 2015 8:22 am
by algrass
Thanks for your reply.
I thought I was entering Unicode characters as I select them from the "Show Character Viewer" in the Mac, see attached file for some of the common symbols I am using.
Square root symbol is U+221A and Phi is U+1D6BD
Can the file for Insert Symbol be modified by me to increase the list of symbols?
I also tried Arial to see if these characters would show in the label but I get a ? instead. The Arial font set does contains these Unicode symbols. I guess Helvetica does too, but I have not looked at the Helvetica character set in full.

Incidentally, I am quite knowledgeable in font development as I have designed severals Open Type fonts. If there is a specific Font need for QCAD let me know. I can help. I am familiar with Font Creator and Fontlab.
Screen Shot 2015-09-08 at 08.13.53.png
Screen Shot 2015-09-08 at 08.13.53.png (134.4 KiB) Viewed 14254 times

Re: Entering Greek/Math Symbols in Label

Posted: Tue Sep 08, 2015 8:33 am
by algrass
Hi Andrew,

I solved the problem. The character must be chosen directly from the Unicode List (see the attached file in my previous posting) and not from the other filtered lists, even the "Favorites" list. It must mean that once selected from the Unicode list they must lose their Unicode reference and become rasterized images. But choosing from the Unicode list any character can be added to the label. This is a powerful feature. A bit inconvenient for repeating characters as one has to scroll through the Unicode list to find the appropriate subset. This implies that I can alter the original Helvetica font set to remove all the other languages and just retain the Latin and Greek character sets and the symbols sets. This way I avoid having to scroll through the long list of Helvetica. I am not sure whether this is breaking the license rules for Helvetica though. I will think about it. If it does I just assemble my own character set. Trouble is all my font sets are calligraphic sets. Ideally I should use a sans-serif for drawings. I will work on it.
See entry example in attached file.
Screen Shot 2015-09-08 at 08.56.14.png
Screen Shot 2015-09-08 at 08.56.14.png (13.34 KiB) Viewed 14251 times

Re: Entering Greek/Math Symbols in Label

Posted: Tue Sep 08, 2015 9:39 am
by andrew
algrass wrote:Can the file for Insert Symbol be modified by me to increase the list of symbols?
You could add more to the list in the file scripts/WidgetFactory.js, function WidgetFactory.initLineEdit:
var symbols = [
                ["\u00F8", qsTr("Diameter")],
                ["\u00B0", qsTr("Degree")],
                ["\u00B1", qsTr("Plus/Minus")],
                ["\u2248", qsTr("Almost equal to")],
                ["\u2243", qsTr("Asymptotically equal to")],
                ["\u03C0", qsTr("Pi")],
                ["\u00D7", qsTr("Multiplication")],
                ["\u00F7", qsTr("Division")],
                ["\u25FB", qsTr("Square")],
                ["\u0394", qsTr("Delta")],
                ["\\SA^B;", qsTr("Stacked text"), "\\\\SA^B;"]
        ];
Note that changes would be lost after an update. I'm happy to extend this list if you can send your modified file or post the desired list of characters here. Obviously, there's a limit to what number of entries is practical for such a context menu though. Long term, this list should probably be configurable in preferences.

Re: Entering Greek/Math Symbols in Label

Posted: Tue Sep 08, 2015 5:42 pm
by algrass
Hi Andrew,

I found the file WidgetFactory.js and I was able to add the following symbols.

1- u221A SQUARE ROOT SYMBOL
2- u03A6 CAPITAL LETTER PHI
3- u0278 SMALL LETTER phi
4- u03C6 ALTERNATIVE SMALL LETTER PHI
5- u3C9 SMALL LETTER OMEGA

I agree that in the longer term the option of defining characters in Preferences would be best.
I also enclose the modified file.

Which font file is the default for Dimensions Settings> Dimension Label Font? The one shown on the drop box? The reason I ask is that as I was scrolling through the Unicode character sets I came across my ALG initials that I usually embed in my own fonts. But I was using Arial and Helvetica in Preferences and I have not modified those font sets at all. I was therefore baffled to see my copyright initials in what I think was Arial or Helvetica.

Re: Entering Greek/Math Symbols in Label

Posted: Wed Sep 09, 2015 7:34 pm
by Husky
algrass wrote:I agree that in the longer term the option of defining characters in Preferences would be best.
Yep - I would second that too.