Lazarus

Free Pascal => General => Topic started by: falecomleoduarte on February 11, 2019, 01:11:08 pm

Title: characters and size of window
Post by: falecomleoduarte on February 11, 2019, 01:11:08 pm
Hello. I am programming a simple program in Pascal language.
My characters are strange after compiling (on the '' DOS '' screen).
How do I change this?
This problem does not happens in the FPC freepascal. The problem only happens in the lazarus.

Another thing, is it possible to increase the compiled program window? That "DOS" screen.
I need to show some numbers But they disappear for lack of space.
Title: Re: characters and size of window
Post by: Handoko on February 11, 2019, 01:53:36 pm
My characters are strange after compiling (on the '' DOS '' screen).

How strange was it?

Can you please provide more information? The compile-able source code and the screenshot?
Title: Re: characters and size of window
Post by: falecomleoduarte on February 11, 2019, 02:16:59 pm
accent words look strange.
 
Title: Re: characters and size of window
Post by: Michl on February 11, 2019, 03:15:24 pm
If you want to use the default (Lazarus uses UTF-8) codepage for your app, you have to tell your console, that it should use that codepage too. You can create a new unit with this code:
Code: Pascal  [Select][+][-]
  1. unit InitConsoleCodepageUTF8;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. implementation
  8.  
  9. uses windows;
  10.  
  11. const
  12.   LF_FACESIZE = 32;
  13.  
  14. type
  15.   CONSOLE_FONT_INFOEX = record
  16.     cbSize      : ULONG;
  17.     nFont       : DWORD;
  18.     dwFontSizeX : SHORT;
  19.     dwFontSizeY : SHORT;
  20.     FontFamily  : UINT;
  21.     FontWeight  : UINT;
  22.     FaceName    : array [0..LF_FACESIZE-1] of WCHAR;
  23.   end;
  24.  
  25. function SetCurrentConsoleFontEx(hConsoleOutput: HANDLE; bMaximumWindow: BOOL; var CONSOLE_FONT_INFOEX): BOOL; stdcall; external 'kernel32.dll' name 'SetCurrentConsoleFontEx';
  26. var
  27.   New_CONSOLE_FONT_INFOEX : CONSOLE_FONT_INFOEX;
  28.  
  29. initialization
  30.   SetConsoleOutputCP(CP_UTF8);
  31.   SetTextCodepage(Output, CP_UTF8);
  32.   FillChar(New_CONSOLE_FONT_INFOEX, SizeOf(CONSOLE_FONT_INFOEX), 0);
  33.   New_CONSOLE_FONT_INFOEX.cbSize := SizeOf(CONSOLE_FONT_INFOEX);
  34.   New_CONSOLE_FONT_INFOEX.FaceName := 'Lucida Console';
  35.   New_CONSOLE_FONT_INFOEX.FontWeight := 400;
  36.   SetCurrentConsoleFontEx(StdOutputHandle, False, New_CONSOLE_FONT_INFOEX);
  37.  
  38. end.

Then simple implement this unit in your program, like:
Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. uses InitConsoleCodepageUTF8;
  4.  
  5. begin
  6.   WriteLn('Test äöüáí etc');
  7.   ReadLn;
  8. end.  

You can also deactivate the usage of UTF-8, see this http://wiki.freepascal.org/Lazarus_with_FPC3.0_without_UTF-8_mode (http://wiki.freepascal.org/Lazarus_with_FPC3.0_without_UTF-8_mode)
TinyPortal © 2005-2018