Other Software > Developer's Corner
Delphi / Windows 7 / ColorFonts like Emoji
KodeZwerg:
Does Delphi show the font in the list of fonts in the property editor?-wraith808 (June 20, 2018, 11:42 PM)
--- End quote ---
In short, yes.
Some news update: I am now able to render the emojis correct but Color is missing, look: Delphi / Windows 7 / ColorFonts like Emoji
What i found out is that Font uses Vector-Data to fill painted parts, maby i get it somehow working.
edit
More news, found out that FireFox uses own Library to render Fonts (cairo)..... I'm on it :-)
wraith808:
Just to be clear, I wasn't asking from an I don't know what Delphi is perspective, but from the perspective of someone that worked in it for years before jumping to C#, so I was just asking if it was in the list of fonts. :-[
KodeZwerg:
Just to be clear, I wasn't asking from an I don't know what Delphi is perspective, but from the perspective of someone that worked in it for years before jumping to C#, so I was just asking if it was in the list of fonts. :-[
-wraith808 (June 21, 2018, 02:51 PM)
--- End quote ---
I am sorry if my "In short, yes" reply was rude or did not satisfy. Please give me another chance to answer question more detailed.
Dear wraith808,
thank you for reading, your interest and try to help. Yes my Delphi show up the Emoji Font in Property Editor but cant handle its content correct.
Now i am able to do things with Font like Windows charmap.exe does. (limited/restricted to colorless mode only [black/white])
wraith808:
No offense taken :) Just thought it might be good to give the perspective from which I was asking. Are you using a standard text control to show it?
Also, if you that's what you're doing, you might try to draw the font on a TCanvas, and see how that turns out, i.e.
--- Code: Delphi ---procedure WriteTextOnImage(imgResult: TImage, strTextToOutput: string);var bmpText: TBitmap;begin bmpText:= TBitmap.Create; try bmpText.Canvas.Font := <FontName> bmpText.Canvas.TextOut(X, Y, textToOutput); imgResult.Picture.Assign(bmpText); finally FreeAndNil(bmpText); end; end;
(Keep in mind, it's been many moons since I touched Delphi, so forgive any errors, but the theory should work)
KodeZwerg:
Thank you wraith808, code looks after that many moons quit good! :up:
My bad, i should have written already what i've tried, i've used this method to do Bitmap thingy like you suggested.
--- Code: Delphi ---const CHESS_WHITE_QUEEN = #$2654; CHESS_WHITE_KING = #$2655; CHESS_WHITE_ROOK = #$2656; CHESS_WHITE_BISHOP = #$2657; CHESS_WHITE_KNIGHT = #$2658; CHESS_WHITE_PAWN = #$2659; CHESS_BLACK_QUEEN = #$265A; CHESS_BLACK_KING = #$265B; CHESS_BLACK_ROOK = #$265C; CHESS_BLACK_BISHOP = #$265D; CHESS_BLACK_KNIGHT = #$265E; CHESS_BLACK_PAWN = #$265F; function CharToBitmap(sFontName: String; c: WideChar; cBackColor, cFontColor, cOutlineColor: TColor; OutlineSize: Integer; bmp: TBitmap): Boolean;var r: TRect; OtmSize: Integer; pTm: POutlineTextMetric; LogFont: TLogFont;begin Result := False; //destination rect r := Rect(0, 0, bmp.Width, bmp.Height); //set new font bmp.Canvas.Font.Name := sFontName; bmp.Canvas.Font.Style := [fsBold]; bmp.Canvas.Font.Size := 10; //fill background bmp.Canvas.Brush.color := cBackColor; bmp.Canvas.FillRect(r); //get font metrics OtmSize := GetOutlineTextMetrics(bmp.Canvas.Handle, SizeOf(TOutlineTextMetric), nil); if OtmSize > 0 then begin //reserve memory GetMem(pTm, OtmSize); try pTm^.otmSize := OtmSize; //set size if GetOutlineTextMetrics(bmp.Canvas.Handle, OtmSize, pTm) <> 0 then begin //fill whole height bmp.Canvas.Font.Height := - bmp.Height; BeginPath(bmp.Canvas.handle); SetBKMode(bmp.Canvas.Handle, TRANSPARENT); DrawTextW(bmp.canvas.handle, @c, 1, r, DT_SINGLELINE or DT_CENTER or DT_VCENTER); EndPath(bmp.Canvas.handle); bmp.Canvas.Brush.color := cFontColor; bmp.Canvas.pen.color := cOutlineColor; bmp.Canvas.pen.width := OutlineSize; StrokeAndFillPath(bmp.Canvas.Handle); Result := True; end; finally FreeMem(pTm); end; end;end; procedure TForm1.Button4Click(Sender: TObject);var bmp: TBitmap;begin bmp := TBitmap.create; try bmp.width := 100; bmp.height := 100; //white piece CharToBitmap('Chess Merida Unicode', CHESS_WHITE_BISHOP, clGreen, clBlack, clWhite, bmp.height div 80, bmp); Image1.Picture.Assign(bmp); //black piece CharToBitmap('Chess Merida Unicode', CHESS_BLACK_KING, clGreen, clBlack, clWhite, bmp.height div 80, bmp); Image2.Picture.Assign(bmp); finally bmp.Free; end;end;That code would grab a chess figure out of a font file and render it to a bitmap. Adopted to my Emoji problem it result in B/W images (if at all... somehow buggy)
I guess that what i want to do isnt that easy at all :'(
FireFox lead my way to his cairo library wich lead to GTK+ wich lead to more sub-stuff.
For Windows 8.1 i have working code that draws everything like it should be (utilizing Direct2D) but prior Windows Version simply ignore it. MSDN writes same about ColorFonts.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version