Skip to content

Fix "Handle_IME"#457

Merged
michaliskambi merged 12 commits into
castle-engine:masterfrom
Freedomax:FixChineseInput
Mar 6, 2023
Merged

Fix "Handle_IME"#457
michaliskambi merged 12 commits into
castle-engine:masterfrom
Freedomax:FixChineseInput

Conversation

@Freedomax
Copy link
Copy Markdown
Contributor

GIF 2023-02-26 08-32-32

Updated code to get caret position of TCastleEdit.
Replaced if vhIMC <> 0 then ... with if vhIMC = 0 then Exit;.Because the nesting of "begin end" is a bit too much.

@Freedomax
Copy link
Copy Markdown
Contributor Author

TextHeight('中Wy') calling TTextureFontData.Glyph will throw a warning:
"Font is missing glyph for character 中 (Unicode number 20013)"

There are several ways to deal with it, I haven't dealt with this warning yet because I'm not sure my way is good .@michaliskambi ,I think you can deal with it yourself.

@michaliskambi
Copy link
Copy Markdown
Member

Thank you!

I added a small commit:

  • Add additional blank lines between nested routines

  • Added as comments 2 of your notes from Fixes for Chinese Input #417 -- to keep this documented in code.

The modification to src/window/windows/castlewindow_winapi.inc is cool for me now.

The modification to TCastleAbstractFont.Measure -- I will want to experiment, and just expose dedicated properties to MeasureRowHeight, MeasureRowHeightBase, MeasureDescend. We need a general solution here, that also works e.g. for fonts that only have digits. Our current solution to this is "you can override Measure method" but this sucks for designing text in editor. And we need a way to customize all these measurements (unless I'll manage to remove RowHeightBase and just make it always RowHeight - Descend).

So, I'll experiment with approach for TCastleAbstractFont.Measure that I'm satisfied with, and then merge it.

@Freedomax
Copy link
Copy Markdown
Contributor Author

The current GetCaretPos is problematic, and many details have been ignored.
If I want to be precise, I need to re-write many code in TCastleEdit.Render, which is unacceptable. Because CGE lacks an interface like TTextService, I need to wait for it to improve it in the future.

@michaliskambi
Copy link
Copy Markdown
Member

michaliskambi commented Feb 27, 2023

If I want to be precise, I need to re-write many code in TCastleEdit.Render, which is unacceptable. Because CGE lacks an interface like TTextService, I need to wait for it to improve it in the future.

Yeah, our text editing should become at some point more feature-rich, with TCastleMemo, and "real" handling of caret and selection common to (at least) TCastleEdit and TCastleMemo. I would like to attack it at some point (but probably after 7.0 release), starting by TCastleMemo, and common code for both TCastleEdit and TCastleMemo.

For now we just have TCastleEdit, and it has the simplest possible caret just always at the end.

Indeed in the future GetCaretPos should be more aware of where is text exactly (so that e.g. paddings etc. in TCastleEdit are accounted). But that's minor, it can indeed wait until we have more features around TCastleEdit and TCastleMemo :)

michaliskambi added a commit that referenced this pull request Mar 3, 2023
- Design in editor testing TCastleLabel, TCastleText, TCastleEdit
- Design in editor international fonts
- Do not complicate code with generating font to Pascal, focus on loading font from OTF/TTF in data
- Do not show X3D explicitly, but show TCastleText with both international and Chinese
- Show TCastleEdit with both international and Chinese
- Added nice screenshot and README

See #457
michaliskambi added a commit that referenced this pull request Mar 6, 2023
- RowHeight->Height
- RowHeightBase->CapHeight
- Descend->DescenderHeight

( Follow standard names --
https://en.wikipedia.org/wiki/Metric_typographic_units
https://fonts.google.com/knowledge/glossary
https://en.wikipedia.org/wiki/Cap_height
https://fonts.google.com/knowledge/glossary/cap_height
https://www.onlineprinters.co.uk/magazine/font-sizes/
)

- Published properties to influence how they are calculated easily: MeasureHeight, MeasureCapHeight, MeasureDescenderHeight

- Also completely removed measuring from TTextureFontData, it doesn't have enough information for it, it should never measure

See #457
michaliskambi added a commit that referenced this pull request Mar 6, 2023
Copy link
Copy Markdown
Member

@michaliskambi michaliskambi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging, thank you!

As for modification how is font measured: I did a few improvements to it in CGE, you can now modify MeasureHeight and MeasureCapHeight properties to influence this comfortably (from code or from editor).

Zrzut ekranu z 2023-03-06 04-48-07

Check out new examples/fonts/test_local_characters/ .

@michaliskambi michaliskambi merged commit 797ae08 into castle-engine:master Mar 6, 2023
@Freedomax Freedomax deleted the FixChineseInput branch March 6, 2023 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants