Psychtoolbox not drawing German Umlauts - non-ascii-characters

I am presenting a German Text in Psychtoolbox. The special characters (Umlauts) are not displaying properly with the DrawText nor DrawFormattedText. The characters are recognized correclty by Matlab when I read in a .txt file to a char cell struct, but Psychtoolbox substututes then the characters with other symbols.
Has anyone solved this issue before?
Thank you!

We just found a solution. If the text is stored in the variable "message"
message='öäüßÄÖÜ'
Display text by casting message as uint8()
DrawFormattedText(w, uint8(message)); % Use uint8() to display Umlaute and other non-ascii signs (UTF-8) by passing as uint8
instead of DrawFormattedText(w, message);** % does not work with Umlaute etc.
Use font that displays all characters, e.g. Arial
Screen('TextFont', w, 'Arial', 1); % Dont use Helvetica, does not show uppercase ÄÖÜ properly (even after converting it to uint8)
Best, Kai

Related

How to display multi character unicode emojis in Overleaf LaTex?

So apparently Overleaf now can render emojis using packages of Noto Color Emojis, where you can use {\NotoEmoji \symbol{"1F343} \symbol{"1F338} } to input an emoji with corresponding unicodes.
My question is how to input complex emojis that are composed of multiple emojis? For example, this one 👩‍👩‍👦‍👦, the unicode is U+1F469‍ U+200D U+1F469‍ U+200D U+1F466‍ U+200D U+1F466.
I've tried combinations like
\symbol{"1F469‍200d1f469200d...1f466}
\symbol{"1F469 200d 1f469 200d...1f466}
\symbol{"1F469} \symbol{"200d}...\symbol{"1f466}}
But none of them works.
You don't need to concatenate them. Here's the solution that I tried in Overleaf and it worked fine.
{\Large
\NotoEmoji
% family emoji
\symbol{"1F468}\symbol{"200D}\symbol{"1F469}\symbol{"200D}\symbol{"1F467}\symbol{"200D}\symbol{"1F466}
}
Expected Output
👨‍👩‍👧‍👦 Family: Man, Woman, Girl, Boy,
You can use the same trick for Emoji Skin Tone Modifiers in Overleaf where the modifier comes right after the emoji Unicode.
{\Large
\NotoEmoji
% Waving Hand emoji
\symbol{"1F44B}%
% Waving Hand: Light Skin Tone
\symbol{"1F44B}\symbol{"1F3FB}
}
Expected Output
👋
👋🏻
Here's the Overleaf Project page about Displaying Color Emojis in Latex that you can check out.
Updated 2020-11-28 : Adding emoji as an image in Latex
Since you mentioned adding emojis as images, I'm also including my solution for that.
\usepackage{tcolorbox}
% change font size here
\includegraphics[height=12]{family-man-woman-girl-boy.png}
The image can be downloaded from EmojiPedia.

What the character codes are in the cmap table in TrueType fonts

Wondering what the "character codes" are for the cmap table in TrueType fonts. Microsoft talks about the Character to Glyph Index Mapping Table, but I don't see what the character or glyph index mean.
Wondering if somewhere in the font file you specify the encoding, such as Unicode 11.0, and then the character codes are equal to the Unicode code points such as U+0061 for a. Or if the character codes are instead the "browser" character codes (decimal codes I guess), such as 97 for a.
Basically wondering how you map keyboard characters to font glyphs, and what that really means. I think you not so much want to map keyboard codes to the font glyphs, but unicode codes like U+0061 to the font glyphs, so if in JavaScript (for example) you can do \u03A9 and it will give you Ω if your font supports that.
Trying to understand the anatomy of a font file in terms of how it maps the mathematical glyphs as vectors/paths, to characters or codes of some sort.
The short, but perhaps not desired, answer is of course "read the OpenType spec. It takes a while", so a slightly longer, but easier and less detailed answer would be http://pomax.github.io/CFF-glyphlet-fonts, although that skips over TTF so let's look at that here:
Your input code gets run through whatever is the applicable CMAP given the context you're applying the font to, which maps the computer's code (ascii code, unicode code point, ISO-2022-jp, what have you) to a glyph id. For TTF specifically, that id is then used as array offset in the "loca" table, which is the "glyph index to data location" table and specifies the byte offset in the "glyf" table for each glyph that the font contains. You then consult the glyf table at that byte offset, and start parsing the bytes as specified by https://learn.microsoft.com/en-us/typography/opentype/spec/glyf

How to make fontsize bigger for one letter in matlab plot title

I want to make \mu to appear the same size as the other letters, how can i do that?
title('Größen-Parameter x in dem spongiösen Knochen(300\mum, 600\mum und 2000\mum)');
To answer the question in the title:
You can adjust the font size of a letter (or a text of any length) with {\fontsize{size},letter}. E.g.:
title('Größen-Parameter x in dem spongiösen Knochen(300{\fontsize{14}\mu}m, 600{\fontsize{14}\mu}m und 2000{\fontsize{14}\mu}m)');
However, your actual problem seems to be that the mu's appear slightly smaller than the rest of the text. The reason for this is that Matlab by default interprets normal text as literal characters (WYSIWYG) while using a latex interpreter if you call a latex command such as \mu. This causes those letters to be displayed differently.
Of course you can just increase the size of those letters, but that's not very elegant and the letters will still have a different style. As an alternative I would suggest using a Latex interpreter for the whole text - aside from solving your problem, it will also look nicer!
title('Groessen-Parameter x in dem spongioesen Knochen (300 $\mu$m, 600 $\mu$m und 2000 $\mu$m)','interpreter','latex');
The only problem are your german special characters (ö and that double s thingy). To display those correctly you would have to load the german language package ngerman. This isn't easy but there are instructions here. However, if you are using a german matlab (if that's a thing) it might work without that.

font with graphic "blackspace" character

I'm looking for a font which contains a graphic character which is (essentially), the space character, inverted. I'm looking for a graphic character equivalent to the largest-possible solid-black box. The closest I have been able to find is Wingings 2 character 162, but that doesn't fill the entire available character space. When I insert two consecutive Wingdings 2 162 characters, there is still appreciable whitespace between them when displayed or printed. Does anyone know of a black-box font/character which would fill all available character space?
All characters are going to have whitespace between them, or they would be unreadable. This is called "kerning". You can adjust the kerning and line-height in whatever program you are using to send the malicious fax, if you want to be sure to use the maximum amount of toner per page.
Have you considered creating your own font using a software package like this or like this? You could edit the space character to be a solid black square. But as Chris McCall mentioned, you may still have space between characters of any size due to kerning applied by the layout engine that draws the fonts.
You other option is to owner draw your own text and programmatically replacing spaces with black boxes. You would have complete control over kerning and everything else.
I don't know if this is exactly what you were looking for, but...
I was looking for the same thing, since I wanted to create a "textbox" when I wanted to write text using the spritefont, but I never knew how long the total string was going to be, so I wanted something that I could "write" in the same location right before the string with a contrasting color which could be expected to be as long as the string it needed to encompass. That being the case, try:
Webdings - character 103.
I tried lining them up and there wasn't even any space in between. Perfect.

How is transformation of code point to final character implemented in Unicode?

Characters included in BMP as specified by 4 digits,
and those characters outside of BMP contains 5 or 6 digits.
But my doubt is:
how is the finanal character drawed from value of code point?
Are the pictures of each character restored in each computer and when displaying just show the matching picture?
Or the final glyph is a computed result of code point itself?
Each Unicode character has a code. The software displaying the character obtains a glyph for that character code - usually from a font installed onto the hosting computer. It then uses the obtained glyph to display the character.
If it can't find a glyph for that character (many fonts for Latin characters completely omit the glyphs used for East Asian languages characters) it formally can't display it. It will then either indicate error or use a supplement glyph meaning that the actual glyph can't be displayed (it can be a question mark or a square or whatever).