fpmake: added c-style operators compiler switch (thanks to Kambi)

glfreetype: added more verbose error message (thanks to Kambi)
added Ubuntu-R.ttf to SVN
started work on a base font class

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2232 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blaszijk
2012-01-06 19:53:46 +00:00
parent 852efcdf25
commit c3e857b8c9
4 changed files with 84 additions and 1 deletions

View File

@ -19,6 +19,7 @@ begin
P.Version := '1.00';
//P.Options.Add('-MObjFPC');
P.Options.Add('-Sc');
if NV_DEBUG then
for i := 0 to High(NV_DEBUG_FLAGS) do
@ -29,6 +30,7 @@ begin
P.Options.Add(NV_PROFILE_FLAGS[i]);
//base widget units
P.Targets.AddUnit('./nvwidgets/nvbasefont.pas');
P.Targets.AddUnit('./nvwidgets/nvwidgets.pas');
write('package ', P.Name, ' configured for ');

View File

@ -206,7 +206,7 @@ begin
//Of all the places where the code might die, this is the most likely,
//as FT_New_Face will die if the font file does not exist or is somehow broken.
if FT_New_Face(library_, PChar(fname), 0, face) = 1 then
raise Exception.Create('FT_New_Face failed (there is probably a problem with your font file)');
raise Exception.CreateFmt('FT_New_Face failed (there is probably a problem with your font file "%s")', [fname]);
//For some twisted reason, Freetype measures font size
//in terms of 1/64ths of pixels. Thus, to make a font

View File

@ -0,0 +1,81 @@
unit nvBaseFont;
{$mode objfpc}{$H+}
interface
uses
fpimage;
type
{ TNVBaseFont }
TNVBaseFont = class
private
FAngle: double;
FFlags: word;
FName: string;
FSize: integer;
function GetFlags(AIndex: integer): boolean;
procedure SetFlags(AIndex: integer; AValue: boolean);
protected
procedure SetAngle(AValue: double); virtual;
public
constructor Create(AName: string; ASize: integer);
//font characteristics
property Name: string read FName;
property Size: integer read FSize;
//text metrics
function TextHeight(Text: string): integer; virtual; abstract;
function TextWidth(Text: string): integer; virtual; abstract;
procedure TextSize(Text: string; var w, h: integer); virtual; abstract;
//font flags <<possibly not implemented for all font classes>>
property Angle: double read FAngle write SetAngle;
property Bold: boolean index 1 read GetFlags write SetFlags;
property Italic: boolean index 2 read GetFlags write SetFlags;
property StrikeTrough: boolean index 3 read GetFlags write SetFlags;
property Underline: boolean index 4 read GetFlags write SetFlags;
//printing function
procedure TextOut(x, y: double; Text: string); virtual; abstract;
end;
implementation
{ TNVBaseFont }
function TNVBaseFont.GetFlags(AIndex: integer): boolean;
begin
Result := (FFlags and (1 shl AIndex)) <> 0;
end;
procedure TNVBaseFont.SetFlags(AIndex: integer; AValue: boolean);
begin
if AValue then
FFlags := FFlags or (1 shl AIndex)
else
FFlags := FFlags and not (1 shl AIndex);
end;
procedure TNVBaseFont.SetAngle(AValue: double);
begin
if FAngle <> AValue then
FAngle := AValue;
end;
constructor TNVBaseFont.Create(AName: string; ASize: integer);
begin
FAngle := 0;
FFlags:= 0;
FName := AName;
FSize := ASize;
end;
end.