Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.060 Beiträge
 
Delphi 10.4 Sydney
 
#15

AW: Name von Unicode-Zeichen

  Alt 28. Jun 2017, 09:09
Du kannst dich auch mal mit DirectWrite beschäftigen!
Da steckt sehr viel drin, was du sicherlich gebrauchen kannst.

Bspw. hat das IDWriteFont Interface eine HasCharacter-Methode.
Daneben gibt es noch eine Vielzahl weiterer Sachen, die sicherlich weiterhelfen:
https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, System.SysUtils, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Direct2D, Winapi.D2D1;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    function GetCharExists(const Chr: Char): Boolean;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Caption := GetCharExists('').ToString(TUseBoolStrs.True);
end;

function TForm1.GetCharExists(const Chr: Char): Boolean;
var
  hr: HRESULT;
  FontHandle: HFont;
  LogFont: TLogFont;
  GdiInterop: IDWriteGdiInterop;
  WriteFont: IDWriteFont;
  CharacterExists: BOOL;
begin
  Result := False;
  hr := DWriteFactory.GetGdiInterop(GdiInterop);
  if SUCCEEDED(hr) and Assigned(GdiInterop) then
  begin
    FontHandle := Self.Font.Handle;
    if GetObject(FontHandle, SizeOf(LogFont), @LogFont) <> 0 then
    begin
      hr := GdiInterop.CreateFontFromLOGFONT(LogFont, WriteFont);
      if SUCCEEDED(hr) and Assigned(WriteFont) then
      begin
        hr := WriteFont.HasCharacter(Ord(Chr), CharacterExists);
        Result := SUCCEEDED(hr) and CharacterExists;
      end;
    end;
  end;
end;

end.

Geändert von TiGü (28. Jun 2017 um 09:18 Uhr)
  Mit Zitat antworten Zitat