In Delphi 2010, I want to display the Greek symbols (alpha, beta, etc.) in TMenuOption and other types of VCL controls.
Assigning
TEdit.Text or TMenuItem.Caption := 'Hydrogen ' + chr(945) + ' More Text'
seems to work fine.
I'm worried that this might won't work on all machines. TEdit has a font property, TMenuItem doesn't, so I'm guessing it uses some default system font.
Should chr(945) always show as the Greek alpha character regardless of font? If not, is there some way for me to assure that the chr(945) always appears on the screen as the alpha character other than hard-wiring the font (which would be tough to do for the system font...)
TIA
You can also use constants. The source files are unicode too so you can add any kind of constant. Just remember to save the source as unicode.
const
alpha = 'α';
beta = 'β';
gamma = 'γ';
Since Delphi 2010 is unicode, chr(945) always point to the same character, in this case Greek Alpha. This character will display correctly if the font that is used to draw the menu item contains that character. There is no risk of another character being drawn, except maybe for the question mark, which is usually used by Windows if a font doesn't contain a specific character.
Most Windows fonts do contain common unicode characters (including Greek). The user might however be able to select a different font that doesn't. You can draw the menu yourself using a different font that is installed on the system, but this might be an awful lot of work for something that will normally work out of the box.
Related
I have a plist file which I decode to load data onto my application.
This plist file contains String type values that gets mapped to UILabel's text property.
I noticed that the truncating behavior of the text in the label is not always the same.
To be more specific, the three dots that are added when the text is truncated are, as opposed to my expectation, two kinds: one being ... and the other being ⋯ which appears to be this unicode character in this link.
I checked UILabel's attribute settings but I was unable to find any settings related to this behavior.
Has anyone else experienced this problem and standardized the truncating character to be ...?
Here is the image describing the problem mentioned above. Both labels have 2 lines and have new line escape character inserted between the first line and the second line of text. I am posting a link to this image because apparently I don't have enough reputation to post an image.
varying truncating characters of UILabel
IMO this is a bug in UILabel, and it may be worth opening a Feedback about it.
TL;DR: I recommend using TTTAttributedLabel.
Long-winded answer, because this was such an interesting question:
UILabel uses a different ellipsis based on the language script being truncated. As you've noticed, for most scripts, they use HORIZONTAL ELLIPSIS (…), or something very similar. But for Chinese, Japanese, and Korean (CJK), they use MIDLINE HORIZONTAL ELLIPSIS (⋯), or again, something very similar. The only other exception I've found is Burmese, which uses three circles that I don't recognize.
In my tests, all the following used …: Latin, Cyrillic, Bengali, Arabic, Hebrew, Hindi, Thai, Kannada, Nepali, and Mongolian (I kid. iOS can't layout Mongolian. Nobody can layout Mongolian, but it still uses …). UILabel even uses … for Lao, even though I thought ຯ was specifically for that, but I guess eventually everything becomes Latin.
The problem with UILabel being so clever for CJK and Burmese is that it decides what character to use exclusively by looking at the first character being removed. And it thinks SPACE is Latin (or at least not "special").
So what to do? My recommendation is probably to use TTTAttributedLabel, since it lets you configure the truncation character, and more importantly, is open source so you can fix it if it's not working the way you want.
The second option would be to truncate the text by hand using techniques like the one described in How to change truncate characters in UILabel?. There are probably better ways to do it using CTFrameGetVisibleStringRange instead of constantly shrinking the string until it fits, but I don't know if it's worth the effort. (If that path sounds useful, I could probably write up something that does it. It's just probably not worth the trouble.)
And the final option I know is to replace the SPACE character with an "equivalent" CJK character. The closest I've found that works is HANGUL FILLER (U+3164), but I don't like it. It's too wide, and I expect that it will make Korean uncomfortable to read (but I rarely try to read Korean, so I may be wrong here):
With SPACE: 안녕 하세요
With FILLER: 안녕ㅤ하세요
There's also HALFWIDTH HANGUL FILLER (U+FFA0), which is better, but UILabel seems to make it zero width (this may be a font issue, so maybe worth trying):
With SPACE: 안녕 하세요
With HALF: 안녕ᅠ하세요
let string = "안녕 하세요"
let filler = "\u{3164}"
label.text = string.replacingOccurrences(of: " ", with: filler)
OTOH, you may run into the same problem if you use any other non-CJK characters, like Latin punctuation or Arabic numerals. So this solution may not scale. And you should make sure that Voice Over properly ignores it.
Is it possible to enter from keyboard special Unicode characters, link the ones below?
U+2603 ☃ SNOWMAN
U+2604 ☄ COMET
U+2605 ★ BLACK STAR
U+2606 ☆ WHITE STAR
U+2607 ☇ LIGHTNING
U+2608 ☈ THUNDERSTORM
U+2609 ☉ SUN
U+260A ☊ ASCENDING NODE
U+260B ☋ DESCENDING NODE
I would like for example to have buttons with up/down arrows in them, without loading images.
I have tried entering Alt+08593 on keyboard but other character (than the expected arrow) will be inserted.
Update:
The reason for this is LAZINESS. I am too lazy to search for icons or create my own icons. For example you can simply replace the notorious 'save' floppy disk icon. Just take a look at: 💾. BAM! Nice. Right?
Update:
It seems some characters such as 📗 (green book = 128215) are not accepted by Delphi, with copy/paste.
Update:
There is nice component that allows you to put unicode chanracters in a image list:
https://github.com/EtheaDev/IconFontsImageList
The Delphi IDE won't accept ALT key codes that high. A couple of alternatives:
Paste the text from somewhere else.
Enter the numeric code directly in the .dfm file.
As an example of the second approach, try this in your .dfm file for the button caption property:
Caption = #8592#8593#8594#8595
You also mention Green Book U+1F4D7. That is from outside the BMP, and hence encoded with a surrogate pair:
Caption = #55357#56535
My guess is that as soon as you want your glyphs to be shown in colour, or at a different size, you will find that using text makes this impossible. You are also likely to encounter fonts that don't contain glyphs for the characters you select. So you will find that using images is the most robust approach.
Or, alternatively, if you had a table of the decimal values:
9731 ☃ SNOWMAN
9732 ☄ COMET
9733 ★ BLACK STAR
9734 ☆ WHITE STAR
9735 ☇ LIGHTNING
9736 ☈ THUNDERSTORM
9737 ☉ SUN
9738 ☊ ASCENDING NODE
9739 ☋ DESCENDING NODE
then you can use the keyboard as follows in Delphi.
To change the caption of Button1 to be the snowman:
Press Alt+F12 to edit the form as text
Press Ctrl+E to enter incremental search mode
Type Button1, or as much of it as is required to locate the definition of Button1
To the right of the Caption = property definition (I'm assuming VCL here) enter # followed by the relevant Unicode value, e.g. #9731
Caption = #9731
If you want text as well as the snowman, the character code goes outside quotes, so e.g.
Caption = 'Snowman = '#9731
More info on the # syntax (which is more commonly entered in Delphi source, rather than in the text view of form files) can be found by reading about control strings, as they are actually called, in the online documentation.
I am just looking to get a better look for my iPad using custom font.
The default Arabic font for iOS8 devices is GeezaPro. and it's in .ttc format.
I am trying to replace it with my custom font.
I use DOSBOX to break system font ttc file into ttf files to make them editable.
Then i use FontLab Studio to replace system font glyphs with my custom font glyphs.
I just copy the glyph from custom font and paste them in the system font (using special paste option FontLab provide).
Then i use DOSBOX again to join these ttf files into ttc file.
That's worked for custom English fonts i used. but using it with arabic fonts show some issues.
The text letters appear separated in iOS apps and everywhere.(as you already know that Arabic language use joined letters and sometimes separated letters depending on the context. if the letter is the first letter it will use specific glyph, the same goes if the letter is in the middle or in the end using different glyph. while in English all letters are always remain separated no matter what. except for handwritten scripts.)
any idea how to fix?
some links:
tutorial I followed to port my fonts
the arabic font I am trying to accomplish (it's free and legit)
P.S: some may say use Bytafont library of fonts but i want to use this specific font. and arabic fonts also limited in the library (20 font only available).
Fonts are complex programs that run on embedded hardware interpreters and font engines (the same way game ROMs run on game hardware or in emulators), and don't just contain the pictures for each letter, but also all the instructions on how to position, combine, and substitute those letters based on what sequence of input it's being told to process.
For almost every font, just copying the glyph outlines is not enough, you also need to make sure that:
the original font's glyph ordering is preserved,
the GPOS table gets copied over (which determines mark positioning, kerning, etc), and
the GSUB table gets copied over (which handles glyph substitution, without which you can't even write Arabic. As an example, you need ـب, ـبـ, بـ or ب depending on context for the same "letter" bā’)
So you generally want to unpack the TTC (which as of OpenType 1.7 can be either truetype or postscript/type2, so that's a thing to remember for the future), then perform the replacements of glyphs (with order-preservation), as well as replacing the GPOS and GSUB tables (using FontForge or TTX) and then pack it back up into the TTC.
I am trying to place an overarrow over a piece of text in MathJax.
I am using a custom font that I declare in the code-
\(\overrightarrow{\style{font-family: mysans, TeX, Arial, sans-serif;}{\text{" + tString + "}}}\)"
It works ok for most letters- for capital W or M , using a couple in a row like "WWW" the overbar is too short.
For lowercase i , using a couple in a row, ie "iii" it is too long. My hunch is that MathJax is using a standard character width size to figure out the length of the overarrow and when the character is much longer or shorter than that size, it calculates the overarrow incorrectly. Is there any way around this?
Thanks!
First off, you generally cannot use custom fonts with MathJax. As the documentation says
Since browsers do not provide APIs to access font metrics, MathJax has to ship with the necessary font data; this font data is generated during development and cannot be generated on the fly. In addition, most fonts do not cover the relevant characters for mathematical layout. Finally, some fonts (e.g. Cambria Math) store important glyphs outside the Unicode range, making them inaccessible to JavaScript.
However, if you are only looking to use custom fonts in text elements, then there is a way to work around this: style the surrounding context and set mtextFontInherit:true for the output jax, cf. e.g. here for HTML-CSS.
Unfortunately, this won't actually help you right now. There's a minor regression in MathJax 2.5 (see this discussion leading to the result you describe). This will be fixed in 2.5.1 and in the mean time you could set noReflows:false for the HTML-CSS output.
I'm working with a TMemo component to display some text in a limited space. Currently it's using a truetype font which doesn't ship with windows and is installed by the app when it runs.
On my PC (Running Windows XP), the spacing between each line of text seems to be about eight pixels. On a different PC running Windows 7, the line spacing seems to be about 14 pixels, which is pushing the bottom row of text out of visibility on the memo.
So, My question is really this:
Is this caused by the different versions of Windows? It's all I could think that was different.
Is there some way I can adjust this value so it would be consistent across all instances of the application, wherever it was running?
Alternatatively, is there a different component I could use which might let me tweak this value?
TMemo is a descendent of Windows Common controls and it's behavior depends on current Windows configuration so it is natural to get different results with it.
If you just want to display some information it's better to use components which let you set texts positions and their style precisely like TRichView. This component is not free but it has it's own text rendering engine and let you style texts with CSS like selectors which look the same in different versions of windows.
In addition to Mohsen's answer I'd like to mention LMD ElPack and it's ElEdit component which also has it's own text rendering engine. Unlike TRichView ElEdit is a plain text edit / memo component, so it's a drop-in replacement for TEdit / TMemo. And line height is configurable there