4

I'm new to Delphi & in DelphiXE4 editor I am trying to make chessboard gui on form, using x64 TRectangle for board (alternate colors). I want to add unicode chess pieces but in ObjectInspector properties when I add unicode it displays literally on the form. How can I add Unicode to TText (so the form displays unicode as chess pieces)? (After I want to add dragndrop to TRectangles/unicode chess-any ideas?).

Rectangle63: TRectangle;
Rectangle64: TRectangle;
Text1: TText;
Text2: TText;

Here is screenshot showing problem: DelphiXe4 FMX TRectangle TText Unicode char not displaying

I'm most grateful for help, thanks

EDIT: Jeroen's answer worked to solve this for me (which I did by copy/paste the actual unicode chess piece image into TText text property). I add screenshot of exe so far. Next up I want to add DRAGNDROP to these pieces.....

DelphiXe4 FMX Trectangle TText Unicode Chessboard correct

EDIT2: (Jeroen-font size issue fixed) Fixed unicode black king display-see screenshot: Fixed unicode black king display

4

1 回答 1

3

The Unicode Chess Pieces can be shown in any Delphi application provided you have a fond that contains the Glyphs for the various CodePoints in Unicode representing the Chess Pieces.

Actually, it does not matter what platform or development environment you use, as long as they support Unicode and you have the right font.

You need:

  1. a means to enter these Unicode CodePoints
  2. a font representing these Unicode CodePoints as Glyphs on your target platform

To start with the last, for Microsoft Windows, these fonts work fine:

For entering these there are two approaches on Microsoft Windows:

  1. if you enable it in the registry: enter hexadecimal Unicode CodePoint numbers through Alt-codes on the keyboard
  2. copy/paste them from an application (i.e. Unicode Input: Selection from Screen) that provides them as text

For copy/paste, I often go to a web page with the correct characters using a Web Browser that supports Unicode, or search for them using the Character Map application.

To make copy/paste easier:

  • These are the white pieces: ♔♕♖♗♘♙
  • These are the black pieces: ♚♛♜♝♞♟

Example FireMonkey form with all the pieces in 1 TText in one TTRectangle:

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 480
  ClientWidth = 640
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [dkDesktop, dkiPhone, dkiPad]
  DesignerMobile = False
  DesignerWidth = 0
  DesignerHeight = 0
  DesignerDeviceName = ''
  DesignerOrientation = 0
  object Rectangle1: TRectangle
    Height = 50.000000000000000000
    Width = 80.000000000000000000
    object Text1: TText
      Color = claBlack
      Height = 50.000000000000000000
      Text = #9812#9813#9814#9815#9816#9817#9818#9819#9820#9821#9822#9823
      Width = 80.000000000000000000
    end
  end
end

Edit

I think you have a font size issue in your form file. Create a new question with the text of your form file. Two ways to do that:

  1. open Notepad, and in notepad open the .FMX file that goes with your form; copy the text to the clipboard
  2. In Delphi, right click on the form then choose "View as Text", select all the text and copy it to the clipboard, right click on your form text then select "View as Form".

Paste the code at http://pastebin.com/ or https://gist.github.com/ then post that link in a new question. After that comment here you did and I will take a look.

于 2013-06-19T12:36:00.000 回答