Entering Greek/Math Symbols in Label

Drop in here to discuss whatever you want.

Moderator: andrew

Post Reply
algrass
Active Member
Posts: 44
Joined: Mon Aug 10, 2015 8:13 pm

Entering Greek/Math Symbols in Label

Post by algrass » Mon Sep 07, 2015 11:25 am

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?

User avatar
andrew
Site Admin
Posts: 6283
Joined: Fri Mar 30, 2007 6:07 am

Re: Entering Greek/Math Symbols in Label

Post by andrew » Mon Sep 07, 2015 12:03 pm

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 7076 times

algrass
Active Member
Posts: 44
Joined: Mon Aug 10, 2015 8:13 pm

Re: Entering Greek/Math Symbols in Label

Post by algrass » Tue Sep 08, 2015 8:22 am

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 7065 times

algrass
Active Member
Posts: 44
Joined: Mon Aug 10, 2015 8:13 pm

Re: Entering Greek/Math Symbols in Label

Post by algrass » Tue Sep 08, 2015 8:33 am

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 7062 times

User avatar
andrew
Site Admin
Posts: 6283
Joined: Fri Mar 30, 2007 6:07 am

Re: Entering Greek/Math Symbols in Label

Post by andrew » Tue Sep 08, 2015 9:39 am

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.

algrass
Active Member
Posts: 44
Joined: Mon Aug 10, 2015 8:13 pm

Re: Entering Greek/Math Symbols in Label

Post by algrass » Tue Sep 08, 2015 5:42 pm

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.
Attachments
WidgetFactory.js
(39.38 KiB) Downloaded 212 times
Screen Shot 2015-09-08 at 18.12.53.png
Screen Shot 2015-09-08 at 18.12.53.png (102.45 KiB) Viewed 7045 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 2641
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Entering Greek/Math Symbols in Label

Post by Husky » Wed Sep 09, 2015 7:34 pm

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.
Work smart, not hard: QCad Pro

If a thread is considered as "solved" please change the title of the first post to "[solved] Title...". Thanks!

Post Reply

Return to “Chat”