Author Topic: TextView  (Read 5546 times)

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 723
  • ObjAsm Developer
    • ObjAsm
Re: TextView
« Reply #15 on: March 07, 2021, 09:13:43 PM »
Hi
Well, I have to clarify a misunderstanding.  :cool:
RichEdit is basically an edit control that is able to interact with the user and display rich-content.
TextView, on the other hand, was developed to display rich-content in a simple way using markups and handle the resource management automatically. It is not designed as an input control. The lack of this functionality has the great advantage that it is very light and fast. When text entry is required, a classic edit control can do the job.

Biterider

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 723
  • ObjAsm Developer
    • ObjAsm
TextView Controls
« Reply #16 on: March 13, 2021, 06:05:26 PM »
Hi
This is a TextView implementation of simple zoomable controls.

The technique used is a combination of active areas and text callbacks. The latter was implemented in the most recent incarnation of this component.
When a mouse or touch interaction is detected in an active area, the implementation of the control responds by setting the appropriate text using the text callback. In the case of the radio button or check box, Unicode characters of the same width have been used to leave the rest of the text unchanged. This way, no recalculation is required, which saves processing time. The only requirement is that the fonts used are installed on the host system. I used "Lucida Sans Unicode" and "Wingdings" which should be included with every Windows installation.

This is a solution for situations where simple interaction is required in a text-based context.
The bonus point is that since it's text based, it's also zoomable, as seen in the attached demo.

Have fun!

Biterider

LiaoMi

  • Member
  • ****
  • Posts: 922
Re: TextView Controls
« Reply #17 on: March 19, 2021, 06:00:49 AM »
Hi
This is a TextView implementation of simple zoomable controls.

The technique used is a combination of active areas and text callbacks. The latter was implemented in the most recent incarnation of this component.
When a mouse or touch interaction is detected in an active area, the implementation of the control responds by setting the appropriate text using the text callback. In the case of the radio button or check box, Unicode characters of the same width have been used to leave the rest of the text unchanged. This way, no recalculation is required, which saves processing time. The only requirement is that the fonts used are installed on the host system. I used "Lucida Sans Unicode" and "Wingdings" which should be included with every Windows installation.

This is a solution for situations where simple interaction is required in a text-based context.
The bonus point is that since it's text based, it's also zoomable, as seen in the attached demo.

Have fun!

Biterider

Hi Biterider,

I have some elements displayed incorrectly :rolleyes:


Biterider

  • Moderator
  • Member
  • *****
  • Posts: 723
  • ObjAsm Developer
    • ObjAsm
Re: TextView
« Reply #18 on: March 19, 2021, 08:42:50 AM »
Hi LiaoMi
Thanks for your feedback. I have a guess as to what is happening here. The selected characters for the checkboxes are 00A3 and 0052 of "Wingdings 2" font. The former (unchecked checkbox) is used to calculate character width. I see on the "Option 4" line a character that is used when the rendering fails. This smaller character reduces the space for the checked checkbox and that is what we see.

Can you check that you have this font installed and what these characters look like when using for instance the option "insert symbols" of MS-Word?
To find out what happens, I can prepare a binary to display the renderable characters of that font.

Thank you for your support.

Biterider

LiaoMi

  • Member
  • ****
  • Posts: 922
Re: TextView
« Reply #19 on: March 19, 2021, 08:52:35 AM »
Hi LiaoMi
Thanks for your feedback. I have a guess as to what is happening here. The selected characters for the checkboxes are 00A3 and 0052 of "Wingdings 2" font. The former (unchecked checkbox) is used to calculate character width. I see on the "Option 4" line a character that is used when the rendering fails. This smaller character reduces the space for the checked checkbox and that is what we see.

Can you check that you have this font installed and what these characters look like when using for instance the option "insert symbols" of MS-Word?
To find out what happens, I can prepare a binary to display the renderable characters of that font.

Thank you for your support.

Biterider

The font is installed on the system and looks like

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 723
  • ObjAsm Developer
    • ObjAsm
Re: TextView
« Reply #20 on: March 20, 2021, 07:26:14 PM »
Hi LiaoMi
I couldn't find an obvious bug on my side, so I decided to add some debug outputs into the code and redirect them to the console (in case you don't have DebugCenter installed).
I also added all characters of the "Wingdings 2" font to the TextView output and found that not all of them are rendered as they should (compared with MS-Mord) and a square is rendered in place of the expected character.

I am very interested to see how this looks on your system.

Biterider

LiaoMi

  • Member
  • ****
  • Posts: 922
Re: TextView
« Reply #21 on: March 20, 2021, 10:23:17 PM »
Hi Biterider,

Debug view  :arrow_left:

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 723
  • ObjAsm Developer
    • ObjAsm
Re: TextView
« Reply #22 on: March 20, 2021, 10:39:00 PM »
Hi LiaoMi
That is a surprising result. The debug output confirms that the characters reaching the DrawText API are correct.
On my system I can render almost all characters from this font, but on your system it is very different. About half of it cannot be rendered. I've searched the internet and found some evidence of character mapping errors on OS level, but I can't understand how it relates to this effect..
Which OS are you using?

Biterider

LiaoMi

  • Member
  • ****
  • Posts: 922
Re: TextView
« Reply #23 on: March 20, 2021, 11:05:03 PM »
@Biterider

Quote
Which OS are you using?

Windows 10 Enterprise Version 1909 Build 18363.418

A couple more links..
http://www.alanwood.net/demos/wingdings-2.html
https://stackoverflow.com/questions/22092370/windows-form-controls-font-not-changing-for-wingding

Other examples also do not display the font correctly.

LiaoMi

  • Member
  • ****
  • Posts: 922
Re: TextView
« Reply #24 on: March 20, 2021, 11:29:39 PM »

and


But I'm not sure if this is the case here:
Why does some text display with square boxes in some apps on Windows 10?
https://support.microsoft.com/en-us/topic/why-does-some-text-display-with-square-boxes-in-some-apps-on-windows-10-b078a35f-9709-1780-44c0-8c27a58205a2

A fallback font is a font which will be used if your other choices aren't usable
https://github.com/gillesgg/DxFontFallback
https://github.com/gillesgg/DxFontFallback/archive/refs/heads/master.zip


fearless

  • Member
  • ****
  • Posts: 515
    • Github
Re: TextView
« Reply #25 on: March 20, 2021, 11:47:55 PM »
Another option could be to create a minimal font - basically just a font with the glyphs/symbols for windings etc that is required. Then embed the font into the control as data (hence the minimal size) and then use that font - as the font can be loaded as a resource once it is in memory.
fearless

Lian Li PC-O11DW Case, ASUS ROG Crosshair VIII Hero WiFi, AMD Ryzen 9 5950X, 32GB DDR4-3600MHz, MSI RX 5700XT Gaming X, NZXT Kraken Z73 360mm Cooler, Seasonic PRIME 1000W PSU

My Github  Twitter

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 723
  • ObjAsm Developer
    • ObjAsm
Re: TextView
« Reply #26 on: March 21, 2021, 06:40:56 PM »
Hi
This is an interesting problem.
I started testing some other rendering APIs like TextOut and ExTextOut. They solved this problem with Wingdings 2, but introduced some new issues using fonts that behave fine with DrawText or DrawTextEx. In addition, TextOut requires kerning handling, which DrawText does automatically.

I've read some information and documentation on the internet, but it seems that there is no one-size-fits-all solution. :sad:

@fearless: your solution seems to be the most promising, but what puzzles me is that LiaoMi and I have the same font ("Wingdings 2", version 1.55), the same operating system and the same binary file and the result is very different.

I wonder if applications like MS-Word use their own rendering algorithms. I guess so...

Biterider

fearless

  • Member
  • ****
  • Posts: 515
    • Github
Re: TextView
« Reply #27 on: March 21, 2021, 09:29:49 PM »
Couple of font making resources that are free (might require signup to website or mailing list but thats it)

fearless

Lian Li PC-O11DW Case, ASUS ROG Crosshair VIII Hero WiFi, AMD Ryzen 9 5950X, 32GB DDR4-3600MHz, MSI RX 5700XT Gaming X, NZXT Kraken Z73 360mm Cooler, Seasonic PRIME 1000W PSU

My Github  Twitter

LiaoMi

  • Member
  • ****
  • Posts: 922
Re: TextView
« Reply #28 on: March 21, 2021, 09:58:32 PM »
Hi
This is an interesting problem.
I started testing some other rendering APIs like TextOut and ExTextOut. They solved this problem with Wingdings 2, but introduced some new issues using fonts that behave fine with DrawText or DrawTextEx. In addition, TextOut requires kerning handling, which DrawText does automatically.

I've read some information and documentation on the internet, but it seems that there is no one-size-fits-all solution. :sad:

@fearless: your solution seems to be the most promising, but what puzzles me is that LiaoMi and I have the same font ("Wingdings 2", version 1.55), the same operating system and the same binary file and the result is very different.

I wonder if applications like MS-Word use their own rendering algorithms. I guess so...

Biterider

@Biterider

Apart from comparing systems, the last picture shows that the same text on different controls but in the same menu is displayed in different ways, how is this possible, very unusual, I did not notice this before  :biggrin:

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 723
  • ObjAsm Developer
    • ObjAsm
Re: TextView
« Reply #29 on: March 22, 2021, 12:13:58 AM »
Hi
@fearless: thanks for the links. I checked them out. The most promising seems to be "fontforge".

@LiaoMi: I don't have a real explanation right now, but I'm still testing.
On my Win7 installation I get the same result as on Win10. On a raw Win8.1 installation, "Wingdings 2" is not installed by default. After installing it, I get the same result as on the other operating systems.
These are the machines I've access today. Tomorrow I will test on other PCs.

Biterider