| @@ -206,7 +206,7 @@ begin | |||
| (m.Advance <> 0))) then | |||
| exit; | |||
| CharImage := TtsImage.Create; | |||
| CharImage := TtsImage.Create(nil); | |||
| try | |||
| if (aCharCode = #0) then begin | |||
| CharImage.CreateEmpty(fRenderRefGenerator.Format, 3, 1); | |||
| @@ -8,13 +8,13 @@ interface | |||
| uses | |||
| Classes, SysUtils, | |||
| utsUtils, utsFontCreator, utsTypes, utsPostProcessor, utsImage; | |||
| utsUtils, utsTypes, utsPostProcessor, utsImage; | |||
| type | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| TtsFont = class(TtsMultiMasterRefManager) | |||
| private | |||
| fCreator: TtsFontCreator; | |||
| fNames: TtsFontNames; | |||
| fMetric: TtsFontMetric; | |||
| fPostProcessor: TtsPostProcessor; | |||
| @@ -22,9 +22,9 @@ type | |||
| fCharSpacing: Integer; | |||
| fLineSpacing: Single; | |||
| protected | |||
| {%H-}constructor Create(const aCreator: TtsFontCreator; const aMetric: TtsFontMetric); | |||
| {%H-}constructor Create(const aMaster: TtsRefManager; const aMetric: TtsFontMetric; const aNames: TtsFontNames); | |||
| public | |||
| property Creator: TtsFontCreator read fCreator; | |||
| property Names: TtsFontNames read fNames; | |||
| property Metric: TtsFontMetric read fMetric; | |||
| property PostProcessor: TtsPostProcessor read fPostProcessor write fPostProcessor; | |||
| @@ -42,11 +42,11 @@ implementation | |||
| /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //TtsFont////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| constructor TtsFont.Create(const aCreator: TtsFontCreator; const aMetric: TtsFontMetric); | |||
| constructor TtsFont.Create(const aMaster: TtsRefManager; const aMetric: TtsFontMetric; const aNames: TtsFontNames); | |||
| begin | |||
| inherited Create(aCreator); | |||
| fCreator := aCreator; | |||
| fMetric := aMetric; | |||
| inherited Create(aMaster); | |||
| fMetric := aMetric; | |||
| fNames := aNames; | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| @@ -8,7 +8,7 @@ interface | |||
| uses | |||
| Classes, SysUtils, | |||
| utsUtils, utsContext; | |||
| utsUtils, utsContext, utsTypes, utsFont; | |||
| type | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| @@ -18,6 +18,10 @@ type | |||
| public | |||
| property Context: TtsContext read fContext; | |||
| function GetFontByName(const aFontname: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; virtual; | |||
| function GetFontByFile(const aFilename: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; virtual; | |||
| function GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; virtual; | |||
| constructor Create(const aContext: TtsContext); | |||
| end; | |||
| @@ -25,6 +29,24 @@ implementation | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //TtsFontCreator//////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| function TtsFontCreator.GetFontByName(const aFontname: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; | |||
| begin | |||
| result := nil; | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| function TtsFontCreator.GetFontByFile(const aFilename: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; | |||
| begin | |||
| result := nil; | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| function TtsFontCreator.GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; | |||
| begin | |||
| result := nil; | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| constructor TtsFontCreator.Create(const aContext: TtsContext); | |||
| begin | |||
| @@ -25,7 +25,8 @@ type | |||
| private | |||
| fHandle: TtsFreeTypeFaceHandle; | |||
| protected | |||
| {%H-}constructor Create(const aHandle: TtsFreeTypeFaceHandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric); | |||
| {%H-}constructor Create(const aHandle: TtsFreeTypeFaceHandle; const aCreator: TtsFontCreator; | |||
| const aMetric: TtsFontMetric; const aNames: TtsFontNames); | |||
| public | |||
| procedure GetCharImage(const aCharCode: WideChar; const aCharImage: TtsImage; const aFormat: TtsFormat); override; | |||
| function GetGlyphMetrics(const aCharCode: WideChar; out aGlyphOrigin, aGlyphSize: TtsPosition; out aAdvance: Integer): Boolean; override; | |||
| @@ -38,11 +39,11 @@ type | |||
| private | |||
| fHandle: FT_Library; | |||
| procedure LoadNames(const aFace: FT_Face; var aMetric: TtsFontMetric); | |||
| procedure LoadNames(const aFace: FT_Face; var aMetric: TtsFontMetric; var aNames: TtsFontNames); | |||
| function CreateFont(const aFace: FT_Face; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; | |||
| public | |||
| function GetFontByFile(const aFilename: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; | |||
| function GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; | |||
| function GetFontByFile(const aFilename: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; override; | |||
| function GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; override; | |||
| constructor Create(const aContext: TtsContext); | |||
| destructor Destroy; override; | |||
| @@ -77,9 +78,9 @@ end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //TtsFontFreeType/////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| constructor TtsFontFreeType.Create(const aHandle: TtsFreeTypeFaceHandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric); | |||
| constructor TtsFontFreeType.Create(const aHandle: TtsFreeTypeFaceHandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric; const aNames: TtsFontNames); | |||
| begin | |||
| inherited Create(aCreator, aMetric); | |||
| inherited Create(aCreator, aMetric, aNames); | |||
| fHandle := aHandle; | |||
| end; | |||
| @@ -218,9 +219,9 @@ begin | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //TtsFontCreatorFreeType////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //TtsFontCreatorFreeType//////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| procedure TtsFontCreatorFreeType.LoadNames(const aFace: FT_Face; var aMetric: TtsFontMetric); | |||
| procedure TtsFontCreatorFreeType.LoadNames(const aFace: FT_Face; var aMetric: TtsFontMetric; var aNames: TtsFontNames); | |||
| var | |||
| i, cnt: FT_Int; | |||
| err: FT_Error; | |||
| @@ -275,16 +276,16 @@ begin | |||
| case name.name_id of | |||
| TT_NAME_ID_COPYRIGHT: | |||
| if (aMetric.Copyright = '') then | |||
| aMetric.Copyright := Decode; | |||
| if (aNames.Copyright = '') then | |||
| aNames.Copyright := Decode; | |||
| TT_NAME_ID_FONT_FAMILY: | |||
| if (aMetric.Fontname = '') then | |||
| aMetric.Fontname := Decode; | |||
| if (aNames.Fontname = '') then | |||
| aNames.Fontname := Decode; | |||
| TT_NAME_ID_FULL_NAME: | |||
| if (aMetric.FullName = '') then | |||
| aMetric.FullName := Decode; | |||
| if (aNames.FullName = '') then | |||
| aNames.FullName := Decode; | |||
| end; | |||
| end; | |||
| end; | |||
| @@ -295,6 +296,7 @@ function TtsFontCreatorFreeType.CreateFont(const aFace: FT_Face; const aSize: In | |||
| var | |||
| err: FT_Error; | |||
| metric: TtsFontMetric; | |||
| names: TtsFontNames; | |||
| os2: PTT_OS2; | |||
| hz: PTT_HoriHeader; | |||
| begin | |||
| @@ -304,9 +306,9 @@ begin | |||
| FillChar(metric{%H-}, SizeOf(metric), #0); | |||
| metric.AntiAliasing := tsAANormal; | |||
| metric.FaceName := String(aFace^.family_name); | |||
| metric.StyleName := String(aFace^.style_name); | |||
| LoadNames(aFace, metric); | |||
| names.FaceName := String(aFace^.family_name); | |||
| names.StyleName := String(aFace^.style_name); | |||
| LoadNames(aFace, metric, names); | |||
| metric.Size := aSize; | |||
| metric.AntiAliasing := aAntiAliasing; | |||
| @@ -336,7 +338,7 @@ begin | |||
| metric.ExternalLeading := hz^.Line_Gap div FT_SIZE_FACTOR; | |||
| end; | |||
| result := TtsFontFreeType.Create(TtsFreeTypeFaceHandle.Create(aFace), self, metric); | |||
| result := TtsFontFreeType.Create(TtsFreeTypeFaceHandle.Create(aFace), self, metric, names); | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| @@ -21,7 +21,7 @@ type | |||
| procedure GetCharImageAANone(const aDC: HDC; const aCharCode: WideChar; const aImage: TtsImage; const aFormat: TtsFormat); | |||
| procedure GetCharImageAANormal(const aDC: HDC; const aCharCode: WideChar; const aImage: TtsImage; const aFormat: TtsFormat); | |||
| protected | |||
| {%H-}constructor Create(const aHandle: THandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric); | |||
| {%H-}constructor Create(const aHandle: THandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric; const aNames: TtsFontNames); | |||
| public | |||
| procedure GetCharImage(const aCharCode: WideChar; const aCharImage: TtsImage; const aFormat: TtsFormat); override; | |||
| function GetGlyphMetrics(const aCharCode: WideChar; out aGlyphOrigin, aGlyphSize: TtsPosition; out aAdvance: Integer): Boolean; override; | |||
| @@ -64,7 +64,8 @@ type | |||
| private | |||
| fRegistration: TtsFontRegistration; | |||
| protected | |||
| {%H-}constructor Create(const aRegistration: TtsFontRegistration; const aHandle: THandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric); | |||
| {%H-}constructor Create(const aRegistration: TtsFontRegistration; const aHandle: THandle; | |||
| const aCreator: TtsFontCreator; const aMetric: TtsFontMetric; const aNames: TtsFontNames); | |||
| public | |||
| destructor Destroy; override; | |||
| end; | |||
| @@ -72,11 +73,11 @@ type | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| TtsFontCreatorGDI = class(TtsFontCreator) | |||
| private | |||
| function CreateFont(const aFontname: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing; out aMetric: TtsFontMetric): THandle; | |||
| function CreateFont(const aFontname: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing; out aMetric: TtsFontMetric; out aNames: TtsFontNames): THandle; | |||
| public | |||
| function GetFontByName(const aFontname: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; | |||
| function GetFontByFile(const aFilename: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; | |||
| function GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; | |||
| function GetFontByName(const aFontname: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; override; | |||
| function GetFontByFile(const aFilename: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; override; | |||
| function GetFontByStream(const aStream: TStream; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing): TtsFont; overload; override; | |||
| constructor Create(const aContext: TtsContext); | |||
| destructor Destroy; override; | |||
| @@ -569,9 +570,9 @@ begin | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| constructor TtsFontGDI.Create(const aHandle: THandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric); | |||
| constructor TtsFontGDI.Create(const aHandle: THandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric; const aNames: TtsFontNames); | |||
| begin | |||
| inherited Create(aCreator, aMetric); | |||
| inherited Create(aCreator, aMetric, aNames); | |||
| FillChar(fMat2, SizeOf(fMat2), #0); | |||
| fMat2.eM11.value := 1; | |||
| fMat2.eM22.value := 1; | |||
| @@ -737,9 +738,10 @@ end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //TtsRegistredFontGDI/////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| constructor TtsRegistredFontGDI.Create(const aRegistration: TtsFontRegistration; const aHandle: THandle; const aCreator: TtsFontCreator; const aMetric: TtsFontMetric); | |||
| constructor TtsRegistredFontGDI.Create(const aRegistration: TtsFontRegistration; const aHandle: THandle; | |||
| const aCreator: TtsFontCreator; const aMetric: TtsFontMetric; const aNames: TtsFontNames); | |||
| begin | |||
| inherited Create(aHandle, aCreator, aMetric); | |||
| inherited Create(aHandle, aCreator, aMetric, aNames); | |||
| fRegistration := aRegistration; | |||
| end; | |||
| @@ -753,7 +755,8 @@ end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //TtsFontCreatorGDI///////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| function TtsFontCreatorGDI.CreateFont(const aFontname: String; const aSize: Integer; const aStyle: TtsFontStyles; const aAntiAliasing: TtsAntiAliasing; out aMetric: TtsFontMetric): THandle; | |||
| function TtsFontCreatorGDI.CreateFont(const aFontname: String; const aSize: Integer; const aStyle: TtsFontStyles; | |||
| const aAntiAliasing: TtsAntiAliasing; out aMetric: TtsFontMetric; out aNames: TtsFontNames): THandle; | |||
| var | |||
| LogFont: TLogFontA; | |||
| i: Integer; | |||
| @@ -777,7 +780,7 @@ begin | |||
| aMetric.Size := aSize; | |||
| aMetric.Style := aStyle; | |||
| aMetric.AntiAliasing := aAntiAliasing; | |||
| aMetric.Fontname := aFontname; | |||
| aNames.Fontname := aFontname; | |||
| // prepare font attribs | |||
| FillChar(LogFont{%H-}, SizeOf(LogFont), #0); | |||
| @@ -804,10 +807,10 @@ begin | |||
| SetLength(Lang, 4); | |||
| GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, @Lang[1], 4); | |||
| GetTTString(Buffer, BufSize, NAME_ID_COPYRIGHT, StrToInt('$' + String(Lang)), aMetric.Copyright); | |||
| GetTTString(Buffer, BufSize, NAME_ID_FACE_NAME, StrToInt('$' + String(Lang)), aMetric.FaceName); | |||
| GetTTString(Buffer, BufSize, NAME_ID_STYLE_NAME, StrToInt('$' + String(Lang)), aMetric.StyleName); | |||
| GetTTString(Buffer, BufSize, NAME_ID_FULL_NAME, StrToInt('$' + String(Lang)), aMetric.FullName); | |||
| GetTTString(Buffer, BufSize, NAME_ID_COPYRIGHT, StrToInt('$' + String(Lang)), aNames.Copyright); | |||
| GetTTString(Buffer, BufSize, NAME_ID_FACE_NAME, StrToInt('$' + String(Lang)), aNames.FaceName); | |||
| GetTTString(Buffer, BufSize, NAME_ID_STYLE_NAME, StrToInt('$' + String(Lang)), aNames.StyleName); | |||
| GetTTString(Buffer, BufSize, NAME_ID_FULL_NAME, StrToInt('$' + String(Lang)), aNames.FullName); | |||
| end; | |||
| finally | |||
| FreeMem(Buffer); | |||
| @@ -841,11 +844,12 @@ function TtsFontCreatorGDI.GetFontByName(const aFontname: String; const aSize: I | |||
| var | |||
| handle: THandle; | |||
| metric: TtsFontMetric; | |||
| names: TtsFontNames; | |||
| begin | |||
| handle := CreateFont(aFontname, aSize, aStyle, aAntiAliasing, metric); | |||
| handle := CreateFont(aFontname, aSize, aStyle, aAntiAliasing, metric, names); | |||
| if (handle = 0) then | |||
| raise EtsException.Create('unable to create font from name: ' + aFontname); | |||
| result := TtsFontGDI.Create(handle, self, metric); | |||
| result := TtsFontGDI.Create(handle, self, metric, names); | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| @@ -854,19 +858,20 @@ var | |||
| reg: TtsFontRegistrationFile; | |||
| handle: THandle; | |||
| metric: TtsFontMetric; | |||
| names: TtsFontNames; | |||
| begin | |||
| reg := TtsFontRegistrationFile.Create(aFilename); | |||
| try | |||
| if not reg.IsRegistered then | |||
| raise EtsException.Create('unable to register font file: ' + aFilename); | |||
| handle := CreateFont(reg.Fontname, aSize, aStyle, aAntiAliasing, metric); | |||
| handle := CreateFont(reg.Fontname, aSize, aStyle, aAntiAliasing, metric, names); | |||
| if (handle = 0) then | |||
| raise EtsException.Create('unable to create font from file: ' + aFilename); | |||
| except | |||
| FreeAndNil(reg); | |||
| raise; | |||
| end; | |||
| result := TtsRegistredFontGDI.Create(reg, handle, self, metric); | |||
| result := TtsRegistredFontGDI.Create(reg, handle, self, metric, names); | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| @@ -875,14 +880,15 @@ var | |||
| reg: TtsFontRegistrationStream; | |||
| handle: THandle; | |||
| metric: TtsFontMetric; | |||
| names: TtsFontNames; | |||
| begin | |||
| reg := TtsFontRegistrationStream.Create(aStream); | |||
| if not reg.IsRegistered then | |||
| raise EtsException.Create('unable to register font from stream'); | |||
| handle := CreateFont(reg.Fontname, aSize, aStyle, aAntiAliasing, metric); | |||
| handle := CreateFont(reg.Fontname, aSize, aStyle, aAntiAliasing, metric, names); | |||
| if (handle = 0) then | |||
| raise EtsException.Create('unable to create font from stream: ' + reg.Fontname); | |||
| result := TtsRegistredFontGDI.Create(reg, handle, self, metric); | |||
| result := TtsRegistredFontGDI.Create(reg, handle, self, metric, names); | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| @@ -8,14 +8,17 @@ interface | |||
| uses | |||
| Classes, SysUtils, | |||
| utsTypes, utsUtils; | |||
| utsTypes, utsUtils, utsContext; | |||
| type | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| TtsImage = class; | |||
| TtsImageFunc = procedure(const aImage: TtsImage; X, Y: Integer; var aPixel: TtsColor4f; aArgs: Pointer); | |||
| TtsImage = class(TObject) | |||
| TtsImageLoadFunc = procedure(const aImage: TtsImage; X, Y: Integer; var aPixel: TtsColor4f; aArgs: Pointer); | |||
| TtsImageBlendFunc = function (const aSrc, aDst: TtsColor4f; aArgs: Pointer): TtsColor4f; | |||
| TtsImage = class(TtsRefManager) | |||
| private | |||
| fContext: TtsContext; | |||
| fWidth: Integer; | |||
| fHeight: Integer; | |||
| fDataSize: Integer; | |||
| @@ -37,20 +40,21 @@ type | |||
| const aLineSize: Integer = 0; | |||
| const aDataSize: Integer = 0); | |||
| public | |||
| property IsEmpty: Boolean read GetIsEmpty; | |||
| property Width: Integer read fWidth; | |||
| property Height: Integer read fHeight; | |||
| property LineSize: Integer read fLineSize; | |||
| property DataSize: Integer read fDataSize; | |||
| property Format: TtsFormat read fFormat; | |||
| property Data: Pointer read fData; | |||
| property Context: TtsContext read fContext; | |||
| property IsEmpty: Boolean read GetIsEmpty; | |||
| property Width: Integer read fWidth; | |||
| property Height: Integer read fHeight; | |||
| property LineSize: Integer read fLineSize; | |||
| property DataSize: Integer read fDataSize; | |||
| property Format: TtsFormat read fFormat; | |||
| property Data: Pointer read fData; | |||
| property Scanline[const aIndex: Integer]: Pointer read GetScanline; | |||
| function GetPixelAt(const x, y: Integer; out aColor: TtsColor4f): Boolean; | |||
| procedure Assign(const aImage: TtsImage); | |||
| procedure CreateEmpty(const aFormat: TtsFormat; const aWidth, aHeight: Integer); | |||
| procedure LoadFromFunc(const aFunc: TtsImageFunc; const aArgs: Pointer); | |||
| procedure LoadFromFunc(const aFunc: TtsImageLoadFunc; const aArgs: Pointer); | |||
| procedure Resize(const aNewWidth, aNewHeight, X, Y: Integer); | |||
| procedure FindMinMax(out aRect: TtsRect); | |||
| @@ -58,9 +62,10 @@ type | |||
| procedure FillColor(const aColor: TtsColor4f; const aChannelMask: TtsColorChannels; const aModes: TtsImageModes); | |||
| procedure FillPattern(const aPattern: TtsImage; X, Y: Integer; const aChannelMask: TtsColorChannels; const aModes: TtsImageModes); | |||
| procedure Blend(const aImage: TtsImage; const X, Y: Integer; const aFunc: TtsBlendColorFunc); | |||
| procedure Blend(const aImage: TtsImage; const X, Y: Integer; const aFunc: TtsImageBlendFunc; const aArgs: Pointer); | |||
| procedure Blur(const aHorzKernel, aVertKernel: TtsKernel1D; const aChannelMask: TtsColorChannels); | |||
| constructor Create; | |||
| constructor Create(const aContext: TtsContext); | |||
| destructor Destroy; override; | |||
| end; | |||
| @@ -70,6 +75,20 @@ uses | |||
| Math, | |||
| utsConstants; | |||
| type | |||
| PBlendProxyArgs = ^TBlendProxyArgs; | |||
| TBlendProxyArgs = packed record | |||
| callback: TtsBlendColorFunc; | |||
| end; | |||
| function tsImageBlendCallbackProxy(const aSrc, aDst: TtsColor4f; aArgs: Pointer): TtsColor4f; | |||
| var | |||
| p: PBlendProxyArgs; | |||
| begin | |||
| p := PBlendProxyArgs(aArgs); | |||
| result := p^.callback(aSrc, aDst); | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //TtsImage////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| @@ -169,7 +188,7 @@ begin | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| procedure TtsImage.LoadFromFunc(const aFunc: TtsImageFunc; const aArgs: Pointer); | |||
| procedure TtsImage.LoadFromFunc(const aFunc: TtsImageLoadFunc; const aArgs: Pointer); | |||
| var | |||
| X, Y: Integer; | |||
| c: TtsColor4f; | |||
| @@ -335,6 +354,15 @@ end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| procedure TtsImage.Blend(const aImage: TtsImage; const X, Y: Integer; const aFunc: TtsBlendColorFunc); | |||
| var | |||
| args: TBlendProxyArgs; | |||
| begin | |||
| args.callback := aFunc; | |||
| Blend(aImage, X, Y, @tsImageBlendCallbackProxy, @args); | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| procedure TtsImage.Blend(const aImage: TtsImage; const X, Y: Integer; const aFunc: TtsImageBlendFunc; const aArgs: Pointer); | |||
| var | |||
| _x, _y, x1, x2, y1, y2: Integer; | |||
| src, dst, tmp: PByte; | |||
| @@ -356,7 +384,7 @@ begin | |||
| for _x := x1 to x2-1 do begin | |||
| tsFormatUnmap(aImage.Format, src, srcColor); | |||
| tsFormatUnmap( Format, dst, dstColor); | |||
| tsFormatMap(aImage.Format, tmp, aFunc(srcColor, dstColor)); | |||
| tsFormatMap(aImage.Format, tmp, aFunc(srcColor, dstColor, aArgs)); | |||
| end; | |||
| end; | |||
| end; | |||
| @@ -406,7 +434,7 @@ var | |||
| end; | |||
| begin | |||
| tmpImage := TtsImage.Create; | |||
| tmpImage := TtsImage.Create(fContext); | |||
| try | |||
| tmpImage.CreateEmpty(Format, Width, Height); | |||
| tmpImage.FillColor(tsColor4f(1, 1, 1, 0), TS_COLOR_CHANNELS_RGBA, TS_IMAGE_MODES_REPLACE_ALL); | |||
| @@ -419,9 +447,10 @@ begin | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| constructor TtsImage.Create; | |||
| constructor TtsImage.Create(const aContext: TtsContext); | |||
| begin | |||
| inherited Create; | |||
| inherited Create(aContext); | |||
| fContext := aContext; | |||
| SetData(nil); | |||
| end; | |||
| @@ -71,6 +71,7 @@ type | |||
| procedure FreeRenderRef(const aRenderRef: TtsRenderRef); override; | |||
| protected | |||
| procedure BeginRender; override; | |||
| procedure EndRender; override; | |||
| procedure SetDrawPos(const aValue: TtsPosition); override; | |||
| function GetDrawPos: TtsPosition; override; | |||
| procedure MoveDrawPos(const aOffset: TtsPosition); override; | |||
| @@ -346,6 +347,12 @@ begin | |||
| fRenderPos.y := 0; | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| procedure TtsBaseOpenGL.EndRender; | |||
| begin | |||
| // DUMMY | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| procedure TtsBaseOpenGL.SetDrawPos(const aValue: TtsPosition); | |||
| begin | |||
| @@ -52,12 +52,15 @@ type | |||
| fItems: TObjectList; | |||
| function GetCount: Integer; | |||
| function GetItem(const aIndex: Integer): TtsPostProcessor; | |||
| function GetOwnsObjects: Boolean; | |||
| procedure SetOwnsObjects(const aValue: Boolean); | |||
| public | |||
| property Count: Integer read GetCount; | |||
| property OwnsObjects: Boolean read GetOwnsObjects write SetOwnsObjects; | |||
| property Items[const aIndex: Integer]: TtsPostProcessor read GetItem; | |||
| procedure Add(const aPostProcessor: TtsPostProcessor); | |||
| procedure Delete(const aIndex: Integer); | |||
| procedure Clear; | |||
| @@ -279,6 +282,12 @@ begin | |||
| result := fItems.Count; | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| function TtsPostProcessorList.GetItem(const aIndex: Integer): TtsPostProcessor; | |||
| begin | |||
| result := TtsPostProcessor(fItems[aIndex]); | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
| function TtsPostProcessorList.GetOwnsObjects: Boolean; | |||
| begin | |||
| @@ -480,7 +489,7 @@ begin | |||
| aImage.Width + 2 * fKernel.SizeX, | |||
| aImage.Height + 2 * fKernel.SizeY, | |||
| fKernel.SizeX, fKernel.SizeY); | |||
| orig := TtsImage.Create; | |||
| orig := TtsImage.Create(fContext); | |||
| try | |||
| orig.Assign(aImage); | |||
| aImage.FillColor(fColor, TS_COLOR_CHANNELS_RGBA, TS_IMAGE_MODES_REPLACE_ALL); | |||
| @@ -554,7 +563,7 @@ begin | |||
| result := inherited Execute(aChar, aImage); | |||
| if not result or not Assigned(aImage) then | |||
| exit; | |||
| orig := TtsImage.Create; | |||
| orig := TtsImage.Create(fContext); | |||
| try | |||
| orig.Assign(aImage); | |||
| aImage.Resize( | |||
| @@ -13,16 +13,19 @@ uses | |||
| {$IFDEF TS_ENABLE_OPENGLES_SUPPORT} utsRendererOpenGLES,{$ENDIF} | |||
| {$IFDEF TS_ENABLE_GDI_SUPPORT} utsFontCreatorGDI,{$ENDIF} | |||
| {$IFDEF TS_ENABLE_FREETYPE_SUPPORT} utsFontCreatorFreeType,{$ENDIF} | |||
| utsContext, utsFont, utsTypes, utsTextBlock, utsChar, utsImage, utsPostProcessor; | |||
| utsContext, utsFont, utsTypes, utsTextBlock, utsImage, | |||
| utsPostProcessor, utsRenderer, utsFontCreator; | |||
| type | |||
| // TextSuite Classes | |||
| TtsContext = utsContext.TtsContext; | |||
| TtsRenderer = utsRenderer.TtsRenderer; | |||
| TtsFontCreator = utsFontCreator.TtsFontCreator; | |||
| TtsFont = utsFont.TtsFont; | |||
| TtsTextBlock = utsTextBlock.TtsTextBlock; | |||
| TtsChar = utsChar.TtsChar; | |||
| TtsImage = utsImage.TtsImage; | |||
| TtsImageFunc = utsImage.TtsImageFunc; | |||
| TtsImageLoadFunc = utsImage.TtsImageLoadFunc; | |||
| TtsImageBlendFunc = utsImage.TtsImageBlendFunc; | |||
| // Post Processor | |||
| TtsCharRangeUsage = utsPostProcessor.TtsCharRangeUsage; | |||
| @@ -51,6 +54,7 @@ type | |||
| TtsBlockFlag = utsTypes.TtsBlockFlag; | |||
| TtsBlockFlags = utsTypes.TtsBlockFlags; | |||
| TtsFontStyle = utsTypes.TtsFontStyle; | |||
| TtsFontStyles = utsTypes.TtsFontStyles; | |||
| TtsColorChannel = utsTypes.TtsColorChannel; | |||
| TtsColorChannels = utsTypes.TtsColorChannels; | |||
| TtsImageMode = utsTypes.TtsImageMode; | |||
| @@ -161,13 +161,15 @@ type | |||
| LineSpacing: Integer; | |||
| end; | |||
| TtsFontMetric = packed record | |||
| TtsFontNames = packed record | |||
| Fontname: String; | |||
| Copyright: String; | |||
| FaceName: String; | |||
| StyleName: String; | |||
| FullName: String; | |||
| Facename: String; | |||
| Stylename: String; | |||
| Fullname: String; | |||
| end; | |||
| TtsFontMetric = packed record | |||
| Size: Integer; | |||
| Style: TtsFontStyles; | |||
| AntiAliasing: TtsAntiAliasing; | |||
| @@ -138,6 +138,8 @@ begin | |||
| inherited Create; | |||
| fMasterRef := aMaster; | |||
| fSlaveRefs := TObjectList.Create(false); | |||
| if Assigned(fMasterRef) then | |||
| fMasterRef.AddSlave(self); | |||
| end; | |||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||