Recent

Author Topic: characters and size of window  (Read 2095 times)

falecomleoduarte

  • New Member
  • *
  • Posts: 14
characters and size of window
« 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.

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: characters and size of window
« Reply #1 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?

falecomleoduarte

  • New Member
  • *
  • Posts: 14
Re: characters and size of window
« Reply #2 on: February 11, 2019, 02:16:59 pm »
accent words look strange.
 

Michl

  • Full Member
  • ***
  • Posts: 226
Re: characters and size of window
« Reply #3 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
Code: [Select]
type
  TLiveSelection = (lsMoney, lsChilds, lsTime);
  TLive = Array[0..1] of TLiveSelection;

 

TinyPortal © 2005-2018