unicode ExtTextOut lazarus / 67-Windows ---------------------------------------------------------------------- mobilevil · 2018-04-03 07:51 Hello, I am trying to fix a printing library's unicode issue. it is using ExtTextOut to print a string with character #251 with font winglings. but it is printing blank. I tested with Canvas.TextOut and found that the print out is right if I change the text from String to WideString. so I go back to the library and found that by doing the same String to WideString change, it still doesn't work. Seems I need ExtTextOutW, but how can I access it in lazarus? looks like it is defined in unifunc.inc. procedure TForm1.Button1Click(Sender: TObject); var   wstr:widestring;   str:string;   therect:TRect; begin   wstr:='AB'#251#252;   str:='AB'#251#252;   paintbox1.Canvas.Font.Name:='WingDings';   PaintBox1.Canvas.TextOut(0,0, wstr);   therect:=PaintBox1.Canvas.ClipRect;   ExtTextOut(PaintBox1.Canvas.Handle,0,20,0, @therect, pchar(str),4,nil); end; ---------------------------------------------------------------------- balazsszekely · 2018-04-03 07:55 Try  ExtTextOutW instead of ExtTextOut and PWideChar(wstr) instead of PChar. ---------------------------------------------------------------------- taazz · 2018-04-03 08:06 unifunc.inc is been linked in the windows.pp unit (uses windows) of for a better declaration use something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function ExtTextOutW(aDC: HDC; aX, aY: Integer; aOptions: UINT; aRect: LPRECT; aText: LPCWSTR; aCount: UINT; aDx: LPINT): BOOL; external 'gdi32.dll' name 'ExtTextOutW'; in any of your units and you are good to go. The funny thing is that fpc comes with jwawindows unit which has a proper declaration although a bit of questionable implementation. ---------------------------------------------------------------------- mobilevil · 2018-04-03 08:34 thanks you guys are faster then the printing library's support lol and by using the windows unit, ExtTextOut is able to print the characters with string!? looks like by using the windows unit, the windows API is handling the ExtTextOut, but without the windows unit, it is handled by lazarus/fpc's own implementation? unit Unit1; {$mode objfpc}{$H+} {$i C:\fpcupdeluxe\fpcsrc\rtl\win\wininc\unifun.inc} interface uses   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,   LCLType, LCLIntf   , Windows   ; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     PaintBox1: TPaintBox;     procedure Button1Click(Sender: TObject);   private   public   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); var   wstr:widestring;   str:string;   therect:TRect; begin   wstr:='AB'#251#252;   str:='AB'#251#252;   paintbox1.Canvas.Font.Name:='WingDings';   PaintBox1.Canvas.TextOut(0,0, wstr);   therect:=PaintBox1.Canvas.ClipRect;   ExtTextOut(PaintBox1.Canvas.Handle,0,20,0, @therect, pchar(str),4,nil);   ExtTextOutW(PaintBox1.Canvas.Handle,0,40,0, @therect, PWideChar(wstr),4, nil); end; end. ---------------------------------------------------------------------- balazsszekely · 2018-04-03 08:43 In the code you posted above ExtTextOutW overwrites ExtTextOut: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  ExtTextOut(PaintBox1.Canvas.Handle,0,20,0, @therect, pchar(str),4,nil); ExtTextOutW(PaintBox1.Canvas.Handle,0,40,0, @therect, PWideChar(wstr),4, nil); Did you try without  ExtTextOutW? ---------------------------------------------------------------------- mobilevil · 2018-04-03 08:50 Quote from: GetMem on April 03, 2018, 10:43:55 amIn the code you posted above ExtTextOutW overwrites ExtTextOut: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  ExtTextOut(PaintBox1.Canvas.Handle,0,20,0, @therect, pchar(str),4,nil); ExtTextOutW(PaintBox1.Canvas.Handle,0,40,0, @therect, PWideChar(wstr),4, nil); Did you try without  ExtTextOutW? no they don't overwrite the drawing. note they prints in different Y position. and yes I tried to remove the ExtTextOutW call, it is really the use of windows unit causing the different. with windows unit, ExtTextOut prints the tick fine. without windows unit, ExtTextOut cannot print the tick. ---------------------------------------------------------------------- balazsszekely · 2018-04-03 08:53 Quoteno they don't overwrite the drawing. note they prints in different Y position.True. I did not notice the different y position. Quoteand yes I tried to remove the ExtTextOutW call, it is really the use of windows unit causing the different. with windows unit, ExtTextOut prints the tick find. without windows unit, ExtTextOut cannot print the tick.OK. Thanks for the feedback.