how does windows deal with drawing chars not in the current font - winapi

I have an app that is trying to display U+23CE (⏎). This is a terminal app, so we are using "Consolas"/"Cascadia"/"Courier". As far as I can see, none of these fonts have this character. And yet, in Visual Studio, when I am debugging this app, it actually displays it correctly in the debugger. Also, when displayed by the new Windows Terminal, it displays correctly. But when I use the app I am working with (actually Putty), it displays the "I don't know this character" glyph.
Putty is a classic Win32 app using ExtTextOutW() to draw that text. I have checked that the correct font is bound to the HDC.
I am assuming that Visual Studio and Windows Terminal are using DirectWrite or other more modern text output logic, but ultimately they have to be getting these unknown glyphs from somewhere.
UPDATE:
I found a font with that character ("Segue UI Symbol"), and if I set Putty to use that font, it displays the missing character (woohoo). Sadly, this is a proportional font, so it looks terrible, and this is not the solution.
#dvix pointed me at a Microsoft page discussing this exact topic, but its not clear which things are done by Windows and which by an app developer. I tried linking "Courier New" (Putty's default) to "Segoe Symbol"", but it made no difference. Does the Putty code need to do all the work itself? Detect an unknown character, read the Registry, and substitute the font for that one char? That is certainly doable, but a pain.

Windows can be directed to "borrow" missing glyphs in a font from another font that carries them using font linking. This applies to both consoles and GUI apps that use GDI (DrawText, ExtTextOut) to render text in Windows 2000 and later.
For example, the following registry entry will link the Consolas font to Segoe UI Symbol (the following can be saved as a .reg file and merged into the registry, will take effect at the next logon).
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
"Consolas"=hex(7):53,45,47,55,49,53,59,4d,2e,54,54,46,2c,53,65,\
67,6f,65,20,55,49,20,53,79,6d,62,6f,6c,00,00
; "Consolas"=REG_MULTI_SZ:"SEGUISYM.TTF,Segoe UI Symbol"
One handy tool to explore coverage of the different fonts is BabelMap. For example this is the list of fonts that carry U+23CE (⏎) on a fairly clean Win10 system.
Another feature of BabelMap is the option to create temporary user-defined composite fonts on the fly, as opposed to the ones "statically" defined in the registry. This is presumably done using the MLang
IMLangFontLink interface, more about that in Raymond Chen's How to display a string without those ugly boxes and Michael Kaplan's Font substitution and linking #2.

Related

Displaying unicode characters in Windows 10 cmd

I want to type and print in windows 10 CMD sinhala unicode characters. but it just display question mark surrounded by a square for each sinhala character i type.
Is there any mechanism to display exact unicode characters in windows console?
Try modifying the registry settings for the cmd console (run regedit). Unfortunately, I am uncertain exactly which value you should enter for the font family, since it is a number.
The screen shot below shows my registry settings for a font of 'Courier New', which somehow translates to 30 (hexidecimal, 48 in base 10) in the registry. Hopefully you can experiment some and determine what number corresponds to a Sinhala font you have installed on your machine.
Additionally, you can select fonts using the cmd window's property dialog, illustrated in the screen shot below. Possibly you already have a font installed that you can use:
You've probably already done 1-3 since you can already type Sinhala, but you need a supporting font. Try the following:
Go to Region & language settings.
Add a language and select, Sinhala.
Click the language, Select Options, and you can select a keyboard type.
For Chinese, I was able to add a language pack, which gave me console fonts that support Chinese. I don't see that option for Sinhala. You may have to manually install a monospace font that support Sinhala. I couldn't find one, but if you do, this answer explains how to install it.

Why some software can display all characters and some not?

Reference text: どうもありがとうございました
Copied to:
Notepad/Notepad++: displays it with no problems
LibreOffice Writer: it changes the font family to work, if you convert to Lucida Console, square boxes appear
Windows: displays it with no problems
Console: it needs the correct chcp and a font family (Lucida Console displays square boxes here too) which can display them if I am right
Is it possible to explain why Notepad can display any text in any font family and LibreOffice + Console cannot? Where is(are) the difference(s)? Is it possible to have the same behaviour on the console as the Notepad does for example?
Some Windows fonts have glyphs for many different scripts, some cover a few scripts, and many cover just one. (Fonts which support many scripts are sometimes called "Unicode fonts," which can be a misleading term. In other OSes, these kinds of fonts are more prevalent. Windows itself doesn't ship with any, though I think you get one or two with the Office suite.)
When you try to output text in multiple scripts using standard Windows functions using one of the well-known fonts, then Windows uses font fallback and/or font linking, which automatically switches between fonts as needed to output the whole string. Most programs, like Notepad and Notepad++, thus get coverage automatically.
I haven't read the LibreOffice code, but I suspect that when you select a font for a span of text, it sticks with that font, effectively preventing Windows's font fallback and font linking mechanisms from helping. This isn't surprising, since a WYSIWYG editor is likely to use lower-level APIs for outputting text in order to have more typographic control. But using the lower-level APIs means you don't get fallback and linking for free, so you'd have to implement it yourself, and that's a lot of extra work that may not be important to very many users.
The Windows console has a lot of legacy and limitations that persist for backward compatibility with older programs. The console mostly emulates DOS systems, which didn't have any sort of Unicode support and instead relied on "Code Pages," which are, roughly speaking, alternate mappings between character values and glyphs. Code Pages are geared at just one (or maybe two) scripts, so if you need characters from another script, you were basically out of luck. I think modern versions of Windows have hacked in some support for a pseudo code page that supports UTF-8, but I've never gotten it to work well and it, too, has limitations.

how to check windows icon file for image quality

I have recently used an icon file received from our marketing team. The icon file when opened in resource editor (Visual Studio 2008) looks like this.
The same file when opened-and-saved in IcoFX appears correctly in resource editor.
My marketing team uses some tools (Picture2Icon ) in Mac and produces the icon file which appears to be corrupt or not fully correct. The same file saved by IcoFx seems to be correct. What is causing the ICOFX out to be correct?
The result is the exe shows bad icons. The exact case where the image is bad is not clear- It is reported in case where color quality is set to be 'medium' (windows XP). It is worse when executable is "selected" in windows explorer.
Here is one icon that shows problem: https://github.com/jayanmn/icontest/blob/master/icontest.ico
Full sample code to create exe is at https://github.com/jayanmn/icontest/
So question is given an ico file, how can I ensure that it works fine on WindowsXP, Windows Vista and Windows7?
I took a good look at your icontest.ico file provided from the GitHub website and discovered that the solution is an easy fix.
First, let me illustrate the problem as I see it on a Windows XP 32bit System using the freeware IrfanView software which is an excellent image viewer for this task.
Here is a composite shot I made illustrating the error for 5 of 6 layers as seen using IrfanView:
To fix the above icontest.ico file, one would think frames 1,2,3,4 and 6 are bad. But the opposite is true! It turns out that frame 5 is the culprit!.
Specifically, frame 5 has compression set on this frame which is causing the issue.
The actual fix that's required is to merely re-save the icontest.ico file without compressing that layer. For this task, the freeware GIMP application which is an excellent image editor is perfect for this task.
Just re-save the icon file with GIMP but remove the compression for the 5th layer as shown below:
The final result is a properly rendered icontestResaved.ico as seen in IrfanView (Tip: To view frames of an icon file in IrfanView, use the Red Arrows that's next to the frame number, i.e. 1/6):
The best way to ensure that the file works in different Windows Operating System's is to actually have a machine available, as the rendering engine is unique and emulators might not work as intended.
For the curious: Setting all layers to be compressed in GIMP resulted in a icon that was not viewable in Windows Explorer.
Tip: To view the reference images above at original size, right mouse-click and choose View Image.
Status Update: Consider installing Axialis IconWorkshop™ Lite Version 6.3.1.1 to handle all your icon development workflow needs. It's a free Visual Studio 2008 Plugin provided by Axialis themselves!

Looking for an "Erase to the Left" symbol for use with Windows Phone 7 Project

I'm looking for an "Erase to the Left" font/character for use with Windows Phone 7 Project. Below is an image of what I'm looking for. Does anyone know if there is a way to use this Character in a WP7 project as a font? I'm looking to avoiding using it as a graphic but I cant find the character in the list of available fonts. I'm just hoping I'm missing something. I'm looking to use it on a button. It's the same one Microsoft uses in its Calculator app.
Thanks
There's an icon to match this (if you flip it use the reflected horizontal ones) in the awesome Windows Phone Icons set by #Templarian: http://templarian.com/project_windows_phone_icons/
http://templarian.com/files/wp_icons/icons/light/appbar.clear.inverse.png
Sorry, but the question is a bit confusing. Using a character "as a font"? "...looking for a 'Delete Character' font..."? I think you might be asking is if any of the available fonts contains this graphic (as a character)? If so, I'm reasonably certain that the answer is "no". For one thing, the graphic is too large to be represented by a character. As #Matt Lacey indicates, what you've posted here is an icon, not a character.
The list of available fonts in Windows Phone (unless Mango brings in additional ones) can be found here:
http://msdn.microsoft.com/en-us/library/ff806365%28v=VS.95%29.aspx
If you can find some character that corresponds to what you want in any of these fonts, then fine, but I don't think you will.
I did my own quick version of this symbol in Expression Blend - it's not perfect but is a Path you can use so you can change the Stroke Colour etc.
<Path Stroke="Black" StrokeThickness="3"
Data="M15.673913,1 L46,1 L46,31 L15.673913,31 L1,15.758064 z M37.624989,8.375 L23.089996,22.91 M23.090002,8.375 L37.624996,22.91"/>
That is not a delete character. Use the standard dustbin/trash can icon as this is the standard delete icon on the platform. If you use this then your users will instantly know what it means. If you use a non-standard icon, at best, you risk confusing your users.
A version of this icon ships with the SDK:
"C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Icons\dark\appbar.delete.rest.png"

How can I delete fonts from my code, under Windows?

This article showed me how to install fonts from a script, but now I'm faced with the problem of removing them. How can I do that ? Any language is ok, I'll convert the info to what I need later.
EDIT: Okay, so I now know how to uninstall fonts ( most of the part at least ). I'm issuing calls to RemoveFontResource. After that I use SendMessage with parameters: 0xffff,0x001D,0,0 ( HWND_BROACAST,WM_FONTCHANGE ... and I forgot what the other two parameters stand for ). The thing is, this deletes the font, but in the Control Panel's Fonts entry, the font still appears there ( even though if you try to delete it from there as well, it will say it cannot read from source file or disk.
So basically, I'm deleting a font in this order:
deleting physically from the C:\Windows\Fonts
calling RemoveFontResource
calling SendMessage
What's the proper way of uninstalling?
From all the documentation I've ever seen those three lines of code are the "proper" way to do it but as we well know it doesn't quite work - as expected.
RemoveFontResource(fontPath);
DeleteFile(fontPath);
::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
REBOOT
I executed the code above and duplicated your problem (control panel still shows the font, however the font file is gone). I then rebooted. Now the font is gone from the Fonts Control Panel applet.
Something else to note: even though control panel still showed the font as "there" applications no longer listed it in their font lists (I specifically tried Wordpad, before and after deleting webdings.ttf - without rebooting)
Yea i know - rebooting is a poor solution - especially if you need to update the Font since you can't reinstall it (via the control panel anyways - it claims the font is still installed) until you reboot after removing it (I tried).
However if all you want to do is remove the font - its not the worst solution - the font is essentially gone after you uninstall it (apps don't see it, its only visible in control panel fonts as far as i can tell) and you wouldn't need to force a reboot.
From the SDK help on RemoveFontResourceFont (which may indicate why the oddness is seen)
If there are outstanding references to
a font, the associated resource
remains loaded until no device context
is using it.
Once you find the actual filename as Havenard mentioned and using the article you mentioned you can do a
objFSO.DeleteFile(FontFilePath);
where FontFilePath is the file path of the file you want to delete.
More Info here:
technet article
A problem that you may run into, which I didn't think of until I saw your comment, is that a program may require that font for some particular item. All known system fonts are stored within the registry. If you remove a font, you should also remove the key from the registry. Registry paths are as follows
Windows 95
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts]
Windows NT
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
The keys are as followed:
Key name = Full name of the font
Key type = REG_SZ
Key Value = name of font file
All your fonts can be found at C:\WINDOWS\Fonts\
Explorer will mask this folder to display the font names instead of the real file names, but its all there. You can edit and comment out the lines of C:\WINDOWS\Fonts\desktop.ini to disable this feature and reveal the font files (maybe you need to reopen the Explorer to take effect).

Resources