Hi Jonas,
[ and cross-posted to lazarus-list ]
Jonas Maebe wrote 23 lines
I will use this code (listed above) in preference to the latter code, as you state the latter code has a higher probability of data loss.
Show quoted text 9 lines
This is how Rect_low (=0) and LastCharacterDefined (byte) are declared.
unit uFixedWidthFonts;
{$MODE Delphi}
interface
uses
graphics, ExtCtrls, SysUtils, Dialogs, SDL;
const
Rects_low = 0;
Rects_high = 255;
type
PFixedFont = ^TFixedFont;
TFixedFont = object
private
Image: TBitmap;
// [ALVAROGP] Rects redefined as array of class TSDL_Rect
{
Rects: array[Rects_low..Rects_high] of PSDL_Rect;
}
Rects: array[Rects_low..Rects_high] of TSDL_Rect;
public
LastCharacterDefined: byte;
TransparentColor,
TextColor,
BackgroundColor: Tcolor;
// this is used only when UseTransparentBackground is false
Char_width,
Char_height: byte; // default is 8x8
ReverseVideo: Boolean; // default =false
HorizontalGap: byte;
// Horizontal Gap between characters in Pixels -- default =1
UseTransparentBackground: Boolean;
constructor Initialize;
procedure LoadFont(const Fontfile: string);
procedure FreeUpAll;
destructor Finalize;
procedure WriteText2(x, y: integer; Txt: string;
var PaintBox1: TPaintBox);
end;
var
Font1: PFixedFont;Show quoted text 14 lines
I could have used your above code as unknown characters appearing as '?' characters is acceptable.
In summary, unless you are an expert at working with unicode, you should not work with such string at the character/code point level, and use higher level helpers instead to achieve what you want to do. You may want to ask for help about that on the Lazarus mailing list (subscription information at http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus), by describing what exactly it is you want to do rather than showing how you are currently doing it.
I am not a unicode expert, but I am interested to learn new skills.
Yes, I am a member of the Lazarus list. For some reason I got Lazarus and Free Pascal confused and perhaps wrongly assumed that this question was better suited to the FP list.
Jonas_______________________________________________
Thank you.
Peter / pew
fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
