| 1 |
{%MainUnit castlefonts.pas} |
| 2 |
{ |
| 3 |
Copyright 2001-2021 Michalis Kamburelis. |
| 4 |
|
| 5 |
This file is part of "Castle Game Engine". |
| 6 |
|
| 7 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 8 |
included in this distribution, for details about the copyright. |
| 9 |
|
| 10 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
|
| 14 |
---------------------------------------------------------------------------- |
| 15 |
} |
| 16 |
|
| 17 |
{$ifdef read_interface} |
| 18 |
|
| 19 |
type |
| 20 |
{ Raised by |
| 21 |
@link(TTextureFontData.Create) or @link(TCastleFont.Load) when |
| 22 |
the freetype library cannot be found, and thus font files cannot be read. } |
| 23 |
EFreeTypeLibraryNotFound = CastleTextureFontData.EFreeTypeLibraryNotFound; |
| 24 |
|
| 25 |
const |
| 26 |
{ Supported font file formats. |
| 27 |
Use these filters with LCL file dialog (easily set by FileFiltersToDialog) |
| 28 |
or TCastleWindow.FileDialog. } |
| 29 |
LoadFont_FileFilters = |
| 30 |
'All Files|*|' + |
| 31 |
'*All Font Files|*.ttf;*.otf|' + |
| 32 |
'TrueType Fonts (*.ttf)|*.ttf|' + |
| 33 |
'OpenType Fonts (*.otf)|*.otf'; |
| 34 |
|
| 35 |
{ Protect characters from being interpreted as special HTML sequences |
| 36 |
by TCastleAbstractFont.Print with Html = @true parameter. |
| 37 |
Replaces '<' with '<' and so on. } |
| 38 |
function SimpleHtmlQuote(const S: String): String; |
| 39 |
|
| 40 |
{$endif read_interface} |
| 41 |
|
| 42 |
{$ifdef read_implementation} |
| 43 |
|
| 44 |
const |
| 45 |
{ These many glyphs will be allocated always. |
| 46 |
This avoids reallocating memory if you just render strings shorter than this. |
| 47 |
|
| 48 |
This affects 2 arrays, and SizeOf(TFloatRectangle) should be 4 * 4. |
| 49 |
So it costs 32 bytes per item. } |
| 50 |
MinimumGlyphsAllocated = 100; |
| 51 |
|
| 52 |
{ globals -------------------------------------------------------------------- } |
| 53 |
|
| 54 |
function SimpleHtmlQuote(const S: String): String; |
| 55 |
const |
| 56 |
Patterns: array [0..4] of String = ('&', '<', '>', ''', '"'); |
| 57 |
Replacements: array [0..4] of String = ('&', '<', '>', '''', '"'); |
| 58 |
begin |
| 59 |
Result := SReplacePatterns(S, Patterns, Replacements, false); |
| 60 |
end; |
| 61 |
|
| 62 |
{$endif read_implementation} |