private static QFont BuildDropShadow(List <QBitmap> sourceFontSheets, QFontGlyph[] sourceFontGlyphs, QFontShadowConfiguration shadowConfig, char[] charSet, byte alphaTolerance)
{
QFontGlyph[] newGlyphs;
var sourceBitmapData = new List <BitmapData>();
foreach (var sourceSheet in sourceFontSheets)
{
sourceBitmapData.Add(sourceSheet.bitmapData);
}
//GenerateBitmapSheetsAndRepack(QFontGlyph[] sourceGlyphs, BitmapData[] sourceBitmaps, int destSheetWidth, int destSheetHeight, out QFontGlyph[] destGlyphs, int destMargin, bool usePowerOfTwo)
var bitmapSheets = GenerateBitmapSheetsAndRepack(sourceFontGlyphs, sourceBitmapData.ToArray(), shadowConfig.PageWidth, shadowConfig.PageHeight, out newGlyphs, shadowConfig.GlyphMargin + shadowConfig.blurRadius * 3, shadowConfig.ForcePowerOfTwo);
//scale up in case we wanted bigger/smaller shadows
if (shadowConfig.Scale != 1.0f)
{
ScaleSheetsAndGlyphs(bitmapSheets, newGlyphs, shadowConfig.Scale); //no point in retargeting yet, since we will do it after blur
}
//blacken and blur
foreach (var bitmapSheet in bitmapSheets)
{
bitmapSheet.Colour32(0, 0, 0);
bitmapSheet.BlurAlpha(shadowConfig.blurRadius, shadowConfig.blurPasses);
}
//retarget after blur and scale
RetargetAllGlyphs(bitmapSheets, newGlyphs, alphaTolerance);
//create list of texture pages
var newTextureSheets = new List <TexturePage>();
foreach (var page in bitmapSheets)
{
newTextureSheets.Add(new TexturePage(page.bitmapData));
}
var fontData = new QFontData();
fontData.CharSetMapping = new Dictionary <char, QFontGlyph>();
for (int i = 0; i < charSet.Length; i++)
{
fontData.CharSetMapping.Add(charSet[i], newGlyphs[i]);
}
fontData.Pages = newTextureSheets.ToArray();
fontData.CalculateMeanWidth();
fontData.CalculateMaxHeight();
foreach (var sheet in bitmapSheets)
{
sheet.Free();
}
return(new QFont(fontData));
}