2016-12-08 08:52:44 -05:00
|
|
|
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "SlateRHIFontTexture.h"
|
|
|
|
|
#include "Rendering/SlateRenderer.h"
|
|
|
|
|
#include "RenderingThread.h"
|
|
|
|
|
#include "RenderUtils.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2016-04-07 16:16:52 -04:00
|
|
|
FSlateFontTextureRHIResource::FSlateFontTextureRHIResource(uint32 InWidth, uint32 InHeight)
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
: Width( InWidth )
|
|
|
|
|
, Height( InHeight )
|
|
|
|
|
{
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2016-04-07 16:16:52 -04:00
|
|
|
void FSlateFontTextureRHIResource::InitDynamicRHI()
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
check( IsInRenderingThread() );
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
// Create the texture
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
if( Width > 0 && Height > 0 )
|
|
|
|
|
{
|
|
|
|
|
check( !IsValidRef( ShaderResource) );
|
|
|
|
|
FRHIResourceCreateInfo CreateInfo;
|
|
|
|
|
ShaderResource = RHICreateTexture2D( Width, Height, PF_A8, 1, 1, TexCreate_Dynamic, CreateInfo );
|
|
|
|
|
check( IsValidRef( ShaderResource ) );
|
|
|
|
|
|
|
|
|
|
// Also assign the reference to the FTextureResource variable so that the Engine can access it
|
|
|
|
|
TextureRHI = ShaderResource;
|
|
|
|
|
|
|
|
|
|
// Create the sampler state RHI resource.
|
|
|
|
|
FSamplerStateInitializerRHI SamplerStateInitializer
|
|
|
|
|
(
|
2015-02-27 08:28:41 -05:00
|
|
|
SF_Bilinear,
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
AM_Clamp,
|
|
|
|
|
AM_Clamp,
|
|
|
|
|
AM_Wrap,
|
2015-02-27 08:28:41 -05:00
|
|
|
0,
|
|
|
|
|
1, // Disable anisotropic filtering, since aniso doesn't respect MaxLOD
|
|
|
|
|
0,
|
|
|
|
|
0
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
);
|
|
|
|
|
SamplerStateRHI = RHICreateSamplerState(SamplerStateInitializer);
|
|
|
|
|
|
|
|
|
|
// Create a custom sampler state for using this texture in a deferred pass, where ddx / ddy are discontinuous
|
|
|
|
|
FSamplerStateInitializerRHI DeferredPassSamplerStateInitializer
|
|
|
|
|
(
|
2015-02-27 08:28:41 -05:00
|
|
|
SF_Bilinear,
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
AM_Clamp,
|
|
|
|
|
AM_Clamp,
|
|
|
|
|
AM_Wrap,
|
|
|
|
|
0,
|
2015-02-27 08:28:41 -05:00
|
|
|
1, // Disable anisotropic filtering, since aniso doesn't respect MaxLOD
|
|
|
|
|
0,
|
|
|
|
|
0
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
);
|
|
|
|
|
DeferredPassSamplerStateRHI = RHICreateSamplerState(DeferredPassSamplerStateInitializer);
|
|
|
|
|
|
|
|
|
|
INC_MEMORY_STAT_BY(STAT_SlateTextureGPUMemory, Width*Height*GPixelFormats[PF_A8].BlockBytes);
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2016-04-07 16:16:52 -04:00
|
|
|
void FSlateFontTextureRHIResource::ReleaseDynamicRHI()
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
check( IsInRenderingThread() );
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
// Release the texture
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
if( IsValidRef(ShaderResource) )
|
|
|
|
|
{
|
|
|
|
|
DEC_MEMORY_STAT_BY(STAT_SlateTextureGPUMemory, Width*Height*GPixelFormats[PF_A8].BlockBytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShaderResource.SafeRelease();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
FSlateFontAtlasRHI::FSlateFontAtlasRHI( uint32 Width, uint32 Height )
|
|
|
|
|
: FSlateFontAtlas( Width, Height )
|
2016-04-07 16:16:52 -04:00
|
|
|
, FontTexture( new FSlateFontTextureRHIResource( Width, Height ) )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSlateFontAtlasRHI::~FSlateFontAtlasRHI()
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
{
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSlateFontAtlasRHI::ReleaseResources()
|
|
|
|
|
{
|
2015-09-23 16:17:33 -04:00
|
|
|
checkSlow( IsThreadSafeForSlateRendering() );
|
2014-03-14 14:13:41 -04:00
|
|
|
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
BeginReleaseResource( FontTexture.Get() );
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSlateFontAtlasRHI::ConditionalUpdateTexture()
|
|
|
|
|
{
|
|
|
|
|
if( bNeedsUpdate )
|
|
|
|
|
{
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
if (IsInRenderingThread())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
FontTexture->InitResource();
|
|
|
|
|
|
2014-11-11 10:35:51 -05:00
|
|
|
uint32 DestStride;
|
|
|
|
|
uint8* TempData = (uint8*)RHILockTexture2D( FontTexture->GetTypedResource(), 0, RLM_WriteOnly, /*out*/ DestStride, false );
|
|
|
|
|
// check( DestStride == Atlas.BytesPerPixel * Atlas.AtlasWidth ); // Temporarily disabling check
|
|
|
|
|
FMemory::Memcpy( TempData, AtlasData.GetData(), BytesPerPixel*AtlasWidth*AtlasHeight );
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
RHIUnlockTexture2D( FontTexture->GetTypedResource(),0,false );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-09-23 16:17:33 -04:00
|
|
|
checkSlow( IsThreadSafeForSlateRendering() );
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
|
|
|
|
|
BeginInitResource( FontTexture.Get() );
|
|
|
|
|
|
2016-04-07 16:16:52 -04:00
|
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER( SlateUpdateFontAtlasTextureCommand,
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
FSlateFontAtlasRHI&, Atlas, *this,
|
|
|
|
|
{
|
2014-11-11 10:35:51 -05:00
|
|
|
uint32 DestStride;
|
|
|
|
|
uint8* TempData = (uint8*)RHILockTexture2D( Atlas.FontTexture->GetTypedResource(), 0, RLM_WriteOnly, /*out*/ DestStride, false );
|
|
|
|
|
// check( DestStride == Atlas.BytesPerPixel * Atlas.AtlasWidth ); // Temporarily disabling check
|
|
|
|
|
FMemory::Memcpy( TempData, Atlas.AtlasData.GetData(), Atlas.BytesPerPixel*Atlas.AtlasWidth*Atlas.AtlasHeight );
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
RHIUnlockTexture2D( Atlas.FontTexture->GetTypedResource(),0,false );
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
bNeedsUpdate = false;
|
|
|
|
|
}
|
Initial support for composite fonts for Slate, UMG, and Canvas
Slate now has the concept of composite fonts and font families (via FCompositeFont and FTypeface). A composite font is a font that contains a default font family, as well as any number of sub-font families which should be used for a given set of character ranges. This change will greatly improve the localization support for fonts.
UFont assets can now use two forms of caching "offline" (which is the way they have always worked historically), and "runtime" (which utilizes the Slate font cache to cache glyphs on demand). These runtime cached UFont assets are now the only way to specify which font to use for a UMG widget, and address the previous issues about ensuring that the required font files were staged for your game.
The Slate font cache now works on FFontData instances, rather than filenames. This allows the UFont asset to embed a blob of TTF or OTF font data inside it, rather than require the fonts be loaded from files on disk.
The Canvas text renderer has been updated to support runtime cached UFont assets. This gives our legacy Canvas based tools the same improved font localization support as the rest of the Slate-based editor UI.
UFont asset creation has been changed to use runtime caching by default, and additionally, you can now import a TTF or OTF file via the Content Browser and it will automatically create a UFont asset. If you still want an offline cached UFont asset, you can just change the cache type in the font editor, and the usual font picker dialog will appear and allow you to generate a font texture atlas.
[CL 2342203 by Jamie Dale in Main branch]
2014-10-28 09:02:03 -04:00
|
|
|
}
|
2016-04-07 16:16:52 -04:00
|
|
|
|
|
|
|
|
FSlateFontTextureRHI::FSlateFontTextureRHI(const uint32 InWidth, const uint32 InHeight, const TArray<uint8>& InRawData)
|
|
|
|
|
: FontTexture(new FSlateFontTextureRHIResource(InWidth, InHeight))
|
|
|
|
|
{
|
|
|
|
|
if (IsInRenderingThread())
|
|
|
|
|
{
|
|
|
|
|
FontTexture->InitResource();
|
|
|
|
|
UpdateTextureFromSource(InWidth, InHeight, InRawData);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
checkSlow(IsThreadSafeForSlateRendering());
|
|
|
|
|
|
|
|
|
|
PendingSourceData.Reset(new FPendingSourceData(InWidth, InHeight, InRawData));
|
|
|
|
|
|
|
|
|
|
BeginInitResource(FontTexture.Get());
|
|
|
|
|
|
|
|
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(SlateUpdateFontTextureCommand,
|
|
|
|
|
FSlateFontTextureRHI&, FontTexture, *this,
|
|
|
|
|
{
|
|
|
|
|
FontTexture.UpdateTextureFromSource(FontTexture.PendingSourceData->SourceWidth, FontTexture.PendingSourceData->SourceHeight, FontTexture.PendingSourceData->SourceData);
|
|
|
|
|
FontTexture.PendingSourceData.Reset();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSlateFontTextureRHI::~FSlateFontTextureRHI()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSlateFontTextureRHI::ReleaseResources()
|
|
|
|
|
{
|
|
|
|
|
checkSlow(IsThreadSafeForSlateRendering());
|
|
|
|
|
|
|
|
|
|
BeginReleaseResource(FontTexture.Get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSlateFontTextureRHI::UpdateTextureFromSource(const uint32 SourceWidth, const uint32 SourceHeight, const TArray<uint8>& SourceData)
|
|
|
|
|
{
|
|
|
|
|
static const uint32 BytesPerPixel = sizeof(uint8);
|
|
|
|
|
|
|
|
|
|
uint32 DestStride;
|
|
|
|
|
uint8* LockedTextureData = static_cast<uint8*>(RHILockTexture2D(FontTexture->GetTypedResource(), 0, RLM_WriteOnly, /*out*/ DestStride, false));
|
|
|
|
|
|
|
|
|
|
// If our stride matches our width, we can copy in a single call, rather than copy each line
|
|
|
|
|
if (BytesPerPixel * SourceWidth == DestStride)
|
|
|
|
|
{
|
|
|
|
|
FMemory::Memcpy(LockedTextureData, SourceData.GetData(), BytesPerPixel * SourceWidth * SourceHeight);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (uint32 RowIndex = 0; RowIndex < SourceHeight; ++RowIndex)
|
|
|
|
|
{
|
|
|
|
|
FMemory::Memcpy(LockedTextureData + (RowIndex * DestStride), SourceData.GetData() + (RowIndex * SourceWidth), BytesPerPixel * SourceWidth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RHIUnlockTexture2D(FontTexture->GetTypedResource(), 0, false);
|
|
|
|
|
}
|