|
@@ -47,8 +47,11 @@ type
|
|
|
published
|
|
|
procedure TestCount;
|
|
|
procedure TestBuildFontCache;
|
|
|
+ procedure TestBuildFontCache_tests_for_bug;
|
|
|
procedure TestClear;
|
|
|
procedure TestFind_FamilyName;
|
|
|
+ procedure TestFind_PostscriptName;
|
|
|
+ procedure TestAssignFontList;
|
|
|
end;
|
|
|
|
|
|
implementation
|
|
@@ -117,10 +120,10 @@ begin
|
|
|
lFC.SearchPath.Add(ExtractFilePath(ParamStr(0)) + 'fonts');
|
|
|
lFC.BuildFontCache;
|
|
|
|
|
|
- lCI := lFC.Find('Liberation Sans');
|
|
|
+ lCI := lFC.Find('LiberationSans');
|
|
|
AssertEquals('Failed on 1', 14684, round(lCI.TextWidth('Country Ppml01', 0.0)));
|
|
|
|
|
|
- lCI := lFC.Find('DejaVu Sans');
|
|
|
+ lCI := lFC.Find('DejaVuSans');
|
|
|
AssertEquals('Failed on 2', 16492, round(lCI.TextWidth('Country Ppml01', 0.0)));
|
|
|
|
|
|
lCI := lFC.Find('Ubuntu'); // 7333 is the raw glyph width, but with kerning it is 7339
|
|
@@ -141,7 +144,7 @@ begin
|
|
|
lFC.SearchPath.Add(ExtractFilePath(ParamStr(0)) + 'fonts');
|
|
|
lFC.BuildFontCache;
|
|
|
|
|
|
- lCI := lFC.Find('Liberation Sans');
|
|
|
+ lCI := lFC.Find('LiberationSans');
|
|
|
px := 14684 * 10 * 96 / (72 * 2048); // 95.599px
|
|
|
AssertEquals('Failed on 1', px, lCI.TextWidth('Country Ppml01', 10.0));
|
|
|
px := 14684 * 12 * 96 / (72 * 2048); // 114.7188px
|
|
@@ -149,7 +152,7 @@ begin
|
|
|
px := 14684 * 24 * 96 / (72 * 2048); // 229.4375px
|
|
|
AssertEquals('Failed on 3', px, lCI.TextWidth('Country Ppml01', 24.0));
|
|
|
|
|
|
- lCI := lFC.Find('DejaVu Sans');
|
|
|
+ lCI := lFC.Find('DejaVuSans');
|
|
|
px := 16492 * 10 * 96 / (72 * 2048); // 107.369px
|
|
|
AssertEquals('Failed on 4', px, lCI.TextWidth('Country Ppml01', 10.0));
|
|
|
px := 16492 * 12 * 96 / (72 * 2048); // 128.8438px
|
|
@@ -211,6 +214,14 @@ begin
|
|
|
AssertEquals('Failed on 5' + cErrFontCountWrong, 4, FC.Count);
|
|
|
end;
|
|
|
|
|
|
+procedure TFPFontCacheListTest.TestBuildFontCache_tests_for_bug;
|
|
|
+begin
|
|
|
+ AssertEquals('Failed on 1', 0, FC.Count);
|
|
|
+ FC.SearchPath.Add(ExtractFilePath(ParamStr(0)) + 'path_doesnt_exist');
|
|
|
+ FC.BuildFontCache;
|
|
|
+ AssertEquals('Failed on 2', 0, FC.Count);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TFPFontCacheListTest.TestClear;
|
|
|
begin
|
|
|
AssertEquals('Failed on 1', 0, FC.Count);
|
|
@@ -238,19 +249,66 @@ begin
|
|
|
{ TODO: We should try and extend this to make font paths user configure
|
|
|
thus the tests could be more flexible. }
|
|
|
|
|
|
- lCI := FC.Find('Ubuntu', True); // bold font
|
|
|
+ lCI := FC.Find('Ubuntu', True, False); // bold font
|
|
|
AssertTrue('Failed on 5', lCI = nil);
|
|
|
lCI := FC.Find('Ubuntu', False, True); // italic font
|
|
|
AssertTrue('Failed on 6', lCI = nil);
|
|
|
lCI := FC.Find('Ubuntu', True, True); // bold+italic font
|
|
|
AssertTrue('Failed on 7', lCI = nil);
|
|
|
|
|
|
- lCI := FC.Find('DejaVu Sans');
|
|
|
+ lCI := FC.Find('DejaVu Sans', False, False);
|
|
|
+ AssertTrue('Failed on 8', Assigned(lCI));
|
|
|
+ lCI := FC.Find('DejaVu Sans', True, False);
|
|
|
+ AssertTrue('Failed on 9', lCI = nil);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TFPFontCacheListTest.TestFind_PostscriptName;
|
|
|
+var
|
|
|
+ lCI: TFPFontCacheItem;
|
|
|
+begin
|
|
|
+ lCI := nil;
|
|
|
+ AssertEquals('Failed on 1', 0, FC.Count);
|
|
|
+ lCI := FC.Find('Ubuntu');
|
|
|
+ AssertTrue('Failed on 2', lCI = nil);
|
|
|
+ FC.SearchPath.Add(ExtractFilePath(ParamStr(0)) + 'fonts');
|
|
|
+ FC.BuildFontCache;
|
|
|
+ AssertEquals('Failed on 3' + cErrFontCountWrong, 4, FC.Count);
|
|
|
+ lCI := FC.Find('Ubuntu');
|
|
|
+ AssertTrue('Failed on 4', Assigned(lCI));
|
|
|
+
|
|
|
+ { TODO: We should try and extend this to make font paths user configure
|
|
|
+ thus the tests could be more flexible. }
|
|
|
+
|
|
|
+ lCI := FC.Find('Ubuntu-Bold');
|
|
|
+ AssertTrue('Failed on 5', lCI = nil);
|
|
|
+ lCI := FC.Find('Ubuntu-Italic');
|
|
|
+ AssertTrue('Failed on 6', lCI = nil);
|
|
|
+ lCI := FC.Find('Ubuntu-BoldItalic');
|
|
|
+ AssertTrue('Failed on 7', lCI = nil);
|
|
|
+
|
|
|
+ lCI := FC.Find('DejaVuSans');
|
|
|
AssertTrue('Failed on 8', Assigned(lCI));
|
|
|
- lCI := FC.Find('DejaVu Sans Bold');
|
|
|
+ lCI := FC.Find('DejaVuSans-Bold');
|
|
|
AssertTrue('Failed on 9', lCI = nil);
|
|
|
end;
|
|
|
|
|
|
+procedure TFPFontCacheListTest.TestAssignFontList;
|
|
|
+var
|
|
|
+ sl: TStringList;
|
|
|
+begin
|
|
|
+ sl := TStringList.Create;
|
|
|
+ try
|
|
|
+ AssertEquals('Failed on 1', 0, FC.Count);
|
|
|
+ FC.SearchPath.Add(ExtractFilePath(ParamStr(0)) + 'fonts');
|
|
|
+ FC.BuildFontCache;
|
|
|
+ AssertEquals('Failed on 2', 4, FC.Count);
|
|
|
+ FC.AssignFontList(sl);
|
|
|
+ AssertEquals('Failed on 3', 4, sl.Count);
|
|
|
+ finally
|
|
|
+ sl.Free;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
|
|
|
initialization
|
|
|
RegisterTest({$ifdef fptest}'fpTTF', {$endif}TFPFontCacheItemTest{$ifdef fptest}.Suite{$endif});
|